50
49
#define LIGHTNESS_SLIDER (1 << 1)
51
50
#define SATURATION_SLIDER (1 << 2)
52
51
#define DRAW (1 << 3)
53
#define SLIDERS (HUE_SLIDER | LIGHTNESS_SLIDER | SATURATION_SLIDER)
52
#define OVERLAP_SLIDER (1 << 4)
53
#define SLIDERS (HUE_SLIDER | \
54
57
#define ALL (SLIDERS | DRAW)
57
60
/* local function prototypes */
59
static void gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass);
60
static void gimp_hue_saturation_tool_init (GimpHueSaturationTool *tool);
62
62
static void gimp_hue_saturation_tool_finalize (GObject *object);
64
64
static gboolean gimp_hue_saturation_tool_initialize (GimpTool *tool,
67
static void gimp_hue_saturation_tool_map (GimpImageMapTool *image_map_tool);
68
static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *image_map_tool);
69
static void gimp_hue_saturation_tool_reset (GimpImageMapTool *image_map_tool);
68
static void gimp_hue_saturation_tool_map (GimpImageMapTool *im_tool);
69
static void gimp_hue_saturation_tool_dialog (GimpImageMapTool *im_tool);
70
static void gimp_hue_saturation_tool_reset (GimpImageMapTool *im_tool);
71
72
static void hue_saturation_update (GimpHueSaturationTool *hs_tool,
81
82
static void hue_saturation_saturation_adjustment_update (GtkAdjustment *adj,
85
/* private variables */
84
static void hue_saturation_overlap_adjustment_update (GtkAdjustment *adj,
88
G_DEFINE_TYPE (GimpHueSaturationTool, gimp_hue_saturation_tool,
89
GIMP_TYPE_IMAGE_MAP_TOOL)
91
#define parent_class gimp_hue_saturation_tool_parent_class
87
93
static gint default_colors[6][3] =
109
111
"gimp-hue-saturation-tool",
110
112
_("Hue-Saturation"),
111
_("Adjust hue and saturation"),
113
_("Hue-Saturation Tool: Adjust hue, saturation, and lightness"),
112
114
N_("Hue-_Saturation..."), NULL,
113
115
NULL, GIMP_HELP_TOOL_HUE_SATURATION,
114
116
GIMP_STOCK_TOOL_HUE_SATURATION,
119
gimp_hue_saturation_tool_get_type (void)
121
static GType tool_type = 0;
125
static const GTypeInfo tool_info =
127
sizeof (GimpHueSaturationToolClass),
128
(GBaseInitFunc) NULL,
129
(GBaseFinalizeFunc) NULL,
130
(GClassInitFunc) gimp_hue_saturation_tool_class_init,
131
NULL, /* class_finalize */
132
NULL, /* class_data */
133
sizeof (GimpHueSaturationTool),
135
(GInstanceInitFunc) gimp_hue_saturation_tool_init,
138
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
139
"GimpHueSaturationTool",
147
/* private functions */
150
121
gimp_hue_saturation_tool_class_init (GimpHueSaturationToolClass *klass)
152
GObjectClass *object_class;
153
GimpToolClass *tool_class;
154
GimpImageMapToolClass *image_map_tool_class;
156
object_class = G_OBJECT_CLASS (klass);
157
tool_class = GIMP_TOOL_CLASS (klass);
158
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
160
parent_class = g_type_class_peek_parent (klass);
162
object_class->finalize = gimp_hue_saturation_tool_finalize;
164
tool_class->initialize = gimp_hue_saturation_tool_initialize;
166
image_map_tool_class->shell_desc = _("Adjust hue / lightness / saturation");
168
image_map_tool_class->map = gimp_hue_saturation_tool_map;
169
image_map_tool_class->dialog = gimp_hue_saturation_tool_dialog;
170
image_map_tool_class->reset = gimp_hue_saturation_tool_reset;
123
GObjectClass *object_class = G_OBJECT_CLASS (klass);
124
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
125
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
127
object_class->finalize = gimp_hue_saturation_tool_finalize;
129
tool_class->initialize = gimp_hue_saturation_tool_initialize;
131
im_tool_class->shell_desc = _("Adjust Hue / Lightness / Saturation");
133
im_tool_class->map = gimp_hue_saturation_tool_map;
134
im_tool_class->dialog = gimp_hue_saturation_tool_dialog;
135
im_tool_class->reset = gimp_hue_saturation_tool_reset;
197
gimp_hue_saturation_tool_initialize (GimpTool *tool,
162
gimp_hue_saturation_tool_initialize (GimpTool *tool,
163
GimpDisplay *display,
200
166
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (tool);
201
167
GimpDrawable *drawable;
203
drawable = gimp_image_active_drawable (gdisp->gimage);
169
drawable = gimp_image_active_drawable (display->image);
208
174
if (! gimp_drawable_is_rgb (drawable))
210
g_message (_("Hue-Saturation operates only on RGB color layers."));
176
g_set_error (error, 0, 0,
177
_("Hue-Saturation operates only on RGB color layers."));
214
181
hue_saturation_init (hs_tool->hue_saturation);
216
GIMP_TOOL_CLASS (parent_class)->initialize (tool, gdisp);
183
GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error);
218
185
hue_saturation_update (hs_tool, ALL);
261
231
hue_partition_table[] =
263
{ N_("M_aster"), 2, 3, 0, 0 },
264
{ N_("_R"), 2, 1, 2, 0 },
265
{ N_("_Y"), 1, 2, 0, 2 },
266
{ N_("_G"), 1, 4, 0, 4 },
267
{ N_("_C"), 2, 5, 2, 6 },
268
{ N_("_B"), 3, 4, 4, 4 },
269
{ N_("_M"), 3, 2, 4, 2 }
233
{ N_("M_aster"), N_("Adjust all colors"), 2, 3, 0, 0 },
234
{ N_("_R"), N_("Red"), 2, 1, 2, 0 },
235
{ N_("_Y"), N_("Yellow"), 1, 2, 0, 2 },
236
{ N_("_G"), N_("Green"), 1, 4, 0, 4 },
237
{ N_("_C"), N_("Cyan"), 2, 5, 2, 6 },
238
{ N_("_B"), N_("Blue"), 3, 4, 4, 4 },
239
{ N_("_M"), N_("Magenta"), 3, 2, 4, 2 }
272
frame = gimp_frame_new (_("Select Primary Color to Modify"));
242
frame = gimp_frame_new (_("Select Primary Color to Adjust"));
273
243
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
275
245
gtk_widget_show (frame);
247
vbox = gtk_vbox_new (FALSE, 6);
248
gtk_container_add (GTK_CONTAINER (frame), vbox);
249
gtk_widget_show (vbox);
277
251
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
278
gtk_container_add (GTK_CONTAINER (frame), abox);
252
gtk_box_pack_start (GTK_BOX (vbox), abox, TRUE, TRUE, 0);
279
253
gtk_widget_show (abox);
281
255
/* The table containing hue partitions */
287
261
gtk_container_add (GTK_CONTAINER (abox), table);
289
263
/* the radio buttons for hue partitions */
290
for (i = 0; i < 7; i++)
264
for (i = 0; i < G_N_ELEMENTS (hue_partition_table); i++)
292
button = gtk_radio_button_new_with_mnemonic (group, gettext (hue_partition_table[i].label));
266
button = gtk_radio_button_new_with_mnemonic (group,
267
gettext (hue_partition_table[i].label));
293
268
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
294
269
g_object_set_data (G_OBJECT (button), "hue_partition",
295
270
GINT_TO_POINTER (i));
272
gimp_help_set_help_data (button,
273
gettext (hue_partition_table[i].tooltip),
299
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
300
gimp_help_set_help_data (button, _("Modify all colors"), NULL);
277
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE);
303
279
gtk_table_attach (GTK_TABLE (table), button,
304
280
hue_partition_table[i].label_col,
341
317
gtk_widget_show (table);
343
frame = gimp_frame_new (_("Modify Selected Color"));
319
label_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
320
spinner_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
322
/* Create the 'Overlap' option slider */
323
table = gtk_table_new (3, 1, FALSE);
324
gtk_table_set_col_spacings (GTK_TABLE (table), 4);
325
gtk_table_set_row_spacings (GTK_TABLE (table), 2);
326
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
327
gtk_widget_show (table);
329
data = gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
330
_("_Overlap:"), SLIDER_WIDTH, -1,
331
0.0, 0, 100.0, 1.0, 15.0, 0,
334
hs_tool->overlap_data = GTK_ADJUSTMENT (data);
336
gtk_size_group_add_widget (label_group, GIMP_SCALE_ENTRY_LABEL (data));
337
gtk_size_group_add_widget (spinner_group, GIMP_SCALE_ENTRY_SPINBUTTON (data));
338
g_object_unref (label_group);
339
g_object_unref (spinner_group);
341
slider = GIMP_SCALE_ENTRY_SCALE (data);
342
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
344
g_signal_connect (data, "value-changed",
345
G_CALLBACK (hue_saturation_overlap_adjustment_update),
348
frame = gimp_frame_new (_("Adjust Selected Color"));
344
349
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
345
350
FALSE, FALSE, 0);
346
351
gtk_widget_show (frame);
365
370
hs_tool->hue_data = GTK_ADJUSTMENT (data);
372
gtk_size_group_add_widget (label_group, GIMP_SCALE_ENTRY_LABEL (data));
373
gtk_size_group_add_widget (spinner_group, GIMP_SCALE_ENTRY_SPINBUTTON (data));
366
375
slider = GIMP_SCALE_ENTRY_SCALE (data);
367
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
376
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
369
g_signal_connect (data, "value_changed",
378
g_signal_connect (data, "value-changed",
370
379
G_CALLBACK (hue_saturation_hue_adjustment_update),
379
388
hs_tool->lightness_data = GTK_ADJUSTMENT (data);
390
gtk_size_group_add_widget (label_group, GIMP_SCALE_ENTRY_LABEL (data));
391
gtk_size_group_add_widget (spinner_group, GIMP_SCALE_ENTRY_SPINBUTTON (data));
380
393
slider = GIMP_SCALE_ENTRY_SCALE (data);
381
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
394
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
383
g_signal_connect (data, "value_changed",
396
g_signal_connect (data, "value-changed",
384
397
G_CALLBACK (hue_saturation_lightness_adjustment_update),
393
406
hs_tool->saturation_data = GTK_ADJUSTMENT (data);
408
gtk_size_group_add_widget (label_group, GIMP_SCALE_ENTRY_LABEL (data));
409
gtk_size_group_add_widget (spinner_group, GIMP_SCALE_ENTRY_SPINBUTTON (data));
394
411
slider = GIMP_SCALE_ENTRY_SCALE (data);
395
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
412
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
397
g_signal_connect (hs_tool->saturation_data, "value_changed",
414
g_signal_connect (hs_tool->saturation_data, "value-changed",
398
415
G_CALLBACK (hue_saturation_saturation_adjustment_update),
402
419
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
403
420
gtk_widget_show (hbox);
405
button = gtk_button_new_with_mnemonic (_("R_eset color"));
422
button = gtk_button_new_with_mnemonic (_("R_eset Color"));
406
423
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
407
424
gtk_widget_show (button);
560
565
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));
570
hue_saturation_overlap_adjustment_update (GtkAdjustment *adjustment,
573
GimpHueSaturationTool *hs_tool = GIMP_HUE_SATURATION_TOOL (data);
575
if (hs_tool->hue_saturation->overlap != adjustment->value)
577
hs_tool->hue_saturation->overlap = adjustment->value;
578
hue_saturation_update (hs_tool, DRAW);
580
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (hs_tool));