From 49e2670eb6bc5289fdbf51004c8ca5e4a02bcb18 Mon Sep 17 00:00:00 2001 From: Martin Nordholts Date: Sun, 11 Nov 2007 14:00:48 +0000 Subject: [PATCH] Removed gimp_rectangle_tool_get_press_coords() as it doesn't make sense 2007-11-11 Martin Nordholts * app/tools/gimprectangletool.[ch]: Removed gimp_rectangle_tool_get_press_coords() as it doesn't make sense for a rectangle tool interface to provide this functionality. Clients should take care of that themselves. Also adjusted internal code accordingly. * app/tools/gimprectangleselecttool.c: Remember the pressed coordinates on _button_press instead of asking GimpRectangleTool about it. svn path=/trunk/; revision=24119 --- ChangeLog | 12 ++++++++++++ app/tools/gimprectangleselecttool.c | 25 ++++++++++++++++++++---- app/tools/gimprectangletool.c | 30 ++++------------------------- app/tools/gimprectangletool.h | 3 --- 4 files changed, 37 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2904bf5985..600ac75709 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2007-11-11 Martin Nordholts + + * app/tools/gimprectangletool.[ch]: Removed + gimp_rectangle_tool_get_press_coords() as it doesn't make sense + for a rectangle tool interface to provide this functionality. + Clients should take care of that themselves. Also adjusted + internal code accordingly. + + * app/tools/gimprectangleselecttool.c: Remember the pressed + coordinates on _button_press instead of asking GimpRectangleTool + about it. + 2007-11-11 Michael Natterer * configure.in: depend on pango 1.18 diff --git a/app/tools/gimprectangleselecttool.c b/app/tools/gimprectangleselecttool.c index b6624ad186..01729e92d4 100644 --- a/app/tools/gimprectangleselecttool.c +++ b/app/tools/gimprectangleselecttool.c @@ -20,6 +20,7 @@ #include +#include "libgimpmath/gimpmath.h" #include "libgimpwidgets/gimpwidgets.h" #include "tools-types.h" @@ -67,6 +68,9 @@ typedef struct GimpRectSelectToolPrivate gboolean round_corners; gdouble corner_radius; + + gdouble press_x; + gdouble press_y; } GimpRectSelectToolPrivate; @@ -219,8 +223,11 @@ gimp_rect_select_tool_init (GimpRectSelectTool *rect_select) GIMP_DIRTY_IMAGE_SIZE | GIMP_DIRTY_SELECTION); - priv->undo = NULL; - priv->redo = NULL; + priv->undo = NULL; + priv->redo = NULL; + + priv->press_x = 0.0; + priv->press_y = 0.0; } static GObject * @@ -374,6 +381,9 @@ gimp_rect_select_tool_button_press (GimpTool *tool, gimp_rectangle_tool_button_press (tool, coords, time, state, display); + priv->press_x = coords->x; + priv->press_y = coords->y; + /* if we have an existing rectangle in the current display, then * we have already "executed", and need to undo at this point, * unless the user has done something in the meantime @@ -703,6 +713,12 @@ gimp_rect_select_tool_execute (GimpRectangleTool *rectangle, gint w, gint h) { + GimpRectSelectTool *rect_sel_tool; + GimpRectSelectToolPrivate *priv; + + rect_sel_tool = GIMP_RECT_SELECT_TOOL (rectangle); + priv = GIMP_RECT_SELECT_TOOL_GET_PRIVATE(rect_sel_tool); + if (w == 0 && h == 0) { GimpImage *image = GIMP_TOOL (rectangle)->display->image; @@ -717,7 +733,8 @@ gimp_rect_select_tool_execute (GimpRectangleTool *rectangle, return TRUE; } - gimp_rectangle_tool_get_press_coords (rectangle, &pressx, &pressy); + pressx = ROUND (priv->press_x); + pressy = ROUND (priv->press_y); /* if the click was inside the marching ants */ if (gimp_pickable_get_opacity_at (GIMP_PICKABLE (selection), @@ -754,7 +771,7 @@ gimp_rect_select_tool_execute (GimpRectangleTool *rectangle, } } - gimp_rect_select_tool_update_option_defaults (GIMP_RECT_SELECT_TOOL (rectangle), + gimp_rect_select_tool_update_option_defaults (rect_sel_tool, FALSE); return TRUE; diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c index bb3995f74f..5ee3e52972 100644 --- a/app/tools/gimprectangletool.c +++ b/app/tools/gimprectangletool.c @@ -100,12 +100,6 @@ struct _GimpRectangleToolPrivate * during gimp_rectangle_tool_button_press and then only read. */ - /* Holds coordinate where button was pressed when rectangle adjustment was - * initiated. - */ - gint pressx; - gint pressy; - /* Holds the coordinate that should be used as the "other side" when * fixed-center is turned off. */ @@ -474,19 +468,6 @@ gimp_rectangle_tool_get_constraint (GimpRectangleTool *tool) return private->constraint; } -void -gimp_rectangle_tool_get_press_coords (GimpRectangleTool *rect_tool, - gint *pressx_ptr, - gint *pressy_ptr) -{ - GimpRectangleToolPrivate *private; - - private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool); - - *pressx_ptr = private->pressx; - *pressy_ptr = private->pressy; -} - /** * gimp_rectangle_tool_pending_size_set: * @width_property: Option property to set to pending rectangle width. @@ -852,9 +833,6 @@ gimp_rectangle_tool_button_press (GimpTool *tool, x += snap_x; y += snap_y; - private->pressx = x; - private->pressy = y; - private->lastx = x; private->lasty = y; @@ -864,8 +842,8 @@ gimp_rectangle_tool_button_press (GimpTool *tool, */ if (private->function == RECT_CREATING) { - private->center_x_on_fixed_center = private->pressx; - private->center_y_on_fixed_center = private->pressy; + private->center_x_on_fixed_center = x; + private->center_y_on_fixed_center = y; } else { @@ -880,8 +858,8 @@ gimp_rectangle_tool_button_press (GimpTool *tool, */ if (private->function == RECT_CREATING) { - private->other_side_x = private->pressx; - private->other_side_y = private->pressy; + private->other_side_x = x; + private->other_side_y = y; } else { diff --git a/app/tools/gimprectangletool.h b/app/tools/gimprectangletool.h index a99107d61c..939c1794c5 100644 --- a/app/tools/gimprectangletool.h +++ b/app/tools/gimprectangletool.h @@ -129,9 +129,6 @@ GimpRectangleConstraint gimp_rectangle_tool_get_constraint GimpRectangleFunction gimp_rectangle_tool_get_function (GimpRectangleTool *rectangle); void gimp_rectangle_tool_set_function (GimpRectangleTool *rectangle, GimpRectangleFunction function); -void gimp_rectangle_tool_get_press_coords (GimpRectangleTool *rectangle, - gint *pressx_ptr, - gint *pressy_ptr); void gimp_rectangle_tool_pending_size_set (GimpRectangleTool *rectangle, GObject *object, const gchar *width_property,