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
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-02-05 22:39:40 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-02-05 22:39:40 +08:00
|
|
|
* (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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2003-02-05 22:39:40 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#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;
|
2010-11-02 04:48:59 +08:00
|
|
|
GtkWidget *vbox2;
|
2003-02-08 01:12:21 +08:00
|
|
|
GtkWidget *frame;
|
2010-11-02 21:05:47 +08:00
|
|
|
GtkWidget *scale;
|
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 */
|
2010-11-02 21:05:47 +08:00
|
|
|
button = gimp_prop_gradient_box_new (NULL, GIMP_CONTEXT (tool_options),
|
|
|
|
_("Gradient"), 2,
|
2008-05-27 17:44:16 +08:00
|
|
|
"gradient-view-type",
|
|
|
|
"gradient-view-size",
|
|
|
|
"gradient-reverse");
|
2010-11-02 21:05:47 +08:00
|
|
|
gtk_table_attach (GTK_TABLE (table), button, 0, 3, 2, 3,
|
|
|
|
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (button);
|
2003-03-26 05:14:48 +08:00
|
|
|
|
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");
|
2010-11-02 21:05:47 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
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);
|
2010-11-02 21:05:47 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 4,
|
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
|
|
|
|
2010-11-02 21:05:47 +08:00
|
|
|
/* the offset scale */
|
|
|
|
scale = gimp_prop_spin_scale_new (config, "offset",
|
|
|
|
_("Offset"),
|
|
|
|
1.0, 10.0, 1);
|
|
|
|
gtk_table_attach (GTK_TABLE (table), scale,
|
|
|
|
0, 3, 5, 6,
|
|
|
|
GTK_FILL | GTK_EXPAND, GTK_FILL | GTK_SHRINK, 0, 0);
|
|
|
|
gtk_widget_show (scale);
|
|
|
|
|
|
|
|
/* the dither toggle */
|
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 */
|
2010-11-02 04:48:59 +08:00
|
|
|
vbox2 = gtk_vbox_new (FALSE, 2);
|
2006-10-19 03:54:18 +08:00
|
|
|
frame = gimp_prop_expanding_frame_new (config, "supersample",
|
|
|
|
_("Adaptive supersampling"),
|
2010-11-02 04:48:59 +08:00
|
|
|
vbox2, NULL);
|
2006-10-19 03:54:18 +08:00
|
|
|
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 */
|
2010-11-02 04:48:59 +08:00
|
|
|
scale = gimp_prop_spin_scale_new (config, "supersample-depth",
|
|
|
|
_("Max depth"),
|
|
|
|
1.0, 1.0, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (scale);
|
2003-02-05 22:39:40 +08:00
|
|
|
|
2003-02-08 01:12:21 +08:00
|
|
|
/* threshold scale */
|
2010-11-02 04:48:59 +08:00
|
|
|
scale = gimp_prop_spin_scale_new (config, "supersample-threshold",
|
|
|
|
_("Threshold"),
|
|
|
|
0.01, 0.1, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox2), scale, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (scale);
|
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
|
|
|
}
|