2005-08-01 02:29:10 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* 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>
|
|
|
|
|
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
2005-08-07 03:08:43 +08:00
|
|
|
#include "base/siox.h"
|
|
|
|
|
2005-08-01 02:29:10 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
|
|
|
|
|
|
|
#include "gimpforegroundselectoptions.h"
|
|
|
|
#include "gimptooloptions-gui.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2005-08-07 03:08:43 +08:00
|
|
|
PROP_EXPANDED,
|
2005-08-03 00:07:16 +08:00
|
|
|
PROP_BACKGROUND,
|
2005-10-17 23:30:10 +08:00
|
|
|
PROP_MULTIBLOB,
|
2005-08-07 03:08:43 +08:00
|
|
|
PROP_STROKE_WIDTH,
|
|
|
|
PROP_SMOOTHNESS,
|
2005-08-10 04:43:44 +08:00
|
|
|
PROP_SENSITIVITY_L,
|
|
|
|
PROP_SENSITIVITY_A,
|
|
|
|
PROP_SENSITIVITY_B
|
2005-08-01 02:29:10 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static void gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *klass);
|
|
|
|
|
|
|
|
static void gimp_foreground_select_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_foreground_select_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
gimp_foreground_select_options_get_type (void)
|
|
|
|
{
|
|
|
|
static GType type = 0;
|
|
|
|
|
|
|
|
if (! type)
|
|
|
|
{
|
|
|
|
static const GTypeInfo info =
|
|
|
|
{
|
|
|
|
sizeof (GimpForegroundSelectOptionsClass),
|
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_foreground_select_options_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpForegroundSelectOptions),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
type = g_type_register_static (GIMP_TYPE_SELECTION_OPTIONS,
|
|
|
|
"GimpForegroundSelectOptions",
|
|
|
|
&info, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
return type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_foreground_select_options_class_init (GimpForegroundSelectOptionsClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
object_class->set_property = gimp_foreground_select_options_set_property;
|
|
|
|
object_class->get_property = gimp_foreground_select_options_get_property;
|
|
|
|
|
2005-08-07 03:08:43 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_EXPANDED,
|
|
|
|
"expanded", NULL,
|
|
|
|
FALSE,
|
|
|
|
0);
|
2005-08-01 02:29:10 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_BACKGROUND,
|
|
|
|
"background", NULL,
|
|
|
|
FALSE,
|
|
|
|
0);
|
2005-10-17 23:30:10 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_MULTIBLOB,
|
|
|
|
"multiblob",
|
|
|
|
_("Select multiple disconnected objects"),
|
|
|
|
FALSE,
|
|
|
|
0);
|
2005-08-06 19:18:26 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_STROKE_WIDTH,
|
2005-08-06 21:03:59 +08:00
|
|
|
"stroke-width",
|
|
|
|
_("Size of the brush used for refinements"),
|
2005-08-09 20:36:40 +08:00
|
|
|
1, 80, 18,
|
2005-08-06 19:18:26 +08:00
|
|
|
0);
|
2005-08-07 03:08:43 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_SMOOTHNESS,
|
|
|
|
"smoothness",
|
|
|
|
_("Smaller values give a more accurate "
|
|
|
|
"selection border but may introduce holes "
|
|
|
|
"in the selection"),
|
|
|
|
0, 8, SIOX_DEFAULT_SMOOTHNESS,
|
|
|
|
0);
|
2005-08-10 04:43:44 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SENSITIVITY_L,
|
|
|
|
"sensitivity-l",
|
|
|
|
_("Sensitivity for brightness component"),
|
|
|
|
0.0, 10.0, SIOX_DEFAULT_SENSITIVITY_L,
|
2005-08-07 03:08:43 +08:00
|
|
|
0);
|
2005-08-10 04:43:44 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SENSITIVITY_A,
|
|
|
|
"sensitivity-a",
|
|
|
|
_("Sensitivity for red/green component"),
|
|
|
|
0.0, 10.0, SIOX_DEFAULT_SENSITIVITY_A,
|
2005-08-07 03:08:43 +08:00
|
|
|
0);
|
2005-08-10 04:43:44 +08:00
|
|
|
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_SENSITIVITY_B,
|
|
|
|
"sensitivity-b",
|
|
|
|
_("Sensitivity for yellow/blue component"),
|
|
|
|
0.0, 10.0, SIOX_DEFAULT_SENSITIVITY_B,
|
2005-08-07 03:08:43 +08:00
|
|
|
0);
|
2005-08-01 02:29:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_foreground_select_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpForegroundSelectOptions *options = GIMP_FOREGROUND_SELECT_OPTIONS (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2005-08-07 03:08:43 +08:00
|
|
|
case PROP_EXPANDED:
|
|
|
|
options->expanded = g_value_get_boolean (value);
|
|
|
|
break;
|
2005-08-01 02:29:10 +08:00
|
|
|
case PROP_BACKGROUND:
|
|
|
|
options->background = g_value_get_boolean (value);
|
|
|
|
break;
|
2005-10-17 23:30:10 +08:00
|
|
|
case PROP_MULTIBLOB:
|
|
|
|
options->multiblob = g_value_get_boolean (value);
|
|
|
|
break;
|
2005-08-03 00:07:16 +08:00
|
|
|
case PROP_STROKE_WIDTH:
|
2005-08-06 19:18:26 +08:00
|
|
|
options->stroke_width = g_value_get_int (value);
|
2005-08-03 00:07:16 +08:00
|
|
|
break;
|
2005-08-07 03:08:43 +08:00
|
|
|
case PROP_SMOOTHNESS:
|
|
|
|
options->smoothness = g_value_get_int (value);
|
|
|
|
break;
|
2005-08-10 04:43:44 +08:00
|
|
|
case PROP_SENSITIVITY_L:
|
|
|
|
options->sensitivity[0] = g_value_get_double (value);
|
2005-08-07 03:08:43 +08:00
|
|
|
break;
|
2005-08-10 04:43:44 +08:00
|
|
|
case PROP_SENSITIVITY_A:
|
|
|
|
options->sensitivity[1] = g_value_get_double (value);
|
2005-08-07 03:08:43 +08:00
|
|
|
break;
|
2005-08-10 04:43:44 +08:00
|
|
|
case PROP_SENSITIVITY_B:
|
|
|
|
options->sensitivity[2] = g_value_get_double (value);
|
2005-08-07 03:08:43 +08:00
|
|
|
break;
|
2005-08-01 02:29:10 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_foreground_select_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpForegroundSelectOptions *options = GIMP_FOREGROUND_SELECT_OPTIONS (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2005-08-07 03:08:43 +08:00
|
|
|
case PROP_EXPANDED:
|
|
|
|
g_value_set_boolean (value, options->expanded);
|
|
|
|
break;
|
2005-08-01 02:29:10 +08:00
|
|
|
case PROP_BACKGROUND:
|
|
|
|
g_value_set_boolean (value, options->background);
|
|
|
|
break;
|
2005-10-17 23:30:10 +08:00
|
|
|
case PROP_MULTIBLOB:
|
|
|
|
g_value_set_boolean (value, options->multiblob);
|
|
|
|
break;
|
2005-08-03 00:07:16 +08:00
|
|
|
case PROP_STROKE_WIDTH:
|
2005-08-06 19:18:26 +08:00
|
|
|
g_value_set_int (value, options->stroke_width);
|
2005-08-03 00:07:16 +08:00
|
|
|
break;
|
2005-08-07 03:08:43 +08:00
|
|
|
case PROP_SMOOTHNESS:
|
|
|
|
g_value_set_int (value, options->smoothness);
|
|
|
|
break;
|
2005-08-10 04:43:44 +08:00
|
|
|
case PROP_SENSITIVITY_L:
|
|
|
|
g_value_set_double (value, options->sensitivity[0]);
|
2005-08-07 03:08:43 +08:00
|
|
|
break;
|
2005-08-10 04:43:44 +08:00
|
|
|
case PROP_SENSITIVITY_A:
|
|
|
|
g_value_set_double (value, options->sensitivity[1]);
|
2005-08-07 03:08:43 +08:00
|
|
|
break;
|
2005-08-10 04:43:44 +08:00
|
|
|
case PROP_SENSITIVITY_B:
|
|
|
|
g_value_set_double (value, options->sensitivity[2]);
|
2005-08-07 03:08:43 +08:00
|
|
|
break;
|
2005-08-01 02:29:10 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_foreground_select_options_gui (GimpToolOptions *tool_options)
|
|
|
|
{
|
2005-08-07 03:08:43 +08:00
|
|
|
GObject *config = G_OBJECT (tool_options);
|
|
|
|
GtkWidget *vbox = gimp_selection_options_gui (tool_options);
|
2005-08-06 21:03:59 +08:00
|
|
|
GtkWidget *hbox;
|
2005-08-01 02:29:10 +08:00
|
|
|
GtkWidget *frame;
|
2005-08-06 21:03:59 +08:00
|
|
|
GtkWidget *scale;
|
|
|
|
GtkWidget *label;
|
2005-08-07 03:08:43 +08:00
|
|
|
GtkWidget *inner_frame;
|
|
|
|
GtkWidget *table;
|
2005-08-07 05:39:43 +08:00
|
|
|
GtkObject *adj;
|
2005-08-07 03:08:43 +08:00
|
|
|
gint row = 0;
|
2005-08-01 02:29:10 +08:00
|
|
|
|
2005-08-07 03:08:43 +08:00
|
|
|
/* foreground / background */
|
|
|
|
frame = gimp_prop_boolean_radio_frame_new (config, "background",
|
2005-08-01 02:29:10 +08:00
|
|
|
_("Interactive refinement"),
|
|
|
|
_("Mark background"),
|
|
|
|
_("Mark foreground"));
|
|
|
|
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
2005-08-07 03:08:43 +08:00
|
|
|
/* stroke width */
|
|
|
|
inner_frame = gtk_vbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (GTK_BIN (frame)->child),
|
|
|
|
inner_frame, FALSE, FALSE, 2);
|
|
|
|
gtk_widget_show (inner_frame);
|
2005-08-06 21:03:59 +08:00
|
|
|
|
|
|
|
hbox = gtk_hbox_new (FALSE, 6);
|
2005-08-07 03:08:43 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (inner_frame), hbox, FALSE, FALSE, 0);
|
2005-08-06 21:03:59 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2005-08-07 03:08:43 +08:00
|
|
|
label = gtk_label_new (_("Small brush"));
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (label),
|
|
|
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
|
|
|
|
-1);
|
2005-08-06 21:03:59 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2005-08-07 03:08:43 +08:00
|
|
|
label = gtk_label_new (_("Large brush"));
|
|
|
|
gimp_label_set_attributes (GTK_LABEL (label),
|
|
|
|
PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC,
|
|
|
|
PANGO_ATTR_SCALE, PANGO_SCALE_SMALL,
|
|
|
|
-1);
|
2005-08-06 21:03:59 +08:00
|
|
|
gtk_box_pack_end (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2005-08-07 03:08:43 +08:00
|
|
|
scale = gimp_prop_hscale_new (config, "stroke-width", 1.0, 5.0, 0);
|
|
|
|
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
|
|
|
gtk_box_pack_start (GTK_BOX (inner_frame), scale, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (scale);
|
|
|
|
|
|
|
|
/* smoothness */
|
|
|
|
table = gtk_table_new (1, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
|
|
|
scale = gimp_prop_hscale_new (config, "smoothness", 0.1, 1.0, 0);
|
2005-08-07 04:01:22 +08:00
|
|
|
gtk_range_set_update_policy (GTK_RANGE (scale), GTK_UPDATE_DELAYED);
|
|
|
|
gtk_scale_set_value_pos (GTK_SCALE (scale), GTK_POS_RIGHT);
|
2005-08-07 03:08:43 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2005-08-07 04:01:22 +08:00
|
|
|
_("Smoothing:"), 0.0, 0.5, scale, 2, FALSE);
|
2005-08-07 03:08:43 +08:00
|
|
|
|
|
|
|
/* granularity */
|
2005-08-10 04:43:44 +08:00
|
|
|
frame = gimp_prop_expander_new (config, "expanded", _("Color Sensitivity"));
|
2005-08-07 03:08:43 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (frame);
|
|
|
|
|
|
|
|
inner_frame = gimp_frame_new ("<expander>");
|
|
|
|
gtk_container_add (GTK_CONTAINER (frame), inner_frame);
|
|
|
|
gtk_widget_show (inner_frame);
|
|
|
|
|
|
|
|
table = gtk_table_new (3, 3, FALSE);
|
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
|
|
|
|
gtk_container_add (GTK_CONTAINER (inner_frame), table);
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2005-08-10 04:43:44 +08:00
|
|
|
adj = gimp_prop_opacity_entry_new (config, "sensitivity-l",
|
2005-08-07 07:04:23 +08:00
|
|
|
GTK_TABLE (table), 0, row++, "L");
|
2005-08-07 05:39:43 +08:00
|
|
|
gtk_range_set_update_policy (GTK_RANGE (GIMP_SCALE_ENTRY_SCALE (adj)),
|
2005-08-07 04:01:22 +08:00
|
|
|
GTK_UPDATE_DELAYED);
|
|
|
|
|
2005-08-10 04:43:44 +08:00
|
|
|
adj = gimp_prop_opacity_entry_new (config, "sensitivity-a",
|
2005-08-07 07:04:23 +08:00
|
|
|
GTK_TABLE (table), 0, row++, "a");
|
2005-08-07 05:39:43 +08:00
|
|
|
gtk_range_set_update_policy (GTK_RANGE (GIMP_SCALE_ENTRY_SCALE (adj)),
|
2005-08-07 04:01:22 +08:00
|
|
|
GTK_UPDATE_DELAYED);
|
|
|
|
|
2005-08-10 04:43:44 +08:00
|
|
|
adj = gimp_prop_opacity_entry_new (config, "sensitivity-b",
|
2005-08-07 07:04:23 +08:00
|
|
|
GTK_TABLE (table), 0, row++, "b");
|
2005-08-07 05:39:43 +08:00
|
|
|
gtk_range_set_update_policy (GTK_RANGE (GIMP_SCALE_ENTRY_SCALE (adj)),
|
2005-08-07 04:01:22 +08:00
|
|
|
GTK_UPDATE_DELAYED);
|
2005-08-07 03:08:43 +08:00
|
|
|
|
2005-08-01 02:29:10 +08:00
|
|
|
return vbox;
|
|
|
|
}
|