From ebc39ee055dcb60d82cd6514bc4c3a92cc53d663 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Fri, 21 Nov 2008 21:07:48 +0000 Subject: [PATCH] moved vectors drawing to its own function. 2008-11-21 Sven Neumann * app/tools/gimpdrawtool.c (gimp_draw_tool_real_draw): moved vectors drawing to its own function. svn path=/trunk/; revision=27702 --- ChangeLog | 5 ++ app/tools/gimpdrawtool.c | 143 +++++++++++++++++++++------------------ 2 files changed, 81 insertions(+), 67 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4c6f10345f..0d9759b8f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2008-11-21 Sven Neumann + + * app/tools/gimpdrawtool.c (gimp_draw_tool_real_draw): moved + vectors drawing to its own function. + 2008-11-21 Sven Neumann * app/tools/gimpdrawtool.[ch]: reordered functions to keep those diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c index a5328d5340..3d0a43a1ae 100644 --- a/app/tools/gimpdrawtool.c +++ b/app/tools/gimpdrawtool.c @@ -43,35 +43,38 @@ #include "gimpdrawtool.h" -static void gimp_draw_tool_finalize (GObject *object); +static void gimp_draw_tool_finalize (GObject *object); -static gboolean gimp_draw_tool_has_display (GimpTool *tool, - GimpDisplay *display); -static GimpDisplay * gimp_draw_tool_has_image (GimpTool *tool, - GimpImage *image); -static void gimp_draw_tool_control (GimpTool *tool, - GimpToolAction action, - GimpDisplay *display); +static gboolean gimp_draw_tool_has_display (GimpTool *tool, + GimpDisplay *display); +static GimpDisplay * gimp_draw_tool_has_image (GimpTool *tool, + GimpImage *image); +static void gimp_draw_tool_control (GimpTool *tool, + GimpToolAction action, + GimpDisplay *display); -static void gimp_draw_tool_draw (GimpDrawTool *draw_tool); -static void gimp_draw_tool_real_draw (GimpDrawTool *draw_tool); +static void gimp_draw_tool_draw (GimpDrawTool *draw_tool); +static void gimp_draw_tool_real_draw (GimpDrawTool *draw_tool); + +static void gimp_draw_tool_draw_vectors (GimpDrawTool *draw_tool, + GList *vectors); static inline void gimp_draw_tool_shift_to_north_west - (gdouble x, - gdouble y, - gint handle_width, - gint handle_height, - GtkAnchorType anchor, - gdouble *shifted_x, - gdouble *shifted_y); + (gdouble x, + gdouble y, + gint handle_width, + gint handle_height, + GtkAnchorType anchor, + gdouble *shifted_x, + gdouble *shifted_y); static inline void gimp_draw_tool_shift_to_center - (gdouble x, - gdouble y, - gint handle_width, - gint handle_height, - GtkAnchorType anchor, - gdouble *shifted_x, - gdouble *shifted_y); + (gdouble x, + gdouble y, + gint handle_width, + gint handle_height, + GtkAnchorType anchor, + gdouble *shifted_x, + gdouble *shifted_y); G_DEFINE_TYPE (GimpDrawTool, gimp_draw_tool, GIMP_TYPE_TOOL) @@ -198,49 +201,8 @@ gimp_draw_tool_draw (GimpDrawTool *draw_tool) static void gimp_draw_tool_real_draw (GimpDrawTool *draw_tool) { - GList *list; - - if (! draw_tool->vectors) - return; - - for (list = draw_tool->vectors; list; list = g_list_next (list)) - { - GimpVectors *vectors = list->data; - 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 && coords->len) - { - if (draw_tool->transform) - { - gint i; - - for (i = 0; i < coords->len; i++) - { - GimpCoords *curr = &g_array_index (coords, GimpCoords, i); - - gimp_matrix3_transform_point (draw_tool->transform, - curr->x, curr->y, - &curr->x, &curr->y); - } - } - - gimp_draw_tool_draw_strokes (draw_tool, - &g_array_index (coords, - GimpCoords, 0), - coords->len, FALSE, FALSE); - } - - if (coords) - g_array_free (coords, TRUE); - } - } + if (draw_tool->vectors) + gimp_draw_tool_draw_vectors (draw_tool, draw_tool->vectors); } void @@ -1618,6 +1580,53 @@ gimp_draw_tool_draw_text_cursor (GimpDrawTool *draw_tool, PROJ_ROUND (tx2) + 3, PROJ_ROUND (ty2) - 2); } +/* This is called from gimp_draw_tool_real_draw() */ +static void +gimp_draw_tool_draw_vectors (GimpDrawTool *draw_tool, + GList *vectors) +{ + GList *list; + + for (list = vectors; list; list = g_list_next (list)) + { + GimpVectors *vectors = list->data; + 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 && coords->len) + { + if (draw_tool->transform) + { + gint i; + + for (i = 0; i < coords->len; i++) + { + GimpCoords *curr = &g_array_index (coords, GimpCoords, i); + + gimp_matrix3_transform_point (draw_tool->transform, + curr->x, curr->y, + &curr->x, &curr->y); + } + } + + gimp_draw_tool_draw_strokes (draw_tool, + &g_array_index (coords, + GimpCoords, 0), + coords->len, FALSE, FALSE); + } + + if (coords) + g_array_free (coords, TRUE); + } + } +} + gboolean gimp_draw_tool_on_handle (GimpDrawTool *draw_tool, GimpDisplay *display,