app/tools/gimpdrawtool.[ch] changed the way that the handles are drawn.

2006-11-05  Sven Neumann  <sven@gimp.org>

	* app/tools/gimpdrawtool.[ch]
	* app/tools/gimprectangletool.c: changed the way that the
handles
	are drawn. This is still work in progress.
This commit is contained in:
Sven Neumann 2006-11-06 08:16:31 +00:00 committed by Sven Neumann
parent 41611db1a4
commit 194f268f89
4 changed files with 137 additions and 111 deletions

View File

@ -1,3 +1,9 @@
2006-11-05 Sven Neumann <sven@gimp.org>
* app/tools/gimpdrawtool.[ch]
* app/tools/gimprectangletool.c: changed the way that the handles
are drawn. This is still work in progress.
2006-11-05 Sven Neumann <sven@gimp.org>
* app/xcf-save.c: formatting.

View File

@ -812,6 +812,71 @@ gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
}
}
void
gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets)
{
GimpDisplayShell *shell;
gint tx, ty;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
g_return_if_fail (width > 2 && height > 2);
shell = GIMP_DISPLAY_SHELL (draw_tool->display->shell);
gimp_display_shell_transform_xy (shell,
x, y,
&tx, &ty,
use_offsets);
switch (anchor)
{
case GTK_ANCHOR_NORTH_WEST:
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
tx + 1, ty + height - 1,
tx + width - 1, ty + height - 1);
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
tx + width - 1, ty + 1,
tx + width - 1, ty + height);
break;
case GTK_ANCHOR_NORTH_EAST:
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
tx - 2, ty + height - 1,
tx - width, ty + height - 1);
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
tx - width, ty + 1,
tx - width, ty + height);
break;
case GTK_ANCHOR_SOUTH_WEST:
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
tx + 1, ty - height,
tx + width - 1, ty - height);
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
tx + width - 1, ty - height,
tx + width - 1, ty - 1);
break;
case GTK_ANCHOR_SOUTH_EAST:
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
tx - 2, ty - height,
tx - width, ty - height);
gimp_canvas_draw_line (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
tx - width, ty - height,
tx - width, ty - 1);
break;
default:
break;
}
}
gboolean
gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
GimpDisplay *display,

View File

@ -160,6 +160,13 @@ void gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
gint height,
GtkAnchorType anchor,
gboolean use_offsets);
void gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gint width,
gint height,
GtkAnchorType anchor,
gboolean use_offsets);
gboolean gimp_draw_tool_on_handle (GimpDrawTool *draw_tool,
GimpDisplay *display,
gdouble x,

View File

@ -54,7 +54,10 @@ enum
};
/* speed of key movement */
#define ARROW_VELOCITY 25
#define ARROW_VELOCITY 25
#define HANDLE_SIZE 50
#define MIN_HANDLE_SIZE 6
#define GIMP_RECTANGLE_TOOL_GET_PRIVATE(obj) \
@ -82,9 +85,6 @@ struct _GimpRectangleToolPrivate
gint lastx; /* previous x coord */
gint lasty; /* previous y coord */
gint dx1, dy1; /* display coords */
gint dx2, dy2; /* */
gint dcw, dch; /* width and height of edges */
gint saved_x1; /* for saving in case action */
@ -1370,7 +1370,8 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
GimpDisplayShell *shell;
gboolean inside_x;
gboolean inside_y;
gdouble handle_w, handle_h;
gdouble handle_w;
gdouble handle_h;
gint function;
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (tool));
@ -1525,8 +1526,6 @@ gimp_rectangle_tool_cursor_update (GimpTool *tool,
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
}
#define ANCHOR_SIZE 14
void
gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
{
@ -1551,118 +1550,81 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
if (gimp_tool_control_is_active (tool->control))
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->display->shell);
gdouble handle_w;
gdouble handle_h;
gint X1 = private->x1;
gint Y1 = private->y1;
gint X2 = private->x2;
gint Y2 = private->y2;
gboolean do_it = TRUE;
handle_w = private->dcw / SCALEFACTOR_X (shell);
handle_h = private->dch / SCALEFACTOR_Y (shell);
gdouble handle_w = private->dcw / SCALEFACTOR_X (shell);
gdouble handle_h = private->dch / SCALEFACTOR_Y (shell);
gdouble x1 = private->x1;
gdouble x2 = private->x2;
gdouble y1 = private->y1;
gdouble y2 = private->y2;
switch (private->function)
{
case RECT_RESIZING_UPPER_LEFT:
gimp_draw_tool_draw_corner (draw_tool,
private->x1, private->y1,
private->dcw, private->dch,
GTK_ANCHOR_NORTH_WEST, FALSE);
break;
case RECT_RESIZING_UPPER_RIGHT:
gimp_draw_tool_draw_corner (draw_tool,
private->x2, private->y1,
private->dcw, private->dch,
GTK_ANCHOR_NORTH_EAST, FALSE);
break;
case RECT_RESIZING_LOWER_LEFT:
gimp_draw_tool_draw_corner (draw_tool,
private->x1, private->y2,
private->dcw, private->dch,
GTK_ANCHOR_SOUTH_WEST, FALSE);
break;
case RECT_RESIZING_LOWER_RIGHT:
gimp_draw_tool_draw_corner (draw_tool,
private->x2, private->y2,
private->dcw, private->dch,
GTK_ANCHOR_SOUTH_EAST, FALSE);
break;
case RECT_RESIZING_LEFT:
X2 = private->x1 + handle_w / 3;
x1 = x2 = private->x1 + handle_w;
gimp_draw_tool_draw_line (draw_tool, x1, y1, x2, y2, FALSE);
break;
case RECT_RESIZING_RIGHT:
X1 = private->x2 - handle_w / 3;
x1 = x2 = private->x2 - handle_w;
gimp_draw_tool_draw_line (draw_tool, x1, y1, x2, y2, FALSE);
break;
case RECT_RESIZING_TOP:
Y2 = private->y1 + handle_h / 3;
y1 = y2 = private->y1 + handle_h;
gimp_draw_tool_draw_line (draw_tool, x1, y1, x2, y2, FALSE);
break;
case RECT_RESIZING_BOTTOM:
Y1 = private->y2 - handle_h / 3;
y1 = y2 = private->y2 - handle_h;
gimp_draw_tool_draw_line (draw_tool, x1, y1, x2, y2, FALSE);
break;
default:
do_it = FALSE;
break;
}
if (do_it)
{
gimp_draw_tool_draw_rectangle (draw_tool, TRUE,
X1, Y1, X2 - X1, Y2 - Y1,
FALSE);
}
else
{
GimpCoords coords[3];
do_it = TRUE;
switch (private->function)
{
case RECT_RESIZING_UPPER_LEFT:
coords[0].x = private->x1;
coords[0].y = private->y1;
coords[1].x = private->x1;
coords[1].y = private->y1 + handle_h;
coords[2].x = private->x1 + handle_w;
coords[2].y = private->y1;
break;
case RECT_RESIZING_UPPER_RIGHT:
coords[0].x = private->x2;
coords[0].y = private->y1;
coords[1].x = private->x2;
coords[1].y = private->y1 + handle_h;
coords[2].x = private->x2 - handle_w;
coords[2].y = private->y1;
break;
case RECT_RESIZING_LOWER_LEFT:
coords[0].x = private->x1;
coords[0].y = private->y2;
coords[1].x = private->x1;
coords[1].y = private->y2 - handle_h;
coords[2].x = private->x1 + handle_w;
coords[2].y = private->y2;
break;
case RECT_RESIZING_LOWER_RIGHT:
coords[0].x = private->x2;
coords[0].y = private->y2;
coords[1].x = private->x2;
coords[1].y = private->y2 - handle_h;
coords[2].x = private->x2 - handle_w;
coords[2].y = private->y2;
break;
default:
do_it = FALSE;
break;
}
if (do_it)
{
gimp_draw_tool_draw_strokes (draw_tool, coords, 3, TRUE, FALSE);
}
}
}
else
{
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
gimp_draw_tool_draw_corner (draw_tool,
private->x1, private->y1,
ANCHOR_SIZE, ANCHOR_SIZE,
private->dcw, private->dch,
GTK_ANCHOR_NORTH_WEST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
gimp_draw_tool_draw_corner (draw_tool,
private->x2, private->y1,
ANCHOR_SIZE, ANCHOR_SIZE,
private->dcw, private->dch,
GTK_ANCHOR_NORTH_EAST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
gimp_draw_tool_draw_corner (draw_tool,
private->x1, private->y2,
ANCHOR_SIZE, ANCHOR_SIZE,
private->dcw, private->dch,
GTK_ANCHOR_SOUTH_WEST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
gimp_draw_tool_draw_corner (draw_tool,
private->x2, private->y2,
ANCHOR_SIZE, ANCHOR_SIZE,
private->dcw, private->dch,
GTK_ANCHOR_SOUTH_EAST, FALSE);
}
@ -1748,10 +1710,9 @@ gimp_rectangle_tool_configure (GimpRectangleTool *rectangle)
GimpRectangleToolPrivate *private;
GimpRectangleOptions *options;
GimpDisplayShell *shell;
gboolean highlight;
gint dx1, dx2;
gint dy1, dy2;
gint dcw, dch;
gboolean highlight;
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (tool);
@ -1784,21 +1745,8 @@ gimp_rectangle_tool_configure (GimpRectangleTool *rectangle)
&dx2, &dy2,
FALSE);
#define SRW 20
#define SRH 20
dcw = ((dx2 - dx1) < SRW) ? (dx2 - dx1) : SRW;
dch = ((dy2 - dy1) < SRH) ? (dy2 - dy1) : SRH;
#undef SRW
#undef SRH
private->dx1 = dx1;
private->dx2 = dx2;
private->dy1 = dy1;
private->dy2 = dy2;
private->dcw = dcw;
private->dch = dch;
private->dcw = CLAMP ((dx2 - dx1) / 3, MIN_HANDLE_SIZE, HANDLE_SIZE);
private->dch = CLAMP ((dy2 - dy1) / 3, MIN_HANDLE_SIZE, HANDLE_SIZE);
}
static void