From 5054241ca61dbdf869701b429a84d0c239a2d22a Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Wed, 29 Jan 2014 23:40:35 +0100 Subject: [PATCH] Bug 722034 - Incorrect snapping behaviour for scale tool Always snap to the center of transform tool handles. --- app/display/gimpcanvashandle.c | 15 +++++++++++++++ app/display/gimpcanvashandle.h | 4 ++++ app/tools/gimptransformtool.c | 18 ++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/app/display/gimpcanvashandle.c b/app/display/gimpcanvashandle.c index da027b5997..8a4146dc7a 100644 --- a/app/display/gimpcanvashandle.c +++ b/app/display/gimpcanvashandle.c @@ -493,6 +493,21 @@ gimp_canvas_handle_new (GimpDisplayShell *shell, NULL); } +void +gimp_canvas_handle_get_position (GimpCanvasItem *handle, + gdouble *x, + gdouble *y) +{ + g_return_if_fail (GIMP_IS_CANVAS_HANDLE (handle)); + g_return_if_fail (x != NULL); + g_return_if_fail (y != NULL); + + g_object_get (handle, + "x", x, + "y", y, + NULL); +} + void gimp_canvas_handle_set_position (GimpCanvasItem *handle, gdouble x, diff --git a/app/display/gimpcanvashandle.h b/app/display/gimpcanvashandle.h index 7dea56ba93..2aeae08c45 100644 --- a/app/display/gimpcanvashandle.h +++ b/app/display/gimpcanvashandle.h @@ -57,9 +57,13 @@ GimpCanvasItem * gimp_canvas_handle_new (GimpDisplayShell *shell, gint width, gint height); +void gimp_canvas_handle_get_position (GimpCanvasItem *handle, + gdouble *x, + gdouble *y); void gimp_canvas_handle_set_position (GimpCanvasItem *handle, gdouble x, gdouble y); + void gimp_canvas_handle_set_angles (GimpCanvasItem *handle, gdouble start_handle, gdouble slice_handle); diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index 15d69d4099..984fc43dee 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -52,6 +52,7 @@ #include "widgets/gimpwidgets-utils.h" #include "display/gimpcanvasgroup.h" +#include "display/gimpcanvashandle.h" #include "display/gimpdisplay.h" #include "display/gimpdisplayshell.h" #include "display/gimpdisplayshell-transform.h" @@ -378,6 +379,23 @@ gimp_transform_tool_button_press (GimpTool *tool, tr_tool->lasty = tr_tool->mousey = coords->y; gimp_tool_control_activate (tool->control); + + if (GIMP_IS_CANVAS_HANDLE (tr_tool->handles[tr_tool->function])) + { + gdouble x, y; + + gimp_canvas_handle_get_position (tr_tool->handles[tr_tool->function], + &x, &y); + + gimp_tool_control_set_snap_offsets (tool->control, + SIGNED_ROUND (x - coords->x), + SIGNED_ROUND (y - coords->y), + 0, 0); + } + else + { + gimp_tool_control_set_snap_offsets (tool->control, 0, 0, 0, 0); + } } void