app/vectors/gimpstroke.[ch] Changed gimp_*_anchor_select to accept the

2003-09-17  Simon Budig  <simon@gimp.org>

	* app/vectors/gimpstroke.[ch]
	* app/vectors/gimpvectors.[ch]: Changed gimp_*_anchor_select to
	accept the selection state as an argument.

	* app/tools/gimpdrawtool.[ch]: Added "exclusive" boolean parameter
	to gimp_draw_tool_on_vectors_handle(), so that you can specify
	that you just get exactly the type of anchor you want to have.

	* app/tools/gimpvectortool.[ch]: Handling of multiple selected
	anchors: Shift-Clicking in Extend mode selects them, you can
	move them together.
This commit is contained in:
Simon Budig 2003-09-17 21:49:45 +00:00 committed by Simon Budig
parent 776bc79292
commit 66cc2b98b5
9 changed files with 170 additions and 53 deletions

View File

@ -1,3 +1,17 @@
2003-09-17 Simon Budig <simon@gimp.org>
* app/vectors/gimpstroke.[ch]
* app/vectors/gimpvectors.[ch]: Changed gimp_*_anchor_select to
accept the selection state as an argument.
* app/tools/gimpdrawtool.[ch]: Added "exclusive" boolean parameter
to gimp_draw_tool_on_vectors_handle(), so that you can specify
that you just get exactly the type of anchor you want to have.
* app/tools/gimpvectortool.[ch]: Handling of multiple selected
anchors: Shift-Clicking in Extend mode selects them, you can
move them together.
2003-09-17 Michael Natterer <mitch@gimp.org> 2003-09-17 Michael Natterer <mitch@gimp.org>
* app/tools/tools.c (tools_init): moved the path tool after the * app/tools/tools.c (tools_init): moved the path tool after the

View File

@ -857,6 +857,7 @@ gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool,
gint width, gint width,
gint height, gint height,
GimpAnchorType preferred, GimpAnchorType preferred,
gboolean exclusive,
GimpAnchor **ret_anchor, GimpAnchor **ret_anchor,
GimpStroke **ret_stroke) GimpStroke **ret_stroke)
{ {
@ -946,15 +947,16 @@ gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool,
return TRUE; return TRUE;
} }
else if (anchor && gimp_draw_tool_on_handle (draw_tool, gdisp, else if (!exclusive && anchor &&
coord->x, gimp_draw_tool_on_handle (draw_tool, gdisp,
coord->y, coord->x,
GIMP_HANDLE_CIRCLE, coord->y,
anchor->position.x, GIMP_HANDLE_CIRCLE,
anchor->position.y, anchor->position.x,
width, height, anchor->position.y,
GTK_ANCHOR_CENTER, width, height,
FALSE)) GTK_ANCHOR_CENTER,
FALSE))
{ {
if (ret_anchor) if (ret_anchor)
*ret_anchor = anchor; *ret_anchor = anchor;
@ -963,6 +965,10 @@ gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool,
return TRUE; return TRUE;
} }
if (ret_anchor)
*ret_anchor = NULL;
if (ret_stroke)
*ret_stroke = NULL;
return FALSE; return FALSE;
} }

View File

@ -185,6 +185,7 @@ gboolean gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool,
gint width, gint width,
gint height, gint height,
GimpAnchorType preferred, GimpAnchorType preferred,
gboolean exclusive,
GimpAnchor **ret_anchor, GimpAnchor **ret_anchor,
GimpStroke **ret_stroke); GimpStroke **ret_stroke);
gboolean gimp_draw_tool_on_vectors_curve (GimpDrawTool *draw_tool, gboolean gimp_draw_tool_on_vectors_curve (GimpDrawTool *draw_tool,

View File

@ -113,6 +113,10 @@ static void gimp_vector_tool_vectors_freeze (GimpVectors *vectors,
static void gimp_vector_tool_vectors_thaw (GimpVectors *vectors, static void gimp_vector_tool_vectors_thaw (GimpVectors *vectors,
GimpVectorTool *vector_tool); GimpVectorTool *vector_tool);
static void gimp_vector_tool_move_selected_anchors
(GimpVectorTool *vector_tool,
gdouble x,
gdouble y);
static void gimp_vector_tool_verify_state (GimpVectorTool *vector_tool); static void gimp_vector_tool_verify_state (GimpVectorTool *vector_tool);
static void gimp_vector_tool_undo_push (GimpVectorTool *vector_tool, static void gimp_vector_tool_undo_push (GimpVectorTool *vector_tool,
const gchar *desc); const gchar *desc);
@ -397,11 +401,12 @@ gimp_vector_tool_button_press (GimpTool *tool,
{ {
gimp_vectors_anchor_select (vector_tool->vectors, gimp_vectors_anchor_select (vector_tool->vectors,
vector_tool->cur_stroke, vector_tool->cur_stroke,
vector_tool->cur_anchor, TRUE); vector_tool->cur_anchor,
TRUE, TRUE);
gimp_draw_tool_on_vectors_handle (GIMP_DRAW_TOOL (tool), gdisp, gimp_draw_tool_on_vectors_handle (GIMP_DRAW_TOOL (tool), gdisp,
vector_tool->vectors, coords, vector_tool->vectors, coords,
TARGET, TARGET, TARGET, TARGET,
GIMP_ANCHOR_CONTROL, GIMP_ANCHOR_CONTROL, FALSE,
&vector_tool->cur_anchor, &vector_tool->cur_anchor,
&vector_tool->cur_stroke); &vector_tool->cur_stroke);
} }
@ -416,7 +421,29 @@ gimp_vector_tool_button_press (GimpTool *tool,
gimp_vectors_anchor_select (vector_tool->vectors, gimp_vectors_anchor_select (vector_tool->vectors,
vector_tool->cur_stroke, vector_tool->cur_stroke,
vector_tool->cur_anchor, TRUE); vector_tool->cur_anchor,
TRUE, TRUE);
}
/* move multiple anchors */
if (vector_tool->function == VECTORS_MOVE_ANCHORSET)
{
gimp_vector_tool_undo_push (vector_tool, _("Drag Anchors"));
if (state & TOGGLE_MASK)
{
gimp_vectors_anchor_select (vector_tool->vectors,
vector_tool->cur_stroke,
vector_tool->cur_anchor,
!vector_tool->cur_anchor->selected,
FALSE);
if (vector_tool->cur_anchor->selected == FALSE)
vector_tool->function = VECTORS_FINISHED;
}
vector_tool->last_x = coords->x;
vector_tool->last_y = coords->y;
} }
@ -441,7 +468,7 @@ gimp_vector_tool_button_press (GimpTool *tool,
gimp_vectors_anchor_select (vector_tool->vectors, gimp_vectors_anchor_select (vector_tool->vectors,
vector_tool->sel_stroke, vector_tool->sel_stroke,
vector_tool->sel_anchor, TRUE); vector_tool->sel_anchor, TRUE, TRUE);
vector_tool->function = VECTORS_FINISHED; vector_tool->function = VECTORS_FINISHED;
} }
@ -455,7 +482,7 @@ gimp_vector_tool_button_press (GimpTool *tool,
gimp_vectors_anchor_select (vector_tool->vectors, gimp_vectors_anchor_select (vector_tool->vectors,
vector_tool->cur_stroke, vector_tool->cur_stroke,
vector_tool->cur_anchor, TRUE); vector_tool->cur_anchor, TRUE, TRUE);
} }
@ -484,7 +511,7 @@ gimp_vector_tool_button_press (GimpTool *tool,
{ {
gimp_vectors_anchor_select (vector_tool->vectors, gimp_vectors_anchor_select (vector_tool->vectors,
vector_tool->cur_stroke, vector_tool->cur_stroke,
vector_tool->cur_anchor, TRUE); vector_tool->cur_anchor, TRUE, TRUE);
vector_tool->function = VECTORS_MOVE_ANCHOR; vector_tool->function = VECTORS_MOVE_ANCHOR;
} }
@ -633,6 +660,16 @@ gimp_vector_tool_motion (GimpTool *tool,
coords, vector_tool->restriction); coords, vector_tool->restriction);
break; break;
case VECTORS_MOVE_ANCHORSET:
gimp_vector_tool_move_selected_anchors (vector_tool,
coords->x - vector_tool->last_x,
coords->y - vector_tool->last_y);
vector_tool->last_x = coords->x;
vector_tool->last_y = coords->y;
break;
case VECTORS_MOVE_STROKE: case VECTORS_MOVE_STROKE:
if (vector_tool->cur_stroke) if (vector_tool->cur_stroke)
{ {
@ -756,6 +793,7 @@ gimp_vector_tool_oper_update (GimpTool *tool,
coords, coords,
TARGET, TARGET, TARGET, TARGET,
GIMP_ANCHOR_ANCHOR, GIMP_ANCHOR_ANCHOR,
vector_tool->sel_count > 2,
&anchor, &stroke); &anchor, &stroke);
if (! on_handle) if (! on_handle)
@ -804,7 +842,17 @@ gimp_vector_tool_oper_update (GimpTool *tool,
{ {
if (anchor->type == GIMP_ANCHOR_ANCHOR) if (anchor->type == GIMP_ANCHOR_ANCHOR)
{ {
vector_tool->function = VECTORS_MOVE_ANCHOR; if (state & TOGGLE_MASK)
{
vector_tool->function = VECTORS_MOVE_ANCHORSET;
}
else
{
if (vector_tool->sel_count >= 2 && anchor->selected)
vector_tool->function = VECTORS_MOVE_ANCHORSET;
else
vector_tool->function = VECTORS_MOVE_ANCHOR;
}
} }
else else
{ {
@ -993,6 +1041,7 @@ gimp_vector_tool_cursor_update (GimpTool *tool,
case VECTORS_MOVE_CURVE: case VECTORS_MOVE_CURVE:
case VECTORS_MOVE_STROKE: case VECTORS_MOVE_STROKE:
case VECTORS_MOVE_VECTORS: case VECTORS_MOVE_VECTORS:
case VECTORS_MOVE_ANCHORSET:
cmodifier = GIMP_CURSOR_MODIFIER_MOVE; cmodifier = GIMP_CURSOR_MODIFIER_MOVE;
break; break;
case VECTORS_CONNECT_STROKES: case VECTORS_CONNECT_STROKES:
@ -1057,46 +1106,49 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
g_list_free (draw_anchors); g_list_free (draw_anchors);
/* control handles */ if (vector_tool->sel_count <= 2)
draw_anchors = gimp_stroke_get_draw_controls (cur_stroke);
for (list = draw_anchors; list; list = g_list_next (list))
{ {
cur_anchor = GIMP_ANCHOR (list->data); /* control handles */
draw_anchors = gimp_stroke_get_draw_controls (cur_stroke);
gimp_draw_tool_draw_handle (draw_tool, for (list = draw_anchors; list; list = g_list_next (list))
GIMP_HANDLE_SQUARE,
cur_anchor->position.x,
cur_anchor->position.y,
TARGET - 3,
TARGET - 3,
GTK_ANCHOR_CENTER,
FALSE);
}
g_list_free (draw_anchors);
/* the lines to the control handles */
coords = gimp_stroke_get_draw_lines (cur_stroke);
if (coords)
{
if (coords->len % 2 == 0)
{ {
gint i; cur_anchor = GIMP_ANCHOR (list->data);
for (i = 0; i < coords->len; i += 2) gimp_draw_tool_draw_handle (draw_tool,
GIMP_HANDLE_SQUARE,
cur_anchor->position.x,
cur_anchor->position.y,
TARGET - 3,
TARGET - 3,
GTK_ANCHOR_CENTER,
FALSE);
}
g_list_free (draw_anchors);
/* the lines to the control handles */
coords = gimp_stroke_get_draw_lines (cur_stroke);
if (coords)
{
if (coords->len % 2 == 0)
{ {
gimp_draw_tool_draw_dashed_line (draw_tool, gint i;
for (i = 0; i < coords->len; i += 2)
{
gimp_draw_tool_draw_dashed_line (draw_tool,
g_array_index (coords, GimpCoords, i).x, g_array_index (coords, GimpCoords, i).x,
g_array_index (coords, GimpCoords, i).y, g_array_index (coords, GimpCoords, i).y,
g_array_index (coords, GimpCoords, i + 1).x, g_array_index (coords, GimpCoords, i + 1).x,
g_array_index (coords, GimpCoords, i + 1).y, g_array_index (coords, GimpCoords, i + 1).y,
FALSE); FALSE);
}
} }
}
g_array_free (coords, TRUE); g_array_free (coords, TRUE);
}
} }
/* the stroke itself */ /* the stroke itself */
@ -1311,12 +1363,47 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_tool,
gimp_draw_tool_resume (draw_tool); gimp_draw_tool_resume (draw_tool);
} }
static void
gimp_vector_tool_move_selected_anchors (GimpVectorTool *vector_tool,
gdouble x,
gdouble y)
{
GimpAnchor *cur_anchor;
GimpStroke *cur_stroke = NULL;
GList *anchors;
GList *list;
GimpCoords offset = { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 };
offset.x = x;
offset.y = y;
while ((cur_stroke = gimp_vectors_stroke_get_next (vector_tool->vectors,
cur_stroke)))
{
/* anchors */
anchors = gimp_stroke_get_draw_anchors (cur_stroke);
for (list = anchors; list; list = g_list_next (list))
{
cur_anchor = GIMP_ANCHOR (list->data);
if (cur_anchor->selected)
gimp_stroke_anchor_move_relative (cur_stroke,
cur_anchor,
&offset,
GIMP_ANCHOR_FEATURE_NONE);
}
g_list_free (anchors);
}
}
static void static void
gimp_vector_tool_verify_state (GimpVectorTool *vector_tool) gimp_vector_tool_verify_state (GimpVectorTool *vector_tool)
{ {
GimpStroke *cur_stroke = NULL; GimpStroke *cur_stroke = NULL;
GimpAnchor *cur_anchor; GimpAnchor *cur_anchor;
GList *draw_anchors; GList *anchors;
GList *list; GList *list;
gboolean cur_anchor_valid; gboolean cur_anchor_valid;
gboolean cur_stroke_valid; gboolean cur_stroke_valid;
@ -1340,12 +1427,12 @@ gimp_vector_tool_verify_state (GimpVectorTool *vector_tool)
cur_stroke))) cur_stroke)))
{ {
/* anchor handles */ /* anchor handles */
draw_anchors = gimp_stroke_get_draw_anchors (cur_stroke); anchors = gimp_stroke_get_draw_anchors (cur_stroke);
if (cur_stroke == vector_tool->cur_stroke) if (cur_stroke == vector_tool->cur_stroke)
cur_stroke_valid = TRUE; cur_stroke_valid = TRUE;
for (list = draw_anchors; list; list = g_list_next (list)) for (list = anchors; list; list = g_list_next (list))
{ {
cur_anchor = GIMP_ANCHOR (list->data); cur_anchor = GIMP_ANCHOR (list->data);
@ -1369,9 +1456,9 @@ gimp_vector_tool_verify_state (GimpVectorTool *vector_tool)
} }
} }
draw_anchors = gimp_stroke_get_draw_controls (cur_stroke); anchors = gimp_stroke_get_draw_controls (cur_stroke);
for (list = draw_anchors; list; list = g_list_next (list)) for (list = anchors; list; list = g_list_next (list))
{ {
cur_anchor = GIMP_ANCHOR (list->data); cur_anchor = GIMP_ANCHOR (list->data);

View File

@ -34,6 +34,7 @@ typedef enum
VECTORS_CREATE_STROKE, VECTORS_CREATE_STROKE,
VECTORS_ADD_ANCHOR, VECTORS_ADD_ANCHOR,
VECTORS_MOVE_ANCHOR, VECTORS_MOVE_ANCHOR,
VECTORS_MOVE_ANCHORSET,
VECTORS_MOVE_HANDLE, VECTORS_MOVE_HANDLE,
VECTORS_MOVE_CURVE, VECTORS_MOVE_CURVE,
VECTORS_MOVE_STROKE, VECTORS_MOVE_STROKE,

View File

@ -66,6 +66,7 @@ static GimpAnchor * gimp_stroke_real_anchor_get_next (const GimpStroke *stroke,
const GimpAnchor *prev); const GimpAnchor *prev);
static void gimp_stroke_real_anchor_select (GimpStroke *stroke, static void gimp_stroke_real_anchor_select (GimpStroke *stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
gboolean selected,
gboolean exclusive); gboolean exclusive);
static void gimp_stroke_real_anchor_move_relative (GimpStroke *stroke, static void gimp_stroke_real_anchor_move_relative (GimpStroke *stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
@ -508,23 +509,26 @@ gimp_stroke_real_anchor_get_next (const GimpStroke *stroke,
void void
gimp_stroke_anchor_select (GimpStroke *stroke, gimp_stroke_anchor_select (GimpStroke *stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
gboolean selected,
gboolean exclusive) gboolean exclusive)
{ {
g_return_if_fail (GIMP_IS_STROKE (stroke)); g_return_if_fail (GIMP_IS_STROKE (stroke));
GIMP_STROKE_GET_CLASS (stroke)->anchor_select (stroke, anchor, exclusive); GIMP_STROKE_GET_CLASS (stroke)->anchor_select (stroke, anchor,
selected, exclusive);
} }
static void static void
gimp_stroke_real_anchor_select (GimpStroke *stroke, gimp_stroke_real_anchor_select (GimpStroke *stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
gboolean selected,
gboolean exclusive) gboolean exclusive)
{ {
GList *list; GList *list;
list = stroke->anchors; list = stroke->anchors;
if (exclusive || anchor == NULL) if (exclusive)
{ {
while (list) while (list)
{ {
@ -536,7 +540,7 @@ gimp_stroke_real_anchor_select (GimpStroke *stroke,
list = g_list_find (stroke->anchors, anchor); list = g_list_find (stroke->anchors, anchor);
if (list) if (list)
GIMP_ANCHOR (list->data)->selected = TRUE; GIMP_ANCHOR (list->data)->selected = selected;
} }

View File

@ -63,6 +63,7 @@ struct _GimpStrokeClass
const GimpAnchor *prev); const GimpAnchor *prev);
void (* anchor_select) (GimpStroke *stroke, void (* anchor_select) (GimpStroke *stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
gboolean selected,
gboolean exclusive); gboolean exclusive);
void (* anchor_move_relative) (GimpStroke *stroke, void (* anchor_move_relative) (GimpStroke *stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
@ -169,6 +170,7 @@ GimpAnchor * gimp_stroke_anchor_get_next (const GimpStroke *stroke,
void gimp_stroke_anchor_select (GimpStroke *stroke, void gimp_stroke_anchor_select (GimpStroke *stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
gboolean selected,
gboolean exclusive); gboolean exclusive);
/* type will be an xorable enum: /* type will be an xorable enum:

View File

@ -852,6 +852,7 @@ void
gimp_vectors_anchor_select (GimpVectors *vectors, gimp_vectors_anchor_select (GimpVectors *vectors,
GimpStroke *target_stroke, GimpStroke *target_stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
gboolean selected,
gboolean exclusive) gboolean exclusive)
{ {
GList *stroke_list; GList *stroke_list;
@ -863,7 +864,7 @@ gimp_vectors_anchor_select (GimpVectors *vectors,
stroke = GIMP_STROKE (stroke_list->data); stroke = GIMP_STROKE (stroke_list->data);
gimp_stroke_anchor_select (stroke, gimp_stroke_anchor_select (stroke,
stroke == target_stroke ? anchor : NULL, stroke == target_stroke ? anchor : NULL,
exclusive); selected, exclusive);
} }
} }

View File

@ -125,6 +125,7 @@ void gimp_vectors_anchor_delete (GimpVectors *vectors,
void gimp_vectors_anchor_select (GimpVectors *vectors, void gimp_vectors_anchor_select (GimpVectors *vectors,
GimpStroke *target_stroke, GimpStroke *target_stroke,
GimpAnchor *anchor, GimpAnchor *anchor,
gboolean selected,
gboolean exclusive); gboolean exclusive);