[gimp/soc-2011-warp: 27/72] gimpwarptool: use a timer to add regularly point to the stroke



commit 7d8d32a0d3574b9f758e4dac29b24fad661cbcdc
Author: Michael Murà <batolettre gmail com>
Date:   Thu Jun 16 14:15:52 2011 +0200

    gimpwarptool: use a timer to add regularly point to the stroke

 app/tools/gimpwarptool.c |   24 ++++++++++++++++++------
 app/tools/gimpwarptool.h |    2 ++
 2 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index 9bf64e2..3824c1b 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -95,6 +95,7 @@ static void       gimp_warp_tool_oper_update        (GimpTool              *tool
                                                      gboolean               proximity,
                                                      GimpDisplay           *display);
 
+static gboolean   gimp_warp_tool_timer              (gpointer               data);
 static void       gimp_warp_tool_draw               (GimpDrawTool          *draw_tool);
 
 static void       gimp_warp_tool_create_graph       (GimpWarpTool          *wt);
@@ -330,12 +331,8 @@ gimp_warp_tool_motion (GimpTool         *tool,
 {
   GimpWarpTool    *wt       = GIMP_WARP_TOOL (tool);
 
-  gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
-
-  gegl_path_append (wt->current_stroke,
-                    'M', coords->x, coords->y);
-
-  gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
+  wt->cursor_x = coords->x;
+  wt->cursor_y = coords->y;
 }
 
 static void
@@ -380,6 +377,10 @@ gimp_warp_tool_button_press (GimpTool            *tool,
     gimp_warp_tool_start (wt, display);
 
   wt->current_stroke = gegl_path_new ();
+  gegl_path_append (wt->current_stroke,
+                    'M', coords->x, coords->y);
+
+  wt->timer = g_timeout_add (100, gimp_warp_tool_timer, wt);
 
   gimp_warp_tool_add_op (wt);
   gimp_warp_tool_image_map_update (wt);
@@ -401,6 +402,8 @@ gimp_warp_tool_button_release (GimpTool              *tool,
 
   gimp_tool_control_halt (tool->control);
 
+  g_source_remove (wt->timer);
+
   printf ("%s\n", gegl_path_to_string (wt->current_stroke));
   gimp_warp_tool_image_map_update (wt);
 
@@ -432,6 +435,15 @@ gimp_warp_tool_cursor_update (GimpTool         *tool,
   GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
 }
 
+gboolean
+gimp_warp_tool_timer (gpointer data)
+{
+  GimpWarpTool    *wt        = GIMP_WARP_TOOL (data);
+
+  gegl_path_append (wt->current_stroke,
+                    'M', wt->cursor_x, wt->cursor_y);
+}
+
 static void
 gimp_warp_tool_draw (GimpDrawTool *draw_tool)
 {
diff --git a/app/tools/gimpwarptool.h b/app/tools/gimpwarptool.h
index f1b4c1f..169d7fd 100644
--- a/app/tools/gimpwarptool.h
+++ b/app/tools/gimpwarptool.h
@@ -52,6 +52,8 @@ struct _GimpWarpTool
 
   GeglPath       *current_stroke;
 
+  guint           timer;
+
   GimpImageMap   *image_map; /* For preview */
 };
 



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