app: add gimp_draw_tool_add_path() and use it in the vector tool

Also clean up gimp_vector_tool_draw() a bit.
This commit is contained in:
Michael Natterer 2010-10-07 14:10:57 +02:00
parent 0b078d3dad
commit 54a65fa9c3
3 changed files with 36 additions and 27 deletions

View File

@ -40,6 +40,7 @@
#include "display/gimpcanvasguide.h"
#include "display/gimpcanvashandle.h"
#include "display/gimpcanvasline.h"
#include "display/gimpcanvaspath.h"
#include "display/gimpcanvaspen.h"
#include "display/gimpcanvaspolygon.h"
#include "display/gimpcanvasrectangle.h"
@ -706,6 +707,24 @@ gimp_draw_tool_add_strokes (GimpDrawTool *draw_tool,
return item;
}
GimpCanvasItem *
gimp_draw_tool_add_path (GimpDrawTool *draw_tool,
const GimpBezierDesc *desc)
{
GimpCanvasItem *item;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), NULL);
g_return_val_if_fail (desc != NULL, NULL);
item = gimp_canvas_path_new (gimp_display_get_shell (draw_tool->display),
desc, FALSE, FALSE);
gimp_draw_tool_add_item (draw_tool, item);
g_object_unref (item);
return item;
}
GimpCanvasItem *
gimp_draw_tool_add_pen (GimpDrawTool *draw_tool,
const GimpVector2 *points,

View File

@ -150,6 +150,8 @@ GimpCanvasItem * gimp_draw_tool_add_strokes (GimpDrawTool *draw_too
const GimpCoords *points,
gint n_points,
gboolean filled);
GimpCanvasItem * gimp_draw_tool_add_path (GimpDrawTool *draw_tool,
const GimpBezierDesc *desc);
GimpCanvasItem * gimp_draw_tool_add_pen (GimpDrawTool *draw_tool,
const GimpVector2 *points,

View File

@ -1401,44 +1401,32 @@ static void
gimp_vector_tool_draw (GimpDrawTool *draw_tool)
{
GimpVectorTool *vector_tool = GIMP_VECTOR_TOOL (draw_tool);
GimpAnchor *cur_anchor = NULL;
GimpStroke *cur_stroke = NULL;
GimpStroke *cur_stroke;
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)))
{
/* the stroke itself */
if (! gimp_item_get_visible (GIMP_ITEM (vectors)))
{
coords = gimp_stroke_interpolate (cur_stroke, 1.0, &closed);
gimp_draw_tool_add_path (draw_tool, gimp_vectors_get_bezier (vectors));
if (coords)
for (cur_stroke = gimp_vectors_stroke_get_next (vectors, NULL);
cur_stroke;
cur_stroke = gimp_vectors_stroke_get_next (vectors, cur_stroke))
{
if (coords->len)
gimp_draw_tool_add_strokes (draw_tool,
&g_array_index (coords,
GimpCoords, 0),
coords->len, FALSE);
g_array_free (coords, TRUE);
}
}
GArray *coords;
GList *draw_anchors;
GList *list;
/* anchor handles */
draw_anchors = gimp_stroke_get_draw_anchors (cur_stroke);
for (list = draw_anchors; list; list = g_list_next (list))
{
cur_anchor = GIMP_ANCHOR (list->data);
GimpAnchor *cur_anchor = GIMP_ANCHOR (list->data);
if (cur_anchor->type == GIMP_ANCHOR_ANCHOR)
{
@ -1490,7 +1478,7 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
for (list = draw_anchors; list; list = g_list_next (list))
{
cur_anchor = GIMP_ANCHOR (list->data);
GimpAnchor *cur_anchor = GIMP_ANCHOR (list->data);
gimp_draw_tool_add_handle (draw_tool,
GIMP_HANDLE_SQUARE,