Commit b41bc680 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

improved highlighting. (gimp_draw_tool_draw_arc_by_anchor): take width and

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

	* app/tools/gimpdrawtool.[ch] (gimp_draw_tool_draw_corner):
	improved highlighting.
	(gimp_draw_tool_draw_arc_by_anchor): take width and height
	arguments instead of radius_x and radius_y.

	* app/tools/gimpiscissorstool.c
	* app/tools/gimpvectortool.c: slightly increased handle sizes.

	* app/tools/gimpmeasuretool.c: increased size of the end points.

	* app/tools/gimpperspectiveclonetool.c: increased handle size.

	* app/tools/gimprectangletool.c: renamed variables.

	* app/tools/gimpsourcetool.c: use a single define for the target
size.

	* app/tools/gimptransformtool.[ch]: increased handle size. Made
	the area that can be grabbed identical to the displayed handle.
	Replaced filled circle with a circle outline and a cross.

	* app/tools/gimptransformtool-undo.c: follow renaming of define
in
	gimptransformtool.h.
parent 4d671542
......@@ -666,8 +666,8 @@ gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint radius_x,
gint radius_y,
gint width,
gint height,
gint angle1,
gint angle2,
GtkAnchorType anchor,
......@@ -685,25 +685,21 @@ gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
&tx, &ty,
use_offsets);
/* well... */
radius_x *= 2;
radius_y *= 2;
gimp_draw_tool_shift_to_north_west (tx, ty,
radius_x, radius_y,
width, height,
anchor,
&tx, &ty);
if (! filled)
{
radius_x -= 1;
radius_y -= 1;
width -= 1;
height -= 1;
}
gimp_canvas_draw_arc (GIMP_CANVAS (shell->canvas), GIMP_CANVAS_STYLE_XOR,
filled,
PROJ_ROUND (tx), PROJ_ROUND (ty),
radius_x, radius_y,
width, height,
angle1, angle2);
}
......@@ -779,8 +775,8 @@ gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
FALSE,
x, y,
width >> 1,
height >> 1,
width,
height,
0, 360 * 64,
anchor,
use_offsets);
......@@ -790,8 +786,8 @@ gimp_draw_tool_draw_handle (GimpDrawTool *draw_tool,
gimp_draw_tool_draw_arc_by_anchor (draw_tool,
TRUE,
x, y,
width >> 1,
height >> 1,
width,
height,
0, 360 * 64,
anchor,
use_offsets);
......@@ -855,6 +851,9 @@ gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
gimp_display_shell_transform_xy (shell, x1, y1, &tx1, &ty1, use_offsets);
gimp_display_shell_transform_xy (shell, x2, y2, &tx2, &ty2, use_offsets);
if (tx2 - tx1 <= width || ty2 - ty1 <= height)
return;
switch (anchor)
{
case GTK_ANCHOR_CENTER:
......@@ -917,37 +916,61 @@ gimp_draw_tool_draw_corner (GimpDrawTool *draw_tool,
break;
}
if (highlight)
if (! highlight)
return;
switch (anchor)
{
switch (anchor)
{
case GTK_ANCHOR_NORTH_WEST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx1 + 1, ty1 + 1,
width - 3, height - 3);
break;
case GTK_ANCHOR_NORTH_EAST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx2 - width + 1, ty1 + 1,
width - 3, height - 3);
break;
case GTK_ANCHOR_SOUTH_WEST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx1 + 1, ty2 - height + 1,
width - 3, height - 3);
break;
case GTK_ANCHOR_SOUTH_EAST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx2 - width + 1, ty2 - height + 1,
width - 3, height - 3);
break;
default:
break;
}
case GTK_ANCHOR_NORTH_WEST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx1 + 1, ty1 + 1,
width - 3, height - 3);
break;
case GTK_ANCHOR_NORTH_EAST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx2 - width + 1, ty1 + 1,
width - 3, height - 3);
break;
case GTK_ANCHOR_SOUTH_WEST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx1 + 1, ty2 - height + 1,
width - 3, height - 3);
break;
case GTK_ANCHOR_SOUTH_EAST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx2 - width + 1, ty2 - height + 1,
width - 3, height - 3);
break;
case GTK_ANCHOR_NORTH:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx1 + 1, ty1 + 1,
tx2 - tx1 - 3, height - 2);
break;
case GTK_ANCHOR_SOUTH:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx1 + 1, ty2 - height + 1,
tx2 - tx1 - 3, height - 3);
break;
case GTK_ANCHOR_WEST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx1 + 1, ty1 + 1,
width - 2, ty2 - ty1 - 3);
break;
case GTK_ANCHOR_EAST:
gimp_canvas_draw_rectangle (canvas, GIMP_CANVAS_STYLE_XOR, FALSE,
tx2 - width + 1, ty1 + 1,
width - 3, ty2 - ty1 - 3);
break;
default:
break;
}
}
......
......@@ -138,8 +138,8 @@ void gimp_draw_tool_draw_arc_by_anchor (GimpDrawTool *draw_tool,
gboolean filled,
gdouble x,
gdouble y,
gint radius_x,
gint radius_y,
gint width,
gint height,
gint angle1,
gint angle2,
GtkAnchorType anchor,
......
......@@ -81,17 +81,16 @@
#include "gimp-intl.h"
/* Other defines... */
/* defines */
#define MAX_GRADIENT 179.606 /* == sqrt (127^2 + 127^2) */
#define GRADIENT_SEARCH 32 /* how far to look when snapping to an edge */
#define TARGET_SIZE 25
#define POINT_WIDTH 9 /* size (in pixels) of seed handles */
#define POINT_HALFWIDTH (POINT_WIDTH / 2)
#define TARGET_SIZE 25
#define POINT_WIDTH 12 /* size (in pixels) of seed handles */
#define EXTEND_BY 0.2 /* proportion to expand cost map by */
#define FIXED 5 /* additional fixed size to expand cost map */
#define MIN_GRADIENT 63 /* gradients < this are directionless */
#define COST_WIDTH 2 /* number of bytes for each pixel in cost map */
#define COST_WIDTH 2 /* number of bytes for each pixel in cost map */
/* weight to give between gradient (_G) and direction (_D) */
#define OMEGA_D 0.2
......@@ -203,7 +202,7 @@ G_DEFINE_TYPE (GimpIscissorsTool, gimp_iscissors_tool,
/* static variables */
/* where to move on a given link direction */
static gint move[8][2] =
static const gint move[8][2] =
{
{ 1, 0 },
{ 0, 1 },
......@@ -1184,7 +1183,7 @@ mouse_over_curve (GimpIscissorsTool *iscissors,
GIMP_TOOL (iscissors)->display,
tx, ty,
x, y,
POINT_HALFWIDTH))
POINT_WIDTH / 2))
{
return list;
}
......@@ -1420,13 +1419,15 @@ calculate_link (TileManager *gradient_map,
/* calculate the contribution of the gradient direction */
x += (gint8)(pixel & 0xff);
y += (gint8)((pixel & 0xff00) >> 8);
if (!gradient_map_value (gradient_map, x, y, &grad2, &dir2))
{
grad2 = 0;
dir2 = 255;
}
value += (direction_value[dir1][link] + direction_value[dir2][link]) *
OMEGA_D;
value +=
(direction_value[dir1][link] + direction_value[dir2][link]) * OMEGA_D;
return value;
}
......@@ -1459,7 +1460,7 @@ plot_pixels (GimpIscissorsTool *iscissors,
list = g_ptr_array_new ();
while (1)
while (TRUE)
{
coords = (y << 16) + x;
g_ptr_array_add (list, GINT_TO_POINTER (coords));
......
......@@ -52,9 +52,8 @@
#include "gimp-intl.h"
/* definitions */
#define TARGET 8
#define ARC_RADIUS 30
#define TARGET 12
#define ARC_RADIUS 30
/* local function prototypes */
......@@ -210,7 +209,7 @@ gimp_measure_tool_button_press (GimpTool *tool,
GIMP_HANDLE_CIRCLE,
measure->x[i],
measure->y[i],
TARGET, TARGET,
TARGET * 2, TARGET * 2,
GTK_ANCHOR_CENTER,
FALSE))
{
......@@ -537,7 +536,7 @@ gimp_measure_tool_cursor_update (GimpTool *tool,
GIMP_HANDLE_CIRCLE,
measure->x[i],
measure->y[i],
TARGET, TARGET,
TARGET * 2, TARGET * 2,
GTK_ANCHOR_CENTER,
FALSE))
{
......@@ -651,8 +650,8 @@ gimp_measure_tool_draw (GimpDrawTool *draw_tool)
FALSE,
measure->x[0],
measure->y[0],
ARC_RADIUS,
ARC_RADIUS,
ARC_RADIUS * 2,
ARC_RADIUS * 2,
angle1, angle2,
GTK_ANCHOR_CENTER,
FALSE);
......
......@@ -45,10 +45,9 @@
#include "gimp-intl.h"
#define HANDLE_SIZE 10
#define HANDLE_SIZE 25
#define TARGET_WIDTH 15
#define TARGET_HEIGHT 15
#define TARGET_SIZE 15
static GObject * gimp_perspective_clone_tool_constructor (GType type,
......@@ -157,7 +156,7 @@ gimp_perspective_clone_tool_init (GimpPerspectiveCloneTool *perspective_clone_to
gimp_tool_control_set_action_object_2 (tool->control,
"context/context-pattern-select-set");
for (i = 0; i < TRAN_INFO_SIZE; i++)
for (i = 0; i < TRANS_INFO_SIZE; i++)
{
perspective_clone_tool->trans_info[i] = 0.0;
perspective_clone_tool->old_trans_info[i] = 0.0;
......@@ -235,7 +234,7 @@ gimp_perspective_clone_tool_initialize (GimpTool *tool,
perspective_clone_tool->function = TRANSFORM_CREATING;
/* Save the current transformation info */
for (i = 0; i < TRAN_INFO_SIZE; i++)
for (i = 0; i < TRANS_INFO_SIZE; i++)
perspective_clone_tool->old_trans_info[i] =
perspective_clone_tool->trans_info[i];
}
......@@ -746,7 +745,7 @@ gimp_perspective_clone_tool_draw (GimpDrawTool *draw_tool)
GIMP_HANDLE_CROSS,
clone_tool->src_x,
clone_tool->src_y,
TARGET_WIDTH, TARGET_WIDTH,
TARGET_SIZE, TARGET_SIZE,
GTK_ANCHOR_CENTER,
FALSE);
......
......@@ -85,7 +85,8 @@ struct _GimpRectangleToolPrivate
gint lastx; /* previous x coord */
gint lasty; /* previous y coord */
gint dcw, dch; /* width and height of edges */
gint handle_w; /* handle width */
gint handle_h; /* handle height */
gint saved_x1; /* for saving in case action */
gint saved_y1; /* is canceled */
......@@ -1388,19 +1389,19 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
return;
}
shell = GIMP_DISPLAY_SHELL (tool->display->shell);
handle_w = private->dcw / SCALEFACTOR_X (shell);
handle_h = private->dch / SCALEFACTOR_Y (shell);
inside_x = coords->x > private->x1 && coords->x < private->x2;
inside_y = coords->y > private->y1 && coords->y < private->y2;
shell = GIMP_DISPLAY_SHELL (tool->display->shell);
handle_w = private->handle_w / SCALEFACTOR_X (shell);
handle_h = private->handle_h / SCALEFACTOR_Y (shell);
if (gimp_draw_tool_on_handle (draw_tool, display,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
private->x1, private->y1,
private->dcw, private->dch,
private->handle_w, private->handle_h,
GTK_ANCHOR_NORTH_WEST,
FALSE))
{
......@@ -1410,7 +1411,7 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
private->x2, private->y2,
private->dcw, private->dch,
private->handle_w, private->handle_h,
GTK_ANCHOR_SOUTH_EAST,
FALSE))
{
......@@ -1420,7 +1421,7 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
private->x2, private->y1,
private->dcw, private->dch,
private->handle_w, private->handle_h,
GTK_ANCHOR_NORTH_EAST,
FALSE))
{
......@@ -1430,25 +1431,25 @@ gimp_rectangle_tool_oper_update (GimpTool *tool,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
private->x1, private->y2,
private->dcw, private->dch,
private->handle_w, private->handle_h,
GTK_ANCHOR_SOUTH_WEST,
FALSE))
{
function = RECT_RESIZING_LOWER_LEFT;
}
else if ((fabs (coords->x - private->x1) < handle_w) && inside_x)
else if ((fabs (coords->x - private->x1) < handle_w) && inside_x && inside_y)
{
function = RECT_RESIZING_LEFT;
}
else if ((fabs (coords->x - private->x2) < handle_w) && inside_x)
else if ((fabs (coords->x - private->x2) < handle_w) && inside_x && inside_y)
{
function = RECT_RESIZING_RIGHT;
}
else if ((fabs (coords->y - private->y1) < handle_h) && inside_y)
else if ((fabs (coords->y - private->y1) < handle_h) && inside_x && inside_y)
{
function = RECT_RESIZING_TOP;
}
else if ((fabs (coords->y - private->y2) < handle_h) && inside_y)
else if ((fabs (coords->y - private->y2) < handle_h) && inside_x && inside_y)
{
function = RECT_RESIZING_BOTTOM;
}
......@@ -1561,22 +1562,22 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
gimp_draw_tool_draw_corner (draw_tool, FALSE,
private->x1, private->y1,
private->x2, private->y2,
private->dcw, private->dch,
private->handle_w, private->handle_h,
GTK_ANCHOR_NORTH_WEST, FALSE);
gimp_draw_tool_draw_corner (draw_tool, FALSE,
private->x1, private->y1,
private->x2, private->y2,
private->dcw, private->dch,
private->handle_w, private->handle_h,
GTK_ANCHOR_NORTH_EAST, FALSE);
gimp_draw_tool_draw_corner (draw_tool, FALSE,
private->x1, private->y1,
private->x2, private->y2,
private->dcw, private->dch,
private->handle_w, private->handle_h,
GTK_ANCHOR_SOUTH_WEST, FALSE);
gimp_draw_tool_draw_corner (draw_tool, FALSE,
private->x1, private->y1,
private->x2, private->y2,
private->dcw, private->dch,
private->handle_w, private->handle_h,
GTK_ANCHOR_SOUTH_EAST, FALSE);
break;
......@@ -1585,7 +1586,7 @@ gimp_rectangle_tool_draw (GimpDrawTool *draw_tool)
! gimp_tool_control_is_active (tool->control),
private->x1, private->y1,
private->x2, private->y2,
private->dcw, private->dch,
private->handle_w, private->handle_h,
gimp_rectangle_tool_get_anchor (private),
FALSE);
break;
......@@ -1708,8 +1709,11 @@ gimp_rectangle_tool_configure (GimpRectangleTool *rectangle)
&dx2, &dy2,
FALSE);
private->dcw = CLAMP ((dx2 - dx1) / 3, MIN_HANDLE_SIZE, HANDLE_SIZE);
private->dch = CLAMP ((dy2 - dy1) / 3, MIN_HANDLE_SIZE, HANDLE_SIZE);
private->handle_w = (dx2 - dx1) / 3;
private->handle_h = (dy2 - dy1) / 3;
private->handle_w = CLAMP (private->handle_w, MIN_HANDLE_SIZE, HANDLE_SIZE);
private->handle_h = CLAMP (private->handle_h, MIN_HANDLE_SIZE, HANDLE_SIZE);
}
static void
......
......@@ -39,8 +39,7 @@
#include "gimp-intl.h"
#define TARGET_WIDTH 15
#define TARGET_HEIGHT 15
#define TARGET_SIZE 15
static gboolean gimp_source_tool_has_display (GimpTool *tool,
......@@ -373,7 +372,7 @@ gimp_source_tool_draw (GimpDrawTool *draw_tool)
GIMP_HANDLE_CROSS,
source_tool->src_x + off_x,
source_tool->src_y + off_y,
TARGET_WIDTH, TARGET_WIDTH,
TARGET_SIZE, TARGET_SIZE,
GTK_ANCHOR_CENTER,
FALSE);
......
......@@ -82,7 +82,7 @@ gimp_transform_tool_push_undo (GimpImage *image,
tu->tool_ID = tool_ID;
tu->tool_type = tool_type;
for (i = 0; i < TRAN_INFO_SIZE; i++)
for (i = 0; i < TRANS_INFO_SIZE; i++)
tu->trans_info[i] = trans_info[i];
if (original)
......@@ -116,7 +116,7 @@ undo_pop_transform (GimpUndo *undo,
gint i;
/* swap the transformation information arrays */
for (i = 0; i < TRAN_INFO_SIZE; i++)
for (i = 0; i < TRANS_INFO_SIZE; i++)
{
d = tu->trans_info[i];
tu->trans_info[i] = tt->trans_info[i];
......
......@@ -66,7 +66,8 @@
#include "gimp-intl.h"
#define HANDLE_SIZE 10
#define HANDLE_SIZE 25
#define MIN_HANDLE_SIZE 6
/* local function prototypes */
......@@ -136,6 +137,8 @@ static void gimp_transform_tool_doit (GimpTransformTool *tr_tool,
static void gimp_transform_tool_transform_bounding_box (GimpTransformTool *tr_tool);
static void gimp_transform_tool_grid_recalc (GimpTransformTool *tr_tool);
static void gimp_transform_tool_handles_recalc (GimpTransformTool *tr_tool,
GimpDisplay *display);
static void gimp_transform_tool_force_expose_preview (GimpTransformTool *tr_tool);
static void gimp_transform_tool_response (GtkWidget *widget,
......@@ -203,7 +206,7 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
tr_tool->function = TRANSFORM_CREATING;
tr_tool->original = NULL;
for (i = 0; i < TRAN_INFO_SIZE; i++)
for (i = 0; i < TRANS_INFO_SIZE; i++)
{
tr_tool->trans_info[i] = 0.0;
tr_tool->old_trans_info[i] = 0.0;
......@@ -215,6 +218,10 @@ gimp_transform_tool_init (GimpTransformTool *tr_tool)
tr_tool->use_handles = FALSE;
tr_tool->use_center = FALSE;
tr_tool->use_mid_handles = FALSE;
tr_tool->handle_w = HANDLE_SIZE;
tr_tool->handle_h = HANDLE_SIZE;
tr_tool->ngx = 0;
tr_tool->ngy = 0;
tr_tool->grid_coords = NULL;
......@@ -351,7 +358,7 @@ gimp_transform_tool_initialize (GimpTool *tool,
tr_tool->function = TRANSFORM_CREATING;
/* Save the current transformation info */
for (i = 0; i < TRAN_INFO_SIZE; i++)
for (i = 0; i < TRANS_INFO_SIZE; i++)
tr_tool->old_trans_info[i] = tr_tool->trans_info[i];
}
......@@ -432,7 +439,7 @@ gimp_transform_tool_button_release (GimpTool *tool,
gimp_transform_tool_expose_preview (tr_tool);
/* Restore the previous transformation info */
for (i = 0; i < TRAN_INFO_SIZE; i++)
for (i = 0; i < TRANS_INFO_SIZE; i++)
tr_tool->trans_info[i] = tr_tool->old_trans_info[i];
/* reget the selection bounds */
......@@ -591,11 +598,12 @@ gimp_transform_tool_oper_update (GimpTool *tool,
x = (tr_tool->tx1 + tr_tool->tx2) / 2.0;
y = (tr_tool->ty1 + tr_tool->ty2) / 2.0;
if (gimp_draw_tool_on_handle (draw_tool, display,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
x, y,
2 * HANDLE_SIZE, 2 * HANDLE_SIZE,
tr_tool->handle_w, tr_tool->handle_h,
GTK_ANCHOR_CENTER,
FALSE))
{
......@@ -604,11 +612,12 @@ gimp_transform_tool_oper_update (GimpTool *tool,
x = (tr_tool->tx2 + tr_tool->tx4) / 2.0;
y = (tr_tool->ty2 + tr_tool->ty4) / 2.0;
if (gimp_draw_tool_on_handle (draw_tool, display,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
x, y,
2 * HANDLE_SIZE, 2 * HANDLE_SIZE,
tr_tool->handle_w, tr_tool->handle_h,
GTK_ANCHOR_CENTER,
FALSE))
{
......@@ -617,11 +626,12 @@ gimp_transform_tool_oper_update (GimpTool *tool,
x = (tr_tool->tx3 + tr_tool->tx4) / 2.0;
y = (tr_tool->ty3 + tr_tool->ty4) / 2.0;
if (gimp_draw_tool_on_handle (draw_tool, display,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
x, y,
2 * HANDLE_SIZE, 2 * HANDLE_SIZE,
tr_tool->handle_w, tr_tool->handle_h,
GTK_ANCHOR_CENTER,
FALSE))
{
......@@ -630,11 +640,12 @@ gimp_transform_tool_oper_update (GimpTool *tool,
x = (tr_tool->tx3 + tr_tool->tx1) / 2.0;
y = (tr_tool->ty3 + tr_tool->ty1) / 2.0;
if (gimp_draw_tool_on_handle (draw_tool, display,
coords->x, coords->y,
GIMP_HANDLE_SQUARE,
x, y,
2 * HANDLE_SIZE, 2 * HANDLE_SIZE,
tr_tool->handle_w, tr_tool->handle_h,
GTK_ANCHOR_CENTER,
FALSE))
{
......@@ -648,7 +659,8 @@ gimp_transform_tool_oper_update (GimpTool *tool,
coords->x, coords->y,
GIMP_HANDLE_CIRCLE,
tr_tool->tcx, tr_tool->tcy,
HANDLE_SIZE, HANDLE_SIZE,
MIN (tr_tool->handle_w, tr_tool->handle_h),
MIN (tr_tool->handle_w, tr_tool->handle_h),
GTK_ANCHOR_CENTER,
FALSE))
{
......@@ -737,9 +749,9 @@ gimp_transform_tool_cursor_update (GimpTool *tool,
static void
gimp_transform_tool_draw (GimpDrawTool *draw_tool)
{
GimpTool *tool = GIMP_TOOL (draw_tool);
GimpTransformTool *tr_tool