53
50
/* local function prototypes */
55
static void gimp_color_balance_tool_class_init (GimpColorBalanceToolClass *klass);
56
static void gimp_color_balance_tool_init (GimpColorBalanceTool *cb_tool);
58
52
static void gimp_color_balance_tool_finalize (GObject *object);
60
54
static gboolean gimp_color_balance_tool_initialize (GimpTool *tool,
63
static void gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool);
64
static void gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool);
65
static void gimp_color_balance_tool_reset (GimpImageMapTool *image_map_tool);
58
static void gimp_color_balance_tool_map (GimpImageMapTool *im_tool);
59
static void gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool);
60
static void gimp_color_balance_tool_reset (GimpImageMapTool *im_tool);
67
62
static void color_balance_update (GimpColorBalanceTool *cb_tool,
80
75
GimpColorBalanceTool *cb_tool);
83
static GimpImageMapToolClass *parent_class = NULL;
78
G_DEFINE_TYPE (GimpColorBalanceTool, gimp_color_balance_tool,
79
GIMP_TYPE_IMAGE_MAP_TOOL)
81
#define parent_class gimp_color_balance_tool_parent_class
89
85
gimp_color_balance_tool_register (GimpToolRegisterCallback callback,
95
91
"gimp-color-balance-tool",
96
92
_("Color Balance"),
97
_("Adjust color balance"),
93
_("Color Balance Tool: Adjust color distribution"),
98
94
N_("Color _Balance..."), NULL,
99
95
NULL, GIMP_HELP_TOOL_COLOR_BALANCE,
100
96
GIMP_STOCK_TOOL_COLOR_BALANCE,
105
gimp_color_balance_tool_get_type (void)
107
static GType tool_type = 0;
111
static const GTypeInfo tool_info =
113
sizeof (GimpColorBalanceToolClass),
114
(GBaseInitFunc) NULL,
115
(GBaseFinalizeFunc) NULL,
116
(GClassInitFunc) gimp_color_balance_tool_class_init,
117
NULL, /* class_finalize */
118
NULL, /* class_data */
119
sizeof (GimpColorBalanceTool),
121
(GInstanceInitFunc) gimp_color_balance_tool_init,
124
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
125
"GimpColorBalanceTool",
133
101
gimp_color_balance_tool_class_init (GimpColorBalanceToolClass *klass)
135
GObjectClass *object_class;
136
GimpToolClass *tool_class;
137
GimpImageMapToolClass *image_map_tool_class;
139
object_class = G_OBJECT_CLASS (klass);
140
tool_class = GIMP_TOOL_CLASS (klass);
141
image_map_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
143
parent_class = g_type_class_peek_parent (klass);
145
object_class->finalize = gimp_color_balance_tool_finalize;
147
tool_class->initialize = gimp_color_balance_tool_initialize;
149
image_map_tool_class->shell_desc = _("Adjust Color Balance");
151
image_map_tool_class->map = gimp_color_balance_tool_map;
152
image_map_tool_class->dialog = gimp_color_balance_tool_dialog;
153
image_map_tool_class->reset = gimp_color_balance_tool_reset;
103
GObjectClass *object_class = G_OBJECT_CLASS (klass);
104
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
105
GimpImageMapToolClass *im_tool_class = GIMP_IMAGE_MAP_TOOL_CLASS (klass);
107
object_class->finalize = gimp_color_balance_tool_finalize;
109
tool_class->initialize = gimp_color_balance_tool_initialize;
111
im_tool_class->shell_desc = _("Adjust Color Balance");
113
im_tool_class->map = gimp_color_balance_tool_map;
114
im_tool_class->dialog = gimp_color_balance_tool_dialog;
115
im_tool_class->reset = gimp_color_balance_tool_reset;
180
gimp_color_balance_tool_initialize (GimpTool *tool,
142
gimp_color_balance_tool_initialize (GimpTool *tool,
143
GimpDisplay *display,
183
146
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (tool);
184
147
GimpDrawable *drawable;
186
drawable = gimp_image_active_drawable (gdisp->gimage);
149
drawable = gimp_image_active_drawable (display->image);
191
154
if (! gimp_drawable_is_rgb (drawable))
193
g_message (_("Color balance operates only on RGB color layers."));
156
g_set_error (error, 0, 0,
157
_("Color Balance operates only on RGB color layers."));
209
gimp_color_balance_tool_map (GimpImageMapTool *image_map_tool)
173
gimp_color_balance_tool_map (GimpImageMapTool *im_tool)
211
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
175
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
213
177
color_balance_create_lookup_tables (cb_tool->color_balance);
214
gimp_image_map_apply (image_map_tool->image_map,
178
gimp_image_map_apply (im_tool->image_map,
179
(GimpImageMapApplyFunc) color_balance,
216
180
cb_tool->color_balance);
227
191
GtkWidget *table,
232
GtkWidget *spinbutton;
235
adj = GTK_ADJUSTMENT (gtk_adjustment_new (0, -100.0, 100.0, 1.0, 10.0, 0.0));
196
GtkWidget *spinbutton;
237
199
label = gtk_label_new (left);
238
200
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
239
201
gtk_table_attach (GTK_TABLE (table), label, 0, 1, col, col + 1,
240
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
202
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
241
203
gtk_widget_show (label);
243
slider = gtk_hscale_new (adj);
205
spinbutton = gimp_spin_button_new (&adj,
206
0, -100.0, 100.0, 1.0, 10.0, 0.0, 1.0, 0);
208
slider = gtk_hscale_new (GTK_ADJUSTMENT (adj));
244
209
gtk_scale_set_draw_value (GTK_SCALE (slider), FALSE);
245
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_DELAYED);
210
gtk_range_set_update_policy (GTK_RANGE (slider), GTK_UPDATE_CONTINUOUS);
246
211
gtk_widget_set_size_request (slider, 100, -1);
247
212
gtk_table_attach_defaults (GTK_TABLE (table), slider, 1, 2, col, col + 1);
248
213
gtk_widget_show (slider);
250
215
label = gtk_label_new (right);
251
216
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
252
217
gtk_table_attach (GTK_TABLE (table), label, 2, 3, col, col + 1,
253
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
218
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
254
219
gtk_widget_show (label);
256
spinbutton = gtk_spin_button_new (adj, 1.0, 0);
257
221
gtk_table_attach (GTK_TABLE (table), spinbutton, 3, 4, col, col + 1,
258
222
GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
259
223
gtk_widget_show (spinbutton);
225
return GTK_ADJUSTMENT (adj);
265
gimp_color_balance_tool_dialog (GimpImageMapTool *image_map_tool)
229
gimp_color_balance_tool_dialog (GimpImageMapTool *im_tool)
267
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
231
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
270
234
GtkWidget *table;
273
237
GtkWidget *frame;
275
239
frame = gimp_enum_radio_frame_new (GIMP_TYPE_TRANSFER_MODE,
276
gtk_label_new (_("Select Range to Modify")),
240
gtk_label_new (_("Select Range to Adjust")),
277
241
G_CALLBACK (color_balance_range_callback),
280
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
244
gtk_box_pack_start (GTK_BOX (im_tool->main_vbox), frame, FALSE, FALSE, 0);
282
245
gtk_widget_show (frame);
284
frame = gimp_frame_new (_("Modify Selected Range's Color Levels"));
285
gtk_box_pack_start (GTK_BOX (image_map_tool->main_vbox), frame,
247
frame = gimp_frame_new (_("Adjust Color Levels"));
248
gtk_box_pack_start (GTK_BOX (im_tool->main_vbox), frame, FALSE, FALSE, 0);
287
249
gtk_widget_show (frame);
289
251
vbox = gtk_vbox_new (FALSE, 4);
300
262
cb_tool->cyan_red_adj =
301
263
create_levels_scale (_("Cyan"), _("Red"), table, 0);
303
g_signal_connect (cb_tool->cyan_red_adj, "value_changed",
265
g_signal_connect (cb_tool->cyan_red_adj, "value-changed",
304
266
G_CALLBACK (color_balance_cr_adjustment_update),
307
269
cb_tool->magenta_green_adj =
308
270
create_levels_scale (_("Magenta"), _("Green"), table, 1);
310
g_signal_connect (cb_tool->magenta_green_adj, "value_changed",
272
g_signal_connect (cb_tool->magenta_green_adj, "value-changed",
311
273
G_CALLBACK (color_balance_mg_adjustment_update),
314
276
cb_tool->yellow_blue_adj =
315
277
create_levels_scale (_("Yellow"), _("Blue"), table, 2);
317
g_signal_connect (cb_tool->yellow_blue_adj, "value_changed",
279
g_signal_connect (cb_tool->yellow_blue_adj, "value-changed",
318
280
G_CALLBACK (color_balance_yb_adjustment_update),
322
284
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
323
285
gtk_widget_show (hbox);
325
button = gtk_button_new_with_mnemonic (_("R_eset range"));
287
button = gtk_button_new_with_mnemonic (_("R_eset Range"));
326
288
gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
327
289
gtk_widget_show (button);
333
295
cb_tool->preserve_toggle =
334
296
gtk_check_button_new_with_mnemonic (_("Preserve _luminosity"));
335
297
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb_tool->preserve_toggle),
336
cb_tool->color_balance->preserve_luminosity);
337
gtk_box_pack_end (GTK_BOX (image_map_tool->main_vbox),
338
cb_tool->preserve_toggle, FALSE, FALSE, 0);
298
cb_tool->color_balance->preserve_luminosity);
299
gtk_box_pack_end (GTK_BOX (im_tool->main_vbox), cb_tool->preserve_toggle,
339
301
gtk_widget_show (cb_tool->preserve_toggle);
341
303
g_signal_connect (cb_tool->preserve_toggle, "toggled",
351
gimp_color_balance_tool_reset (GimpImageMapTool *image_map_tool)
313
gimp_color_balance_tool_reset (GimpImageMapTool *im_tool)
353
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (image_map_tool);
315
GimpColorBalanceTool *cb_tool = GIMP_COLOR_BALANCE_TOOL (im_tool);
355
317
color_balance_init (cb_tool->color_balance);
356
318
color_balance_update (cb_tool, ALL);