From 8587e1e920655440bf786b13865cd7975a0b4aea Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Mon, 4 Oct 2010 22:02:12 +0200 Subject: [PATCH] app/tools: introduce gimp_draw_tool_add_crosshair() gimp_draw_tool_add_crosshair() is a convenience function that adds two intersecting guide lines in a stroke group. --- app/tools/gimpcolortool.c | 13 +++---------- app/tools/gimpdrawtool.c | 31 +++++++++++++++++++++++++++++-- app/tools/gimpdrawtool.h | 3 +++ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c index ace95b854b..1bdbdae90c 100644 --- a/app/tools/gimpcolortool.c +++ b/app/tools/gimpcolortool.c @@ -548,16 +548,9 @@ gimp_color_tool_draw (GimpDrawTool *draw_tool) if (color_tool->sample_point_x != SAMPLE_POINT_POSITION_INVALID && color_tool->sample_point_y != SAMPLE_POINT_POSITION_INVALID) { - gimp_draw_tool_push_group (draw_tool, - gimp_draw_tool_add_stroke_group (draw_tool)); - gimp_draw_tool_add_guide (draw_tool, - GIMP_ORIENTATION_VERTICAL, - color_tool->sample_point_x, FALSE); - gimp_draw_tool_add_guide (draw_tool, - GIMP_ORIENTATION_HORIZONTAL, - color_tool->sample_point_y, FALSE); - - gimp_draw_tool_pop_group (draw_tool); + gimp_draw_tool_add_crosshair (draw_tool, + color_tool->sample_point_x, + color_tool->sample_point_y); } } else if (color_tool->options->sample_average && diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c index 227af3025b..7d4cf125d9 100644 --- a/app/tools/gimpdrawtool.c +++ b/app/tools/gimpdrawtool.c @@ -466,7 +466,7 @@ gimp_draw_tool_add_line (GimpDrawTool *draw_tool, } /** - * gimp_draw_tool_draw_guide: + * gimp_draw_tool_add_guide: * @draw_tool: the #GimpDrawTool * @orientation: the orientation of the guide line * @position: the position of the guide line in image coordinates @@ -493,7 +493,34 @@ gimp_draw_tool_add_guide (GimpDrawTool *draw_tool, } /** - * gimp_draw_tool_draw_sample_point: + * gimp_draw_tool_add_crosshair: + * @draw_tool: the #GimpDrawTool + * @position_x: the position of the vertical guide line in image coordinates + * @position_y: the position of the horizontal guide line in image coordinates + * + * This function draws two crossing guide lines across the canvas. + **/ +GimpCanvasItem * +gimp_draw_tool_add_crosshair (GimpDrawTool *draw_tool, + gint position_x, + gint position_y) +{ + GimpCanvasGroup *group; + + group = gimp_draw_tool_add_stroke_group (draw_tool); + + gimp_draw_tool_push_group (draw_tool, group); + gimp_draw_tool_add_guide (draw_tool, + GIMP_ORIENTATION_VERTICAL, position_x, FALSE); + gimp_draw_tool_add_guide (draw_tool, + GIMP_ORIENTATION_HORIZONTAL, position_y, FALSE); + gimp_draw_tool_pop_group (draw_tool); + + return GIMP_CANVAS_ITEM (group); +} + +/** + * gimp_draw_tool_add_sample_point: * @draw_tool: the #GimpDrawTool * @x: X position of the sample point * @y: Y position of the sample point diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h index 807fadd6d0..22327e446d 100644 --- a/app/tools/gimpdrawtool.h +++ b/app/tools/gimpdrawtool.h @@ -101,6 +101,9 @@ GimpCanvasItem * gimp_draw_tool_add_guide (GimpDrawTool *draw_too GimpOrientationType orientation, gint position, gboolean guide_style); +GimpCanvasItem * gimp_draw_tool_add_crosshair (GimpDrawTool *draw_tool, + gint position_x, + gint position_y); GimpCanvasItem * gimp_draw_tool_add_sample_point (GimpDrawTool *draw_tool, gint x, gint y,