Bill Skaggs <weskaggs@primate.ucdavis.edu>

Trying to implement some usability recommendations from
	Peter Sikking: bigger handles, more feedback to user.

	* app/display/gimpcanvas.[ch]: add
	GIMP_CANVAS_STYLE_XOR_STIPPLED to set of styles.

	* app/tools/gimpdrawtool.[ch]
	(gimp_draw_tool_draw_rectangle_stippled): new function.
	Needs a better stipple pattern, though.

	* app/tools/gimprectangletool.c: bigger handles in corners,
	and highlight thing that user is currently moving.
This commit is contained in:
William Skaggs 2006-09-15 00:01:59 +00:00
parent 769fd8c5a3
commit 3c2c165b9c
6 changed files with 194 additions and 15 deletions

View File

@ -1,3 +1,18 @@
2006-09-14 Bill Skaggs <weskaggs@primate.ucdavis.edu>
Trying to implement some usability recommendations from
Peter Sikking: bigger handles, more feedback to user.
* app/display/gimpcanvas.[ch]: add
GIMP_CANVAS_STYLE_XOR_STIPPLED to set of styles.
* app/tools/gimpdrawtool.[ch]
(gimp_draw_tool_draw_rectangle_stippled): new function.
Needs a better stipple pattern, though.
* app/tools/gimprectangletool.c: bigger handles in corners,
and highlight thing that user is currently moving.
2006-09-14 Bill Skaggs <weskaggs@primate.ucdavis.edu>
* app/widgets/gimprectangletool.c: even if constraining to boundaries,

View File

@ -217,6 +217,12 @@ gimp_canvas_gc_new (GimpCanvas *canvas,
values.graphics_exposures = TRUE;
break;
case GIMP_CANVAS_STYLE_XOR_STIPPLED:
mask |= GDK_GC_FILL | GDK_GC_STIPPLE;
values.fill = GDK_STIPPLED;
values.stipple = canvas->stipple[0];
/* fallthrough */
case GIMP_CANVAS_STYLE_XOR_DOTTED:
case GIMP_CANVAS_STYLE_XOR_DASHED:
mask |= GDK_GC_LINE_STYLE;

View File

@ -31,6 +31,7 @@ typedef enum
GIMP_CANVAS_STYLE_XOR,
GIMP_CANVAS_STYLE_XOR_DASHED,
GIMP_CANVAS_STYLE_XOR_DOTTED,
GIMP_CANVAS_STYLE_XOR_STIPPLED,
GIMP_CANVAS_STYLE_SELECTION_IN,
GIMP_CANVAS_STYLE_SELECTION_OUT,
GIMP_CANVAS_STYLE_LAYER_BOUNDARY,

View File

@ -563,6 +563,63 @@ gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool,
w - 1, h - 1);
}
/**
* gimp_draw_tool_draw_rectangle_stippled:
* @draw_tool: the #GimpDrawTool
* @x: horizontal image coordinate
* @y: vertical image coordinate
* @width: width in image coordinates
* @height: height in image coordinates
* @use_offsets: whether to use the image pixel offsets of the tool's display
*
* This function takes image space coordinates and transforms them to
* screen window coordinates, then draws the resulting rectangle, filling
* it with the default stipple pattern.
**/
void
gimp_draw_tool_draw_rectangle_stippled (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
gboolean use_offsets)
{
GimpDisplayShell *shell;
gint tx1, ty1;
gint tx2, ty2;
guint w, h;
g_return_if_fail (GIMP_IS_DRAW_TOOL (draw_tool));
shell = GIMP_DISPLAY_SHELL (draw_tool->display->shell);
gimp_display_shell_transform_xy (shell,
MIN (x, x + width), MIN (y, y + height),
&tx1, &ty1,
use_offsets);
gimp_display_shell_transform_xy (shell,
MAX (x, x + width), MAX (y, y + height),
&tx2, &ty2,
use_offsets);
tx1 = CLAMP (tx1, -1, shell->disp_width + 1);
ty1 = CLAMP (ty1, -1, shell->disp_height + 1);
tx2 = CLAMP (tx2, -1, shell->disp_width + 1);
ty2 = CLAMP (ty2, -1, shell->disp_height + 1);
tx2 -= tx1;
ty2 -= ty1;
w = MAX (0, tx2);
h = MAX (0, ty2);
if (w > 0 && h > 0)
gimp_canvas_draw_rectangle (GIMP_CANVAS (shell->canvas),
GIMP_CANVAS_STYLE_XOR_STIPPLED,
TRUE,
tx1, ty1,
w - 1, h - 1);
}
void
gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gboolean filled,

View File

@ -116,6 +116,12 @@ void gimp_draw_tool_draw_rectangle (GimpDrawTool *draw_tool,
gdouble width,
gdouble height,
gboolean use_offsets);
void gimp_draw_tool_draw_rectangle_stippled (GimpDrawTool *draw_tool,
gdouble x,
gdouble y,
gdouble width,
gdouble height,
gboolean use_offsets);
void gimp_draw_tool_draw_arc (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,

View File

@ -854,7 +854,9 @@ gimp_rectangle_tool_button_press (GimpTool *tool,
private->lastx = x;
private->lasty = y;
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
gimp_tool_control_activate (tool->control);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
}
void
@ -873,7 +875,9 @@ gimp_rectangle_tool_button_release (GimpTool *tool,
options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (tool);
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
gimp_tool_control_halt (tool->control);
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool);
g_object_get (rectangle, "function", &function, NULL);
@ -1884,7 +1888,7 @@ gimp_rectangle_tool_cursor_update (GimpTool *tool,
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
}
#define ANCHOR_SIZE 6
#define ANCHOR_SIZE 20
void
gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
@ -1892,9 +1896,13 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
GimpRectangleToolPrivate *private;
gint x1, x2, y1, y2;
guint function;
gboolean button1_down;
GimpTool *tool;
g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (draw_tool));
tool = GIMP_TOOL (draw_tool);
private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (draw_tool);
g_object_get (GIMP_RECTANGLE_TOOL (draw_tool), "function", &function, NULL);
@ -1910,18 +1918,104 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
gimp_draw_tool_draw_rectangle (draw_tool, FALSE,
x1, y1, x2 - x1, y2 - y1, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x1, y1, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_NORTH_WEST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x2, y1, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_NORTH_EAST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x1, y2, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_SOUTH_WEST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x2, y2, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_SOUTH_EAST, FALSE);
button1_down = gimp_tool_control_is_active (tool->control);
if (button1_down)
{
GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (tool->display->shell);
gdouble handle_w;
gdouble handle_h;
gint X1, Y1;
gint X2, Y2;
gboolean do_it = TRUE;
handle_w = private->dcw / SCALEFACTOR_X (shell);
handle_h = private->dch / SCALEFACTOR_Y (shell);
switch (private->function)
{
case RECT_RESIZING_LEFT:
X1 = x1;
X2 = x1 + handle_w / 2;
Y1 = y1;
Y2 = y2;
break;
case RECT_RESIZING_RIGHT:
X1 = x2 - handle_w / 2;
X2 = x2;
Y1 = y1;
Y2 = y2;
break;
case RECT_RESIZING_TOP:
X1 = x1 + handle_w;
X2 = x2 - handle_w;
Y1 = y1;
Y2 = y1 + handle_h / 2;
break;
case RECT_RESIZING_BOTTOM:
X1 = x1;
X2 = x2;
Y1 = y2 - handle_h / 2;
Y2 = y2;
break;
case RECT_RESIZING_UPPER_LEFT:
X1 = x1;
X2 = x1 + handle_w;
Y1 = y1;
Y2 = y1 + handle_h;
break;
case RECT_RESIZING_UPPER_RIGHT:
X1 = x2 - handle_w;
X2 = x2;
Y1 = y1;
Y2 = y1 + handle_h;
break;
case RECT_RESIZING_LOWER_LEFT:
X1 = x1;
X2 = x1 + handle_w;
Y1 = y2 - handle_h;
Y2 = y2;
break;
case RECT_RESIZING_LOWER_RIGHT:
X1 = x2 - handle_w;
X2 = x2;
Y1 = y2 - handle_h;
Y2 = y2;
break;
default:
do_it = FALSE;
break;
}
if (do_it)
gimp_draw_tool_draw_rectangle_stippled (draw_tool,
X1, Y1, X2 - X1, Y2 - Y1,
FALSE);
}
else
{
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x1, y1, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_NORTH_WEST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x2, y1, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_NORTH_EAST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x1, y2, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_SOUTH_WEST, FALSE);
gimp_draw_tool_draw_handle (draw_tool, GIMP_HANDLE_FILLED_SQUARE,
x2, y2, ANCHOR_SIZE, ANCHOR_SIZE,
GTK_ANCHOR_SOUTH_EAST, FALSE);
}
gimp_rectangle_tool_draw_guides (draw_tool);
}
@ -2048,8 +2142,8 @@ gimp_rectangle_tool_configure (GimpRectangleTool *rectangle)
&dx2, &dy2,
FALSE);
#define SRW 10
#define SRH 10
#define SRW 20
#define SRH 20
dcw = ((dx2 - dx1) < SRW) ? (dx2 - dx1) : SRW;
dch = ((dy2 - dy1) < SRH) ? (dy2 - dy1) : SRH;