2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-02-05 22:39:40 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
2003-03-23 00:26:11 +08:00
|
|
|
#include "core/gimpdatafactory.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2006-10-19 03:54:18 +08:00
|
|
|
#include "widgets/gimppropwidgets.h"
|
2008-05-27 17:44:16 +08:00
|
|
|
#include "widgets/gimpviewablebox.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
|
|
|
|
#include "gimpblendoptions.h"
|
2003-06-30 04:40:45 +08:00
|
|
|
#include "gimppaintoptions-gui.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_OFFSET,
|
|
|
|
PROP_GRADIENT_TYPE,
|
2004-11-24 01:01:51 +08:00
|
|
|
PROP_GRADIENT_REPEAT, /* overrides a GimpPaintOptions property */
|
2003-02-08 01:12:21 +08:00
|
|
|
PROP_SUPERSAMPLE,
|
|
|
|
PROP_SUPERSAMPLE_DEPTH,
|
2003-07-21 09:13:35 +08:00
|
|
|
PROP_SUPERSAMPLE_THRESHOLD,
|
|
|
|
PROP_DITHER
|
2003-02-08 01:12:21 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-03-26 05:14:48 +08:00
|
|
|
static void gimp_blend_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_blend_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
2003-03-26 05:14:48 +08:00
|
|
|
static void blend_options_gradient_type_notify (GimpBlendOptions *options,
|
|
|
|
GParamSpec *pspec,
|
2004-04-18 23:12:42 +08:00
|
|
|
GtkWidget *repeat_combo);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
|
2006-05-15 17:46:31 +08:00
|
|
|
G_DEFINE_TYPE (GimpBlendOptions, gimp_blend_options, GIMP_TYPE_PAINT_OPTIONS)
|
2003-02-05 22:39:40 +08:00
|
|
|
|
|
|
|
|
2003-07-22 22:24:11 +08:00
|
|
|
static void
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_blend_options_class_init (GimpBlendOptionsClass *klass)
|
|
|
|
{
|
2004-09-24 20:01:35 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
object_class->set_property = gimp_blend_options_set_property;
|
|
|
|
object_class->get_property = gimp_blend_options_get_property;
|
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_OFFSET,
|
|
|
|
"offset", NULL,
|
|
|
|
0.0, 100.0, 0.0,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-08 01:12:21 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRADIENT_TYPE,
|
|
|
|
"gradient-type", NULL,
|
|
|
|
GIMP_TYPE_GRADIENT_TYPE,
|
2003-08-27 02:12:42 +08:00
|
|
|
GIMP_GRADIENT_LINEAR,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2004-03-13 23:48:32 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRADIENT_REPEAT,
|
|
|
|
"gradient-repeat", NULL,
|
|
|
|
GIMP_TYPE_REPEAT_MODE,
|
|
|
|
GIMP_REPEAT_NONE,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SUPERSAMPLE,
|
|
|
|
"supersample", NULL,
|
|
|
|
FALSE,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-08 01:12:21 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_SUPERSAMPLE_DEPTH,
|
|
|
|
"supersample-depth", NULL,
|
2004-02-29 23:02:04 +08:00
|
|
|
0, 6, 3,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-08 01:12:21 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SUPERSAMPLE_THRESHOLD,
|
|
|
|
"supersample-threshold", NULL,
|
|
|
|
0.0, 4.0, 0.2,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-07-21 09:13:35 +08:00
|
|
|
|
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DITHER,
|
|
|
|
"dither", NULL,
|
|
|
|
TRUE,
|
2006-01-19 04:29:40 +08:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
static void
|
|
|
|
gimp_blend_options_init (GimpBlendOptions *options)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
static void
|
|
|
|
gimp_blend_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2004-09-24 20:01:35 +08:00
|
|
|
GimpBlendOptions *options = GIMP_BLEND_OPTIONS (object);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_OFFSET:
|
|
|
|
options->offset = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
case PROP_GRADIENT_TYPE:
|
|
|
|
options->gradient_type = g_value_get_enum (value);
|
|
|
|
break;
|
2004-03-13 23:48:32 +08:00
|
|
|
case PROP_GRADIENT_REPEAT:
|
|
|
|
GIMP_PAINT_OPTIONS (options)->gradient_options->gradient_repeat =
|
|
|
|
g_value_get_enum (value);
|
|
|
|
break;
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
case PROP_SUPERSAMPLE:
|
|
|
|
options->supersample = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
case PROP_SUPERSAMPLE_DEPTH:
|
|
|
|
options->supersample_depth = g_value_get_int (value);
|
|
|
|
break;
|
|
|
|
case PROP_SUPERSAMPLE_THRESHOLD:
|
|
|
|
options->supersample_threshold = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
|
2003-07-21 09:13:35 +08:00
|
|
|
case PROP_DITHER:
|
|
|
|
options->dither = g_value_get_boolean (value);
|
|
|
|
break;
|
2003-07-22 22:24:11 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_blend_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2004-09-24 20:01:35 +08:00
|
|
|
GimpBlendOptions *options = GIMP_BLEND_OPTIONS (object);
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_OFFSET:
|
|
|
|
g_value_set_double (value, options->offset);
|
|
|
|
break;
|
|
|
|
case PROP_GRADIENT_TYPE:
|
|
|
|
g_value_set_enum (value, options->gradient_type);
|
|
|
|
break;
|
2004-03-13 23:48:32 +08:00
|
|
|
case PROP_GRADIENT_REPEAT:
|
|
|
|
g_value_set_enum (value,
|
|
|
|
GIMP_PAINT_OPTIONS (options)->gradient_options->gradient_repeat);
|
|
|
|
break;
|
2003-02-08 01:12:21 +08:00
|
|
|
|
|
|
|
case PROP_SUPERSAMPLE:
|
|
|
|
g_value_set_boolean (value, options->supersample);
|
|
|
|
break;
|
|
|
|
case PROP_SUPERSAMPLE_DEPTH:
|
|
|
|
g_value_set_int (value, options->supersample_depth);
|
|
|
|
break;
|
|
|
|
case PROP_SUPERSAMPLE_THRESHOLD:
|
|
|
|
g_value_set_double (value, options->supersample_threshold);
|
|
|
|
break;
|
|
|
|
|
2003-07-21 09:13:35 +08:00
|
|
|
case PROP_DITHER:
|
|
|
|
g_value_set_boolean (value, options->dither);
|
|
|
|
break;
|
2003-07-22 22:24:11 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|
|
|
|
|
2003-02-10 01:32:52 +08:00
|
|
|
GtkWidget *
|
2003-02-05 22:39:40 +08:00
|
|
|
gimp_blend_options_gui (GimpToolOptions *tool_options)
|
|
|
|
{
|
2004-09-24 20:01:35 +08:00
|
|
|
GObject *config = G_OBJECT (tool_options);
|
2006-08-28 06:19:35 +08:00
|
|
|
GtkWidget *vbox = gimp_paint_options_gui (tool_options);
|
2003-02-08 01:12:21 +08:00
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *frame;
|
2004-04-18 23:12:42 +08:00
|
|
|
GtkWidget *combo;
|
2003-02-08 01:12:21 +08:00
|
|
|
GtkWidget *button;
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-03-26 05:14:48 +08:00
|
|
|
table = g_object_get_data (G_OBJECT (vbox), GIMP_PAINT_OPTIONS_TABLE_KEY);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2008-05-27 17:44:16 +08:00
|
|
|
/* the gradient */
|
|
|
|
button = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (tool_options), 2,
|
|
|
|
"gradient-view-type",
|
|
|
|
"gradient-view-size",
|
|
|
|
"gradient-reverse");
|
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
|
|
|
_("Gradient:"), 0.0, 0.5,
|
|
|
|
button, 2, TRUE);
|
|
|
|
|
2003-03-26 05:14:48 +08:00
|
|
|
/* the offset scale */
|
|
|
|
gimp_prop_scale_entry_new (config, "offset",
|
|
|
|
GTK_TABLE (table), 0, 3,
|
|
|
|
_("Offset:"),
|
|
|
|
1.0, 10.0, 1,
|
|
|
|
FALSE, 0.0, 0.0);
|
|
|
|
|
2003-02-05 22:39:40 +08:00
|
|
|
/* the gradient type menu */
|
2004-04-18 23:12:42 +08:00
|
|
|
combo = gimp_prop_enum_combo_box_new (config, "gradient-type", 0, 0);
|
2007-02-28 02:44:55 +08:00
|
|
|
g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
2004-04-18 23:12:42 +08:00
|
|
|
gimp_enum_combo_box_set_stock_prefix (GIMP_ENUM_COMBO_BOX (combo),
|
|
|
|
"gimp-gradient");
|
2003-03-26 05:14:48 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
|
2004-09-24 20:01:35 +08:00
|
|
|
_("Shape:"), 0.0, 0.5,
|
2004-10-15 06:55:18 +08:00
|
|
|
combo, 2, FALSE);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
|
|
|
/* the repeat option */
|
2004-04-18 23:12:42 +08:00
|
|
|
combo = gimp_prop_enum_combo_box_new (config, "gradient-repeat", 0, 0);
|
2007-02-28 02:44:55 +08:00
|
|
|
g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
|
2003-03-26 05:14:48 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 5,
|
2004-09-24 20:01:35 +08:00
|
|
|
_("Repeat:"), 0.0, 0.5,
|
2004-10-15 06:55:18 +08:00
|
|
|
combo, 2, FALSE);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
g_signal_connect (config, "notify::gradient-type",
|
2003-03-26 05:14:48 +08:00
|
|
|
G_CALLBACK (blend_options_gradient_type_notify),
|
2004-04-18 23:12:42 +08:00
|
|
|
combo);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-07-21 09:13:35 +08:00
|
|
|
button = gimp_prop_check_button_new (config, "dither",
|
|
|
|
_("Dithering"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
2003-07-22 22:24:11 +08:00
|
|
|
|
2004-11-24 01:01:51 +08:00
|
|
|
/* supersampling options */
|
|
|
|
table = gtk_table_new (2, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 1);
|
|
|
|
|
2006-10-19 03:54:18 +08:00
|
|
|
frame = gimp_prop_expanding_frame_new (config, "supersample",
|
|
|
|
_("Adaptive supersampling"),
|
|
|
|
table, NULL);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
/* max depth scale */
|
|
|
|
gimp_prop_scale_entry_new (config, "supersample-depth",
|
|
|
|
GTK_TABLE (table), 0, 0,
|
2005-08-23 07:39:12 +08:00
|
|
|
_("Max depth:"),
|
2003-02-08 01:12:21 +08:00
|
|
|
1.0, 1.0, 0,
|
|
|
|
FALSE, 0.0, 0.0);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
/* threshold scale */
|
|
|
|
gimp_prop_scale_entry_new (config, "supersample-threshold",
|
|
|
|
GTK_TABLE (table), 0, 1,
|
|
|
|
_("Threshold:"),
|
|
|
|
0.01, 0.1, 2,
|
|
|
|
FALSE, 0.0, 0.0);
|
2003-02-10 01:32:52 +08:00
|
|
|
|
|
|
|
return vbox;
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-03-26 05:14:48 +08:00
|
|
|
blend_options_gradient_type_notify (GimpBlendOptions *options,
|
|
|
|
GParamSpec *pspec,
|
2004-04-18 23:12:42 +08:00
|
|
|
GtkWidget *repeat_combo)
|
2003-02-05 22:39:40 +08:00
|
|
|
{
|
2004-04-18 23:12:42 +08:00
|
|
|
gtk_widget_set_sensitive (repeat_combo, options->gradient_type < 6);
|
2003-02-05 22:39:40 +08:00
|
|
|
}
|