Do not modify the selection state of the anchors. When extending

2003-08-29  Simon Budig  <simon@gimp.org>

	* app/vectors/gimpbezierstroke.c: Do not modify the selection
	state of the anchors. When extending EXTEND_EDITABLE return
	the anchor created (not the handle at the end of the list)

	* app/tools/tools-enums.h: Added new mode-enum for the vector tool.
	* app/tools/tools-enums.c: regenerated

	* app/tools/gimpvectortool.[ch]: Implemented moving (Shortcuts
	ALT and ALT+CTRL. The whole assignment of modifiers right now
	gets revised. Right now you have to use the Tool options to
	switch between the modes of operation. Connecting strokes now
	works in Insert/Delete mode by clicking on startpoint and
	dragging to target endpoint.

	I will write a mail to gimp-devel when the shortcuts are
	setteled a bit more. Sorry for the inconvenience.
This commit is contained in:
Simon Budig 2003-08-29 15:17:06 +00:00 committed by Simon Budig
parent 417221b6bf
commit e7d0cfadc7
6 changed files with 189 additions and 107 deletions

View File

@ -1,3 +1,22 @@
2003-08-29 Simon Budig <simon@gimp.org>
* app/vectors/gimpbezierstroke.c: Do not modify the selection
state of the anchors. When extending EXTEND_EDITABLE return
the anchor created (not the handle at the end of the list)
* app/tools/tools-enums.h: Added new mode-enum for the vector tool.
* app/tools/tools-enums.c: regenerated
* app/tools/gimpvectortool.[ch]: Implemented moving (Shortcuts
ALT and ALT+CTRL. The whole assignment of modifiers right now
gets revised. Right now you have to use the Tool options to
switch between the modes of operation. Connecting strokes now
works in Insert/Delete mode by clicking on startpoint and
dragging to target endpoint.
I will write a mail to gimp-devel when the shortcuts are
setteled a bit more. Sorry for the inconvenience.
2003-08-29 Sven Neumann <sven@gimp.org>
* app/tools/gimptextoptions.c (gimp_text_options_gui): move the

View File

@ -396,8 +396,6 @@ gimp_vector_tool_button_press (GimpTool *tool,
vector_tool->cur_anchor,
EXTEND_EDITABLE);
/* We want to drag out the control point later */
state |= GDK_CONTROL_MASK;
vector_tool->restriction = GIMP_ANCHOR_FEATURE_SYMMETRIC;
if (!options->polygonal)
@ -435,27 +433,22 @@ gimp_vector_tool_button_press (GimpTool *tool,
break; /* here it is... :-) */
case VECTORS_CONNECT_STROKES:
gimp_vector_tool_on_handle (tool, coords, GIMP_ANCHOR_ANCHOR,
gdisp, &anchor, &stroke);
if (anchor && stroke &&
vector_tool->cur_anchor && vector_tool->cur_stroke &&
anchor != vector_tool->cur_anchor &&
gimp_stroke_is_extendable (stroke, anchor) &&
gimp_stroke_is_extendable (vector_tool->cur_stroke,
vector_tool->cur_anchor))
if (gimp_vector_tool_on_handle (tool, coords, GIMP_ANCHOR_ANCHOR,
gdisp, &anchor, &stroke)
&& gimp_stroke_is_extendable (stroke, anchor))
{
gimp_stroke_connect_stroke (vector_tool->cur_stroke,
vector_tool->cur_anchor,
stroke, anchor);
if (stroke != vector_tool->cur_stroke
&& gimp_stroke_is_empty (stroke))
gimp_vectors_stroke_remove (vector_tool->vectors, stroke);
vector_tool->cur_stroke = stroke;
vector_tool->cur_anchor = anchor;
vector_tool->function = VECTORS_MOVE_ANCHOR;
vector_tool->last_x = anchor->position.x;
vector_tool->last_y = anchor->position.y;
}
else
{
vector_tool->function = VECTORS_FINISHED;
}
break;
case VECTORS_MOVE_CURVE:
if (gimp_vector_tool_on_curve (tool, coords, gdisp,
NULL, &pos, &segment_start, &stroke)
@ -501,6 +494,23 @@ gimp_vector_tool_button_press (GimpTool *tool,
break;
case VECTORS_MOVE_STROKE:
case VECTORS_MOVE_VECTORS:
if (gimp_vector_tool_on_handle (tool, coords,
GIMP_ANCHOR_ANCHOR, gdisp,
&anchor, &stroke) ||
gimp_vector_tool_on_curve (tool, coords, gdisp,
NULL, NULL, &anchor, &stroke))
{
vector_tool->cur_anchor = anchor;
vector_tool->cur_stroke = stroke;
}
vector_tool->last_x = coords->x;
vector_tool->last_y = coords->y;
break;
default:
break;
}
@ -520,9 +530,29 @@ gimp_vector_tool_button_release (GimpTool *tool,
{
GimpVectorTool *vector_tool;
GimpViewable *viewable;
GimpAnchor *anchor=NULL;
GimpStroke *stroke=NULL;
vector_tool = GIMP_VECTOR_TOOL (tool);
if (vector_tool->function == VECTORS_CONNECT_STROKES
&& gimp_vector_tool_on_handle (tool, coords, GIMP_ANCHOR_ANCHOR,
gdisp, &anchor, &stroke)
&& anchor != vector_tool->cur_anchor
&& gimp_stroke_is_extendable (stroke, anchor))
{
gimp_vectors_freeze (vector_tool->vectors);
gimp_stroke_connect_stroke (vector_tool->cur_stroke,
vector_tool->cur_anchor,
stroke, anchor);
if (stroke != vector_tool->cur_stroke
&& gimp_stroke_is_empty (stroke))
gimp_vectors_stroke_remove (vector_tool->vectors, stroke);
vector_tool->cur_anchor = anchor;
gimp_vectors_thaw (vector_tool->vectors);
}
vector_tool->function = VECTORS_FINISHED;
/* THIS DOES NOT BELONG HERE! */
@ -586,6 +616,30 @@ gimp_vector_tool_motion (GimpTool *tool,
coords, vector_tool->restriction);
break;
case VECTORS_MOVE_STROKE:
gimp_stroke_translate (vector_tool->cur_stroke,
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_VECTORS:
gimp_item_translate (GIMP_ITEM (vector_tool->vectors),
coords->x - vector_tool->last_x,
coords->y - vector_tool->last_y, FALSE);
vector_tool->last_x = coords->x;
vector_tool->last_y = coords->y;
break;
case VECTORS_CONNECT_STROKES:
vector_tool->last_x = coords->x;
vector_tool->last_y = coords->y;
break;
default:
break;
}
@ -808,99 +862,94 @@ gimp_vector_tool_oper_update (GimpTool *tool,
GimpVectorTool *vector_tool;
GimpVectorOptions *options;
GimpAnchor *anchor = NULL;
GimpVectorMode edit_mode;
GdkModifierType modifier_mask = GDK_CONTROL_MASK;
vector_tool = GIMP_VECTOR_TOOL (tool);
options = GIMP_VECTOR_OPTIONS (tool->tool_info->tool_options);
edit_mode = options->edit_mode;
if (! vector_tool->vectors || GIMP_DRAW_TOOL (tool)->gdisp != gdisp)
switch (options->edit_mode)
{
vector_tool->function =
edit_mode == GIMP_VECTOR_MODE_ADJUST ?
VECTORS_FINISHED :
VECTORS_CREATE_VECTOR;
return;
}
if (gimp_vector_tool_on_handle (tool, coords, GIMP_ANCHOR_ANCHOR,
gdisp, &anchor, NULL))
{
if (state & GDK_CONTROL_MASK)
case GIMP_VECTOR_MODE_CREATE:
if (! vector_tool->vectors || GIMP_DRAW_TOOL (tool)->gdisp != gdisp)
{
if (state & GDK_SHIFT_MASK)
vector_tool->function = VECTORS_CREATE_VECTOR;
}
else if (gimp_vector_tool_on_handle (tool, coords, GIMP_ANCHOR_ANCHOR,
gdisp, &anchor, NULL))
{
if (state & modifier_mask)
{
if (state & GDK_MOD1_MASK)
vector_tool->function = VECTORS_CONNECT_STROKES;
else
vector_tool->function = VECTORS_CONVERT_EDGE;
vector_tool->function = VECTORS_MOVE_ANCHOR;
}
else
{
if (edit_mode == GIMP_VECTOR_MODE_ADJUST
&& anchor->type == GIMP_ANCHOR_ANCHOR)
{
vector_tool->function = VECTORS_DELETE_ANCHOR;
}
if (anchor->type == GIMP_ANCHOR_ANCHOR)
vector_tool->function = VECTORS_MOVE_ANCHOR;
else
{
if (!options->polygonal)
vector_tool->function = VECTORS_MOVE_HANDLE;
else
vector_tool->function = VECTORS_MOVE_ANCHOR;
}
vector_tool->function = VECTORS_MOVE_HANDLE;
}
}
else if (gimp_vector_tool_on_curve (tool, coords, gdisp,
NULL, NULL, NULL, NULL))
{
vector_tool->function = VECTORS_MOVE_CURVE;
}
else
{
if (vector_tool->cur_stroke && vector_tool->cur_anchor
&& gimp_stroke_is_extendable (vector_tool->cur_stroke,
vector_tool->cur_anchor))
vector_tool->function = VECTORS_ADD_ANCHOR;
else
vector_tool->function = VECTORS_CREATE_STROKE;
}
break;
case GIMP_VECTOR_MODE_ADJUST:
if (! vector_tool->vectors || GIMP_DRAW_TOOL (tool)->gdisp != gdisp)
{
vector_tool->function = VECTORS_FINISHED;
}
else if (gimp_vector_tool_on_handle (tool, coords, GIMP_ANCHOR_ANCHOR,
gdisp, &anchor, NULL))
{
if (state & modifier_mask)
{
vector_tool->function = VECTORS_DELETE_ANCHOR;
}
else
{
vector_tool->function = VECTORS_CONNECT_STROKES;
vector_tool->cur_anchor = NULL; /* slightly misplaced here */
}
}
else if (gimp_vector_tool_on_curve (tool, coords, gdisp,
NULL, NULL, NULL, NULL))
{
if (state & modifier_mask)
{
vector_tool->function = VECTORS_DELETE_SEGMENT;
}
else
{
vector_tool->function = VECTORS_INSERT_ANCHOR;
}
}
else
{
vector_tool->function = VECTORS_MOVE_ANCHOR;
}
}
else
{
if (gimp_vector_tool_on_curve (tool,
coords, gdisp,
NULL, NULL, NULL, NULL))
{
if (edit_mode == GIMP_VECTOR_MODE_ADJUST)
{
if (state & GDK_CONTROL_MASK)
{
vector_tool->function = VECTORS_DELETE_SEGMENT;
}
else
{
vector_tool->function = VECTORS_INSERT_ANCHOR;
}
}
else
{
if (!options->polygonal)
vector_tool->function = VECTORS_MOVE_CURVE;
else
vector_tool->function = VECTORS_ADD_ANCHOR;
}
vector_tool->function = VECTORS_FINISHED;
}
break;
case GIMP_VECTOR_MODE_MOVE:
if (state & modifier_mask)
vector_tool->function = VECTORS_MOVE_VECTORS;
else
{
if (vector_tool->cur_stroke && vector_tool->cur_anchor &&
gimp_stroke_is_extendable (vector_tool->cur_stroke,
vector_tool->cur_anchor))
{
vector_tool->function =
edit_mode == GIMP_VECTOR_MODE_ADJUST ?
VECTORS_FINISHED :
VECTORS_ADD_ANCHOR;
}
else
{
vector_tool->function =
edit_mode == GIMP_VECTOR_MODE_ADJUST ?
VECTORS_FINISHED :
VECTORS_CREATE_STROKE;
}
}
vector_tool->function = VECTORS_MOVE_STROKE;
break;
}
}
@ -942,6 +991,8 @@ gimp_vector_tool_cursor_update (GimpTool *tool,
break;
case VECTORS_MOVE_ANCHOR:
case VECTORS_MOVE_CURVE:
case VECTORS_MOVE_STROKE:
case VECTORS_MOVE_VECTORS:
cmodifier = GIMP_CURSOR_MODIFIER_MOVE;
break;
case VECTORS_CONNECT_STROKES:
@ -1060,6 +1111,17 @@ gimp_vector_tool_draw (GimpDrawTool *draw_tool)
g_array_free (coords, TRUE);
}
}
if (vector_tool->function == VECTORS_CONNECT_STROKES
&& vector_tool->cur_anchor)
{
gimp_draw_tool_draw_line (draw_tool,
vector_tool->cur_anchor->position.x,
vector_tool->cur_anchor->position.y,
vector_tool->last_x,
vector_tool->last_y,
FALSE);
}
}
static void

View File

@ -35,6 +35,8 @@ typedef enum
VECTORS_MOVE_ANCHOR,
VECTORS_MOVE_HANDLE,
VECTORS_MOVE_CURVE,
VECTORS_MOVE_STROKE,
VECTORS_MOVE_VECTORS,
VECTORS_INSERT_ANCHOR,
VECTORS_DELETE_ANCHOR,
VECTORS_CONNECT_STROKES,

View File

@ -72,6 +72,7 @@ static const GEnumValue gimp_vector_mode_enum_values[] =
{
{ GIMP_VECTOR_MODE_CREATE, N_("Extend Stroke/Move Nodes"), "create" },
{ GIMP_VECTOR_MODE_ADJUST, N_("Insert/Delete Nodes"), "adjust" },
{ GIMP_VECTOR_MODE_MOVE, N_("Move Stroke/Path"), "move" },
{ 0, NULL, NULL }
};

View File

@ -112,6 +112,7 @@ typedef enum /*< pdb-skip >*/
{
GIMP_VECTOR_MODE_CREATE, /*< desc="Extend Stroke/Move Nodes" >*/
GIMP_VECTOR_MODE_ADJUST, /*< desc="Insert/Delete Nodes" >*/
GIMP_VECTOR_MODE_MOVE, /*< desc="Move Stroke/Path" >*/
} GimpVectorMode;

View File

@ -878,11 +878,10 @@ gimp_bezier_stroke_extend (GimpStroke *stroke,
coords, anchor,
EXTEND_SIMPLE);
gimp_stroke_anchor_select (stroke, anchor, TRUE);
anchor = gimp_bezier_stroke_extend (stroke,
coords, anchor,
EXTEND_SIMPLE);
/* we return the GIMP_ANCHOR_ANCHOR */
gimp_bezier_stroke_extend (stroke,
coords, anchor,
EXTEND_SIMPLE);
break;
@ -1035,17 +1034,15 @@ gimp_bezier_stroke_extend (GimpStroke *stroke,
neighbor,
EXTEND_SIMPLE);
case 2:
neighbor = gimp_bezier_stroke_extend (stroke,
coords,
neighbor,
EXTEND_SIMPLE);
gimp_stroke_anchor_select (stroke, neighbor, TRUE);
anchor = gimp_bezier_stroke_extend (stroke,
coords,
neighbor,
EXTEND_SIMPLE);
neighbor = gimp_bezier_stroke_extend (stroke,
coords,
anchor,
EXTEND_SIMPLE);
break;
default:
g_warning ("inconsistent bezier curve: "