52
53
#include "gimp-intl.h"
54
#define EPSILON 3 /* move distance after which we do a box-select */
55
#define MARKER_WIDTH 5 /* size (in pixels) of the square handles */
56
#define EPSILON 3 /* move distance after which we do a box-select */
57
59
/* local function prototypes */
59
static GObject * gimp_align_tool_constructor (GType type,
61
GObjectConstructParam *params);
62
static gboolean gimp_align_tool_initialize (GimpTool *tool,
65
static void gimp_align_tool_finalize (GObject *object);
67
static void gimp_align_tool_control (GimpTool *tool,
68
GimpToolAction action,
69
GimpDisplay *display);
70
static void gimp_align_tool_button_press (GimpTool *tool,
73
GdkModifierType state,
74
GimpDisplay *display);
75
static void gimp_align_tool_button_release (GimpTool *tool,
78
GdkModifierType state,
79
GimpButtonReleaseType release_tyle,
80
GimpDisplay *display);
81
static void gimp_align_tool_motion (GimpTool *tool,
84
GdkModifierType state,
85
GimpDisplay *display);
86
static void gimp_align_tool_oper_update (GimpTool *tool,
88
GdkModifierType state,
90
GimpDisplay *display);
91
static void gimp_align_tool_status_update (GimpTool *tool,
93
GdkModifierType state,
95
static void gimp_align_tool_cursor_update (GimpTool *tool,
97
GdkModifierType state,
98
GimpDisplay *display);
100
static void gimp_align_tool_draw (GimpDrawTool *draw_tool);
102
static GtkWidget *button_with_stock (GimpAlignmentType action,
103
GimpAlignTool *align_tool);
104
static GtkWidget *gimp_align_tool_controls (GimpAlignTool *align_tool);
105
static void do_alignment (GtkWidget *widget,
107
static void clear_selected_object (GObject *object,
108
GimpAlignTool *align_tool);
109
static void clear_all_selected_objects (GimpAlignTool *align_tool);
110
static GimpLayer *select_layer_by_coords (GimpImage *image,
113
void gimp_image_arrange_objects (GimpImage *image,
115
GimpAlignmentType alignment,
117
GimpAlignmentType reference_alignment,
61
static void gimp_align_tool_constructed (GObject *object);
63
static void gimp_align_tool_control (GimpTool *tool,
64
GimpToolAction action,
65
GimpDisplay *display);
66
static void gimp_align_tool_button_press (GimpTool *tool,
67
const GimpCoords *coords,
69
GdkModifierType state,
70
GimpButtonPressType press_type,
71
GimpDisplay *display);
72
static void gimp_align_tool_button_release (GimpTool *tool,
73
const GimpCoords *coords,
75
GdkModifierType state,
76
GimpButtonReleaseType release_type,
77
GimpDisplay *display);
78
static void gimp_align_tool_motion (GimpTool *tool,
79
const GimpCoords *coords,
81
GdkModifierType state,
82
GimpDisplay *display);
83
static gboolean gimp_align_tool_key_press (GimpTool *tool,
85
GimpDisplay *display);
86
static void gimp_align_tool_oper_update (GimpTool *tool,
87
const GimpCoords *coords,
88
GdkModifierType state,
90
GimpDisplay *display);
91
static void gimp_align_tool_status_update (GimpTool *tool,
93
GdkModifierType state,
95
static void gimp_align_tool_cursor_update (GimpTool *tool,
96
const GimpCoords *coords,
97
GdkModifierType state,
98
GimpDisplay *display);
100
static void gimp_align_tool_draw (GimpDrawTool *draw_tool);
102
static void gimp_align_tool_align (GimpAlignTool *align_tool,
103
GimpAlignmentType align_type);
105
static void gimp_align_tool_object_removed (GObject *object,
106
GimpAlignTool *align_tool);
107
static void gimp_align_tool_clear_selected (GimpAlignTool *align_tool);
120
110
G_DEFINE_TYPE (GimpAlignTool, gimp_align_tool, GIMP_TYPE_DRAW_TOOL)
166
155
GimpTool *tool = GIMP_TOOL (align_tool);
168
align_tool->controls = NULL;
170
align_tool->function = ALIGN_TOOL_IDLE;
171
align_tool->selected_objects = NULL;
173
align_tool->align_type = GIMP_ALIGN_LEFT;
175
align_tool->horz_offset = 0;
176
align_tool->vert_offset = 0;
178
157
gimp_tool_control_set_snap_to (tool->control, FALSE);
179
158
gimp_tool_control_set_precision (tool->control,
180
159
GIMP_CURSOR_PRECISION_PIXEL_BORDER);
181
160
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_MOVE);
186
gimp_align_tool_constructor (GType type,
188
GObjectConstructParam *params)
192
GimpAlignTool *align_tool;
193
GtkContainer *container;
196
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
198
tool = GIMP_TOOL (object);
199
align_tool = GIMP_ALIGN_TOOL (object);
200
options = G_OBJECT (gimp_tool_get_options (tool));
202
/* This line of code is evil because it relies on that the 'options'
203
* object is fully constructed before we get here, which is not
206
container = GTK_CONTAINER (g_object_get_data (options,
207
"controls-container"));
211
align_tool->controls = gimp_align_tool_controls (align_tool);
212
gtk_container_add (container, align_tool->controls);
213
gtk_widget_show (align_tool->controls);
162
align_tool->function = ALIGN_TOOL_IDLE;
220
gimp_align_tool_finalize (GObject *object)
222
GimpTool *tool = GIMP_TOOL (object);
223
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (object);
225
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (object)))
226
gimp_draw_tool_stop (GIMP_DRAW_TOOL (object));
228
if (gimp_tool_control_is_active (tool->control))
229
gimp_tool_control_halt (tool->control);
231
if (align_tool->controls)
233
gtk_widget_destroy (align_tool->controls);
234
align_tool->controls = NULL;
237
G_OBJECT_CLASS (parent_class)->finalize (object);
241
gimp_align_tool_initialize (GimpTool *tool,
242
GimpDisplay *display,
245
if (tool->display != display)
166
gimp_align_tool_constructed (GObject *object)
168
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (object);
169
GimpAlignOptions *options;
171
if (G_OBJECT_CLASS (parent_class)->constructed)
172
G_OBJECT_CLASS (parent_class)->constructed (object);
174
options = GIMP_ALIGN_TOOL_GET_OPTIONS (align_tool);
176
g_signal_connect_object (options, "align-button-clicked",
177
G_CALLBACK (gimp_align_tool_align),
178
align_tool, G_CONNECT_SWAPPED);
317
238
gimp_align_tool_button_release (GimpTool *tool,
239
const GimpCoords *coords,
320
241
GdkModifierType state,
321
242
GimpButtonReleaseType release_type,
322
243
GimpDisplay *display)
324
245
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
325
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
246
GimpAlignOptions *options = GIMP_ALIGN_TOOL_GET_OPTIONS (tool);
247
GimpDisplayShell *shell = gimp_display_get_shell (display);
326
248
GObject *object = NULL;
327
GimpImage *image = display->image;
249
GimpImage *image = gimp_display_get_image (display);
250
GdkModifierType extend_mask;
253
extend_mask = gimp_get_extend_selection_mask ();
330
255
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
257
gimp_tool_control_halt (tool->control);
332
259
if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
334
align_tool->x1 = align_tool->x0;
335
align_tool->y1 = align_tool->y0;
261
align_tool->x2 = align_tool->x1;
262
align_tool->y2 = align_tool->y1;
337
264
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
341
if (! (state & GDK_SHIFT_MASK)) /* start a new list */
268
if (! (state & extend_mask)) /* start a new list */
343
clear_all_selected_objects (align_tool);
270
gimp_align_tool_clear_selected (align_tool);
344
271
align_tool->set_reference = FALSE;
347
/* if mouse has moved less than EPSILON pixels since button press, select
348
the nearest thing, otherwise make a rubber-band rectangle */
349
if (hypot (coords->x - align_tool->x0, coords->y - align_tool->y0) < EPSILON)
274
/* if mouse has moved less than EPSILON pixels since button press,
275
* select the nearest thing, otherwise make a rubber-band rectangle
277
if (hypot (coords->x - align_tool->x1,
278
coords->y - align_tool->y1) < EPSILON)
351
280
GimpVectors *vectors;
352
281
GimpGuide *guide;
353
282
GimpLayer *layer;
357
GIMP_DISPLAY_CONFIG (display->image->gimp->config)->snap_distance;
283
gint snap_distance = display->config->snap_distance;
359
285
if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), display,
360
286
coords, snap_distance, snap_distance,
385
311
if (! g_list_find (align_tool->selected_objects, object))
387
align_tool->selected_objects
388
= g_list_append (align_tool->selected_objects, object);
313
align_tool->selected_objects =
314
g_list_append (align_tool->selected_objects, object);
389
316
g_signal_connect (object, "removed",
390
G_CALLBACK (clear_selected_object),
391
(gpointer) align_tool);
317
G_CALLBACK (gimp_align_tool_object_removed),
393
320
/* if an object has been selected using unmodified click,
394
321
* it should be used as the reference
396
if (! (state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)))
323
if (! (state & extend_mask))
397
324
align_tool->set_reference = TRUE;
401
328
else /* FIXME: look for vectors too */
403
gint X0 = MIN (coords->x, align_tool->x0);
404
gint X1 = MAX (coords->x, align_tool->x0);
405
gint Y0 = MIN (coords->y, align_tool->y0);
406
gint Y1 = MAX (coords->y, align_tool->y0);
330
gint X0 = MIN (coords->x, align_tool->x1);
331
gint X1 = MAX (coords->x, align_tool->x1);
332
gint Y0 = MIN (coords->y, align_tool->y1);
333
gint Y1 = MAX (coords->y, align_tool->y1);
409
for (list = GIMP_LIST (image->layers)->list;
411
list = g_list_next (list))
337
all_layers = gimp_image_get_layer_list (image);
339
for (list = all_layers; list; list = g_list_next (list))
413
341
GimpLayer *layer = list->data;
414
342
gint x0, y0, x1, y1;
426
354
if (g_list_find (align_tool->selected_objects, layer))
429
align_tool->selected_objects
430
= g_list_append (align_tool->selected_objects, layer);
431
g_signal_connect (layer, "removed", G_CALLBACK (clear_selected_object),
432
(gpointer) align_tool);
357
align_tool->selected_objects =
358
g_list_append (align_tool->selected_objects, layer);
360
g_signal_connect (layer, "removed",
361
G_CALLBACK (gimp_align_tool_object_removed),
365
g_list_free (all_layers);
436
for (i = 0; i < ALIGN_TOOL_NUM_BUTTONS; i++)
368
for (i = 0; i < ALIGN_OPTIONS_N_BUTTONS; i++)
438
if (align_tool->button[i])
440
gtk_widget_set_sensitive (align_tool->button[i],
441
(align_tool->selected_objects != NULL));
370
if (options->button[i])
371
gtk_widget_set_sensitive (options->button[i],
372
align_tool->selected_objects != NULL);
445
align_tool->x1 = align_tool->x0;
446
align_tool->y1 = align_tool->y0;
375
align_tool->x2 = align_tool->x1;
376
align_tool->y2 = align_tool->y1;
448
378
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
452
gimp_align_tool_motion (GimpTool *tool,
455
GdkModifierType state,
456
GimpDisplay *display)
382
gimp_align_tool_motion (GimpTool *tool,
383
const GimpCoords *coords,
385
GdkModifierType state,
386
GimpDisplay *display)
458
388
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
460
390
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
462
align_tool->x1 = coords->x;
463
align_tool->y1 = coords->y;
392
align_tool->x2 = coords->x;
393
align_tool->y2 = coords->y;
465
395
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
399
gimp_align_tool_key_press (GimpTool *tool,
401
GimpDisplay *display)
403
if (display == tool->display)
405
switch (kevent->keyval)
408
gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display);
469
gimp_align_tool_oper_update (GimpTool *tool,
471
GdkModifierType state,
473
GimpDisplay *display)
420
gimp_align_tool_oper_update (GimpTool *tool,
421
const GimpCoords *coords,
422
GdkModifierType state,
424
GimpDisplay *display)
475
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
476
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
426
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
427
GimpDisplayShell *shell = gimp_display_get_shell (display);
428
GimpImage *image = gimp_display_get_image (display);
429
gint snap_distance = display->config->snap_distance;
480
GIMP_DISPLAY_CONFIG (display->image->gimp->config)->snap_distance;
432
add = ((state & gimp_get_extend_selection_mask ()) &&
433
align_tool->selected_objects);
482
435
if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), display,
483
436
coords, snap_distance, snap_distance,
484
437
NULL, NULL, NULL, NULL, NULL, NULL))
486
if ((state & GDK_SHIFT_MASK) && align_tool->selected_objects)
487
440
align_tool->function = ALIGN_TOOL_ADD_PATH;
489
442
align_tool->function = ALIGN_TOOL_PICK_PATH;
491
444
else if (gimp_display_shell_get_show_guides (shell) &&
492
(NULL != gimp_image_find_guide (display->image,
493
coords->x, coords->y,
494
FUNSCALEX (shell, snap_distance),
495
FUNSCALEY (shell, snap_distance))))
445
gimp_image_find_guide (image,
446
coords->x, coords->y,
447
FUNSCALEX (shell, snap_distance),
448
FUNSCALEY (shell, snap_distance)))
497
if ((state & GDK_SHIFT_MASK) && align_tool->selected_objects)
498
451
align_tool->function = ALIGN_TOOL_ADD_GUIDE;
500
453
align_tool->function = ALIGN_TOOL_PICK_GUIDE;
504
GimpLayer *layer = select_layer_by_coords (display->image,
505
coords->x, coords->y);
459
layer = gimp_image_pick_layer_by_bounds (image, coords->x, coords->y);
509
if ((state & GDK_SHIFT_MASK) && align_tool->selected_objects)
510
464
align_tool->function = ALIGN_TOOL_ADD_LAYER;
512
466
align_tool->function = ALIGN_TOOL_PICK_LAYER;
694
gimp_item_offsets (item, &x, &y);
638
gimp_item_get_offset (item, &x, &y);
696
w = gimp_item_width (item);
697
h = gimp_item_height (item);
640
w = gimp_item_get_width (item);
641
h = gimp_item_get_height (item);
700
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
701
x, y, MARKER_WIDTH, MARKER_WIDTH,
702
GTK_ANCHOR_NORTH_WEST, FALSE);
703
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
704
x + w, y, MARKER_WIDTH, MARKER_WIDTH,
705
GTK_ANCHOR_NORTH_EAST, FALSE);
706
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
707
x, y + h, MARKER_WIDTH, MARKER_WIDTH,
708
GTK_ANCHOR_SOUTH_WEST, FALSE);
709
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
710
x + w, y + h, MARKER_WIDTH, MARKER_WIDTH,
711
GTK_ANCHOR_SOUTH_EAST, FALSE);
644
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
646
GIMP_TOOL_HANDLE_SIZE_SMALL,
647
GIMP_TOOL_HANDLE_SIZE_SMALL,
648
GIMP_HANDLE_ANCHOR_NORTH_WEST);
649
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
651
GIMP_TOOL_HANDLE_SIZE_SMALL,
652
GIMP_TOOL_HANDLE_SIZE_SMALL,
653
GIMP_HANDLE_ANCHOR_NORTH_EAST);
654
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
656
GIMP_TOOL_HANDLE_SIZE_SMALL,
657
GIMP_TOOL_HANDLE_SIZE_SMALL,
658
GIMP_HANDLE_ANCHOR_SOUTH_WEST);
659
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
661
GIMP_TOOL_HANDLE_SIZE_SMALL,
662
GIMP_TOOL_HANDLE_SIZE_SMALL,
663
GIMP_HANDLE_ANCHOR_SOUTH_EAST);
713
665
else if (GIMP_IS_GUIDE (list->data))
715
GimpGuide *guide = GIMP_GUIDE (list->data);
716
GimpImage *image = GIMP_TOOL (draw_tool)->display->image;
667
GimpGuide *guide = list->data;
668
GimpImage *image = gimp_display_get_image (GIMP_TOOL (draw_tool)->display);
722
674
case GIMP_ORIENTATION_VERTICAL:
723
675
x = gimp_guide_get_position (guide);
724
676
h = gimp_image_get_height (image);
725
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
726
x, h, MARKER_WIDTH, MARKER_WIDTH,
727
GTK_ANCHOR_SOUTH, FALSE);
728
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
729
x, 0, MARKER_WIDTH, MARKER_WIDTH,
730
GTK_ANCHOR_NORTH, FALSE);
677
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
679
GIMP_TOOL_HANDLE_SIZE_SMALL,
680
GIMP_TOOL_HANDLE_SIZE_SMALL,
681
GIMP_HANDLE_ANCHOR_SOUTH);
682
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
684
GIMP_TOOL_HANDLE_SIZE_SMALL,
685
GIMP_TOOL_HANDLE_SIZE_SMALL,
686
GIMP_HANDLE_ANCHOR_NORTH);
733
689
case GIMP_ORIENTATION_HORIZONTAL:
734
690
y = gimp_guide_get_position (guide);
735
691
w = gimp_image_get_width (image);
736
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
737
w, y, MARKER_WIDTH, MARKER_WIDTH,
738
GTK_ANCHOR_EAST, FALSE);
739
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
740
0, y, MARKER_WIDTH, MARKER_WIDTH,
741
GTK_ANCHOR_WEST, FALSE);
692
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
694
GIMP_TOOL_HANDLE_SIZE_SMALL,
695
GIMP_TOOL_HANDLE_SIZE_SMALL,
696
GIMP_HANDLE_ANCHOR_EAST);
697
gimp_draw_tool_add_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
699
GIMP_TOOL_HANDLE_SIZE_SMALL,
700
GIMP_TOOL_HANDLE_SIZE_SMALL,
701
GIMP_HANDLE_ANCHOR_WEST);
752
gimp_align_tool_controls (GimpAlignTool *align_tool)
754
GtkWidget *main_vbox;
760
GtkWidget *spinbutton;
764
main_vbox = gtk_vbox_new (FALSE, 12);
766
frame = gimp_frame_new (_("Align"));
767
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
768
gtk_widget_show (frame);
770
vbox = gtk_vbox_new (FALSE, 6);
771
gtk_container_add (GTK_CONTAINER (frame), vbox);
772
gtk_widget_show (vbox);
774
hbox = gtk_hbox_new (FALSE, 6);
775
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
776
gtk_widget_show (hbox);
778
frame = gimp_frame_new (_("Relative to:"));
779
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
780
gtk_widget_show (frame);
782
combo = gimp_enum_combo_box_new (GIMP_TYPE_ALIGN_REFERENCE);
783
gtk_container_add (GTK_CONTAINER (frame), combo);
784
gimp_int_combo_box_connect (GIMP_INT_COMBO_BOX (combo),
785
GIMP_ALIGN_REFERENCE_FIRST,
786
G_CALLBACK (gimp_int_combo_box_get_active),
787
&align_tool->align_reference_type);
788
gtk_widget_show (combo);
790
hbox = gtk_hbox_new (FALSE, 6);
791
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
792
gtk_widget_show (hbox);
794
button = button_with_stock (GIMP_ALIGN_LEFT, align_tool);
795
align_tool->button[n++] = button;
796
gimp_help_set_help_data (button, _("Align left edge of target"), NULL);
797
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
798
gtk_widget_show (button);
800
button = button_with_stock (GIMP_ALIGN_HCENTER, align_tool);
801
align_tool->button[n++] = button;
802
gimp_help_set_help_data (button, _("Align center of target"), NULL);
803
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
804
gtk_widget_show (button);
806
button = button_with_stock (GIMP_ALIGN_RIGHT, align_tool);
807
align_tool->button[n++] = button;
808
gimp_help_set_help_data (button, _("Align right edge of target"), NULL);
809
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
810
gtk_widget_show (button);
812
hbox = gtk_hbox_new (FALSE, 6);
813
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
814
gtk_widget_show (hbox);
816
button = button_with_stock (GIMP_ALIGN_TOP, align_tool);
817
align_tool->button[n++] = button;
818
gimp_help_set_help_data (button, _("Align top edge of target"), NULL);
819
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
820
gtk_widget_show (button);
822
button = button_with_stock (GIMP_ALIGN_VCENTER, align_tool);
823
align_tool->button[n++] = button;
824
gimp_help_set_help_data (button, _("Align middle of target"), NULL);
825
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
826
gtk_widget_show (button);
828
button = button_with_stock (GIMP_ALIGN_BOTTOM, align_tool);
829
align_tool->button[n++] = button;
830
gimp_help_set_help_data (button, _("Align bottom of target"), NULL);
831
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
832
gtk_widget_show (button);
834
frame = gimp_frame_new (_("Distribute"));
835
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
836
gtk_widget_show (frame);
838
vbox = gtk_vbox_new (FALSE, 6);
839
gtk_container_add (GTK_CONTAINER (frame), vbox);
840
gtk_widget_show (vbox);
842
hbox = gtk_hbox_new (FALSE, 6);
843
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
844
gtk_widget_show (hbox);
846
button = button_with_stock (GIMP_ARRANGE_LEFT, align_tool);
847
align_tool->button[n++] = button;
848
gimp_help_set_help_data (button, _("Distribute left edges of targets"), NULL);
849
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
850
gtk_widget_show (button);
852
button = button_with_stock (GIMP_ARRANGE_HCENTER, align_tool);
853
align_tool->button[n++] = button;
854
gimp_help_set_help_data (button,
855
_("Distribute horizontal centers of targets"), NULL);
856
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
857
gtk_widget_show (button);
859
button = button_with_stock (GIMP_ARRANGE_RIGHT, align_tool);
860
align_tool->button[n++] = button;
861
gimp_help_set_help_data (button,
862
_("Distribute right edges of targets"), NULL);
863
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
864
gtk_widget_show (button);
866
hbox = gtk_hbox_new (FALSE, 6);
867
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
868
gtk_widget_show (hbox);
870
button = button_with_stock (GIMP_ARRANGE_TOP, align_tool);
871
align_tool->button[n++] = button;
872
gimp_help_set_help_data (button, _("Distribute top edges of targets"), NULL);
873
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
874
gtk_widget_show (button);
876
button = button_with_stock (GIMP_ARRANGE_VCENTER, align_tool);
877
align_tool->button[n++] = button;
878
gimp_help_set_help_data (button,
879
_("Distribute vertical centers of targets"), NULL);
880
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
881
gtk_widget_show (button);
883
button = button_with_stock (GIMP_ARRANGE_BOTTOM, align_tool);
884
align_tool->button[n++] = button;
885
gimp_help_set_help_data (button, _("Distribute bottoms of targets"), NULL);
886
gtk_box_pack_start (GTK_BOX (hbox), button, FALSE, FALSE, 0);
887
gtk_widget_show (button);
889
hbox = gtk_hbox_new (FALSE, 6);
890
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
891
gtk_widget_show (hbox);
893
label = gtk_label_new (_("Offset:"));
894
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
895
gtk_widget_show (label);
897
spinbutton = gimp_spin_button_new (&align_tool->horz_offset_adjustment,
902
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
903
g_signal_connect (align_tool->horz_offset_adjustment, "value-changed",
904
G_CALLBACK (gimp_double_adjustment_update),
905
&align_tool->horz_offset);
906
gtk_widget_show (spinbutton);
913
do_alignment (GtkWidget *widget,
712
gimp_align_tool_align (GimpAlignTool *align_tool,
713
GimpAlignmentType align_type)
916
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (data);
917
GimpAlignmentType action;
919
GObject *reference_object = NULL;
923
image = GIMP_TOOL (align_tool)->display->image;
924
action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "action"));
925
offset = align_tool->horz_offset;
715
GimpAlignOptions *options = GIMP_ALIGN_TOOL_GET_OPTIONS (align_tool);
717
GObject *reference_object = NULL;
721
/* if nothing is selected, just return */
722
if (! align_tool->selected_objects)
725
image = gimp_display_get_image (GIMP_TOOL (align_tool)->display);
929
729
case GIMP_ALIGN_LEFT:
930
730
case GIMP_ALIGN_HCENTER:
1013
810
gimp_image_flush (image);
1017
button_with_stock (GimpAlignmentType action,
1018
GimpAlignTool *align_tool)
1022
const gchar *stock_id = NULL;
1026
case GIMP_ALIGN_LEFT:
1027
stock_id = GIMP_STOCK_GRAVITY_WEST;
1029
case GIMP_ALIGN_HCENTER:
1030
stock_id = GIMP_STOCK_HCENTER;
1032
case GIMP_ALIGN_RIGHT:
1033
stock_id = GIMP_STOCK_GRAVITY_EAST;
1035
case GIMP_ALIGN_TOP:
1036
stock_id = GIMP_STOCK_GRAVITY_NORTH;
1038
case GIMP_ALIGN_VCENTER:
1039
stock_id = GIMP_STOCK_VCENTER;
1041
case GIMP_ALIGN_BOTTOM:
1042
stock_id = GIMP_STOCK_GRAVITY_SOUTH;
1044
case GIMP_ARRANGE_LEFT:
1045
stock_id = GIMP_STOCK_GRAVITY_WEST;
1047
case GIMP_ARRANGE_HCENTER:
1048
stock_id = GIMP_STOCK_HCENTER;
1050
case GIMP_ARRANGE_RIGHT:
1051
stock_id = GIMP_STOCK_GRAVITY_EAST;
1053
case GIMP_ARRANGE_TOP:
1054
stock_id = GIMP_STOCK_GRAVITY_NORTH;
1056
case GIMP_ARRANGE_VCENTER:
1057
stock_id = GIMP_STOCK_VCENTER;
1059
case GIMP_ARRANGE_BOTTOM:
1060
stock_id = GIMP_STOCK_GRAVITY_SOUTH;
1063
g_return_val_if_reached (NULL);
1067
button = gtk_button_new ();
1068
g_object_set_data (G_OBJECT (button), "action", GINT_TO_POINTER (action));
1070
image = gtk_image_new_from_stock (stock_id, GTK_ICON_SIZE_BUTTON);
1071
gtk_misc_set_padding (GTK_MISC (image), 2, 2);
1072
gtk_container_add (GTK_CONTAINER (button), image);
1073
gtk_widget_show (image);
1075
g_signal_connect (button, "clicked",
1076
G_CALLBACK (do_alignment),
1079
gtk_widget_set_sensitive (button, FALSE);
1080
gtk_widget_show (button);
1086
clear_selected_object (GObject *object,
1087
GimpAlignTool *align_tool)
814
gimp_align_tool_object_removed (GObject *object,
815
GimpAlignTool *align_tool)
1089
817
gimp_draw_tool_pause (GIMP_DRAW_TOOL (align_tool));
1091
819
if (align_tool->selected_objects)
1092
820
g_signal_handlers_disconnect_by_func (object,
1093
G_CALLBACK (clear_selected_object),
1094
(gpointer) align_tool);
821
gimp_align_tool_object_removed,
1096
824
align_tool->selected_objects = g_list_remove (align_tool->selected_objects,