mirror of https://github.com/GNOME/gimp.git
Added enum for vector tool operation mode
2003-08-21 Simon Budig <simon@gimp.org> * app/tools/tools-enums.h: Added enum for vector tool operation mode * app/tools/tools-enums.c: regenerated * app/tools/gimpvectoroptions.[ch]: Use new enum. Add "Polygonal" Option * app/tools/gimpvectortool.c: New Option "Polygonal" that places all newly generated handles at the position of their anchor, effectively ensuring that only polygons can be created. Cleaned up the editing states. It is now possible to move anchors in the Insert/Delete mode. Cleaned up the associated cursors. Fixed warning when Shift+Ctrl-Clicking on an inactive Anchor.
This commit is contained in:
parent
52a16ff5a4
commit
2a47fda7f0
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2003-08-21 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/tools/tools-enums.h: Added enum for vector tool operation
|
||||
mode
|
||||
|
||||
* app/tools/tools-enums.c: regenerated
|
||||
|
||||
* app/tools/gimpvectoroptions.[ch]: Use new enum.
|
||||
Add "Polygonal" Option
|
||||
|
||||
* app/tools/gimpvectortool.c: New Option "Polygonal" that
|
||||
places all newly generated handles at the position of their
|
||||
anchor, effectively ensuring that only polygons can be created.
|
||||
|
||||
Cleaned up the editing states. It is now possible to move anchors
|
||||
in the Insert/Delete mode. Cleaned up the associated cursors.
|
||||
|
||||
Fixed warning when Shift+Ctrl-Clicking on an inactive Anchor.
|
||||
|
||||
2003-08-20 Simon Budig <simon@gimp.org>
|
||||
|
||||
* app/vectors/gimpstroke.[ch]: Add hooks for insertion of points
|
||||
|
|
|
@ -42,7 +42,8 @@
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_VECTORS_EDIT_MODE
|
||||
PROP_VECTORS_EDIT_MODE,
|
||||
PROP_VECTORS_POLYGONAL
|
||||
};
|
||||
|
||||
static void gimp_vector_options_init (GimpVectorOptions *options);
|
||||
|
@ -100,8 +101,15 @@ gimp_vector_options_class_init (GimpVectorOptionsClass *klass)
|
|||
object_class->set_property = gimp_vector_options_set_property;
|
||||
object_class->get_property = gimp_vector_options_get_property;
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_VECTORS_EDIT_MODE,
|
||||
"vectors-edit-mode", NULL,
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_VECTORS_EDIT_MODE,
|
||||
"vectors-edit-mode", NULL,
|
||||
GIMP_TYPE_VECTOR_MODE,
|
||||
GIMP_VECTOR_MODE_CREATE,
|
||||
0);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_VECTORS_POLYGONAL,
|
||||
"vectors-polygonal",
|
||||
N_("restrict editing to polygonals"),
|
||||
FALSE,
|
||||
0);
|
||||
}
|
||||
|
@ -124,7 +132,10 @@ gimp_vector_options_set_property (GObject *object,
|
|||
switch (property_id)
|
||||
{
|
||||
case PROP_VECTORS_EDIT_MODE:
|
||||
options->edit_mode = g_value_get_boolean (value);
|
||||
options->edit_mode = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_VECTORS_POLYGONAL:
|
||||
options->polygonal = g_value_get_boolean (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -146,7 +157,10 @@ gimp_vector_options_get_property (GObject *object,
|
|||
switch (property_id)
|
||||
{
|
||||
case PROP_VECTORS_EDIT_MODE:
|
||||
g_value_set_boolean (value, options->edit_mode);
|
||||
g_value_set_enum (value, options->edit_mode);
|
||||
break;
|
||||
case PROP_VECTORS_POLYGONAL:
|
||||
g_value_set_boolean (value, options->polygonal);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -161,18 +175,22 @@ gimp_vector_options_gui (GimpToolOptions *tool_options)
|
|||
GObject *config;
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *button;
|
||||
|
||||
config = G_OBJECT (tool_options);
|
||||
|
||||
vbox = gimp_tool_options_gui (tool_options);
|
||||
|
||||
/* tool toggle */
|
||||
frame = gimp_prop_boolean_radio_frame_new (config, "vectors-edit-mode",
|
||||
_("Edit Mode"),
|
||||
_("Insert/Delete Nodes"),
|
||||
_("Extend Stroke/Move Nodes"));
|
||||
frame = gimp_prop_enum_radio_frame_new (config, "vectors-edit-mode",
|
||||
_("Edit Mode"), 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
button = gimp_prop_check_button_new (config, "vectors-polygonal",
|
||||
_("Polygonal"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
||||
gtk_widget_show (button);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,8 @@ struct _GimpVectorOptions
|
|||
{
|
||||
GimpSelectionOptions parent_instance;
|
||||
|
||||
gboolean edit_mode;
|
||||
GimpVectorMode edit_mode;
|
||||
gboolean polygonal;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -291,7 +291,7 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
|||
gimp_tool_control_activate (tool->control);
|
||||
tool->gdisp = gdisp;
|
||||
|
||||
if (options->edit_mode)
|
||||
if (options->edit_mode == GIMP_VECTOR_MODE_ADJUST)
|
||||
{
|
||||
switch (vector_tool->function)
|
||||
{
|
||||
|
@ -303,6 +303,11 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
|||
anchor = gimp_stroke_anchor_insert (stroke, segment_start, pos);
|
||||
if (anchor)
|
||||
{
|
||||
if (options->polygonal)
|
||||
{
|
||||
gimp_stroke_anchor_convert (stroke, anchor,
|
||||
GIMP_ANCHOR_FEATURE_EDGE);
|
||||
}
|
||||
vector_tool->function = VECTORS_MOVE_ANCHOR;
|
||||
}
|
||||
else
|
||||
|
@ -318,7 +323,6 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
|||
break;
|
||||
|
||||
default:
|
||||
vector_tool->function = VECTORS_FINISHED;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -363,13 +367,17 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
|||
state |= GDK_CONTROL_MASK;
|
||||
vector_tool->restriction = GIMP_ANCHOR_FEATURE_SYMMETRIC;
|
||||
|
||||
vector_tool->function = VECTORS_MOVE_HANDLE;
|
||||
if (!options->polygonal)
|
||||
vector_tool->function = VECTORS_MOVE_HANDLE;
|
||||
else
|
||||
vector_tool->function = VECTORS_MOVE_ANCHOR;
|
||||
vector_tool->cur_anchor = anchor;
|
||||
|
||||
/* no break! */
|
||||
|
||||
case VECTORS_MOVE_HANDLE:
|
||||
preferred = GIMP_ANCHOR_CONTROL;
|
||||
if (!options->polygonal)
|
||||
preferred = GIMP_ANCHOR_CONTROL;
|
||||
|
||||
/* no break! */
|
||||
|
||||
|
@ -377,16 +385,13 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
|||
gimp_vector_tool_on_handle (tool, coords,
|
||||
preferred, gdisp, &anchor, &stroke);
|
||||
|
||||
/* g_return_if_fail (anchor != NULL && stroke != NULL); */
|
||||
|
||||
if (anchor && stroke && anchor->type == GIMP_ANCHOR_ANCHOR)
|
||||
{
|
||||
gimp_vectors_anchor_select (vector_tool->vectors, stroke,
|
||||
anchor, TRUE);
|
||||
|
||||
/* if the selected anchor changed, the visible control
|
||||
* points might have changed too
|
||||
*/
|
||||
* points might have changed too */
|
||||
if (vector_tool->function == VECTORS_MOVE_HANDLE)
|
||||
gimp_vector_tool_on_handle (tool, coords, GIMP_ANCHOR_CONTROL,
|
||||
gdisp, &anchor, &stroke);
|
||||
|
@ -401,14 +406,32 @@ gimp_vector_tool_button_press (GimpTool *tool,
|
|||
break; /* here it is... :-) */
|
||||
|
||||
case VECTORS_CONVERT_EDGE:
|
||||
gimp_stroke_anchor_convert (vector_tool->cur_stroke,
|
||||
vector_tool->cur_anchor,
|
||||
GIMP_ANCHOR_FEATURE_EDGE);
|
||||
vector_tool->cur_stroke = NULL;
|
||||
vector_tool->cur_anchor = NULL;
|
||||
if (gimp_vector_tool_on_handle (tool, coords,
|
||||
GIMP_ANCHOR_ANCHOR, gdisp,
|
||||
&anchor, &stroke))
|
||||
{
|
||||
gimp_vectors_anchor_select (vector_tool->vectors, stroke,
|
||||
anchor, TRUE);
|
||||
gimp_stroke_anchor_convert (stroke, anchor,
|
||||
GIMP_ANCHOR_FEATURE_EDGE);
|
||||
|
||||
/* avoid doing anything stupid */
|
||||
vector_tool->function = VECTORS_FINISHED;
|
||||
if (anchor->type == GIMP_ANCHOR_ANCHOR)
|
||||
{
|
||||
vector_tool->cur_stroke = stroke;
|
||||
vector_tool->cur_anchor = anchor;
|
||||
|
||||
/* avoid doing anything stupid */
|
||||
vector_tool->function = VECTORS_MOVE_ANCHOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
vector_tool->cur_stroke = NULL;
|
||||
vector_tool->cur_anchor = NULL;
|
||||
|
||||
/* avoid doing anything stupid */
|
||||
vector_tool->function = VECTORS_FINISHED;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
@ -706,10 +729,13 @@ gimp_vector_tool_oper_update (GimpTool *tool,
|
|||
GimpVectorTool *vector_tool;
|
||||
GimpVectorOptions *options;
|
||||
GimpAnchor *anchor;
|
||||
GimpVectorMode edit_mode;
|
||||
|
||||
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)
|
||||
{
|
||||
vector_tool->function = VECTORS_CREATE_VECTOR;
|
||||
|
@ -737,7 +763,10 @@ gimp_vector_tool_oper_update (GimpTool *tool,
|
|||
}
|
||||
else
|
||||
{
|
||||
vector_tool->function = VECTORS_MOVE_HANDLE;
|
||||
if (!options->polygonal)
|
||||
vector_tool->function = VECTORS_MOVE_HANDLE;
|
||||
else
|
||||
vector_tool->function = VECTORS_MOVE_ANCHOR;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -751,14 +780,10 @@ gimp_vector_tool_oper_update (GimpTool *tool,
|
|||
coords, gdisp,
|
||||
NULL, NULL, NULL, NULL))
|
||||
{
|
||||
if (options->edit_mode)
|
||||
{
|
||||
vector_tool->function = VECTORS_INSERT_ANCHOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
vector_tool->function = VECTORS_MOVE_CURVE;
|
||||
}
|
||||
vector_tool->function =
|
||||
edit_mode == GIMP_VECTOR_MODE_ADJUST ?
|
||||
VECTORS_INSERT_ANCHOR :
|
||||
VECTORS_MOVE_CURVE;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -766,11 +791,17 @@ gimp_vector_tool_oper_update (GimpTool *tool,
|
|||
gimp_stroke_is_extendable (vector_tool->cur_stroke,
|
||||
vector_tool->cur_anchor))
|
||||
{
|
||||
vector_tool->function = VECTORS_ADD_ANCHOR;
|
||||
vector_tool->function =
|
||||
edit_mode == GIMP_VECTOR_MODE_ADJUST ?
|
||||
VECTORS_FINISHED :
|
||||
VECTORS_ADD_ANCHOR;
|
||||
}
|
||||
else
|
||||
{
|
||||
vector_tool->function = VECTORS_CREATE_STROKE;
|
||||
vector_tool->function =
|
||||
edit_mode == GIMP_VECTOR_MODE_ADJUST ?
|
||||
VECTORS_FINISHED :
|
||||
VECTORS_CREATE_STROKE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -785,11 +816,13 @@ gimp_vector_tool_cursor_update (GimpTool *tool,
|
|||
{
|
||||
GimpVectorTool *vector_tool;
|
||||
GimpToolCursorType tool_cursor;
|
||||
GimpCursorType cursor;
|
||||
GimpCursorModifier cmodifier;
|
||||
|
||||
vector_tool = GIMP_VECTOR_TOOL (tool);
|
||||
|
||||
tool_cursor = gimp_tool_control_get_tool_cursor (tool->control);
|
||||
cursor = GIMP_MOUSE_CURSOR;
|
||||
cmodifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
|
||||
switch (vector_tool->function)
|
||||
|
@ -810,9 +843,11 @@ gimp_vector_tool_cursor_update (GimpTool *tool,
|
|||
cmodifier = GIMP_CURSOR_MODIFIER_MOVE;
|
||||
break;
|
||||
case VECTORS_MOVE_CURVE:
|
||||
cmodifier = GIMP_CURSOR_MODIFIER_MINUS;
|
||||
cmodifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
break;
|
||||
default:
|
||||
cursor = GIMP_BAD_CURSOR;
|
||||
cmodifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
/* GIMP_CURSOR_MODIFIER_MINUS */
|
||||
break;
|
||||
}
|
||||
|
@ -824,7 +859,7 @@ gimp_vector_tool_cursor_update (GimpTool *tool,
|
|||
* gimp_tool_control_set_cursor_modifier (tool->control, cmodifier);
|
||||
*/
|
||||
|
||||
gimp_tool_set_cursor (tool, gdisp, GIMP_MOUSE_CURSOR, tool_cursor, cmodifier);
|
||||
gimp_tool_set_cursor (tool, gdisp, cursor, tool_cursor, cmodifier);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -68,6 +68,25 @@ gimp_transform_type_get_type (void)
|
|||
}
|
||||
|
||||
|
||||
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" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
GType
|
||||
gimp_vector_mode_get_type (void)
|
||||
{
|
||||
static GType enum_type = 0;
|
||||
|
||||
if (!enum_type)
|
||||
enum_type = g_enum_register_static ("GimpVectorMode", gimp_vector_mode_enum_values);
|
||||
|
||||
return enum_type;
|
||||
}
|
||||
|
||||
|
||||
static const GEnumValue gimp_transform_grid_type_enum_values[] =
|
||||
{
|
||||
{ GIMP_TRANSFORM_GRID_TYPE_NONE, N_("Don't Show Grid"), "none" },
|
||||
|
|
|
@ -104,6 +104,17 @@ typedef enum /*< pdb-skip >*/
|
|||
} GimpTransformType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_VECTOR_MODE (gimp_vector_mode_get_type ())
|
||||
|
||||
GType gimp_vector_mode_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum /*< pdb-skip >*/
|
||||
{
|
||||
GIMP_VECTOR_MODE_CREATE, /*< desc="Extend Stroke/Move Nodes" >*/
|
||||
GIMP_VECTOR_MODE_ADJUST, /*< desc="Insert/Delete Nodes" >*/
|
||||
} GimpVectorMode;
|
||||
|
||||
|
||||
#define GIMP_TYPE_TRANSFORM_GRID_TYPE (gimp_transform_grid_type_get_type ())
|
||||
|
||||
GType gimp_transform_grid_type_get_type (void) G_GNUC_CONST;
|
||||
|
|
Loading…
Reference in New Issue