diff --git a/ChangeLog b/ChangeLog index 103a4bf505..029964e7a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2003-09-17 Simon Budig + + * 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 * app/tools/tools.c (tools_init): moved the path tool after the diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c index 6a9fbb287a..a1c51cc7d8 100644 --- a/app/tools/gimpdrawtool.c +++ b/app/tools/gimpdrawtool.c @@ -857,6 +857,7 @@ gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool, gint width, gint height, GimpAnchorType preferred, + gboolean exclusive, GimpAnchor **ret_anchor, GimpStroke **ret_stroke) { @@ -946,15 +947,16 @@ gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool, return TRUE; } - else if (anchor && gimp_draw_tool_on_handle (draw_tool, gdisp, - coord->x, - coord->y, - GIMP_HANDLE_CIRCLE, - anchor->position.x, - anchor->position.y, - width, height, - GTK_ANCHOR_CENTER, - FALSE)) + else if (!exclusive && anchor && + gimp_draw_tool_on_handle (draw_tool, gdisp, + coord->x, + coord->y, + GIMP_HANDLE_CIRCLE, + anchor->position.x, + anchor->position.y, + width, height, + GTK_ANCHOR_CENTER, + FALSE)) { if (ret_anchor) *ret_anchor = anchor; @@ -963,6 +965,10 @@ gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool, return TRUE; } + if (ret_anchor) + *ret_anchor = NULL; + if (ret_stroke) + *ret_stroke = NULL; return FALSE; } diff --git a/app/tools/gimpdrawtool.h b/app/tools/gimpdrawtool.h index b3a7442e04..37620c50eb 100644 --- a/app/tools/gimpdrawtool.h +++ b/app/tools/gimpdrawtool.h @@ -185,6 +185,7 @@ gboolean gimp_draw_tool_on_vectors_handle (GimpDrawTool *draw_tool, gint width, gint height, GimpAnchorType preferred, + gboolean exclusive, GimpAnchor **ret_anchor, GimpStroke **ret_stroke); gboolean gimp_draw_tool_on_vectors_curve (GimpDrawTool *draw_tool, diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c index e46e51b693..a54f596e95 100644 --- a/app/tools/gimpvectortool.c +++ b/app/tools/gimpvectortool.c @@ -113,6 +113,10 @@ static void gimp_vector_tool_vectors_freeze (GimpVectors *vectors, static void gimp_vector_tool_vectors_thaw (GimpVectors *vectors, 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_undo_push (GimpVectorTool *vector_tool, const gchar *desc); @@ -397,11 +401,12 @@ gimp_vector_tool_button_press (GimpTool *tool, { gimp_vectors_anchor_select (vector_tool->vectors, 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, vector_tool->vectors, coords, TARGET, TARGET, - GIMP_ANCHOR_CONTROL, + GIMP_ANCHOR_CONTROL, FALSE, &vector_tool->cur_anchor, &vector_tool->cur_stroke); } @@ -416,7 +421,29 @@ gimp_vector_tool_button_press (GimpTool *tool, gimp_vectors_anchor_select (vector_tool->vectors, 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, vector_tool->sel_stroke, - vector_tool->sel_anchor, TRUE); + vector_tool->sel_anchor, TRUE, TRUE); vector_tool->function = VECTORS_FINISHED; } @@ -455,7 +482,7 @@ gimp_vector_tool_button_press (GimpTool *tool, gimp_vectors_anchor_select (vector_tool->vectors, 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, vector_tool->cur_stroke, - vector_tool->cur_anchor, TRUE); + vector_tool->cur_anchor, TRUE, TRUE); vector_tool->function = VECTORS_MOVE_ANCHOR; } @@ -633,6 +660,16 @@ gimp_vector_tool_motion (GimpTool *tool, coords, vector_tool->restriction); 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: if (vector_tool->cur_stroke) { @@ -756,6 +793,7 @@ gimp_vector_tool_oper_update (GimpTool *tool, coords, TARGET, TARGET, GIMP_ANCHOR_ANCHOR, + vector_tool->sel_count > 2, &anchor, &stroke); if (! on_handle) @@ -804,7 +842,17 @@ gimp_vector_tool_oper_update (GimpTool *tool, { 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 { @@ -993,6 +1041,7 @@ gimp_vector_tool_cursor_update (GimpTool *tool, case VECTORS_MOVE_CURVE: case VECTORS_MOVE_STROKE: case VECTORS_MOVE_VECTORS: + case VECTORS_MOVE_ANCHORSET: cmodifier = GIMP_CURSOR_MODIFIER_MOVE; break; case VECTORS_CONNECT_STROKES: @@ -1057,46 +1106,49 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool) g_list_free (draw_anchors); - /* control handles */ - draw_anchors = gimp_stroke_get_draw_controls (cur_stroke); - - for (list = draw_anchors; list; list = g_list_next (list)) + if (vector_tool->sel_count <= 2) { - cur_anchor = GIMP_ANCHOR (list->data); + /* control handles */ + draw_anchors = gimp_stroke_get_draw_controls (cur_stroke); - 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) + for (list = draw_anchors; list; list = g_list_next (list)) { - 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).y, g_array_index (coords, GimpCoords, i + 1).x, g_array_index (coords, GimpCoords, i + 1).y, FALSE); + } } - } - g_array_free (coords, TRUE); + g_array_free (coords, TRUE); + } } /* the stroke itself */ @@ -1311,12 +1363,47 @@ gimp_vector_tool_set_vectors (GimpVectorTool *vector_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 gimp_vector_tool_verify_state (GimpVectorTool *vector_tool) { GimpStroke *cur_stroke = NULL; GimpAnchor *cur_anchor; - GList *draw_anchors; + GList *anchors; GList *list; gboolean cur_anchor_valid; gboolean cur_stroke_valid; @@ -1340,12 +1427,12 @@ gimp_vector_tool_verify_state (GimpVectorTool *vector_tool) cur_stroke))) { /* 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) 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); @@ -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); diff --git a/app/tools/gimpvectortool.h b/app/tools/gimpvectortool.h index 97f201cfaa..e26bc2d107 100644 --- a/app/tools/gimpvectortool.h +++ b/app/tools/gimpvectortool.h @@ -34,6 +34,7 @@ typedef enum VECTORS_CREATE_STROKE, VECTORS_ADD_ANCHOR, VECTORS_MOVE_ANCHOR, + VECTORS_MOVE_ANCHORSET, VECTORS_MOVE_HANDLE, VECTORS_MOVE_CURVE, VECTORS_MOVE_STROKE, diff --git a/app/vectors/gimpstroke.c b/app/vectors/gimpstroke.c index ec1b9cb9f3..c5a57781ee 100644 --- a/app/vectors/gimpstroke.c +++ b/app/vectors/gimpstroke.c @@ -66,6 +66,7 @@ static GimpAnchor * gimp_stroke_real_anchor_get_next (const GimpStroke *stroke, const GimpAnchor *prev); static void gimp_stroke_real_anchor_select (GimpStroke *stroke, GimpAnchor *anchor, + gboolean selected, gboolean exclusive); static void gimp_stroke_real_anchor_move_relative (GimpStroke *stroke, GimpAnchor *anchor, @@ -508,23 +509,26 @@ gimp_stroke_real_anchor_get_next (const GimpStroke *stroke, void gimp_stroke_anchor_select (GimpStroke *stroke, GimpAnchor *anchor, + gboolean selected, gboolean exclusive) { 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 gimp_stroke_real_anchor_select (GimpStroke *stroke, GimpAnchor *anchor, + gboolean selected, gboolean exclusive) { GList *list; list = stroke->anchors; - if (exclusive || anchor == NULL) + if (exclusive) { while (list) { @@ -536,7 +540,7 @@ gimp_stroke_real_anchor_select (GimpStroke *stroke, list = g_list_find (stroke->anchors, anchor); if (list) - GIMP_ANCHOR (list->data)->selected = TRUE; + GIMP_ANCHOR (list->data)->selected = selected; } diff --git a/app/vectors/gimpstroke.h b/app/vectors/gimpstroke.h index a721f7bba0..7fd3bf9b6e 100644 --- a/app/vectors/gimpstroke.h +++ b/app/vectors/gimpstroke.h @@ -63,6 +63,7 @@ struct _GimpStrokeClass const GimpAnchor *prev); void (* anchor_select) (GimpStroke *stroke, GimpAnchor *anchor, + gboolean selected, gboolean exclusive); void (* anchor_move_relative) (GimpStroke *stroke, GimpAnchor *anchor, @@ -169,6 +170,7 @@ GimpAnchor * gimp_stroke_anchor_get_next (const GimpStroke *stroke, void gimp_stroke_anchor_select (GimpStroke *stroke, GimpAnchor *anchor, + gboolean selected, gboolean exclusive); /* type will be an xorable enum: diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c index de926db528..bdd8b9448a 100644 --- a/app/vectors/gimpvectors.c +++ b/app/vectors/gimpvectors.c @@ -852,6 +852,7 @@ void gimp_vectors_anchor_select (GimpVectors *vectors, GimpStroke *target_stroke, GimpAnchor *anchor, + gboolean selected, gboolean exclusive) { GList *stroke_list; @@ -863,7 +864,7 @@ gimp_vectors_anchor_select (GimpVectors *vectors, stroke = GIMP_STROKE (stroke_list->data); gimp_stroke_anchor_select (stroke, stroke == target_stroke ? anchor : NULL, - exclusive); + selected, exclusive); } } diff --git a/app/vectors/gimpvectors.h b/app/vectors/gimpvectors.h index 9d5d558497..84bd241d7d 100644 --- a/app/vectors/gimpvectors.h +++ b/app/vectors/gimpvectors.h @@ -125,6 +125,7 @@ void gimp_vectors_anchor_delete (GimpVectors *vectors, void gimp_vectors_anchor_select (GimpVectors *vectors, GimpStroke *target_stroke, GimpAnchor *anchor, + gboolean selected, gboolean exclusive);