[gimp/soc-2011-warp] warp tool: fix the undo to update the whole dirtied area



commit 648602401cdcc14fcc9a1908ce692a7bf5232b71
Author: Michael Murà <batolettre gmail com>
Date:   Mon Aug 1 21:22:55 2011 +0200

    warp tool: fix the undo to update the whole dirtied area

 app/tools/gimpwarptool.c |   35 +++++++++++++++++++++++++++--------
 1 files changed, 27 insertions(+), 8 deletions(-)
---
diff --git a/app/tools/gimpwarptool.c b/app/tools/gimpwarptool.c
index d1c489b..42488de 100644
--- a/app/tools/gimpwarptool.c
+++ b/app/tools/gimpwarptool.c
@@ -445,8 +445,8 @@ gimp_warp_tool_draw (GimpDrawTool *draw_tool)
 
   gimp_draw_tool_add_arc (draw_tool,
                           FALSE,
-                          wt->cursor_x - options->effect_size / 2.0,
-                          wt->cursor_y - options->effect_size / 2.0,
+                          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);
@@ -517,8 +517,8 @@ gimp_warp_tool_image_map_update (GimpWarpTool *wt)
   GeglRectangle     region;
   GeglRectangle     to_update;
 
-  region.x = wt->cursor_x - options->effect_size / 2.0;
-  region.y = wt->cursor_y - options->effect_size / 2.0;
+  region.x = wt->cursor_x - options->effect_size * 0.5;
+  region.y = wt->cursor_y - options->effect_size * 0.5;
   region.width = options->effect_size;
   region.height = options->effect_size;
 
@@ -569,9 +569,16 @@ gimp_warp_tool_add_op (GimpWarpTool *wt)
 static void
 gimp_warp_tool_undo (GimpWarpTool *wt)
 {
-  GeglNode    *to_delete;
-  GeglNode    *previous;
-  const gchar *type;
+  GeglNode      *to_delete;
+  GeglNode      *previous;
+  const gchar   *type;
+  GeglPath      *stroke;
+  gdouble        min_x;
+  gdouble        max_x;
+  gdouble        min_y;
+  gdouble        max_y;
+  gdouble        size;
+  GeglRectangle  bbox;
 
   to_delete = gegl_node_get_producer (wt->render_node, "aux", NULL);
   type = gegl_node_get_operation(to_delete);
@@ -584,8 +591,20 @@ gimp_warp_tool_undo (GimpWarpTool *wt)
   gegl_node_disconnect (to_delete, "input");
   gegl_node_connect_to (previous, "output", wt->render_node, "aux");
 
+  gegl_node_get (to_delete, "stroke", &stroke, NULL);
+  gegl_node_get (to_delete, "size", &size, NULL);
+
+  if (stroke)
+  {
+    gegl_path_get_bounds (stroke, &min_x, &max_x, &min_y, &max_y);
+    bbox.x      = min_x - size * 0.5;
+    bbox.y      = min_y - size * 0.5;
+    bbox.width  = max_x - min_x + size;
+    bbox.height = max_y - min_y + size;
 
+    gimp_image_map_apply_region (wt->image_map, &bbox);
+  }
 
+  g_object_unref (stroke);
   g_object_unref (to_delete);
-  gimp_warp_tool_image_map_update (wt);
 }



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