[gimp/metadata-browser] transformtool: Add temporary new handles



commit 4814cf57144e61ec9ac81d833e132ea628e3dfba
Author: Mikael Magnusson <mikachu src gnome org>
Date:   Thu Jun 14 02:48:44 2012 +0200

    transformtool: Add temporary new handles
    
    put perspective handles on the outside instead (if you invert the frame,
    they'll switch place with the scale handles, oh well)

 app/display/display-enums.c          |    4 +
 app/display/display-enums.h          |    2 +
 app/display/gimpcanvashandle.c       |   31 +++-
 app/tools/gimptransformtool.h        |   26 ++-
 app/tools/gimpunifiedtransformtool.c |  334 +++++++++++++++++++++-------------
 5 files changed, 257 insertions(+), 140 deletions(-)
---
diff --git a/app/display/display-enums.c b/app/display/display-enums.c
index 827d6da..985068d 100644
--- a/app/display/display-enums.c
+++ b/app/display/display-enums.c
@@ -89,6 +89,8 @@ gimp_handle_type_get_type (void)
     { GIMP_HANDLE_FILLED_SQUARE, "GIMP_HANDLE_FILLED_SQUARE", "filled-square" },
     { GIMP_HANDLE_CIRCLE, "GIMP_HANDLE_CIRCLE", "circle" },
     { GIMP_HANDLE_FILLED_CIRCLE, "GIMP_HANDLE_FILLED_CIRCLE", "filled-circle" },
+    { GIMP_HANDLE_DIAMOND, "GIMP_HANDLE_DIAMOND", "diamond" },
+    { GIMP_HANDLE_FILLED_DIAMOND, "GIMP_HANDLE_FILLED_DIAMOND", "filled-diamond" },
     { GIMP_HANDLE_CROSS, "GIMP_HANDLE_CROSS", "cross" },
     { 0, NULL, NULL }
   };
@@ -99,6 +101,8 @@ gimp_handle_type_get_type (void)
     { GIMP_HANDLE_FILLED_SQUARE, "GIMP_HANDLE_FILLED_SQUARE", NULL },
     { GIMP_HANDLE_CIRCLE, "GIMP_HANDLE_CIRCLE", NULL },
     { GIMP_HANDLE_FILLED_CIRCLE, "GIMP_HANDLE_FILLED_CIRCLE", NULL },
+    { GIMP_HANDLE_DIAMOND, "GIMP_HANDLE_DIAMOND", NULL },
+    { GIMP_HANDLE_FILLED_DIAMOND, "GIMP_HANDLE_FILLED_DIAMOND", NULL },
     { GIMP_HANDLE_CROSS, "GIMP_HANDLE_CROSS", NULL },
     { 0, NULL, NULL }
   };
diff --git a/app/display/display-enums.h b/app/display/display-enums.h
index da76552..cbc0cfa 100644
--- a/app/display/display-enums.h
+++ b/app/display/display-enums.h
@@ -58,6 +58,8 @@ typedef enum
   GIMP_HANDLE_FILLED_SQUARE,
   GIMP_HANDLE_CIRCLE,
   GIMP_HANDLE_FILLED_CIRCLE,
+  GIMP_HANDLE_DIAMOND,
+  GIMP_HANDLE_FILLED_DIAMOND,
   GIMP_HANDLE_CROSS
 } GimpHandleType;
 
diff --git a/app/display/gimpcanvashandle.c b/app/display/gimpcanvashandle.c
index 67c184f..fce5329 100644
--- a/app/display/gimpcanvashandle.c
+++ b/app/display/gimpcanvashandle.c
@@ -277,6 +277,8 @@ gimp_canvas_handle_transform (GimpCanvasItem   *item,
     case GIMP_HANDLE_CIRCLE:
     case GIMP_HANDLE_FILLED_CIRCLE:
     case GIMP_HANDLE_CROSS:
+    case GIMP_HANDLE_DIAMOND:
+    case GIMP_HANDLE_FILLED_DIAMOND:
       gimp_canvas_item_shift_to_center (private->anchor,
                                         *x, *y,
                                         private->width,
@@ -344,6 +346,20 @@ gimp_canvas_handle_draw (GimpCanvasItem   *item,
       _gimp_canvas_item_stroke (item, cr);
       break;
 
+    case GIMP_HANDLE_DIAMOND:
+    case GIMP_HANDLE_FILLED_DIAMOND:
+      cairo_move_to (cr, x, y - (gdouble) private->height / 2.0);
+      cairo_line_to (cr, x + (gdouble) private->width / 2.0, y);
+      cairo_line_to (cr, x, y + (gdouble) private->height / 2.0);
+      cairo_line_to (cr, x - (gdouble) private->width / 2.0, y);
+      cairo_line_to (cr, x, y - (gdouble) private->height / 2.0);
+
+      if (private->type == GIMP_HANDLE_DIAMOND)
+        _gimp_canvas_item_stroke (item, cr);
+      else
+        _gimp_canvas_item_fill (item, cr);
+      break;
+
     default:
       break;
     }
@@ -372,10 +388,12 @@ gimp_canvas_handle_get_extents (GimpCanvasItem   *item,
     case GIMP_HANDLE_CIRCLE:
     case GIMP_HANDLE_FILLED_CIRCLE:
     case GIMP_HANDLE_CROSS:
-      rectangle.x      = x - private->width  / 2 - 1.5;
-      rectangle.y      = y - private->height / 2 - 1.5;
-      rectangle.width  = private->width  + 3.0;
-      rectangle.height = private->height + 3.0;
+    case GIMP_HANDLE_DIAMOND:
+    case GIMP_HANDLE_FILLED_DIAMOND:
+      rectangle.x      = x - private->width  / 2 - 2.0;
+      rectangle.y      = y - private->height / 2 - 2.0;
+      rectangle.width  = private->width  + 4.0;
+      rectangle.height = private->height + 4.0;
       break;
 
     default:
@@ -422,6 +440,11 @@ gimp_canvas_handle_hit (GimpCanvasItem   *item,
         return ((SQR (handle_tx - tx) + SQR (handle_ty - ty)) < SQR (width));
       }
 
+    case GIMP_HANDLE_DIAMOND:
+    case GIMP_HANDLE_FILLED_DIAMOND:
+      return ((ABS (handle_tx - tx) + ABS (handle_ty - ty)) < ABS (private->width));
+      break;
+
     default:
       break;
     }
diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h
index 03166e1..b6fbef1 100644
--- a/app/tools/gimptransformtool.h
+++ b/app/tools/gimptransformtool.h
@@ -22,8 +22,6 @@
 #include "gimpdrawtool.h"
 
 
-#define TRANS_INFO_SIZE 10
-
 typedef enum
 {
   TRANSFORM_CREATING,
@@ -36,10 +34,26 @@ typedef enum
   TRANSFORM_HANDLE_S,  /* south      */
   TRANSFORM_HANDLE_E,  /* east       */
   TRANSFORM_HANDLE_W,  /* west       */
-  TRANSFORM_HANDLE_PIVOT, /* pivot for rotation and scaling */
-  TRANSFORM_HANDLE_CENTER /* for moving */
+  TRANSFORM_HANDLE_PIVOT,  /* pivot for rotation and scaling */
+  TRANSFORM_HANDLE_CENTER, /* for moving */
+  /* extra handles for unified tool */
+  TRANSFORM_HANDLE_NW_P, /* perspective handles */
+  TRANSFORM_HANDLE_NE_P,
+  TRANSFORM_HANDLE_SW_P,
+  TRANSFORM_HANDLE_SE_P,
+  TRANSFORM_HANDLE_N_S,  /* shearing handles */
+  TRANSFORM_HANDLE_S_S,
+  TRANSFORM_HANDLE_E_S,
+  TRANSFORM_HANDLE_W_S,
+  TRANSFORM_HANDLE_ROTATION, /* rotation handle */
+
+  TRANSFORM_HANDLE_NUM /* keep this last so *handles[] is the right size */
 } TransformAction;
 
+/* This is not the number of items in the enum above, but the max size of the
+ * enums at the top of each transformation tool, stored in trans_info and related */
+#define TRANS_INFO_SIZE 10
+
 typedef gdouble TransInfo[TRANS_INFO_SIZE];
 
 
@@ -74,7 +88,7 @@ struct _GimpTransformTool
   gint            x1, y1;          /*  upper left hand coordinate        */
   gint            x2, y2;          /*  lower right hand coords           */
   gdouble         cx, cy;          /*  center point (for moving)         */
-  gdouble         px, py;          /*  pivot point (for rotation)        */
+  gdouble         px, py;          /*  pivot point (for rotation/scaling)*/
   gdouble         aspect;          /*  original aspect ratio             */
 
   gdouble         tx1, ty1;        /*  transformed handle coords         */
@@ -102,7 +116,7 @@ struct _GimpTransformTool
   gboolean        use_mid_handles; /*  use handles at midpoints of edges */
   gboolean        use_pivot;       /*  use pivot point                   */
 
-  GimpCanvasItem *handles[TRANSFORM_HANDLE_CENTER + 1];
+  GimpCanvasItem *handles[TRANSFORM_HANDLE_NUM];
 
   const gchar    *progress_text;
 
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index bd583d0..d6ff14a 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -95,7 +95,7 @@ gimp_unified_transform_tool_register (GimpToolRegisterCallback  callback,
                 _("Unified Transform"),
                 _("Unified Transform Tool: "
                   "Transform the layer, selection or path"),
-                N_("_Unified Transform"), "<shift>U",
+                N_("_Unified Transform"), "<shift>L",
                 NULL, GIMP_HELP_TOOL_UNIFIED_TRANSFORM,
                 GIMP_STOCK_TOOL_UNIFIED_TRANSFORM,
                 data);
@@ -179,9 +179,10 @@ gimp_unified_transform_tool_draw (GimpDrawTool *draw_tool)
   GimpTransformTool    *tr_tool = GIMP_TRANSFORM_TOOL (draw_tool);
   GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool);
   GimpImage            *image   = gimp_display_get_image (tool->display);
-  gint                  handle_w;
-  gint                  handle_h;
-  gint                  i;
+  GimpCanvasGroup      *stroke_group;
+  gint                  handle_w, handle_h;
+  gint                  i, d;
+  gdouble               x, y;
 
   for (i = 0; i < G_N_ELEMENTS (tr_tool->handles); i++)
     tr_tool->handles[i] = NULL;
@@ -214,133 +215,202 @@ gimp_unified_transform_tool_draw (GimpDrawTool *draw_tool)
   gimp_transform_tool_handles_recalc (tr_tool, tool->display,
                                       &handle_w, &handle_h);
 
-  if (tr_tool->use_handles)
-    {
-      /*  draw the tool handles  */
-      tr_tool->handles[TRANSFORM_HANDLE_NW] =
-        gimp_draw_tool_add_handle (draw_tool,
-                                   GIMP_HANDLE_SQUARE,
-                                   tr_tool->tx1, tr_tool->ty1,
-                                   handle_w, handle_h,
-                                   GIMP_HANDLE_ANCHOR_CENTER);
-
-      tr_tool->handles[TRANSFORM_HANDLE_NE] =
-        gimp_draw_tool_add_handle (draw_tool,
-                                   GIMP_HANDLE_SQUARE,
-                                   tr_tool->tx2, tr_tool->ty2,
-                                   handle_w, handle_h,
-                                   GIMP_HANDLE_ANCHOR_CENTER);
-
-      tr_tool->handles[TRANSFORM_HANDLE_SW] =
-        gimp_draw_tool_add_handle (draw_tool,
-                                   GIMP_HANDLE_SQUARE,
-                                   tr_tool->tx3, tr_tool->ty3,
-                                   handle_w, handle_h,
-                                   GIMP_HANDLE_ANCHOR_CENTER);
-
-      tr_tool->handles[TRANSFORM_HANDLE_SE] =
-        gimp_draw_tool_add_handle (draw_tool,
-                                   GIMP_HANDLE_SQUARE,
-                                   tr_tool->tx4, tr_tool->ty4,
-                                   handle_w, handle_h,
-                                   GIMP_HANDLE_ANCHOR_CENTER);
-
-      if (tr_tool->use_mid_handles)
-        {
-          gdouble x, y;
-
-          x = (tr_tool->tx1 + tr_tool->tx2) / 2.0;
-          y = (tr_tool->ty1 + tr_tool->ty2) / 2.0;
-
-          tr_tool->handles[TRANSFORM_HANDLE_N] =
-            gimp_draw_tool_add_handle (draw_tool,
-                                       GIMP_HANDLE_SQUARE,
-                                       x, y,
-                                       handle_w, handle_h,
-                                       GIMP_HANDLE_ANCHOR_CENTER);
-
-          x = (tr_tool->tx2 + tr_tool->tx4) / 2.0;
-          y = (tr_tool->ty2 + tr_tool->ty4) / 2.0;
-
-          tr_tool->handles[TRANSFORM_HANDLE_E] =
-            gimp_draw_tool_add_handle (draw_tool,
-                                       GIMP_HANDLE_SQUARE,
-                                       x, y,
-                                       handle_w, handle_h,
-                                       GIMP_HANDLE_ANCHOR_CENTER);
-
-          x = (tr_tool->tx3 + tr_tool->tx4) / 2.0;
-          y = (tr_tool->ty3 + tr_tool->ty4) / 2.0;
-
-          tr_tool->handles[TRANSFORM_HANDLE_S] =
-            gimp_draw_tool_add_handle (draw_tool,
-                                       GIMP_HANDLE_SQUARE,
-                                       x, y,
-                                       handle_w, handle_h,
-                                       GIMP_HANDLE_ANCHOR_CENTER);
-
-          x = (tr_tool->tx3 + tr_tool->tx1) / 2.0;
-          y = (tr_tool->ty3 + tr_tool->ty1) / 2.0;
-
-          tr_tool->handles[TRANSFORM_HANDLE_W] =
-            gimp_draw_tool_add_handle (draw_tool,
-                                       GIMP_HANDLE_SQUARE,
-                                       x, y,
-                                       handle_w, handle_h,
-                                       GIMP_HANDLE_ANCHOR_CENTER);
-        }
-    }
-
-  if (tr_tool->use_pivot)
-    {
-      GimpCanvasGroup *stroke_group;
-      gint d = MIN (handle_w, handle_h) * 2; /* so you can grab it from under the center handle */
+  /*  draw the scale handles  */
+  tr_tool->handles[TRANSFORM_HANDLE_NW] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               tr_tool->tx1, tr_tool->ty1,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_NORTH_WEST);
+
+  tr_tool->handles[TRANSFORM_HANDLE_NE] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               tr_tool->tx2, tr_tool->ty2,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_NORTH_EAST);
+
+  tr_tool->handles[TRANSFORM_HANDLE_SW] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               tr_tool->tx3, tr_tool->ty3,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_SOUTH_WEST);
+
+  tr_tool->handles[TRANSFORM_HANDLE_SE] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               tr_tool->tx4, tr_tool->ty4,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_SOUTH_EAST);
+
+  /*  draw the perspective handles  */
+  tr_tool->handles[TRANSFORM_HANDLE_NW_P] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               tr_tool->tx1, tr_tool->ty1,
+                               handle_w/4*3, handle_h/4*3,
+                               GIMP_HANDLE_ANCHOR_SOUTH_EAST);
+
+  tr_tool->handles[TRANSFORM_HANDLE_NE_P] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               tr_tool->tx2, tr_tool->ty2,
+                               handle_w/4*3, handle_h/4*3,
+                               GIMP_HANDLE_ANCHOR_SOUTH_WEST);
+
+  tr_tool->handles[TRANSFORM_HANDLE_SW_P] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               tr_tool->tx3, tr_tool->ty3,
+                               handle_w/4*3, handle_h/4*3,
+                               GIMP_HANDLE_ANCHOR_NORTH_EAST);
+
+  tr_tool->handles[TRANSFORM_HANDLE_SE_P] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               tr_tool->tx4, tr_tool->ty4,
+                               handle_w/4*3, handle_h/4*3,
+                               GIMP_HANDLE_ANCHOR_NORTH_WEST);
+
+  /*  draw the side handles  */
+  x = (tr_tool->tx1 + tr_tool->tx2) / 2.0;
+  y = (tr_tool->ty1 + tr_tool->ty2) / 2.0;
+
+  tr_tool->handles[TRANSFORM_HANDLE_N] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+  x = (tr_tool->tx2 + tr_tool->tx4) / 2.0;
+  y = (tr_tool->ty2 + tr_tool->ty4) / 2.0;
+
+  tr_tool->handles[TRANSFORM_HANDLE_E] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+  x = (tr_tool->tx3 + tr_tool->tx4) / 2.0;
+  y = (tr_tool->ty3 + tr_tool->ty4) / 2.0;
+
+  tr_tool->handles[TRANSFORM_HANDLE_S] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+  x = (tr_tool->tx3 + tr_tool->tx1) / 2.0;
+  y = (tr_tool->ty3 + tr_tool->ty1) / 2.0;
+
+  tr_tool->handles[TRANSFORM_HANDLE_W] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_SQUARE,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+  /*  draw the shear handles  */
+  x = (tr_tool->tx1 * 2 + tr_tool->tx2 * 3) / 5;
+  y = (tr_tool->ty1 * 2 + tr_tool->ty2 * 3) / 5;
+
+  tr_tool->handles[TRANSFORM_HANDLE_N_S] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_FILLED_DIAMOND,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+  x = (tr_tool->tx2 * 2 + tr_tool->tx4 * 3) / 5;
+  y = (tr_tool->ty2 * 2 + tr_tool->ty4 * 3) / 5;
+
+  tr_tool->handles[TRANSFORM_HANDLE_E_S] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_FILLED_DIAMOND,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+  x = (tr_tool->tx3 * 3 + tr_tool->tx4 * 2) / 5;
+  y = (tr_tool->ty3 * 3 + tr_tool->ty4 * 2) / 5;
+
+  tr_tool->handles[TRANSFORM_HANDLE_S_S] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_FILLED_DIAMOND,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+  x = (tr_tool->tx3 * 3 + tr_tool->tx1 * 2) / 5;
+  y = (tr_tool->ty3 * 3 + tr_tool->ty1 * 2) / 5;
+
+  tr_tool->handles[TRANSFORM_HANDLE_W_S] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_FILLED_DIAMOND,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+
+  /*  draw the rotation handle  */
+  x = (tr_tool->tx1 * 3 + tr_tool->tx2 * 2) / 5;
+  y = (tr_tool->ty1 * 3 + tr_tool->ty2 * 2) / 5;
+
+  tr_tool->handles[TRANSFORM_HANDLE_ROTATION] =
+    gimp_draw_tool_add_handle (draw_tool,
+                               GIMP_HANDLE_FILLED_CIRCLE,
+                               x, y,
+                               handle_w, handle_h,
+                               GIMP_HANDLE_ANCHOR_CENTER);
+
+
+  /*  draw the rotation center axis handle  */
+  d = MIN (handle_w, handle_h) * 2; /* so you can grab it from under the center handle */
+
+  stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
+
+  tr_tool->handles[TRANSFORM_HANDLE_PIVOT] = GIMP_CANVAS_ITEM (stroke_group);
+
+  gimp_draw_tool_push_group (draw_tool, stroke_group);
+
+  gimp_draw_tool_add_handle (draw_tool,
+                             GIMP_HANDLE_SQUARE,
+                             tr_tool->tpx, tr_tool->tpy,
+                             d, d,
+                             GIMP_HANDLE_ANCHOR_CENTER);
+  gimp_draw_tool_add_handle (draw_tool,
+                             GIMP_HANDLE_CROSS,
+                             tr_tool->tpx, tr_tool->tpy,
+                             d, d,
+                             GIMP_HANDLE_ANCHOR_CENTER);
+
+  gimp_draw_tool_pop_group (draw_tool);
+
+  /*  draw the move handle  */
+  d = MIN (handle_w, handle_h);
+
+  stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
+
+  tr_tool->handles[TRANSFORM_HANDLE_CENTER] = GIMP_CANVAS_ITEM (stroke_group);
+
+  gimp_draw_tool_push_group (draw_tool, stroke_group);
+
+  gimp_draw_tool_add_handle (draw_tool,
+                             GIMP_HANDLE_CIRCLE,
+                             tr_tool->tcx, tr_tool->tcy,
+                             d, d,
+                             GIMP_HANDLE_ANCHOR_CENTER);
+  gimp_draw_tool_add_handle (draw_tool,
+                             GIMP_HANDLE_CROSS,
+                             tr_tool->tcx, tr_tool->tcy,
+                             d, d,
+                             GIMP_HANDLE_ANCHOR_CENTER);
 
-      stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
-
-      tr_tool->handles[TRANSFORM_HANDLE_PIVOT] = GIMP_CANVAS_ITEM (stroke_group);
-
-      gimp_draw_tool_push_group (draw_tool, stroke_group);
-
-      gimp_draw_tool_add_handle (draw_tool,
-                                 GIMP_HANDLE_SQUARE,
-                                 tr_tool->tpx, tr_tool->tpy,
-                                 d, d,
-                                 GIMP_HANDLE_ANCHOR_CENTER);
-      gimp_draw_tool_add_handle (draw_tool,
-                                 GIMP_HANDLE_CROSS,
-                                 tr_tool->tpx, tr_tool->tpy,
-                                 d, d,
-                                 GIMP_HANDLE_ANCHOR_CENTER);
-
-      gimp_draw_tool_pop_group (draw_tool);
-    }
-
-  /*  draw the center  */
-  if (tr_tool->use_center)
-    {
-      GimpCanvasGroup *stroke_group;
-      gint             d = MIN (handle_w, handle_h);
-
-      stroke_group = gimp_draw_tool_add_stroke_group (draw_tool);
-
-      tr_tool->handles[TRANSFORM_HANDLE_CENTER] = GIMP_CANVAS_ITEM (stroke_group);
-
-      gimp_draw_tool_push_group (draw_tool, stroke_group);
-
-      gimp_draw_tool_add_handle (draw_tool,
-                                 GIMP_HANDLE_CIRCLE,
-                                 tr_tool->tcx, tr_tool->tcy,
-                                 d, d,
-                                 GIMP_HANDLE_ANCHOR_CENTER);
-      gimp_draw_tool_add_handle (draw_tool,
-                                 GIMP_HANDLE_CROSS,
-                                 tr_tool->tcx, tr_tool->tcy,
-                                 d, d,
-                                 GIMP_HANDLE_ANCHOR_CENTER);
-
-      gimp_draw_tool_pop_group (draw_tool);
-    }
+  gimp_draw_tool_pop_group (draw_tool);
 
   if (tr_tool->handles[tr_tool->function])
     {
@@ -348,6 +418,7 @@ gimp_unified_transform_tool_draw (GimpDrawTool *draw_tool)
                                       TRUE);
     }
 
+  /* the rest of the function is the same as in the parent class */
   if (options->type == GIMP_TRANSFORM_TYPE_SELECTION)
     {
       GimpMatrix3         matrix = tr_tool->transform;
@@ -698,6 +769,9 @@ gimp_unified_transform_tool_motion (GimpTransformTool *transform_tool)
       return;
     }
     case TRANSFORM_HANDLE_CENTER:
+      if (options->constrain) {
+        diff_y = diff_x;
+      }
       *x[0] += diff_x;
       *y[0] += diff_y;
       *x[1] += diff_x;



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