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

View File

@ -429,10 +429,13 @@ gimp_transform_tool_button_press (GimpTool *tool,
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,
GIMP_HANDLE_CIRCLE,
gt_tool->tcx, gt_tool->tcy,
HANDLE >> 1))
HANDLE, HANDLE,
GIMP_HANDLE_CIRCLE,
FALSE))
{
gt_tool->function = TRANSFORM_HANDLE_CENTER;
}
@ -859,29 +862,38 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
}
/* draw the tool handles */
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE,
tr_tool->tx1, tr_tool->ty1,
HANDLE, HANDLE,
FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE,
tr_tool->tx2, tr_tool->ty2,
HANDLE, HANDLE,
FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE,
tr_tool->tx3, tr_tool->ty3,
HANDLE, HANDLE,
FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE,
tr_tool->tx4, tr_tool->ty4,
HANDLE, HANDLE,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx1, tr_tool->ty1,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx2, tr_tool->ty2,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx3, tr_tool->ty3,
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 */
gimp_draw_tool_draw_arc_by_center (draw_tool, TRUE,
tr_tool->tcx, tr_tool->tcy,
HANDLE >> 1,
0, 23040,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_FILLED_CIRCLE,
tr_tool->tcx, tr_tool->tcy,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
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);
/* Draw start target */
gimp_draw_tool_draw_cross (draw_tool,
floor (paint_tool->last_coords.x) + 0.5,
floor (paint_tool->last_coords.y) + 0.5,
TARGET_SIZE,
TRUE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
floor (paint_tool->last_coords.x) + 0.5,
floor (paint_tool->last_coords.y) + 0.5,
TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw end target */
gimp_draw_tool_draw_cross (draw_tool,
floor (paint_tool->cur_coords.x) + 0.5,
floor (paint_tool->cur_coords.y) + 0.5,
TARGET_SIZE,
TRUE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
floor (paint_tool->cur_coords.x) + 0.5,
floor (paint_tool->cur_coords.y) + 0.5,
TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw the line between the start and end coords */
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);
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_MOUSE_CURSOR,

View File

@ -498,18 +498,24 @@ gimp_blend_tool_draw (GimpDrawTool *draw_tool)
blend_tool = GIMP_BLEND_TOOL (draw_tool);
/* Draw start target */
gimp_draw_tool_draw_cross (draw_tool,
floor (blend_tool->startx) + 0.5,
floor (blend_tool->starty) + 0.5,
TARGET_SIZE,
TRUE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
floor (blend_tool->startx) + 0.5,
floor (blend_tool->starty) + 0.5,
TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw end target */
gimp_draw_tool_draw_cross (draw_tool,
floor (blend_tool->endx) + 0.5,
floor (blend_tool->endy) + 0.5,
TARGET_SIZE,
TRUE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
floor (blend_tool->endx) + 0.5,
floor (blend_tool->endy) + 0.5,
TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw the line between the start and end coords */
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);
/* Draw start target */
gimp_draw_tool_draw_cross (draw_tool,
floor (paint_tool->last_coords.x) + 0.5,
floor (paint_tool->last_coords.y) + 0.5,
TARGET_SIZE,
TRUE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
floor (paint_tool->last_coords.x) + 0.5,
floor (paint_tool->last_coords.y) + 0.5,
TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw end target */
gimp_draw_tool_draw_cross (draw_tool,
floor (paint_tool->cur_coords.x) + 0.5,
floor (paint_tool->cur_coords.y) + 0.5,
TARGET_SIZE,
TRUE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
floor (paint_tool->cur_coords.x) + 0.5,
floor (paint_tool->cur_coords.y) + 0.5,
TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw the line between the start and end coords */
gimp_draw_tool_draw_line (draw_tool,

View File

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

View File

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

View File

@ -36,14 +36,31 @@ enum
LAST_SIGNAL
};
static void gimp_draw_tool_class_init (GimpDrawToolClass *klass);
static void gimp_draw_tool_init (GimpDrawTool *draw_tool);
static void gimp_draw_tool_class_init (GimpDrawToolClass *klass);
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,
ToolAction action,
GimpDisplay *gdisp);
static void gimp_draw_tool_control (GimpTool *tool,
ToolAction action,
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 };
@ -108,7 +125,7 @@ gimp_draw_tool_class_init (GimpDrawToolClass *klass)
static void
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->gc = NULL;
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 (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 ;) */
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);
draw_tool->draw_state = VISIBLE;
draw_tool->draw_state = GIMP_DRAW_TOOL_STATE_VISIBLE;
}
void
@ -204,12 +221,12 @@ gimp_draw_tool_stop (GimpDrawTool *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;
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
@ -217,7 +234,7 @@ gimp_draw_tool_pause (GimpDrawTool *draw_tool)
{
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);
}
@ -235,7 +252,7 @@ gimp_draw_tool_resume (GimpDrawTool *draw_tool)
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);
}
@ -249,15 +266,12 @@ gimp_draw_tool_calc_distance (GimpDrawTool *draw_tool,
gdouble x2,
gdouble y2)
{
GimpTool *tool;
gdouble tx1, ty1;
gdouble tx2, ty2;
gdouble tx1, ty1;
gdouble tx2, ty2;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), 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, x2, y2, &tx2, &ty2, FALSE);
@ -273,15 +287,12 @@ gimp_draw_tool_in_radius (GimpDrawTool *draw_tool,
gdouble y2,
gint radius)
{
GimpTool *tool;
gdouble tx1, ty1;
gdouble tx2, ty2;
gdouble tx1, ty1;
gdouble tx2, ty2;
g_return_val_if_fail (GIMP_IS_DRAW_TOOL (draw_tool), 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, x2, y2, &tx2, &ty2, FALSE);
@ -390,13 +401,14 @@ gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
}
void
gimp_draw_tool_draw_rectangle_by_center (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint width,
gint height,
gboolean use_offsets)
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)
{
GimpTool *tool;
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);
gimp_draw_tool_shift_to_north_west (tx, ty,
width, height,
anchor,
&tx, &ty);
if (filled)
{
width++;
height++;
}
gdk_draw_rectangle (draw_tool->win,
draw_tool->gc,
filled,
RINT (tx) - (width >> 1), RINT (ty) - (height >> 1),
RINT (tx), RINT (ty),
width, height);
}
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)
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)
{
GimpTool *tool;
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);
/* 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,
draw_tool->gc,
filled,
RINT (tx) - radius, RINT (ty) - radius,
2 * radius, 2 * radius,
RINT (tx), RINT (ty),
radius_x, radius_y,
angle1, angle2);
}
void
gimp_draw_tool_draw_cross (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gint size,
gboolean use_offsets)
gimp_draw_tool_draw_cross_by_anchor (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{
GimpTool *tool;
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);
gimp_draw_tool_shift_to_center (tx, ty,
width, height,
anchor,
&tx, &ty);
gdk_draw_line (draw_tool->win,
draw_tool->gc,
RINT (tx) - (size >> 1), RINT (ty),
RINT (tx) + (size >> 1), RINT (ty));
RINT (tx), RINT (ty) - (height >> 1),
RINT (tx), RINT (ty) + (height >> 1));
gdk_draw_line (draw_tool->win,
draw_tool->gc,
RINT (tx), RINT (ty) - (size >> 1),
RINT (tx), RINT (ty) + (size >> 1));
RINT (tx) - (width >> 1), RINT (ty),
RINT (tx) + (width >> 1), RINT (ty));
}
void
gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
GimpHandleType type,
gboolean filled,
gdouble x,
gdouble y,
gint size,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
@ -490,29 +538,120 @@ gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
switch (type)
{
case GIMP_HANDLE_SQUARE:
gimp_draw_tool_draw_rectangle_by_center (draw_tool,
filled,
gimp_draw_tool_draw_rectangle_by_anchor (draw_tool,
FALSE,
x, y,
size,
size,
width,
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);
break;
case GIMP_HANDLE_CIRCLE:
gimp_draw_tool_draw_arc_by_center (draw_tool,
filled,
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
FALSE,
x, y,
size >> 1,
width >> 1,
height >> 1,
0, 360 * 64,
anchor,
use_offsets);
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:
g_warning ("gimp_draw_tool_draw_handle(): invalid handle type");
g_warning ("%s: invalid handle type %d", G_GNUC_PRETTY_FUNCTION, type);
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
gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
@ -555,3 +694,130 @@ gimp_draw_tool_draw_lines (GimpDrawTool *draw_tool,
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"
/* draw states */
#define INVISIBLE 0
#define VISIBLE 1
typedef enum
{
GIMP_DRAW_TOOL_STATE_INVISIBLE,
GIMP_DRAW_TOOL_STATE_VISIBLE
} GimpDrawToolState;
typedef enum
{
GIMP_HANDLE_SQUARE,
GIMP_HANDLE_CIRCLE
GIMP_HANDLE_FILLED_SQUARE,
GIMP_HANDLE_CIRCLE,
GIMP_HANDLE_FILLED_CIRCLE,
GIMP_HANDLE_CROSS
} GimpHandleType;
@ -47,19 +51,19 @@ typedef struct _GimpDrawToolClass GimpDrawToolClass;
struct _GimpDrawTool
{
GimpTool parent_instance;
GimpTool parent_instance;
GdkGC *gc; /* Graphics context for draw functions */
GdkWindow *win; /* Window to draw draw operation to */
GdkGC *gc; /* Graphics context for draw functions */
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_style; /**/
gint cap_style; /* line attributes */
gint join_style; /**/
gint line_width; /* line attributes */
gint line_style; /**/
gint cap_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
@ -72,77 +76,93 @@ struct _GimpDrawToolClass
GType gimp_draw_tool_get_type (void);
void gimp_draw_tool_start (GimpDrawTool *draw_tool,
GdkWindow *window);
void gimp_draw_tool_stop (GimpDrawTool *draw_tool);
void gimp_draw_tool_pause (GimpDrawTool *draw_tool);
void gimp_draw_tool_resume (GimpDrawTool *draw_tool);
void gimp_draw_tool_start (GimpDrawTool *draw_tool,
GdkWindow *window);
void gimp_draw_tool_stop (GimpDrawTool *draw_tool);
void gimp_draw_tool_pause (GimpDrawTool *draw_tool);
void gimp_draw_tool_resume (GimpDrawTool *draw_tool);
gdouble gimp_draw_tool_calc_distance (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
gboolean gimp_draw_tool_in_radius (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gint radius);
gdouble gimp_draw_tool_calc_distance (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
gboolean gimp_draw_tool_in_radius (GimpDrawTool *draw_tool,
GimpDisplay *gdisp,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gint radius);
void gimp_draw_tool_draw_line (GimpDrawTool *draw_tool,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gboolean use_offsets);
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,
void gimp_draw_tool_draw_line (GimpDrawTool *draw_tool,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2,
gboolean use_offsets);
void gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
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);
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 */
if (iscissors->draw & DRAW_CURRENT_SEED)
{
gimp_draw_tool_draw_cross (draw_tool,
iscissors->x,
iscissors->y,
TARGET_WIDTH,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
iscissors->x,
iscissors->y,
TARGET_WIDTH,
TARGET_WIDTH,
GTK_ANCHOR_CENTER,
FALSE);
/* Draw a line boundary */
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 */
if (! iscissors->connected)
{
gimp_draw_tool_draw_arc_by_center (draw_tool,
TRUE,
iscissors->ix,
iscissors->iy,
POINT_WIDTH >> 1,
0, 23040,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_FILLED_CIRCLE,
iscissors->ix,
iscissors->iy,
POINT_WIDTH,
POINT_WIDTH,
GTK_ANCHOR_CENTER,
FALSE);
}
/* Go through the list of icurves, and render each one... */
@ -887,13 +891,14 @@ gimp_iscissors_tool_draw (GimpDrawTool *draw_tool)
/* plot the curve */
iscissors_draw_curve (draw_tool, curve);
gimp_draw_tool_draw_arc_by_center (draw_tool,
TRUE,
curve->x1,
curve->y1,
POINT_WIDTH >> 1,
0, 23040,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_FILLED_CIRCLE,
curve->x1,
curve->y1,
POINT_WIDTH,
POINT_WIDTH,
GTK_ANCHOR_CENTER,
FALSE);
}
}
@ -919,13 +924,14 @@ gimp_iscissors_tool_draw (GimpDrawTool *draw_tool)
FALSE);
}
gimp_draw_tool_draw_arc_by_center (draw_tool,
TRUE,
iscissors->nx,
iscissors->ny,
POINT_WIDTH >> 1,
0, 23040,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_FILLED_CIRCLE,
iscissors->nx,
iscissors->ny,
POINT_WIDTH,
POINT_WIDTH,
GTK_ANCHOR_CENTER,
FALSE);
}
}
@ -1203,22 +1209,28 @@ mouse_over_vertex (GimpIscissorsTool *iscissors,
{
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,
curve->x1, curve->y1,
x, y,
POINT_HALFWIDTH))
GIMP_HANDLE_CIRCLE,
curve->x1, curve->y1,
POINT_WIDTH, POINT_WIDTH,
GTK_ANCHOR_CENTER,
FALSE))
{
iscissors->curve1 = curve;
if (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,
curve->x2, curve->y2,
x, y,
POINT_HALFWIDTH))
GIMP_HANDLE_CIRCLE,
curve->x2, curve->y2,
POINT_WIDTH, POINT_WIDTH,
GTK_ANCHOR_CENTER,
FALSE))
{
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++)
{
if (gimp_draw_tool_in_radius (GIMP_DRAW_TOOL (tool), gdisp,
measure_tool->x[i],
measure_tool->y[i],
if (gimp_draw_tool_on_handle (GIMP_DRAW_TOOL (tool), gdisp,
coords->x,
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))
{
@ -692,12 +695,15 @@ gimp_measure_tool_cursor_update (GimpTool *tool,
{
for (i = 0; i < measure_tool->num_points; i++)
{
if (gimp_draw_tool_in_radius (GIMP_DRAW_TOOL (tool), gdisp,
measure_tool->x[i],
measure_tool->y[i],
if (gimp_draw_tool_on_handle (GIMP_DRAW_TOOL (tool), gdisp,
coords->x,
coords->y,
TARGET))
GIMP_HANDLE_CIRCLE,
measure_tool->x[i],
measure_tool->y[i],
TARGET, TARGET,
GTK_ANCHOR_CENTER,
FALSE))
{
in_handle = TRUE;
@ -754,21 +760,25 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
{
if (i == 0 && measure_tool->num_points == 3)
{
gimp_draw_tool_draw_arc_by_center (draw_tool,
FALSE,
measure_tool->x[i],
measure_tool->y[i],
TARGET >> 1,
0, 23040,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CIRCLE,
measure_tool->x[i],
measure_tool->y[i],
TARGET,
TARGET,
GTK_ANCHOR_CENTER,
FALSE);
}
else
{
gimp_draw_tool_draw_cross (draw_tool,
measure_tool->x[i],
measure_tool->y[i],
TARGET * 2,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
measure_tool->x[i],
measure_tool->y[i],
TARGET * 2,
TARGET * 2,
GTK_ANCHOR_CENTER,
FALSE);
}
if (i > 0)
@ -804,12 +814,14 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
if (angle2 != 0)
{
gimp_draw_tool_draw_arc_by_center (draw_tool,
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
FALSE,
measure_tool->x[0],
measure_tool->y[0],
ARC_RADIUS,
ARC_RADIUS,
angle1, angle2,
GTK_ANCHOR_CENTER,
FALSE);
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);
/* Draw start target */
gimp_draw_tool_draw_cross (draw_tool,
floor (paint_tool->last_coords.x) + 0.5,
floor (paint_tool->last_coords.y) + 0.5,
TARGET_SIZE,
TRUE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
floor (paint_tool->last_coords.x) + 0.5,
floor (paint_tool->last_coords.y) + 0.5,
TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw end target */
gimp_draw_tool_draw_cross (draw_tool,
floor (paint_tool->cur_coords.x) + 0.5,
floor (paint_tool->cur_coords.y) + 0.5,
TARGET_SIZE,
TRUE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CROSS,
floor (paint_tool->cur_coords.x) + 0.5,
floor (paint_tool->cur_coords.y) + 0.5,
TARGET_SIZE,
TARGET_SIZE,
GTK_ANCHOR_CENTER,
TRUE);
/* Draw the line between the start and end coords */
gimp_draw_tool_draw_line (draw_tool,

View File

@ -881,11 +881,11 @@ gimp_path_tool_draw_helper (NPath *path,
{
GimpPathTool *path_tool;
GimpDrawTool *draw_tool;
gboolean draw = TRUE;
gboolean draw = TRUE;
path_tool = GIMP_PATH_TOOL (tool);
draw_tool = GIMP_DRAW_TOOL (tool);
if (path_tool->draw & PATH_TOOL_REDRAW_ACTIVE)
draw = (segment->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_HANDLE_CIRCLE,
FALSE,
segment->x, segment->y,
PATH_TOOL_WIDTH,
PATH_TOOL_WIDTH,
GTK_ANCHOR_CENTER,
FALSE);
}
else
{
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_CIRCLE,
TRUE,
GIMP_HANDLE_FILLED_CIRCLE,
segment->x, segment->y,
PATH_TOOL_WIDTH,
PATH_TOOL_WIDTH,
GTK_ANCHOR_CENTER,
FALSE);
}
if (segment->next)
path_curve_draw_segment (draw_tool, segment);
}
static void
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;
}
if (gimp_draw_tool_in_radius (draw_tool, gdisp,
if (gimp_draw_tool_on_handle (draw_tool, gdisp,
coords->x, coords->y,
GIMP_HANDLE_CIRCLE,
gt_tool->tcx, gt_tool->tcy,
HANDLE >> 1))
HANDLE, HANDLE,
GIMP_HANDLE_CIRCLE,
FALSE))
{
gt_tool->function = TRANSFORM_HANDLE_CENTER;
}
@ -859,29 +862,38 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool)
}
/* draw the tool handles */
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE,
tr_tool->tx1, tr_tool->ty1,
HANDLE, HANDLE,
FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE,
tr_tool->tx2, tr_tool->ty2,
HANDLE, HANDLE,
FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE,
tr_tool->tx3, tr_tool->ty3,
HANDLE, HANDLE,
FALSE);
gimp_draw_tool_draw_rectangle_by_center (draw_tool, FALSE,
tr_tool->tx4, tr_tool->ty4,
HANDLE, HANDLE,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx1, tr_tool->ty1,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx2, tr_tool->ty2,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
tr_tool->tx3, tr_tool->ty3,
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 */
gimp_draw_tool_draw_arc_by_center (draw_tool, TRUE,
tr_tool->tcx, tr_tool->tcy,
HANDLE >> 1,
0, 23040,
FALSE);
gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_FILLED_CIRCLE,
tr_tool->tcx, tr_tool->tcy,
HANDLE, HANDLE,
GTK_ANCHOR_CENTER,
FALSE);
if (gimp_transform_tool_showpath ())
{