21
21
#include <gtk/gtk.h>
23
#include "libgimpmath/gimpmath.h"
23
#include "libgimpconfig/gimpconfig.h"
24
24
#include "libgimpwidgets/gimpwidgets.h"
26
26
#include "tools-types.h"
28
#include "config/gimpconfig-params.h"
29
28
#include "config/gimpcoreconfig.h"
31
30
#include "core/gimp.h"
32
31
#include "core/gimptoolinfo.h"
34
#include "widgets/gimppropwidgets.h"
35
33
#include "widgets/gimpwidgets-utils.h"
37
35
#include "gimprotatetool.h"
75
70
static void gimp_transform_options_preview_notify (GimpTransformOptions *options,
77
72
GtkWidget *density_box);
78
static void gimp_scale_options_constrain_callback (GtkWidget *widget,
80
static void gimp_scale_options_constrain_notify (GimpTransformOptions *options,
85
static GimpToolOptionsClass *parent_class = NULL;
89
gimp_transform_options_get_type (void)
91
static GType type = 0;
95
static const GTypeInfo info =
97
sizeof (GimpTransformOptionsClass),
99
(GBaseFinalizeFunc) NULL,
100
(GClassInitFunc) gimp_transform_options_class_init,
101
NULL, /* class_finalize */
102
NULL, /* class_data */
103
sizeof (GimpTransformOptions),
105
(GInstanceInitFunc) NULL
108
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
109
"GimpTransformOptions",
75
G_DEFINE_TYPE (GimpTransformOptions, gimp_transform_options,
76
GIMP_TYPE_TOOL_OPTIONS)
78
#define parent_class gimp_transform_options_parent_class
117
82
gimp_transform_options_class_init (GimpTransformOptionsClass *klass)
131
94
GIMP_TYPE_TRANSFORM_TYPE,
132
95
GIMP_TRANSFORM_TYPE_LAYER,
96
GIMP_PARAM_STATIC_STRINGS);
134
97
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_DIRECTION,
135
98
"direction", NULL,
136
99
GIMP_TYPE_TRANSFORM_DIRECTION,
137
100
GIMP_TRANSFORM_FORWARD,
101
GIMP_PARAM_STATIC_STRINGS);
139
102
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION,
140
103
"interpolation", NULL,
141
104
GIMP_TYPE_INTERPOLATION_TYPE,
142
105
GIMP_INTERPOLATION_LINEAR,
106
GIMP_PARAM_STATIC_STRINGS);
144
107
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SUPERSAMPLE,
145
108
"supersample", NULL,
110
GIMP_PARAM_STATIC_STRINGS);
150
113
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_RECURSION_LEVEL,
151
114
"recursion-level", NULL,
116
GIMP_PARAM_STATIC_STRINGS);
156
119
g_object_class_install_property (object_class, PROP_RECURSION_LEVEL,
157
120
g_param_spec_int ("recursion-level",
123
GIMP_PARAM_READWRITE |
161
124
G_PARAM_CONSTRUCT));
163
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CLIP,
126
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_CLIP,
128
GIMP_TYPE_TRANSFORM_RESIZE,
129
GIMP_TRANSFORM_RESIZE_ADJUST,
130
GIMP_PARAM_STATIC_STRINGS);
167
131
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_PREVIEW_TYPE,
168
132
"preview-type", NULL,
169
133
GIMP_TYPE_TRANSFORM_PREVIEW_TYPE,
170
134
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE,
135
GIMP_PARAM_STATIC_STRINGS);
172
136
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_GRID_TYPE,
173
137
"grid-type", NULL,
174
138
GIMP_TYPE_TRANSFORM_GRID_TYPE,
175
139
GIMP_TRANSFORM_GRID_TYPE_N_LINES,
140
GIMP_PARAM_STATIC_STRINGS);
177
141
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_GRID_SIZE,
178
142
"grid-size", NULL,
181
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_1,
185
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONSTRAIN_2,
144
GIMP_PARAM_STATIC_STRINGS);
145
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_CONSTRAIN,
148
GIMP_PARAM_STATIC_STRINGS);
152
gimp_transform_options_init (GimpTransformOptions *options)
274
236
case PROP_GRID_SIZE:
275
237
g_value_set_int (value, options->grid_size);
277
case PROP_CONSTRAIN_1:
278
g_value_set_boolean (value, options->constrain_1);
280
case PROP_CONSTRAIN_2:
281
g_value_set_boolean (value, options->constrain_2);
240
g_value_set_boolean (value, options->constrain);
284
243
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
307
266
GObject *config = G_OBJECT (tool_options);
308
267
GimpTransformOptions *options = GIMP_TRANSFORM_OPTIONS (tool_options);
268
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
311
270
GtkWidget *label;
312
271
GtkWidget *frame;
313
272
GtkWidget *table;
314
273
GtkWidget *combo;
315
274
GtkWidget *button;
317
vbox = gimp_tool_options_gui (tool_options);
275
const gchar *constrain = NULL;
319
277
hbox = gimp_prop_enum_stock_box_new (config, "type", "gimp", 0, 0);
320
278
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
321
279
gtk_widget_show (hbox);
323
label = gtk_label_new (_("Affect:"));
281
label = gtk_label_new (_("Transform:"));
324
282
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
325
283
gtk_box_reorder_child (GTK_BOX (hbox), label, 0);
326
284
gtk_widget_show (label);
328
286
frame = gimp_prop_enum_radio_frame_new (config, "direction",
329
_("Transform Direction"), 0, 0);
287
_("Direction"), 0, 0);
330
288
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
331
289
gtk_widget_show (frame);
333
291
/* the interpolation menu */
334
hbox = gtk_hbox_new (FALSE, 4);
292
hbox = gtk_hbox_new (FALSE, 6);
335
293
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
336
294
gtk_widget_show (hbox);
349
307
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
350
308
gtk_widget_show (button);
352
/* the clip resulting image toggle button */
353
button = gimp_prop_check_button_new (config, "clip", _("Clip result"));
354
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
355
gtk_widget_show (button);
310
/* the clipping menu */
311
hbox = gtk_hbox_new (FALSE, 6);
312
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
313
gtk_widget_show (hbox);
315
label = gtk_label_new (_("Clipping:"));
316
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
317
gtk_widget_show (label);
319
combo = gimp_prop_enum_combo_box_new (config, "clip", 0, 0);
320
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
321
gtk_widget_show (combo);
357
323
/* the preview frame */
358
324
frame = gimp_frame_new (NULL);
404
370
FALSE, 0.0, 0.0);
406
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL ||
407
tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
412
/* the constraints frame */
413
frame = gimp_frame_new (_("Constraints"));
414
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
415
gtk_widget_show (frame);
417
vbox2 = gtk_vbox_new (FALSE, 2);
418
gtk_container_add (GTK_CONTAINER (frame), vbox2);
419
gtk_widget_show (vbox2);
421
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL)
425
str = g_strdup_printf (_("15 degrees %s"),
426
gimp_get_mod_string (GDK_CONTROL_MASK));
428
button = gimp_prop_check_button_new (config, "constrain-1", str);
429
gtk_box_pack_start (GTK_BOX (vbox2), button, FALSE, FALSE, 0);
430
gtk_widget_show (button);
434
else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
442
initial = ((options->constrain_1 ? 1 : 0) +
443
(options->constrain_2 ? 2 : 0));
445
str1 = g_strdup_printf (_("Keep height %s"),
446
gimp_get_mod_string (GDK_CONTROL_MASK));
447
str2 = g_strdup_printf (_("Keep width %s"),
448
gimp_get_mod_string (GDK_MOD1_MASK));
449
str3 = g_strdup_printf (_("Keep aspect %s"),
450
gimp_get_mod_string (GDK_CONTROL_MASK |
453
vbox3 = gimp_int_radio_group_new (FALSE, NULL,
454
G_CALLBACK (gimp_scale_options_constrain_callback),
457
_("None"), 0, &button,
464
gtk_box_pack_start (GTK_BOX (vbox2), vbox3, FALSE, FALSE, 0);
465
gtk_widget_show (vbox3);
467
g_signal_connect_object (config, "notify::constrain-1",
468
G_CALLBACK (gimp_scale_options_constrain_notify),
469
G_OBJECT (button), 0);
470
g_signal_connect_object (config, "notify::constrain-2",
471
G_CALLBACK (gimp_scale_options_constrain_notify),
472
G_OBJECT (button), 0);
372
if (tool_options->tool_info->tool_type == GIMP_TYPE_ROTATE_TOOL)
374
constrain = (_("15 degrees (%s)"));
376
else if (tool_options->tool_info->tool_type == GIMP_TYPE_SCALE_TOOL)
378
constrain = (_("Keep aspect (%s)"));
383
gchar *label = g_strdup_printf (constrain,
384
gimp_get_mod_string (GDK_CONTROL_MASK));
386
button = gimp_prop_check_button_new (config, "constrain", label);
387
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
388
gtk_widget_show (button);
494
407
options->preview_type ==
495
408
GIMP_TRANSFORM_PREVIEW_TYPE_IMAGE_GRID);
499
gimp_scale_options_constrain_callback (GtkWidget *widget,
502
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
508
value = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget),
513
if (value == 1 || value == 3)
515
if (value == 2 || value == 3)
518
g_object_set (config,
526
gimp_scale_options_constrain_notify (GimpTransformOptions *options,
532
value = ((options->constrain_1 ? 1 : 0) +
533
(options->constrain_2 ? 2 : 0));
535
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (button), value);