restructured the new draw utility functions and added

2001-11-15  Michael Natterer  <mitch@gimp.org>

	* app/tools/gimpdrawtool.[ch]: restructured the new draw utility
	functions and added gimp_draw_tool_draw_handle() and
	gimp_draw_tool_on_handle().

	* app/tools/gimpbezierselecttool.c
	* app/tools/gimpblendtool.c
	* app/tools/gimpcroptool.[ch]
	* app/tools/gimpiscissorstool.c
	* app/tools/gimpmeasuretool.c
	* app/tools/gimppainttool.c
	* app/tools/gimppathtool.c
	* app/tools/gimptransformtool.c: use the new functions all over
	the place so handle drawing and mouse_over detection work the same
	for all tools.
This commit is contained in:
Michael Natterer 2001-11-15 21:17:36 +00:00 committed by Michael Natterer
parent 2377f709e9
commit f901b46da6
16 changed files with 785 additions and 356 deletions

View file

@ -1,3 +1,20 @@
2001-11-15 Michael Natterer <mitch@gimp.org>
* app/tools/gimpdrawtool.[ch]: restructured the new draw utility
functions and added gimp_draw_tool_draw_handle() and
gimp_draw_tool_on_handle().
* app/tools/gimpbezierselecttool.c
* app/tools/gimpblendtool.c
* app/tools/gimpcroptool.[ch]
* app/tools/gimpiscissorstool.c
* app/tools/gimpmeasuretool.c
* app/tools/gimppainttool.c
* app/tools/gimppathtool.c
* app/tools/gimptransformtool.c: use the new functions all over
the place so handle drawing and mouse_over detection work the same
for all tools.
2001-11-15 Michael Natterer <mitch@gimp.org> 2001-11-15 Michael Natterer <mitch@gimp.org>
* Makefile.am: removed antique Makefile targets, including the * Makefile.am: removed antique Makefile targets, including the

View file

@ -429,10 +429,13 @@ gimp_transform_tool_button_press (GimpTool *tool,
gt_tool->function = TRANSFORM_HANDLE_4; gt_tool->function = TRANSFORM_HANDLE_4;
} }
if (gimp_draw_tool_in_radius (draw_tool, gdisp, if (gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->x, coords->y, coords->x, coords->y,
GIMP_HANDLE_CIRCLE,
gt_tool->tcx, gt_tool->tcy, gt_tool->tcx, gt_tool->tcy,
HANDLE >> 1)) HANDLE, HANDLE,
GIMP_HANDLE_CIRCLE,
FALSE))
{ {
gt_tool->function = TRANSFORM_HANDLE_CENTER; gt_tool->function = TRANSFORM_HANDLE_CENTER;
} }
@ -859,29 +862,38 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
} }
/* draw the tool handles */ /* draw the tool handles */
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tx1, tr_tool->ty1, GIMP_HANDLE_SQUARE,
HANDLE, HANDLE, tr_tool->tx1, tr_tool->ty1,
FALSE); HANDLE, HANDLE,
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, GTK_ANCHOR_CENTER,
tr_tool->tx2, tr_tool->ty2, FALSE);
HANDLE, HANDLE, gimp_draw_tool_draw_handle (draw_tool,
FALSE); GIMP_HANDLE_SQUARE,
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, tr_tool->tx2, tr_tool->ty2,
tr_tool->tx3, tr_tool->ty3, HANDLE, HANDLE,
HANDLE, HANDLE, GTK_ANCHOR_CENTER,
FALSE); FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tx4, tr_tool->ty4, GIMP_HANDLE_SQUARE,
HANDLE, HANDLE, tr_tool->tx3, tr_tool->ty3,
FALSE); HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx4, tr_tool->ty4,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
/* draw the center */ /* draw the center */
gimp_draw_tool_draw_arc_by_center (draw_tool, TRUE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tcx, tr_tool->tcy, GIMP_HANDLE_FILLED_CIRCLE,
HANDLE >> 1, tr_tool->tcx, tr_tool->tcy,
0, 23040, HANDLE, HANDLE,
FALSE); GTK_ANCHOR_CENTER,
FALSE);
if (gimp_transform_tool_showpath ()) if (gimp_transform_tool_showpath ())
{ {

View file

@ -429,10 +429,13 @@ gimp_transform_tool_button_press (GimpTool *tool,
gt_tool->function = TRANSFORM_HANDLE_4; gt_tool->function = TRANSFORM_HANDLE_4;
} }
if (gimp_draw_tool_in_radius (draw_tool, gdisp, if (gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->x, coords->y, coords->x, coords->y,
GIMP_HANDLE_CIRCLE,
gt_tool->tcx, gt_tool->tcy, gt_tool->tcx, gt_tool->tcy,
HANDLE >> 1)) HANDLE, HANDLE,
GIMP_HANDLE_CIRCLE,
FALSE))
{ {
gt_tool->function = TRANSFORM_HANDLE_CENTER; gt_tool->function = TRANSFORM_HANDLE_CENTER;
} }
@ -859,29 +862,38 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
} }
/* draw the tool handles */ /* draw the tool handles */
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tx1, tr_tool->ty1, GIMP_HANDLE_SQUARE,
HANDLE, HANDLE, tr_tool->tx1, tr_tool->ty1,
FALSE); HANDLE, HANDLE,
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, GTK_ANCHOR_CENTER,
tr_tool->tx2, tr_tool->ty2, FALSE);
HANDLE, HANDLE, gimp_draw_tool_draw_handle (draw_tool,
FALSE); GIMP_HANDLE_SQUARE,
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, tr_tool->tx2, tr_tool->ty2,
tr_tool->tx3, tr_tool->ty3, HANDLE, HANDLE,
HANDLE, HANDLE, GTK_ANCHOR_CENTER,
FALSE); FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tx4, tr_tool->ty4, GIMP_HANDLE_SQUARE,
HANDLE, HANDLE, tr_tool->tx3, tr_tool->ty3,
FALSE); HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx4, tr_tool->ty4,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
/* draw the center */ /* draw the center */
gimp_draw_tool_draw_arc_by_center (draw_tool, TRUE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tcx, tr_tool->tcy, GIMP_HANDLE_FILLED_CIRCLE,
HANDLE >> 1, tr_tool->tcx, tr_tool->tcy,
0, 23040, HANDLE, HANDLE,
FALSE); GTK_ANCHOR_CENTER,
FALSE);
if (gimp_transform_tool_showpath ()) if (gimp_transform_tool_showpath ())
{ {

View file

@ -788,18 +788,24 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
paint_tool = GIMP_PAINT_TOOL (draw_tool); paint_tool = GIMP_PAINT_TOOL (draw_tool);
/* Draw start target */ /* Draw start target */
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
floor (paint_tool->last_coords.x) + 0.5, GIMP_HANDLE_CROSS,
floor (paint_tool->last_coords.y) + 0.5, floor (paint_tool->last_coords.x) + 0.5,
TARGET_SIZE, floor (paint_tool->last_coords.y) + 0.5,
TRUE); TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw end target */ /* Draw end target */
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
floor (paint_tool->cur_coords.x) + 0.5, GIMP_HANDLE_CROSS,
floor (paint_tool->cur_coords.y) + 0.5, floor (paint_tool->cur_coords.x) + 0.5,
TARGET_SIZE, floor (paint_tool->cur_coords.y) + 0.5,
TRUE); TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw the line between the start and end coords */ /* Draw the line between the start and end coords */
gimp_draw_tool_draw_line (draw_tool, gimp_draw_tool_draw_line (draw_tool,

View file

@ -1869,7 +1869,8 @@ gimp_bezier_select_tool_cursor_update (GimpTool *tool,
shell = GIMP_DISPLAY_SHELL (gdisp->shell); shell = GIMP_DISPLAY_SHELL (gdisp->shell);
if (gdisp != tool->gdisp || draw_tool->draw_state == INVISIBLE) if (gdisp != tool->gdisp ||
draw_tool->draw_state == GIMP_DRAW_TOOL_STATE_INVISIBLE)
{ {
gimp_display_shell_install_tool_cursor (shell, gimp_display_shell_install_tool_cursor (shell,
GIMP_MOUSE_CURSOR, GIMP_MOUSE_CURSOR,

View file

@ -498,18 +498,24 @@ gimp_blend_tool_draw (GimpDrawTool *draw_tool)
blend_tool = GIMP_BLEND_TOOL (draw_tool); blend_tool = GIMP_BLEND_TOOL (draw_tool);
/* Draw start target */ /* Draw start target */
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
floor (blend_tool->startx) + 0.5, GIMP_HANDLE_CROSS,
floor (blend_tool->starty) + 0.5, floor (blend_tool->startx) + 0.5,
TARGET_SIZE, floor (blend_tool->starty) + 0.5,
TRUE); TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw end target */ /* Draw end target */
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
floor (blend_tool->endx) + 0.5, GIMP_HANDLE_CROSS,
floor (blend_tool->endy) + 0.5, floor (blend_tool->endx) + 0.5,
TARGET_SIZE, floor (blend_tool->endy) + 0.5,
TRUE); TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw the line between the start and end coords */ /* Draw the line between the start and end coords */
gimp_draw_tool_draw_line (draw_tool, gimp_draw_tool_draw_line (draw_tool,

View file

@ -788,18 +788,24 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
paint_tool = GIMP_PAINT_TOOL (draw_tool); paint_tool = GIMP_PAINT_TOOL (draw_tool);
/* Draw start target */ /* Draw start target */
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
floor (paint_tool->last_coords.x) + 0.5, GIMP_HANDLE_CROSS,
floor (paint_tool->last_coords.y) + 0.5, floor (paint_tool->last_coords.x) + 0.5,
TARGET_SIZE, floor (paint_tool->last_coords.y) + 0.5,
TRUE); TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw end target */ /* Draw end target */
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
floor (paint_tool->cur_coords.x) + 0.5, GIMP_HANDLE_CROSS,
floor (paint_tool->cur_coords.y) + 0.5, floor (paint_tool->cur_coords.x) + 0.5,
TARGET_SIZE, floor (paint_tool->cur_coords.y) + 0.5,
TRUE); TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw the line between the start and end coords */ /* Draw the line between the start and end coords */
gimp_draw_tool_draw_line (draw_tool, gimp_draw_tool_draw_line (draw_tool,

View file

@ -314,9 +314,11 @@ gimp_crop_tool_button_press (GimpTool *tool,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
GimpCropTool *crop; GimpCropTool *crop;
GimpDrawTool *draw_tool;
GimpDisplayShell *shell; GimpDisplayShell *shell;
crop = GIMP_CROP_TOOL (tool); crop = GIMP_CROP_TOOL (tool);
draw_tool = GIMP_DRAW_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell); shell = GIMP_DISPLAY_SHELL (gdisp->shell);
@ -329,27 +331,43 @@ gimp_crop_tool_button_press (GimpTool *tool,
/* If the cursor is in either the upper left or lower right boxes, /* If the cursor is in either the upper left or lower right boxes,
* The new function will be to resize the current crop area * The new function will be to resize the current crop area
*/ */
if (coords->x == CLAMP (coords->x, crop->x1, crop->x1 + crop->cw) && if (gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->y == CLAMP (coords->y, crop->y1, crop->y1 + crop->ch)) coords->x, coords->y,
GIMP_HANDLE_SQUARE,
crop->x1, crop->y1,
crop->dcw, crop->dch,
GTK_ANCHOR_NORTH_WEST,
FALSE))
{ {
crop->function = RESIZING_LEFT; crop->function = RESIZING_LEFT;
} }
else if (coords->x == CLAMP (coords->x, crop->x2 - crop->cw, crop->x2) && else if (gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->y == CLAMP (coords->y, crop->y2 - crop->ch, crop->y2)) coords->x, coords->y,
GIMP_HANDLE_SQUARE,
crop->x2, crop->y2,
crop->dcw, crop->dch,
GTK_ANCHOR_SOUTH_EAST,
FALSE))
{ {
crop->function = RESIZING_RIGHT; crop->function = RESIZING_RIGHT;
} }
/* If the cursor is in either the upper right or lower left boxes, /* If the cursor is in either the upper right or lower left boxes,
* The new function will be to translate the current crop area * The new function will be to translate the current crop area
*/ */
else if ((coords->x == CLAMP (coords->x, else if (gimp_draw_tool_on_handle (draw_tool, gdisp,
crop->x1, crop->x1 + crop->cw) && coords->x, coords->y,
coords->y == CLAMP (coords->y, GIMP_HANDLE_SQUARE,
crop->y2 - crop->ch, crop->y2)) || crop->x2, crop->y1,
(coords->x == CLAMP (coords->x, crop->dcw, crop->dch,
crop->x2 - crop->cw, crop->x2) && GTK_ANCHOR_NORTH_EAST,
coords->y == CLAMP (coords->y, FALSE) ||
crop->y1, crop->y1 + crop->ch))) gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
crop->x1, crop->y2,
crop->dcw, crop->dch,
GTK_ANCHOR_SOUTH_WEST,
FALSE))
{ {
crop->function = MOVING; crop->function = MOVING;
} }
@ -726,11 +744,13 @@ gimp_crop_tool_cursor_update (GimpTool *tool,
GimpDisplay *gdisp) GimpDisplay *gdisp)
{ {
GimpCropTool *crop; GimpCropTool *crop;
GimpDrawTool *draw_tool;
GimpDisplayShell *shell; GimpDisplayShell *shell;
GdkCursorType ctype = GIMP_MOUSE_CURSOR; GdkCursorType ctype = GIMP_MOUSE_CURSOR;
GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE; GimpCursorModifier cmodifier = GIMP_CURSOR_MODIFIER_NONE;
crop = GIMP_CROP_TOOL (tool); crop = GIMP_CROP_TOOL (tool);
draw_tool = GIMP_DRAW_TOOL (tool);
shell = GIMP_DISPLAY_SHELL (gdisp->shell); shell = GIMP_DISPLAY_SHELL (gdisp->shell);
@ -739,23 +759,37 @@ gimp_crop_tool_cursor_update (GimpTool *tool,
{ {
ctype = GIMP_CROSSHAIR_SMALL_CURSOR; ctype = GIMP_CROSSHAIR_SMALL_CURSOR;
} }
else if (coords->x == CLAMP (coords->x, crop->x1, crop->x1 + crop->cw) && else if (gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->y == CLAMP (coords->y, crop->y1, crop->y1 + crop->ch)) coords->x, coords->y,
GIMP_HANDLE_SQUARE,
crop->x1, crop->y1,
crop->dcw, crop->dch,
GTK_ANCHOR_NORTH_WEST,
FALSE) ||
gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
crop->x2, crop->y2,
crop->dcw, crop->dch,
GTK_ANCHOR_SOUTH_EAST,
FALSE))
{ {
cmodifier = GIMP_CURSOR_MODIFIER_RESIZE; cmodifier = GIMP_CURSOR_MODIFIER_RESIZE;
} }
else if (coords->x == CLAMP (coords->x, crop->x2 - crop->cw, crop->x2) && else if (gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->y == CLAMP (coords->y, crop->y2 - crop->ch, crop->y2)) coords->x, coords->y,
{ GIMP_HANDLE_SQUARE,
cmodifier = GIMP_CURSOR_MODIFIER_RESIZE; crop->x2, crop->y1,
} crop->dcw, crop->dch,
else if (coords->x == CLAMP (coords->x, crop->x1, crop->x1 + crop->cw) && GTK_ANCHOR_NORTH_EAST,
coords->y == CLAMP (coords->y, crop->y2 - crop->ch, crop->y2)) FALSE) ||
{ gimp_draw_tool_on_handle (draw_tool, gdisp,
cmodifier = GIMP_CURSOR_MODIFIER_MOVE; coords->x, coords->y,
} GIMP_HANDLE_SQUARE,
else if (coords->x == CLAMP (coords->x, crop->x2 - crop->cw, crop->x2) && crop->x1, crop->y2,
coords->y == CLAMP (coords->y, crop->y1, crop->y1 + crop->ch)) crop->dcw, crop->dch,
GTK_ANCHOR_SOUTH_WEST,
FALSE))
{ {
cmodifier = GIMP_CURSOR_MODIFIER_MOVE; cmodifier = GIMP_CURSOR_MODIFIER_MOVE;
} }
@ -798,18 +832,30 @@ gimp_crop_tool_draw (GimpDrawTool *draw)
crop->dx2, crop->dy2, crop->dx2, crop->dy2,
crop->dx2, 0); crop->dx2, 0);
gdk_draw_rectangle (draw->win, draw->gc, TRUE, gimp_draw_tool_draw_handle (draw,
crop->dx1, crop->dy1, GIMP_HANDLE_FILLED_SQUARE,
crop->dcw, crop->dch); crop->x1, crop->y1,
gdk_draw_rectangle (draw->win, draw->gc, TRUE, crop->dcw, crop->dch,
crop->dx2 - crop->dcw, crop->dy2-crop->dch, GTK_ANCHOR_NORTH_WEST,
crop->dcw, crop->dch); FALSE);
gdk_draw_rectangle (draw->win, draw->gc, TRUE, gimp_draw_tool_draw_handle (draw,
crop->dx2 - crop->dcw, crop->dy1, GIMP_HANDLE_FILLED_SQUARE,
crop->dcw, crop->dch); crop->x2, crop->y1,
gdk_draw_rectangle (draw->win, draw->gc, TRUE, crop->dcw, crop->dch,
crop->dx1, crop->dy2-crop->dch, GTK_ANCHOR_NORTH_EAST,
crop->dcw, crop->dch); FALSE);
gimp_draw_tool_draw_handle (draw,
GIMP_HANDLE_FILLED_SQUARE,
crop->x1, crop->y2,
crop->dcw, crop->dch,
GTK_ANCHOR_SOUTH_WEST,
FALSE);
gimp_draw_tool_draw_handle (draw,
GIMP_HANDLE_FILLED_SQUARE,
crop->x2, crop->y2,
crop->dcw, crop->dch,
GTK_ANCHOR_SOUTH_EAST,
FALSE);
crop_info_update (tool); crop_info_update (tool);
} }
@ -851,9 +897,6 @@ crop_recalc (GimpTool *tool,
crop->dcw = ((crop->dx2 - crop->dx1) < SRW) ? (crop->dx2 - crop->dx1) : SRW; crop->dcw = ((crop->dx2 - crop->dx1) < SRW) ? (crop->dx2 - crop->dx1) : SRW;
crop->dch = ((crop->dy2 - crop->dy1) < SRH) ? (crop->dy2 - crop->dy1) : SRH; crop->dch = ((crop->dy2 - crop->dy1) < SRH) ? (crop->dy2 - crop->dy1) : SRH;
crop->cw = UNSCALEX (tool->gdisp, crop->dcw);
crop->ch = UNSCALEY (tool->gdisp, crop->dch);
#undef SRW #undef SRW
#undef SRH #undef SRH
} }

View file

@ -54,13 +54,10 @@ struct _GimpCropTool
gint x1, y1; /* upper left hand coordinate */ gint x1, y1; /* upper left hand coordinate */
gint x2, y2; /* lower right hand coords */ gint x2, y2; /* lower right hand coords */
gint cw, ch; /* corners in image coords */
guint function; /* moving or resizing */ guint function; /* moving or resizing */
gint dx1, dy1; /* display coords */ gint dx1, dy1; /* display coords */
gint dx2, dy2; /* */ gint dx2, dy2; /* */
gint dcw, dch; /* width and height of corners */ gint dcw, dch; /* width and height of corners */

View file

@ -36,14 +36,31 @@ enum
LAST_SIGNAL LAST_SIGNAL
}; };
static void gimp_draw_tool_class_init (GimpDrawToolClass *klass); static void gimp_draw_tool_class_init (GimpDrawToolClass *klass);
static void gimp_draw_tool_init (GimpDrawTool *draw_tool); static void gimp_draw_tool_init (GimpDrawTool *draw_tool);
static void gimp_draw_tool_finalize (GObject *object); static void gimp_draw_tool_finalize (GObject *object);
static void gimp_draw_tool_control (GimpTool *tool, static void gimp_draw_tool_control (GimpTool *tool,
ToolAction action, ToolAction action,
GimpDisplay *gdisp); GimpDisplay *gdisp);
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);
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);
static guint gimp_draw_tool_signals[LAST_SIGNAL] = { 0 }; static guint gimp_draw_tool_signals[LAST_SIGNAL] = { 0 };
@ -108,7 +125,7 @@ gimp_draw_tool_class_init (GimpDrawToolClass *klass)
static void static void
gimp_draw_tool_init (GimpDrawTool *draw_tool) gimp_draw_tool_init (GimpDrawTool *draw_tool)
{ {
draw_tool->draw_state = INVISIBLE; draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_INVISIBLE;
draw_tool->win = NULL; draw_tool->win = NULL;
draw_tool->gc = NULL; draw_tool->gc = NULL;
draw_tool->paused_count = 0; draw_tool->paused_count = 0;
@ -173,7 +190,7 @@ gimp_draw_tool_start (GimpDrawTool *draw_tool,
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
g_return_if_fail (GDK_IS_WINDOW (win)); g_return_if_fail (GDK_IS_WINDOW (win));
if (draw_tool->draw_state != INVISIBLE) if (draw_tool->draw_state != GIMP_DRAW_TOOL_STATE_INVISIBLE)
gimp_draw_tool_stop (draw_tool); /* this seems backwards ;) */ gimp_draw_tool_stop (draw_tool); /* this seems backwards ;) */
draw_tool->win = win; draw_tool->win = win;
@ -196,7 +213,7 @@ gimp_draw_tool_start (GimpDrawTool *draw_tool,
g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0); g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0);
draw_tool->draw_state = VISIBLE; draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_VISIBLE;
} }
void void
@ -204,12 +221,12 @@ gimp_draw_tool_stop (GimpDrawTool *draw_tool)
{ {
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
if (draw_tool->draw_state == INVISIBLE) if (draw_tool->draw_state == GIMP_DRAW_TOOL_STATE_INVISIBLE)
return; return;
g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0); g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0);
draw_tool->draw_state = INVISIBLE; draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_INVISIBLE;
} }
void void
@ -217,7 +234,7 @@ gimp_draw_tool_pause (GimpDrawTool *draw_tool)
{ {
if (draw_tool->paused_count == 0) if (draw_tool->paused_count == 0)
{ {
draw_tool->draw_state = INVISIBLE; draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_INVISIBLE;
g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0); g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0);
} }
@ -235,7 +252,7 @@ gimp_draw_tool_resume (GimpDrawTool *draw_tool)
if (draw_tool->paused_count == 0) if (draw_tool->paused_count == 0)
{ {
draw_tool->draw_state = VISIBLE; draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_VISIBLE;
g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0); g_signal_emit (G_OBJECT (draw_tool), gimp_draw_tool_signals[DRAW], 0);
} }
@ -249,15 +266,12 @@ gimp_draw_tool_calc_distance (GimpDrawTool *draw_tool,
gdouble x2, gdouble x2,
gdouble y2) gdouble y2)
{ {
GimpTool *tool; gdouble tx1, ty1;
gdouble tx1, ty1; gdouble tx2, ty2;
gdouble tx2, ty2;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), 0.0); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), 0.0);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), 0.0); g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), 0.0);
tool = GIMP_TOOL (draw_tool);
gdisplay_transform_coords_f (gdisp, x1, y1, &tx1, &ty1, FALSE); gdisplay_transform_coords_f (gdisp, x1, y1, &tx1, &ty1, FALSE);
gdisplay_transform_coords_f (gdisp, x2, y2, &tx2, &ty2, FALSE); gdisplay_transform_coords_f (gdisp, x2, y2, &tx2, &ty2, FALSE);
@ -273,15 +287,12 @@ gimp_draw_tool_in_radius (GimpDrawTool *draw_tool,
gdouble y2, gdouble y2,
gint radius) gint radius)
{ {
GimpTool *tool; gdouble tx1, ty1;
gdouble tx1, ty1; gdouble tx2, ty2;
gdouble tx2, ty2;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), FALSE); g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), FALSE);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), FALSE); g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), FALSE);
tool = GIMP_TOOL (draw_tool);
gdisplay_transform_coords_f (gdisp, x1, y1, &tx1, &ty1, FALSE); gdisplay_transform_coords_f (gdisp, x1, y1, &tx1, &ty1, FALSE);
gdisplay_transform_coords_f (gdisp, x2, y2, &tx2, &ty2, FALSE); gdisplay_transform_coords_f (gdisp, x2, y2, &tx2, &ty2, FALSE);
@ -390,13 +401,14 @@ gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
} }
void void
gimp_draw_tool_draw_rectangle_by_center (GimpDrawTool *draw_tool, gimp_draw_tool_draw_rectangle_by_anchor (GimpDrawTool *draw_tool,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
gdouble y, gdouble y,
gint width, gint width,
gint height, gint height,
gboolean use_offsets) GtkAnchorType anchor,
gboolean use_offsets)
{ {
GimpTool *tool; GimpTool *tool;
GimpDisplayShell *shell; GimpDisplayShell *shell;
@ -410,22 +422,35 @@ gimp_draw_tool_draw_rectangle_by_center (GimpDrawTool *draw_tool,
gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets); gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets);
gimp_draw_tool_shift_to_north_west (tx, ty,
width, height,
anchor,
&tx, &ty);
if (filled)
{
width++;
height++;
}
gdk_draw_rectangle (draw_tool->win, gdk_draw_rectangle (draw_tool->win,
draw_tool->gc, draw_tool->gc,
filled, filled,
RINT (tx) - (width >> 1), RINT (ty) - (height >> 1), RINT (tx), RINT (ty),
width, height); width, height);
} }
void void
gimp_draw_tool_draw_arc_by_center (GimpDrawTool *draw_tool, gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
gdouble y, gdouble y,
gint radius, gint radius_x,
gint angle1, gint radius_y,
gint angle2, gint angle1,
gboolean use_offsets) gint angle2,
GtkAnchorType anchor,
gboolean use_offsets)
{ {
GimpTool *tool; GimpTool *tool;
GimpDisplayShell *shell; GimpDisplayShell *shell;
@ -439,20 +464,37 @@ gimp_draw_tool_draw_arc_by_center (GimpDrawTool *draw_tool,
gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets); gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets);
/* well... */
radius_x *= 2;
radius_y *= 2;
gimp_draw_tool_shift_to_north_west (tx, ty,
radius_x, radius_y,
anchor,
&tx, &ty);
if (filled)
{
radius_x += 1;
radius_y += 1;
}
gdk_draw_arc (draw_tool->win, gdk_draw_arc (draw_tool->win,
draw_tool->gc, draw_tool->gc,
filled, filled,
RINT (tx) - radius, RINT (ty) - radius, RINT (tx), RINT (ty),
2 * radius, 2 * radius, radius_x, radius_y,
angle1, angle2); angle1, angle2);
} }
void void
gimp_draw_tool_draw_cross (GimpDrawTool *draw_tool, gimp_draw_tool_draw_cross_by_anchor (GimpDrawTool *draw_tool,
gdouble x, gdouble x,
gdouble y, gdouble y,
gint size, gint width,
gboolean use_offsets) gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{ {
GimpTool *tool; GimpTool *tool;
GimpDisplayShell *shell; GimpDisplayShell *shell;
@ -466,23 +508,29 @@ gimp_draw_tool_draw_cross (GimpDrawTool *draw_tool,
gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets); gdisplay_transform_coords_f (tool->gdisp, x, y, &tx, &ty, use_offsets);
gimp_draw_tool_shift_to_center (tx, ty,
width, height,
anchor,
&tx, &ty);
gdk_draw_line (draw_tool->win, gdk_draw_line (draw_tool->win,
draw_tool->gc, draw_tool->gc,
RINT (tx) - (size >> 1), RINT (ty), RINT (tx), RINT (ty) - (height >> 1),
RINT (tx) + (size >> 1), RINT (ty)); RINT (tx), RINT (ty) + (height >> 1));
gdk_draw_line (draw_tool->win, gdk_draw_line (draw_tool->win,
draw_tool->gc, draw_tool->gc,
RINT (tx), RINT (ty) - (size >> 1), RINT (tx) - (width >> 1), RINT (ty),
RINT (tx), RINT (ty) + (size >> 1)); RINT (tx) + (width >> 1), RINT (ty));
} }
void void
gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool, gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
GimpHandleType type, GimpHandleType type,
gboolean filled,
gdouble x, gdouble x,
gdouble y, gdouble y,
gint size, gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets) gboolean use_offsets)
{ {
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool)); g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
@ -490,29 +538,120 @@ gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
switch (type) switch (type)
{ {
case GIMP_HANDLE_SQUARE: case GIMP_HANDLE_SQUARE:
gimp_draw_tool_draw_rectangle_by_center (draw_tool, gimp_draw_tool_draw_rectangle_by_anchor (draw_tool,
filled, FALSE,
x, y, x, y,
size, width,
size, height,
anchor,
use_offsets);
break;
case GIMP_HANDLE_FILLED_SQUARE:
gimp_draw_tool_draw_rectangle_by_anchor (draw_tool,
TRUE,
x, y,
width,
height,
anchor,
use_offsets); use_offsets);
break; break;
case GIMP_HANDLE_CIRCLE: case GIMP_HANDLE_CIRCLE:
gimp_draw_tool_draw_arc_by_center (draw_tool, gimp_draw_tool_draw_arc_by_anchor (draw_tool,
filled, FALSE,
x, y, x, y,
size >> 1, width >> 1,
height >> 1,
0, 360 * 64, 0, 360 * 64,
anchor,
use_offsets); use_offsets);
break; break;
case GIMP_HANDLE_FILLED_CIRCLE:
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
TRUE,
x, y,
width >> 1,
height >> 1,
0, 360 * 64,
anchor,
use_offsets);
break;
case GIMP_HANDLE_CROSS:
gimp_draw_tool_draw_cross_by_anchor (draw_tool,
x, y,
width,
height,
anchor,
use_offsets);
break;
default: default:
g_warning ("gimp_draw_tool_draw_handle(): invalid handle type"); g_warning ("%s: invalid handle type %d", G_GNUC_PRETTY_FUNCTION, type);
break; break;
} }
} }
gboolean
gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x,
gdouble y,
GimpHandleType type,
gdouble handle_x,
gdouble handle_y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{
gdouble tx, ty;
gdouble handle_tx, handle_ty;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), 0.0);
g_return_val_if_fail (GIMP_IS_DISPLAY (gdisp), 0.0);
gdisplay_transform_coords_f (gdisp, x, y, &tx, &ty, use_offsets);
gdisplay_transform_coords_f (gdisp,
handle_x, handle_y,
&handle_tx, &handle_ty,
use_offsets);
switch (type)
{
case GIMP_HANDLE_SQUARE:
case GIMP_HANDLE_FILLED_SQUARE:
case GIMP_HANDLE_CROSS:
gimp_draw_tool_shift_to_north_west (handle_tx, handle_ty,
width, height,
anchor,
&handle_tx, &handle_ty);
return (tx == CLAMP (tx, handle_tx, handle_tx + width) &&
ty == CLAMP (ty, handle_ty, handle_ty + height));
case GIMP_HANDLE_CIRCLE:
case GIMP_HANDLE_FILLED_CIRCLE:
gimp_draw_tool_shift_to_center (handle_tx, handle_ty,
width, height,
anchor,
&handle_tx, &handle_ty);
/* FIXME */
if (width != height)
width = (width + height) >> 1;
return ((SQR (handle_tx - tx) + SQR (handle_ty - ty)) < SQR (width));
default:
g_warning ("%s: invalid handle type %d", G_GNUC_PRETTY_FUNCTION, type);
break;
}
return FALSE;
}
void void
gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool, gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
@ -555,3 +694,130 @@ gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
g_free (coords); g_free (coords);
} }
/* private functions */
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)
{
switch (anchor)
{
case GTK_ANCHOR_CENTER:
x -= (handle_width >> 1);
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_NORTH:
x -= (handle_width >> 1);
break;
case GTK_ANCHOR_NORTH_WEST:
/* nothing, this is the default */
break;
case GTK_ANCHOR_NORTH_EAST:
x -= handle_width;
break;
case GTK_ANCHOR_SOUTH:
x -= (handle_width >> 1);
y -= handle_height;
break;
case GTK_ANCHOR_SOUTH_WEST:
y -= handle_height;
break;
case GTK_ANCHOR_SOUTH_EAST:
x -= handle_width;
y -= handle_height;
break;
case GTK_ANCHOR_WEST:
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_EAST:
x -= handle_width;
y -= (handle_height >> 1);
break;
default:
break;
}
if (shifted_x)
*shifted_x = x;
if (shifted_y)
*shifted_y = 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)
{
switch (anchor)
{
case GTK_ANCHOR_CENTER:
/* nothing, this is the default */
break;
case GTK_ANCHOR_NORTH:
y += (handle_height >> 1);
break;
case GTK_ANCHOR_NORTH_WEST:
x += (handle_width >> 1);
y += (handle_height >> 1);
break;
case GTK_ANCHOR_NORTH_EAST:
x -= (handle_width >> 1);
y += (handle_height >> 1);
break;
case GTK_ANCHOR_SOUTH:
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_SOUTH_WEST:
x += (handle_width >> 1);
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_SOUTH_EAST:
x -= (handle_width >> 1);
y -= (handle_height >> 1);
break;
case GTK_ANCHOR_WEST:
x += (handle_width >> 1);
break;
case GTK_ANCHOR_EAST:
x -= (handle_width >> 1);
break;
default:
break;
}
if (shifted_x)
*shifted_x = x;
if (shifted_y)
*shifted_y = y;
}

View file

@ -23,15 +23,19 @@
#include "gimptool.h" #include "gimptool.h"
/* draw states */ typedef enum
#define INVISIBLE 0 {
#define VISIBLE 1 GIMP_DRAW_TOOL_STATE_INVISIBLE,
GIMP_DRAW_TOOL_STATE_VISIBLE
} GimpDrawToolState;
typedef enum typedef enum
{ {
GIMP_HANDLE_SQUARE, GIMP_HANDLE_SQUARE,
GIMP_HANDLE_CIRCLE GIMP_HANDLE_FILLED_SQUARE,
GIMP_HANDLE_CIRCLE,
GIMP_HANDLE_FILLED_CIRCLE,
GIMP_HANDLE_CROSS
} GimpHandleType; } GimpHandleType;
@ -47,19 +51,19 @@ typedef struct _GimpDrawToolClass GimpDrawToolClass;
struct _GimpDrawTool struct _GimpDrawTool
{ {
GimpTool parent_instance; GimpTool parent_instance;
GdkGC *gc; /* Graphics context for draw functions */ GdkGC *gc; /* Graphics context for draw functions */
GdkWindow *win; /* Window to draw draw operation to */ GdkWindow *win; /* Window to draw draw operation to */
gint draw_state; /* Current state in the draw process */ GimpDrawToolState draw_state; /* Current state in the draw process */
gint line_width; /**/ gint line_width; /* line attributes */
gint line_style; /**/ gint line_style; /**/
gint cap_style; /* line attributes */ gint cap_style; /**/
gint join_style; /**/ gint join_style; /**/
gint paused_count; /* count to keep track of multiple pauses */ gint paused_count; /* count to keep track of multiple pauses */
}; };
struct _GimpDrawToolClass struct _GimpDrawToolClass
@ -72,77 +76,93 @@ struct _GimpDrawToolClass
GType gimp_draw_tool_get_type (void); GType gimp_draw_tool_get_type (void);
void gimp_draw_tool_start (GimpDrawTool *draw_tool, void gimp_draw_tool_start (GimpDrawTool *draw_tool,
GdkWindow *window); GdkWindow *window);
void gimp_draw_tool_stop (GimpDrawTool *draw_tool); void gimp_draw_tool_stop (GimpDrawTool *draw_tool);
void gimp_draw_tool_pause (GimpDrawTool *draw_tool); void gimp_draw_tool_pause (GimpDrawTool *draw_tool);
void gimp_draw_tool_resume (GimpDrawTool *draw_tool); void gimp_draw_tool_resume (GimpDrawTool *draw_tool);
gdouble gimp_draw_tool_calc_distance (GimpDrawTool *draw_tool, gdouble gimp_draw_tool_calc_distance (GimpDrawTool *draw_tool,
GimpDisplay *gdisp, GimpDisplay *gdisp,
gdouble x1, gdouble x1,
gdouble y1, gdouble y1,
gdouble x2, gdouble x2,
gdouble y2); gdouble y2);
gboolean gimp_draw_tool_in_radius (GimpDrawTool *draw_tool, gboolean gimp_draw_tool_in_radius (GimpDrawTool *draw_tool,
GimpDisplay *gdisp, GimpDisplay *gdisp,
gdouble x1, gdouble x1,
gdouble y1, gdouble y1,
gdouble x2, gdouble x2,
gdouble y2, gdouble y2,
gint radius); gint radius);
void gimp_draw_tool_draw_line (GimpDrawTool *draw_tool, void gimp_draw_tool_draw_line (GimpDrawTool *draw_tool,
gdouble x1, gdouble x1,
gdouble y1, gdouble y1,
gdouble x2, gdouble x2,
gdouble y2, gdouble y2,
gboolean use_offsets); gboolean use_offsets);
void gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool, void gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
gboolean use_offsets);
void gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
gint angle1,
gint angle2,
gboolean use_offsets);
void gimp_draw_tool_draw_arc_by_center (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint radius,
gint angle1,
gint angle2,
gboolean use_offsets);
void gimp_draw_tool_draw_rectangle_by_center (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint width,
gint height,
gboolean use_offsets);
void gimp_draw_tool_draw_cross (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gint size,
gboolean use_offsets);
void gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
GimpHandleType type,
gboolean filled, gboolean filled,
gdouble x, gdouble x,
gdouble y, gdouble y,
gint size, gdouble width,
gdouble height,
gboolean use_offsets);
void gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
gint angle1,
gint angle2,
gboolean use_offsets);
void gimp_draw_tool_draw_rectangle_by_anchor (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets);
void gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint radius_x,
gint radius_y,
gint angle1,
gint angle2,
GtkAnchorType anchor,
gboolean use_offsets);
void gimp_draw_tool_draw_cross_by_anchor (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets);
void gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
GimpHandleType type,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets);
gboolean gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x,
gdouble y,
GimpHandleType type,
gdouble handle_x,
gdouble handle_y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets); gboolean use_offsets);
void gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool, void gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,

View file

@ -811,11 +811,14 @@ gimp_iscissors_tool_draw (GimpDrawTool *draw_tool)
/* Draw the crosshairs target if we're placing a seed */ /* Draw the crosshairs target if we're placing a seed */
if (iscissors->draw & DRAW_CURRENT_SEED) if (iscissors->draw & DRAW_CURRENT_SEED)
{ {
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
iscissors->x, GIMP_HANDLE_CROSS,
iscissors->y, iscissors->x,
TARGET_WIDTH, iscissors->y,
FALSE); TARGET_WIDTH,
TARGET_WIDTH,
GTK_ANCHOR_CENTER,
FALSE);
/* Draw a line boundary */ /* Draw a line boundary */
if (! iscissors->first_point && ! (iscissors->draw & DRAW_LIVEWIRE)) if (! iscissors->first_point && ! (iscissors->draw & DRAW_LIVEWIRE))
@ -870,13 +873,14 @@ gimp_iscissors_tool_draw (GimpDrawTool *draw_tool)
/* Draw a point at the init point coordinates */ /* Draw a point at the init point coordinates */
if (! iscissors->connected) if (! iscissors->connected)
{ {
gimp_draw_tool_draw_arc_by_center (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
TRUE, GIMP_HANDLE_FILLED_CIRCLE,
iscissors->ix, iscissors->ix,
iscissors->iy, iscissors->iy,
POINT_WIDTH >> 1, POINT_WIDTH,
0, 23040, POINT_WIDTH,
FALSE); GTK_ANCHOR_CENTER,
FALSE);
} }
/* Go through the list of icurves, and render each one... */ /* Go through the list of icurves, and render each one... */
@ -887,13 +891,14 @@ gimp_iscissors_tool_draw (GimpDrawTool *draw_tool)
/* plot the curve */ /* plot the curve */
iscissors_draw_curve (draw_tool, curve); iscissors_draw_curve (draw_tool, curve);
gimp_draw_tool_draw_arc_by_center (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
TRUE, GIMP_HANDLE_FILLED_CIRCLE,
curve->x1, curve->x1,
curve->y1, curve->y1,
POINT_WIDTH >> 1, POINT_WIDTH,
0, 23040, POINT_WIDTH,
FALSE); GTK_ANCHOR_CENTER,
FALSE);
} }
} }
@ -919,13 +924,14 @@ gimp_iscissors_tool_draw (GimpDrawTool *draw_tool)
FALSE); FALSE);
} }
gimp_draw_tool_draw_arc_by_center (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
TRUE, GIMP_HANDLE_FILLED_CIRCLE,
iscissors->nx, iscissors->nx,
iscissors->ny, iscissors->ny,
POINT_WIDTH >> 1, POINT_WIDTH,
0, 23040, POINT_WIDTH,
FALSE); GTK_ANCHOR_CENTER,
FALSE);
} }
} }
@ -1203,22 +1209,28 @@ mouse_over_vertex (GimpIscissorsTool *iscissors,
{ {
curve = (ICurve *) list->data; curve = (ICurve *) list->data;
if (gimp_draw_tool_in_radius (GIMP_DRAW_TOOL (iscissors), if (gimp_draw_tool_on_handle (GIMP_DRAW_TOOL (iscissors),
GIMP_TOOL (iscissors)->gdisp, GIMP_TOOL (iscissors)->gdisp,
curve->x1, curve->y1,
x, y, x, y,
POINT_HALFWIDTH)) GIMP_HANDLE_CIRCLE,
curve->x1, curve->y1,
POINT_WIDTH, POINT_WIDTH,
GTK_ANCHOR_CENTER,
FALSE))
{ {
iscissors->curve1 = curve; iscissors->curve1 = curve;
if (curves_found++) if (curves_found++)
return curves_found; return curves_found;
} }
else if (gimp_draw_tool_in_radius (GIMP_DRAW_TOOL (iscissors), else if (gimp_draw_tool_on_handle (GIMP_DRAW_TOOL (iscissors),
GIMP_TOOL (iscissors)->gdisp, GIMP_TOOL (iscissors)->gdisp,
curve->x2, curve->y2,
x, y, x, y,
POINT_HALFWIDTH)) GIMP_HANDLE_CIRCLE,
curve->x2, curve->y2,
POINT_WIDTH, POINT_WIDTH,
GTK_ANCHOR_CENTER,
FALSE))
{ {
iscissors->curve2 = curve; iscissors->curve2 = curve;

View file

@ -276,12 +276,15 @@ gimp_measure_tool_button_press (GimpTool *tool,
*/ */
for (i = 0; i < measure_tool->num_points; i++) for (i = 0; i < measure_tool->num_points; i++)
{ {
if (gimp_draw_tool_in_radius (GIMP_DRAW_TOOL (tool), gdisp, if (gimp_draw_tool_on_handle (GIMP_DRAW_TOOL (tool), gdisp,
measure_tool->x[i],
measure_tool->y[i],
coords->x, coords->x,
coords->y, coords->y,
TARGET)) GIMP_HANDLE_CIRCLE,
measure_tool->x[i],
measure_tool->y[i],
TARGET, TARGET,
GTK_ANCHOR_CENTER,
FALSE))
{ {
if (state & (GDK_CONTROL_MASK | GDK_MOD1_MASK)) if (state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))
{ {
@ -692,12 +695,15 @@ gimp_measure_tool_cursor_update (GimpTool *tool,
{ {
for (i = 0; i < measure_tool->num_points; i++) for (i = 0; i < measure_tool->num_points; i++)
{ {
if (gimp_draw_tool_in_radius (GIMP_DRAW_TOOL (tool), gdisp, if (gimp_draw_tool_on_handle (GIMP_DRAW_TOOL (tool), gdisp,
measure_tool->x[i],
measure_tool->y[i],
coords->x, coords->x,
coords->y, coords->y,
TARGET)) GIMP_HANDLE_CIRCLE,
measure_tool->x[i],
measure_tool->y[i],
TARGET, TARGET,
GTK_ANCHOR_CENTER,
FALSE))
{ {
in_handle = TRUE; in_handle = TRUE;
@ -754,21 +760,25 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
{ {
if (i == 0 && measure_tool->num_points == 3) if (i == 0 && measure_tool->num_points == 3)
{ {
gimp_draw_tool_draw_arc_by_center (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
FALSE, GIMP_HANDLE_CIRCLE,
measure_tool->x[i], measure_tool->x[i],
measure_tool->y[i], measure_tool->y[i],
TARGET >> 1, TARGET,
0, 23040, TARGET,
FALSE); GTK_ANCHOR_CENTER,
FALSE);
} }
else else
{ {
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
measure_tool->x[i], GIMP_HANDLE_CROSS,
measure_tool->y[i], measure_tool->x[i],
TARGET * 2, measure_tool->y[i],
FALSE); TARGET * 2,
TARGET * 2,
GTK_ANCHOR_CENTER,
FALSE);
} }
if (i > 0) if (i > 0)
@ -804,12 +814,14 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
if (angle2 != 0) if (angle2 != 0)
{ {
gimp_draw_tool_draw_arc_by_center (draw_tool, gimp_draw_tool_draw_arc_by_anchor (draw_tool,
FALSE, FALSE,
measure_tool->x[0], measure_tool->x[0],
measure_tool->y[0], measure_tool->y[0],
ARC_RADIUS, ARC_RADIUS,
ARC_RADIUS,
angle1, angle2, angle1, angle2,
GTK_ANCHOR_CENTER,
FALSE); FALSE);
if (measure_tool->num_points == 2) if (measure_tool->num_points == 2)

View file

@ -788,18 +788,24 @@ gimp_paint_tool_draw (GimpDrawTool *draw_tool)
paint_tool = GIMP_PAINT_TOOL (draw_tool); paint_tool = GIMP_PAINT_TOOL (draw_tool);
/* Draw start target */ /* Draw start target */
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
floor (paint_tool->last_coords.x) + 0.5, GIMP_HANDLE_CROSS,
floor (paint_tool->last_coords.y) + 0.5, floor (paint_tool->last_coords.x) + 0.5,
TARGET_SIZE, floor (paint_tool->last_coords.y) + 0.5,
TRUE); TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw end target */ /* Draw end target */
gimp_draw_tool_draw_cross (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
floor (paint_tool->cur_coords.x) + 0.5, GIMP_HANDLE_CROSS,
floor (paint_tool->cur_coords.y) + 0.5, floor (paint_tool->cur_coords.x) + 0.5,
TARGET_SIZE, floor (paint_tool->cur_coords.y) + 0.5,
TRUE); TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw the line between the start and end coords */ /* Draw the line between the start and end coords */
gimp_draw_tool_draw_line (draw_tool, gimp_draw_tool_draw_line (draw_tool,

View file

@ -881,11 +881,11 @@ gimp_path_tool_draw_helper (NPath *path,
{ {
GimpPathTool *path_tool; GimpPathTool *path_tool;
GimpDrawTool *draw_tool; GimpDrawTool *draw_tool;
gboolean draw = TRUE; gboolean draw = TRUE;
path_tool = GIMP_PATH_TOOL (tool); path_tool = GIMP_PATH_TOOL (tool);
draw_tool = GIMP_DRAW_TOOL (tool); draw_tool = GIMP_DRAW_TOOL (tool);
if (path_tool->draw & PATH_TOOL_REDRAW_ACTIVE) if (path_tool->draw & PATH_TOOL_REDRAW_ACTIVE)
draw = (segment->flags & SEGMENT_ACTIVE || draw = (segment->flags & SEGMENT_ACTIVE ||
(segment->next && segment->next->flags & SEGMENT_ACTIVE)); (segment->next && segment->next->flags & SEGMENT_ACTIVE));
@ -894,25 +894,26 @@ gimp_path_tool_draw_helper (NPath *path,
{ {
gimp_draw_tool_draw_handle (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CIRCLE, GIMP_HANDLE_CIRCLE,
FALSE,
segment->x, segment->y, segment->x, segment->y,
PATH_TOOL_WIDTH, PATH_TOOL_WIDTH,
PATH_TOOL_WIDTH,
GTK_ANCHOR_CENTER,
FALSE); FALSE);
} }
else else
{ {
gimp_draw_tool_draw_handle (draw_tool, gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CIRCLE, GIMP_HANDLE_FILLED_CIRCLE,
TRUE,
segment->x, segment->y, segment->x, segment->y,
PATH_TOOL_WIDTH, PATH_TOOL_WIDTH,
PATH_TOOL_WIDTH,
GTK_ANCHOR_CENTER,
FALSE); FALSE);
} }
if (segment->next) if (segment->next)
path_curve_draw_segment (draw_tool, segment); path_curve_draw_segment (draw_tool, segment);
} }
static void static void
gimp_path_tool_draw (GimpDrawTool *draw_tool) gimp_path_tool_draw (GimpDrawTool *draw_tool)

View file

@ -429,10 +429,13 @@ gimp_transform_tool_button_press (GimpTool *tool,
gt_tool->function = TRANSFORM_HANDLE_4; gt_tool->function = TRANSFORM_HANDLE_4;
} }
if (gimp_draw_tool_in_radius (draw_tool, gdisp, if (gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->x, coords->y, coords->x, coords->y,
GIMP_HANDLE_CIRCLE,
gt_tool->tcx, gt_tool->tcy, gt_tool->tcx, gt_tool->tcy,
HANDLE >> 1)) HANDLE, HANDLE,
GIMP_HANDLE_CIRCLE,
FALSE))
{ {
gt_tool->function = TRANSFORM_HANDLE_CENTER; gt_tool->function = TRANSFORM_HANDLE_CENTER;
} }
@ -859,29 +862,38 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
} }
/* draw the tool handles */ /* draw the tool handles */
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tx1, tr_tool->ty1, GIMP_HANDLE_SQUARE,
HANDLE, HANDLE, tr_tool->tx1, tr_tool->ty1,
FALSE); HANDLE, HANDLE,
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, GTK_ANCHOR_CENTER,
tr_tool->tx2, tr_tool->ty2, FALSE);
HANDLE, HANDLE, gimp_draw_tool_draw_handle (draw_tool,
FALSE); GIMP_HANDLE_SQUARE,
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, tr_tool->tx2, tr_tool->ty2,
tr_tool->tx3, tr_tool->ty3, HANDLE, HANDLE,
HANDLE, HANDLE, GTK_ANCHOR_CENTER,
FALSE); FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tx4, tr_tool->ty4, GIMP_HANDLE_SQUARE,
HANDLE, HANDLE, tr_tool->tx3, tr_tool->ty3,
FALSE); HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx4, tr_tool->ty4,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
/* draw the center */ /* draw the center */
gimp_draw_tool_draw_arc_by_center (draw_tool, TRUE, gimp_draw_tool_draw_handle (draw_tool,
tr_tool->tcx, tr_tool->tcy, GIMP_HANDLE_FILLED_CIRCLE,
HANDLE >> 1, tr_tool->tcx, tr_tool->tcy,
0, 23040, HANDLE, HANDLE,
FALSE); GTK_ANCHOR_CENTER,
FALSE);
if (gimp_transform_tool_showpath ()) if (gimp_transform_tool_showpath ())
{ {