[gimp] app: let the vectors tool draw vectors the old way again



commit 72b25fd35574592d0116e9a28c4f7d195fb547af
Author: Sven Neumann <sven gimp org>
Date:   Thu Sep 16 23:09:14 2010 +0200

    app: let the vectors tool draw vectors the old way again
    
    Seems like the best solution until tool drawing is ported to cairo.

 app/tools/gimpvectortool.c |   77 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 68 insertions(+), 9 deletions(-)
---
diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c
index 5b870db..5a57a68 100644
--- a/app/tools/gimpvectortool.c
+++ b/app/tools/gimpvectortool.c
@@ -118,6 +118,8 @@ static void     gimp_vector_tool_vectors_changed (GimpImage             *image,
                                                   GimpVectorTool        *vector_tool);
 static void     gimp_vector_tool_vectors_removed (GimpVectors           *vectors,
                                                   GimpVectorTool        *vector_tool);
+static void     gimp_vector_tool_vectors_visible (GimpVectors           *vectors,
+                                                  GimpVectorTool        *vector_tool);
 static void     gimp_vector_tool_vectors_freeze  (GimpVectors           *vectors,
                                                   GimpVectorTool        *vector_tool);
 static void     gimp_vector_tool_vectors_thaw    (GimpVectors           *vectors,
@@ -1397,15 +1399,18 @@ gimp_vector_tool_cursor_update (GimpTool         *tool,
 static void
 gimp_vector_tool_draw (GimpDrawTool *draw_tool)
 {
-  GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (draw_tool);
-  GimpVectors    *vectors     = vector_tool->vectors;
-  GimpAnchor     *cur_anchor  = NULL;
-  GimpStroke     *cur_stroke  = NULL;
-  GArray         *coords;
-  GList          *draw_anchors;
-  GList          *list;
-
-  if (! vectors)
+  GimpVectorTool  *vector_tool = GIMP_VECTOR_TOOL (draw_tool);
+  GimpAnchor      *cur_anchor  = NULL;
+  GimpStroke      *cur_stroke  = NULL;
+  GimpVectors     *vectors;
+  GArray          *coords;
+  gboolean         closed;
+  GList           *draw_anchors;
+  GList           *list;
+
+  vectors = vector_tool->vectors;
+
+  if (!vectors)
     return;
 
   while ((cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke)))
@@ -1478,6 +1483,23 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
               g_array_free (coords, TRUE);
             }
         }
+
+      /* the stroke itself */
+      if (! gimp_item_get_visible (GIMP_ITEM (vectors)))
+        {
+          coords = gimp_stroke_interpolate (cur_stroke, 1.0, &closed);
+
+          if (coords)
+            {
+              if (coords->len)
+                gimp_draw_tool_draw_strokes (draw_tool,
+                                             &g_array_index (coords,
+                                                             GimpCoords, 0),
+                                             coords->len, FALSE, FALSE);
+
+              g_array_free (coords, TRUE);
+            }
+        }
     }
 }
 
@@ -1497,6 +1519,37 @@ gimp_vector_tool_vectors_removed (GimpVectors    *vectors,
 }
 
 static void
+gimp_vector_tool_vectors_visible (GimpVectors    *vectors,
+                                  GimpVectorTool *vector_tool)
+{
+  GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (vector_tool);
+
+  if (gimp_draw_tool_is_active (draw_tool) && draw_tool->paused_count == 0)
+    {
+      GimpStroke *stroke = NULL;
+
+      while ((stroke = gimp_vectors_stroke_get_next (vectors, stroke)))
+        {
+          GArray   *coords;
+          gboolean  closed;
+
+          coords = gimp_stroke_interpolate (stroke, 1.0, &closed);
+
+          if (coords)
+            {
+              if (coords->len)
+                gimp_draw_tool_draw_strokes (draw_tool,
+                                             &g_array_index (coords,
+                                                             GimpCoords, 0),
+                                             coords->len, FALSE, FALSE);
+
+              g_array_free (coords, TRUE);
+            }
+        }
+    }
+}
+
+static void
 gimp_vector_tool_vectors_freeze (GimpVectors    *vectors,
                                  GimpVectorTool *vector_tool)
 {
@@ -1558,6 +1611,9 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
                                             gimp_vector_tool_vectors_removed,
                                             vector_tool);
       g_signal_handlers_disconnect_by_func (vector_tool->vectors,
+                                            gimp_vector_tool_vectors_visible,
+                                            vector_tool);
+      g_signal_handlers_disconnect_by_func (vector_tool->vectors,
                                             gimp_vector_tool_vectors_freeze,
                                             vector_tool);
       g_signal_handlers_disconnect_by_func (vector_tool->vectors,
@@ -1609,6 +1665,9 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
   g_signal_connect_object (vectors, "removed",
                            G_CALLBACK (gimp_vector_tool_vectors_removed),
                            vector_tool, 0);
+  g_signal_connect_object (vectors, "visibility-changed",
+                           G_CALLBACK (gimp_vector_tool_vectors_visible),
+                           vector_tool, 0);
   g_signal_connect_object (vectors, "freeze",
                            G_CALLBACK (gimp_vector_tool_vectors_freeze),
                            vector_tool, 0);



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