[gimp/gimp-2-10] app: in scale tool, scale around center even when using numeric input



commit 5b93eee52a656ac3fd5829b49c62184f221337d5
Author: Ell <ell_se yahoo com>
Date:   Thu Nov 15 12:48:23 2018 -0500

    app: in scale tool, scale around center even when using numeric input
    
    In the scale tool, when the "around center" option is toggled,
    scale the item around its center not only through canvas
    interaction, but also when entering width/height values through the
    tool GUI.
    
    (cherry picked from commit 786bfa517120f772eddf64d453ab12734d24fba4)

 app/tools/gimpscaletool.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)
---
diff --git a/app/tools/gimpscaletool.c b/app/tools/gimpscaletool.c
index a3848e0965..d555e02750 100644
--- a/app/tools/gimpscaletool.c
+++ b/app/tools/gimpscaletool.c
@@ -371,8 +371,26 @@ gimp_scale_tool_size_notify (GtkWidget             *box,
           GimpTool          *tool    = GIMP_TOOL (tg_tool);
           GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tg_tool);
 
-          tg_tool->trans_info[X1] = tg_tool->trans_info[X0] + width;
-          tg_tool->trans_info[Y1] = tg_tool->trans_info[Y0] + height;
+          if (options->frompivot_scale)
+            {
+              gdouble center_x;
+              gdouble center_y;
+
+              center_x = (tg_tool->trans_info[X0] +
+                          tg_tool->trans_info[X1]) / 2.0;
+              center_y = (tg_tool->trans_info[Y0] +
+                          tg_tool->trans_info[Y1]) / 2.0;
+
+              tg_tool->trans_info[X0] = center_x - width  / 2.0;
+              tg_tool->trans_info[Y0] = center_y - height / 2.0;
+              tg_tool->trans_info[X1] = center_x + width  / 2.0;
+              tg_tool->trans_info[Y1] = center_y + height / 2.0;
+            }
+          else
+            {
+              tg_tool->trans_info[X1] = tg_tool->trans_info[X0] + width;
+              tg_tool->trans_info[Y1] = tg_tool->trans_info[Y0] + height;
+            }
 
           gimp_transform_grid_tool_push_internal_undo (tg_tool);
 


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