[gimp] Bug 722034 - Incorrect snapping behaviour for scale tool



commit 5054241ca61dbdf869701b429a84d0c239a2d22a
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jan 29 23:40:35 2014 +0100

    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(+), 0 deletions(-)
---
diff --git a/app/display/gimpcanvashandle.c b/app/display/gimpcanvashandle.c
index da027b5..8a4146d 100644
--- a/app/display/gimpcanvashandle.c
+++ b/app/display/gimpcanvashandle.c
@@ -494,6 +494,21 @@ gimp_canvas_handle_new (GimpDisplayShell *shell,
 }
 
 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,
                                  gdouble         y)
diff --git a/app/display/gimpcanvashandle.h b/app/display/gimpcanvashandle.h
index 7dea56b..2aeae08 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 15d69d4..984fc43 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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]