[gimp] app: reorder warp tool functions to be in standard order



commit b63be0e79afc94199a2befbe41381c745f63b613
Author: Michael Natterer <mitch gimp org>
Date:   Wed May 22 00:47:43 2013 +0200

    app: reorder warp tool functions to be in standard order

 app/tools/gimpwarptool.c |  283 +++++++++++++++++++++++-----------------------
 1 files changed, 142 insertions(+), 141 deletions(-)
---
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index 8aa28fd..6d9f789 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -73,30 +73,31 @@ static void       gimp_warp_tool_button_release     (GimpTool              *tool
                                                      GdkModifierType        state,
                                                      GimpButtonReleaseType  release_type,
                                                      GimpDisplay           *display);
-static gboolean   gimp_warp_tool_key_press          (GimpTool              *tool,
-                                                     GdkEventKey           *kevent,
-                                                     GimpDisplay           *display);
 static void       gimp_warp_tool_motion             (GimpTool              *tool,
                                                      const GimpCoords      *coords,
                                                      guint32                time,
                                                      GdkModifierType        state,
                                                      GimpDisplay           *display);
-static void       gimp_warp_tool_cursor_update      (GimpTool              *tool,
-                                                     const GimpCoords      *coords,
-                                                     GdkModifierType        state,
+static gboolean   gimp_warp_tool_key_press          (GimpTool              *tool,
+                                                     GdkEventKey           *kevent,
                                                      GimpDisplay           *display);
 static void       gimp_warp_tool_oper_update        (GimpTool              *tool,
                                                      const GimpCoords      *coords,
                                                      GdkModifierType        state,
                                                      gboolean               proximity,
                                                      GimpDisplay           *display);
+static void       gimp_warp_tool_cursor_update      (GimpTool              *tool,
+                                                     const GimpCoords      *coords,
+                                                     GdkModifierType        state,
+                                                     GimpDisplay           *display);
+
+static void       gimp_warp_tool_draw               (GimpDrawTool          *draw_tool);
 
 static void       gimp_warp_tool_start              (GimpWarpTool          *wt,
                                                      GimpDisplay           *display);
 static void       gimp_warp_tool_halt               (GimpWarpTool          *wt);
 
 static gboolean   gimp_warp_tool_stroke_timer       (gpointer               data);
-static void       gimp_warp_tool_draw               (GimpDrawTool          *draw_tool);
 
 static void       gimp_warp_tool_create_graph       (GimpWarpTool          *wt);
 static void       gimp_warp_tool_create_image_map   (GimpWarpTool          *wt,
@@ -139,10 +140,10 @@ gimp_warp_tool_class_init (GimpWarpToolClass *klass)
   tool_class->control        = gimp_warp_tool_control;
   tool_class->button_press   = gimp_warp_tool_button_press;
   tool_class->button_release = gimp_warp_tool_button_release;
-  tool_class->key_press      = gimp_warp_tool_key_press;
   tool_class->motion         = gimp_warp_tool_motion;
-  tool_class->cursor_update  = gimp_warp_tool_cursor_update;
+  tool_class->key_press      = gimp_warp_tool_key_press;
   tool_class->oper_update    = gimp_warp_tool_oper_update;
+  tool_class->cursor_update  = gimp_warp_tool_cursor_update;
 
   draw_tool_class->draw      = gimp_warp_tool_draw;
 }
@@ -185,75 +186,84 @@ gimp_warp_tool_control (GimpTool       *tool,
 }
 
 static void
-gimp_warp_tool_start (GimpWarpTool *wt,
-                      GimpDisplay  *display)
+gimp_warp_tool_button_press (GimpTool            *tool,
+                             const GimpCoords    *coords,
+                             guint32              time,
+                             GdkModifierType      state,
+                             GimpButtonPressType  press_type,
+                             GimpDisplay         *display)
 {
-  GimpTool      *tool     = GIMP_TOOL (wt);
-  GimpImage     *image    = gimp_display_get_image (display);
-  GimpDrawable  *drawable = gimp_image_get_active_drawable (image);
-  const Babl    *format;
-  gint           x1, x2, y1, y2;
-  GeglRectangle  bbox;
-
-  tool->display = display;
+  GimpWarpTool *wt = GIMP_WARP_TOOL (tool);
 
-  /* Create the coords buffer, with the size of the selection */
-  format = babl_format_n (babl_type ("float"), 2);
+  if (tool->display && display != tool->display)
+    gimp_warp_tool_halt (wt);
 
-  gimp_channel_bounds (gimp_image_get_mask (image), &x1, &y1, &x2, &y2);
+  if (! tool->display)
+    gimp_warp_tool_start (wt, display);
 
-  bbox.x      = MIN (x1, x2);
-  bbox.y      = MIN (y1, y2);
-  bbox.width  = ABS (x1 - x2);
-  bbox.height = ABS (y1 - y2);
+  wt->current_stroke = gegl_path_new ();
+  gegl_path_append (wt->current_stroke,
+                    'M', coords->x, coords->y);
 
-  printf ("Initialize coordinate buffer (%d,%d) at %d,%d\n",
-          bbox.width, bbox.height, bbox.x, bbox.y);
-  wt->coords_buffer = gegl_buffer_new (&bbox, format);
+  gimp_warp_tool_add_op (wt);
 
-  gegl_rectangle_set (&wt->last_region, 0, 0, 0, 0);
+  gimp_warp_tool_image_map_update (wt);
 
-  gimp_warp_tool_create_image_map (wt, drawable);
+  wt->stroke_timer = g_timeout_add (STROKE_PERIOD,
+                                    gimp_warp_tool_stroke_timer,
+                                    wt);
 
-  if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (wt)))
-    gimp_draw_tool_start (GIMP_DRAW_TOOL (wt), display);
+  gimp_tool_control_activate (tool->control);
 }
 
-static void
-gimp_warp_tool_halt (GimpWarpTool *wt)
+void
+gimp_warp_tool_button_release (GimpTool              *tool,
+                               const GimpCoords      *coords,
+                               guint32                time,
+                               GdkModifierType        state,
+                               GimpButtonReleaseType  release_type,
+                               GimpDisplay           *display)
 {
-  GimpTool *tool = GIMP_TOOL (wt);
+  GimpWarpTool *wt = GIMP_WARP_TOOL (tool);
 
-  if (wt->coords_buffer)
+  gimp_draw_tool_pause (GIMP_DRAW_TOOL (wt));
+
+  gimp_tool_control_halt (tool->control);
+
+  g_source_remove (wt->stroke_timer);
+  wt->stroke_timer = 0;
+
+  printf ("%s\n", gegl_path_to_string (wt->current_stroke));
+
+  if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
     {
-      g_object_unref (wt->coords_buffer);
-      wt->coords_buffer = NULL;
+      gimp_warp_tool_undo (wt);
     }
-
-  if (wt->graph)
+  else
     {
-      g_object_unref (wt->graph);
-      wt->graph       = NULL;
-      wt->render_node = NULL;
+      gimp_warp_tool_image_map_update (wt);
     }
 
-  if (wt->image_map)
-    {
-      gimp_tool_control_set_preserve (tool->control, TRUE);
+  gegl_rectangle_set (&wt->last_region, 0, 0, 0, 0);
 
-      gimp_image_map_abort (wt->image_map);
-      g_object_unref (wt->image_map);
-      wt->image_map = NULL;
+  gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
+}
 
-      gimp_tool_control_set_preserve (tool->control, FALSE);
+static void
+gimp_warp_tool_motion (GimpTool         *tool,
+                       const GimpCoords *coords,
+                       guint32           time,
+                       GdkModifierType   state,
+                       GimpDisplay      *display)
+{
+  GimpWarpTool *wt = GIMP_WARP_TOOL (tool);
 
-      gimp_image_flush (gimp_display_get_image (tool->display));
-    }
+  gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
 
-  tool->display = NULL;
+  wt->cursor_x = coords->x;
+  wt->cursor_y = coords->y;
 
-  if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (wt)))
-    gimp_draw_tool_stop (GIMP_DRAW_TOOL (wt));
+  gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
 }
 
 static gboolean
@@ -297,23 +307,6 @@ gimp_warp_tool_key_press (GimpTool    *tool,
 }
 
 static void
-gimp_warp_tool_motion (GimpTool         *tool,
-                       const GimpCoords *coords,
-                       guint32           time,
-                       GdkModifierType   state,
-                       GimpDisplay      *display)
-{
-  GimpWarpTool *wt = GIMP_WARP_TOOL (tool);
-
-  gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
-
-  wt->cursor_x = coords->x;
-  wt->cursor_y = coords->y;
-
-  gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
-}
-
-static void
 gimp_warp_tool_oper_update (GimpTool         *tool,
                             const GimpCoords *coords,
                             GdkModifierType   state,
@@ -345,85 +338,108 @@ gimp_warp_tool_oper_update (GimpTool         *tool,
 }
 
 static void
-gimp_warp_tool_button_press (GimpTool            *tool,
-                             const GimpCoords    *coords,
-                             guint32              time,
-                             GdkModifierType      state,
-                             GimpButtonPressType  press_type,
-                             GimpDisplay         *display)
+gimp_warp_tool_cursor_update (GimpTool         *tool,
+                              const GimpCoords *coords,
+                              GdkModifierType   state,
+                              GimpDisplay      *display)
 {
-  GimpWarpTool *wt = GIMP_WARP_TOOL (tool);
-
-  if (tool->display && display != tool->display)
-    gimp_warp_tool_halt (wt);
-
-  if (! tool->display)
-    gimp_warp_tool_start (wt, display);
+  GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_PLUS;
 
-  wt->current_stroke = gegl_path_new ();
-  gegl_path_append (wt->current_stroke,
-                    'M', coords->x, coords->y);
+  if (tool->display)
+    {
+      modifier = GIMP_CURSOR_MODIFIER_MOVE;
+    }
 
-  gimp_warp_tool_add_op (wt);
+  gimp_tool_control_set_cursor_modifier (tool->control, modifier);
 
-  gimp_warp_tool_image_map_update (wt);
+  GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
+}
 
-  wt->stroke_timer = g_timeout_add (STROKE_PERIOD,
-                                    gimp_warp_tool_stroke_timer,
-                                    wt);
+static void
+gimp_warp_tool_draw (GimpDrawTool *draw_tool)
+{
+  GimpWarpTool    *wt      = GIMP_WARP_TOOL (draw_tool);
+  GimpWarpOptions *options = GIMP_WARP_TOOL_GET_OPTIONS (wt);
 
-  gimp_tool_control_activate (tool->control);
+  gimp_draw_tool_add_arc (draw_tool,
+                          FALSE,
+                          wt->cursor_x - options->effect_size * 0.5,
+                          wt->cursor_y - options->effect_size * 0.5,
+                          options->effect_size,
+                          options->effect_size,
+                          0.0, 2.0 * G_PI);
 }
 
-void
-gimp_warp_tool_button_release (GimpTool              *tool,
-                               const GimpCoords      *coords,
-                               guint32                time,
-                               GdkModifierType        state,
-                               GimpButtonReleaseType  release_type,
-                               GimpDisplay           *display)
+static void
+gimp_warp_tool_start (GimpWarpTool *wt,
+                      GimpDisplay  *display)
 {
-  GimpWarpTool *wt = GIMP_WARP_TOOL (tool);
+  GimpTool      *tool     = GIMP_TOOL (wt);
+  GimpImage     *image    = gimp_display_get_image (display);
+  GimpDrawable  *drawable = gimp_image_get_active_drawable (image);
+  const Babl    *format;
+  gint           x1, x2, y1, y2;
+  GeglRectangle  bbox;
 
-  gimp_draw_tool_pause (GIMP_DRAW_TOOL (wt));
+  tool->display = display;
 
-  gimp_tool_control_halt (tool->control);
+  /* Create the coords buffer, with the size of the selection */
+  format = babl_format_n (babl_type ("float"), 2);
 
-  g_source_remove (wt->stroke_timer);
-  wt->stroke_timer = 0;
+  gimp_channel_bounds (gimp_image_get_mask (image), &x1, &y1, &x2, &y2);
 
-  printf ("%s\n", gegl_path_to_string (wt->current_stroke));
+  bbox.x      = MIN (x1, x2);
+  bbox.y      = MIN (y1, y2);
+  bbox.width  = ABS (x1 - x2);
+  bbox.height = ABS (y1 - y2);
 
-  if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
-    {
-      gimp_warp_tool_undo (wt);
-    }
-  else
-    {
-      gimp_warp_tool_image_map_update (wt);
-    }
+  printf ("Initialize coordinate buffer (%d,%d) at %d,%d\n",
+          bbox.width, bbox.height, bbox.x, bbox.y);
+  wt->coords_buffer = gegl_buffer_new (&bbox, format);
 
   gegl_rectangle_set (&wt->last_region, 0, 0, 0, 0);
 
-  gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
+  gimp_warp_tool_create_image_map (wt, drawable);
+
+  if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (wt)))
+    gimp_draw_tool_start (GIMP_DRAW_TOOL (wt), display);
 }
 
 static void
-gimp_warp_tool_cursor_update (GimpTool         *tool,
-                              const GimpCoords *coords,
-                              GdkModifierType   state,
-                              GimpDisplay      *display)
+gimp_warp_tool_halt (GimpWarpTool *wt)
 {
-  GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_PLUS;
+  GimpTool *tool = GIMP_TOOL (wt);
 
-  if (tool->display)
+  if (wt->coords_buffer)
     {
-      modifier = GIMP_CURSOR_MODIFIER_MOVE;
+      g_object_unref (wt->coords_buffer);
+      wt->coords_buffer = NULL;
     }
 
-  gimp_tool_control_set_cursor_modifier (tool->control, modifier);
+  if (wt->graph)
+    {
+      g_object_unref (wt->graph);
+      wt->graph       = NULL;
+      wt->render_node = NULL;
+    }
 
-  GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
+  if (wt->image_map)
+    {
+      gimp_tool_control_set_preserve (tool->control, TRUE);
+
+      gimp_image_map_abort (wt->image_map);
+      g_object_unref (wt->image_map);
+      wt->image_map = NULL;
+
+      gimp_tool_control_set_preserve (tool->control, FALSE);
+
+      gimp_image_flush (gimp_display_get_image (tool->display));
+    }
+
+  tool->display = NULL;
+
+  if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (wt)))
+    gimp_draw_tool_stop (GIMP_DRAW_TOOL (wt));
 }
 
 static gboolean
@@ -440,21 +456,6 @@ gimp_warp_tool_stroke_timer (gpointer data)
 }
 
 static void
-gimp_warp_tool_draw (GimpDrawTool *draw_tool)
-{
-  GimpWarpTool     *wt      = GIMP_WARP_TOOL (draw_tool);
-  GimpWarpOptions  *options = GIMP_WARP_TOOL_GET_OPTIONS (wt);
-
-  gimp_draw_tool_add_arc (draw_tool,
-                          FALSE,
-                          wt->cursor_x - options->effect_size * 0.5,
-                          wt->cursor_y - options->effect_size * 0.5,
-                          options->effect_size,
-                          options->effect_size,
-                          0.0, 2.0 * G_PI);
-}
-
-static void
 gimp_warp_tool_create_graph (GimpWarpTool *wt)
 {
   GeglNode *graph;           /* Wraper to be returned */


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