[gimp/soc-2012-unified-transformation] transformtool: Set the cursor and tool cursor properly on each handle by way of the new cursor_updat



commit 08cd798ec6ff578aff9780737758354637c94197
Author: Mikael Magnusson <mikachu src gnome org>
Date:   Mon Aug 20 19:42:49 2012 +0200

    transformtool: Set the cursor and tool cursor properly on each handle by way of the new cursor_update method

 app/tools/gimptransformtool.c        |    9 +++++
 app/tools/gimptransformtool.h        |    3 ++
 app/tools/gimpunifiedtransformtool.c |   61 ++++++++++++++++++++++++++++++++--
 3 files changed, 70 insertions(+), 3 deletions(-)
---
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 1230094..415d765 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -651,18 +651,22 @@ gimp_transform_tool_cursor_update (GimpTool         *tool,
       switch (tr_tool->function)
         {
         case TRANSFORM_HANDLE_NW:
+        case TRANSFORM_HANDLE_NW_P:
           cursor = GIMP_CURSOR_CORNER_TOP_LEFT;
           break;
 
         case TRANSFORM_HANDLE_NE:
+        case TRANSFORM_HANDLE_NE_P:
           cursor = GIMP_CURSOR_CORNER_TOP_RIGHT;
           break;
 
         case TRANSFORM_HANDLE_SW:
+        case TRANSFORM_HANDLE_SW_P:
           cursor = GIMP_CURSOR_CORNER_BOTTOM_LEFT;
           break;
 
         case TRANSFORM_HANDLE_SE:
+        case TRANSFORM_HANDLE_SE_P:
           cursor = GIMP_CURSOR_CORNER_BOTTOM_RIGHT;
           break;
 
@@ -693,6 +697,11 @@ gimp_transform_tool_cursor_update (GimpTool         *tool,
       modifier = GIMP_CURSOR_MODIFIER_MOVE;
     }
 
+  if (GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->cursor_update)
+    {
+      GIMP_TRANSFORM_TOOL_GET_CLASS (tr_tool)->cursor_update (tr_tool, &cursor, &modifier);
+    }
+
   switch (options->type)
     {
       GimpDrawable *drawable;
diff --git a/app/tools/gimptransformtool.h b/app/tools/gimptransformtool.h
index 2f6950a..e2d86d3 100644
--- a/app/tools/gimptransformtool.h
+++ b/app/tools/gimptransformtool.h
@@ -137,6 +137,9 @@ struct _GimpTransformToolClass
                                      const GimpCoords  *coords,
                                      GdkModifierType    state,
                                      GimpDisplay       *display);
+  void            (* cursor_update) (GimpTransformTool  *tr_tool,
+                                     GimpCursorType     *cursor,
+                                     GimpCursorModifier *modifier);
   void            (* draw_gui)      (GimpTransformTool *tool,
                                      gint               handle_w,
                                      gint               handle_h);
diff --git a/app/tools/gimpunifiedtransformtool.c b/app/tools/gimpunifiedtransformtool.c
index fc0881a..9c2ec76 100644
--- a/app/tools/gimpunifiedtransformtool.c
+++ b/app/tools/gimpunifiedtransformtool.c
@@ -78,6 +78,9 @@ static TransformAction gimp_unified_transform_tool_pick_function (GimpTransformT
                                                                   const GimpCoords  *coords,
                                                                   GdkModifierType    state,
                                                                   GimpDisplay       *display);
+static void            gimp_unified_transform_tool_cursor_update (GimpTransformTool  *tr_tool,
+                                                                  GimpCursorType     *cursor,
+                                                                  GimpCursorModifier *modifier);
 static void            gimp_unified_transform_tool_draw_gui      (GimpTransformTool *tr_tool,
                                                                   gint               handle_w,
                                                                   gint               handle_h);
@@ -117,6 +120,7 @@ gimp_unified_transform_tool_class_init (GimpUnifiedTransformToolClass *klass)
   trans_class->recalc_matrix = gimp_unified_transform_tool_recalc_matrix;
   trans_class->get_undo_desc = gimp_unified_transform_tool_get_undo_desc;
   trans_class->pick_function = gimp_unified_transform_tool_pick_function;
+  trans_class->cursor_update = gimp_unified_transform_tool_cursor_update;
   trans_class->draw_gui      = gimp_unified_transform_tool_draw_gui;
 }
 
@@ -126,9 +130,6 @@ gimp_unified_transform_tool_init (GimpUnifiedTransformTool *unified_tool)
   GimpTool          *tool    = GIMP_TOOL (unified_tool);
   GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (unified_tool);
 
-  gimp_tool_control_set_tool_cursor (tool->control,
-                                     GIMP_TOOL_CURSOR_UNIFIED_TRANSFORM);
-
   tr_tool->progress_text = _("Unified transform");
 
   tr_tool->use_grid    = TRUE;
@@ -244,6 +245,60 @@ gimp_unified_transform_tool_pick_function (GimpTransformTool *tr_tool,
 }
 
 static void
+gimp_unified_transform_tool_cursor_update (GimpTransformTool  *tr_tool,
+                                           GimpCursorType     *cursor,
+                                           GimpCursorModifier *modifier)
+{
+  GimpToolCursorType toolcursor = GIMP_TOOL_CURSOR_NONE;
+
+  /* parent class handles *cursor and *modifier for most handles */
+  switch (tr_tool->function)
+    {
+    case TRANSFORM_HANDLE_NONE:
+      toolcursor = GIMP_TOOL_CURSOR_NONE;
+      break;
+    case TRANSFORM_HANDLE_NW_P:
+    case TRANSFORM_HANDLE_NE_P:
+    case TRANSFORM_HANDLE_SW_P:
+    case TRANSFORM_HANDLE_SE_P:
+      toolcursor = GIMP_TOOL_CURSOR_PERSPECTIVE;
+      break;
+    case TRANSFORM_HANDLE_NW:
+    case TRANSFORM_HANDLE_NE:
+    case TRANSFORM_HANDLE_SW:
+    case TRANSFORM_HANDLE_SE:
+    case TRANSFORM_HANDLE_N:
+    case TRANSFORM_HANDLE_S:
+    case TRANSFORM_HANDLE_E:
+    case TRANSFORM_HANDLE_W:
+      toolcursor = GIMP_TOOL_CURSOR_RESIZE;
+      break;
+    case TRANSFORM_HANDLE_CENTER:
+      toolcursor = GIMP_TOOL_CURSOR_MOVE;
+      break;
+    case TRANSFORM_HANDLE_PIVOT:
+      toolcursor = GIMP_TOOL_CURSOR_ROTATE;
+      *modifier = GIMP_CURSOR_MODIFIER_MOVE;
+      break;
+    case TRANSFORM_HANDLE_N_S:
+    case TRANSFORM_HANDLE_S_S:
+    case TRANSFORM_HANDLE_E_S:
+    case TRANSFORM_HANDLE_W_S:
+      toolcursor = GIMP_TOOL_CURSOR_SHEAR;
+      *cursor = GIMP_CURSOR_CROSSHAIR_SMALL;
+      break;
+    case TRANSFORM_HANDLE_ROTATION:
+      toolcursor = GIMP_TOOL_CURSOR_ROTATE;
+      break;
+    default:
+      g_assert_not_reached();
+    }
+
+  /* parent class sets cursor and cursor_modifier */
+  gimp_tool_control_set_tool_cursor (GIMP_TOOL (tr_tool)->control, toolcursor);
+}
+
+static void
 gimp_unified_transform_tool_draw_gui (GimpTransformTool *tr_tool,
                                       gint               handle_w,
                                       gint               handle_h)



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