app: put the lines and the angle arc into a stroke group

This looks much better, and makes the lines appear under the handles
as a nice side effect.
This commit is contained in:
Michael Natterer 2010-09-26 15:49:10 +02:00
parent a306a46d45
commit e0f35d8979
1 changed files with 30 additions and 14 deletions

View File

@ -42,6 +42,7 @@
#include "widgets/gimptooldialog.h"
#include "widgets/gimpwidgets-utils.h"
#include "display/gimpcanvasgroup.h"
#include "display/gimpcanvashandle.h"
#include "display/gimpdisplay.h"
#include "display/gimpdisplayshell.h"
@ -663,9 +664,17 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
{
GimpMeasureTool *measure = GIMP_MEASURE_TOOL (draw_tool);
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpCanvasItem *stroke_group;
GimpCanvasItem *item;
gint i;
gint draw_arc = 0;
stroke_group = gimp_canvas_group_new ();
gimp_canvas_group_set_group_stroking (GIMP_CANVAS_GROUP (stroke_group),
TRUE);
gimp_draw_tool_add_item (draw_tool, stroke_group);
g_object_unref (stroke_group);
for (i = 0; i < measure->num_points; i++)
{
if (i == 0 && measure->num_points == 3)
@ -691,11 +700,14 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
if (i > 0)
{
gimp_draw_tool_add_line (draw_tool,
measure->x[0],
measure->y[0],
measure->x[i],
measure->y[i]);
item = gimp_draw_tool_add_line (draw_tool,
measure->x[0],
measure->y[0],
measure->x[i],
measure->y[i]);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item);
gimp_draw_tool_remove_item (draw_tool, item);
/* only draw the arc if the lines are long enough */
if (gimp_draw_tool_calc_distance (draw_tool, tool->display,
@ -722,8 +734,6 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
if (angle2 != 0.0)
{
GimpCanvasItem *item;
item = gimp_draw_tool_add_handle (draw_tool,
GIMP_HANDLE_CIRCLE,
measure->x[0],
@ -735,6 +745,9 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
gimp_canvas_handle_set_angles (GIMP_CANVAS_HANDLE (item),
angle1, angle2);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item);
gimp_draw_tool_remove_item (draw_tool, item);
if (measure->num_points == 2)
{
GimpDisplayShell *shell;
@ -746,13 +759,16 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
target = FUNSCALEX (shell, (TARGET >> 1));
arc_radius = FUNSCALEX (shell, ARC_RADIUS);
gimp_draw_tool_add_line (draw_tool,
measure->x[0],
measure->y[0],
(measure->x[1] >= measure->x[0] ?
measure->x[0] + arc_radius + target :
measure->x[0] - arc_radius - target),
measure->y[0]);
item = gimp_draw_tool_add_line (draw_tool,
measure->x[0],
measure->y[0],
(measure->x[1] >= measure->x[0] ?
measure->x[0] + arc_radius + target :
measure->x[0] - arc_radius - target),
measure->y[0]);
gimp_canvas_group_add_item (GIMP_CANVAS_GROUP (stroke_group), item);
gimp_draw_tool_remove_item (draw_tool, item);
}
}
}