From 995a944ca89ffc783dce99aabdac4efb1312700b Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sat, 5 Jul 2008 09:47:39 +0000 Subject: [PATCH] Mark the center of rectangles/bounding rectangles so that it is easier to 2008-07-05 Martin Nordholts * app/tools/gimprectangletool.c: * app/tools/gimpeditselectiontool.c: Mark the center of rectangles/bounding rectangles so that it is easier to predict and see where snapping occurs. Completes the fix for bug #527659. svn path=/trunk/; revision=26065 --- ChangeLog | 7 +++++++ app/tools/gimpeditselectiontool.c | 17 +++++++++++++++++ app/tools/gimprectangletool.c | 19 +++++++++++++++++-- 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 121453a0a4..4c0a9af9be 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-07-05 Martin Nordholts + + * app/tools/gimprectangletool.c: + * app/tools/gimpeditselectiontool.c: Mark the center of + rectangles/bounding rectangles so that it is easier to predict and + see where snapping occurs. Completes the fix for bug #527659. + 2008-07-05 Martin Nordholts * app/tools/gimpeditselectiontool.[ch]: Don't expose the icky diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index 4bf4e89ad6..aa25776dd2 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -62,6 +62,7 @@ #define EDIT_SELECT_SCROLL_LOCK FALSE #define ARROW_VELOCITY 25 +#define CENTER_CROSS_SIZE 6 typedef struct _GimpEditSelectionTool @@ -79,6 +80,9 @@ typedef struct _GimpEditSelectionTool gint x1, y1; /* Bounding box of selection mask */ gint x2, y2; + gdouble center_x; /* Where to draw the mark of center */ + gdouble center_y; + GimpTranslateMode edit_mode; /* Translate the mask or layer? */ gboolean first_move; /* Don't push undos after the first */ @@ -430,6 +434,10 @@ gimp_edit_selection_tool_start (GimpTool *parent_tool, y1 - coords->y, x2 - x1, y2 - y1); + + /* Save where to draw the mark of the center */ + edit_select->center_x = x1 + (x2 - x1) / 2.0; + edit_select->center_y = y1 + (y2 - y1) / 2.0; } gimp_tool_control_activate (GIMP_TOOL (edit_select)->control); @@ -951,6 +959,15 @@ gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool) break; } + /* Mark the center because we snap to it */ + gimp_draw_tool_draw_cross_by_anchor (draw_tool, + edit_select->center_x + edit_select->cumlx, + edit_select->center_y + edit_select->cumly, + CENTER_CROSS_SIZE, + CENTER_CROSS_SIZE, + GTK_ANCHOR_CENTER, + FALSE); + GIMP_DRAW_TOOL_CLASS (parent_class)->draw (draw_tool); } diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c index 8ef4aa8c45..f0a22586e1 100644 --- a/app/tools/gimprectangletool.c +++ b/app/tools/gimprectangletool.c @@ -64,6 +64,7 @@ enum #define MIN_HANDLE_SIZE 15 #define NARROW_MODE_HANDLE_SIZE 15 #define NARROW_MODE_THRESHOLD 45 +#define CENTER_CROSS_SIZE 6 #define SQRT5 2.236067977 @@ -1666,9 +1667,23 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool) switch (private->function) { case GIMP_RECTANGLE_TOOL_MOVING: + if (gimp_tool_control_is_active (tool->control)) - break; - /* else fallthrough */ + { + /* Mark the center because we snap to it */ + gimp_draw_tool_draw_cross_by_anchor (draw_tool, + pub_x1 + (pub_x2 - pub_x1) / 2.0, + pub_y1 + (pub_y2 - pub_y1) / 2.0, + CENTER_CROSS_SIZE, + CENTER_CROSS_SIZE, + GTK_ANCHOR_CENTER, + FALSE); + break; + } + else + { + /* Fallthrough */ + } case GIMP_RECTANGLE_TOOL_DEAD: case GIMP_RECTANGLE_TOOL_CREATING: