summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-02-23 21:52:43 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-02-23 21:52:43 +0000
commit24577e91f0d05820369344d0881275e838fa2eef (patch)
tree9a48764a110091712cb30290d6904e6700042fed /src
parentWarning and space cleanup (diff)
downloadinkscape-24577e91f0d05820369344d0881275e838fa2eef.tar.gz
inkscape-24577e91f0d05820369344d0881275e838fa2eef.zip
* on-canvas clip and mask editing :) in the object menu you can find how to edit them.
* show helperpath toggle on node-edit toolbar. so helperpath is now also available for normal paths (instead of only for LPE'd paths) (bzr r4834)
Diffstat (limited to 'src')
-rw-r--r--src/menus-skeleton.h2
-rw-r--r--src/nodepath.cpp22
-rw-r--r--src/nodepath.h1
-rw-r--r--src/preferences-skeleton.h2
-rw-r--r--src/selection-chemistry.cpp50
-rw-r--r--src/selection-chemistry.h2
-rw-r--r--src/shape-editor.cpp4
-rw-r--r--src/shape-editor.h1
-rw-r--r--src/verbs.cpp10
-rw-r--r--src/verbs.h2
-rw-r--r--src/widgets/toolbox.cpp19
11 files changed, 114 insertions, 1 deletions
diff --git a/src/menus-skeleton.h b/src/menus-skeleton.h
index ac4209703..208bc7994 100644
--- a/src/menus-skeleton.h
+++ b/src/menus-skeleton.h
@@ -160,10 +160,12 @@ static char const menus_skeleton[] =
" <separator/>\n"
" <submenu name=\"" N_("Cli_p") "\">\n"
" <verb verb-id=\"ObjectSetClipPath\" />\n"
+" <verb verb-id=\"ObjectEditClipPath\" />\n"
" <verb verb-id=\"ObjectUnSetClipPath\" />\n"
" </submenu>\n"
" <submenu name=\"" N_("Mas_k") "\">\n"
" <verb verb-id=\"ObjectSetMask\" />\n"
+" <verb verb-id=\"ObjectEditMask\" />\n"
" <verb verb-id=\"ObjectUnSetMask\" />\n"
" </submenu>\n"
" <submenu name=\"" N_("Patter_n") "\">\n"
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index d0becd45d..e03484d7a 100644
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
@@ -201,6 +201,8 @@ Inkscape::NodePath::Path *sp_nodepath_new(SPDesktop *desktop, SPObject *object,
np->local_change = 0;
np->show_handles = show_handles;
np->helper_path = NULL;
+ np->helperpath_rgba = 0xff0000ff;
+ np->helperpath_width = 1.0;
np->curve = sp_curve_copy(curve);
np->show_helperpath = false;
np->straight_path = false;
@@ -4541,6 +4543,26 @@ void sp_nodepath_set_curve (Inkscape::NodePath::Path *np, SPCurve *curve) {
void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *np, bool show) {
np->show_helperpath = show;
+
+ if (show) {
+ SPCurve *helper_curve = sp_curve_copy(np->curve);
+ sp_curve_transform(helper_curve, np->i2d );
+ if (!np->helper_path) {
+ np->helper_path = sp_canvas_bpath_new(sp_desktop_controls(np->desktop), helper_curve);
+ sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(np->helper_path), np->helperpath_rgba, np->helperpath_width, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
+ sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(np->helper_path), 0, SP_WIND_RULE_NONZERO);
+ sp_canvas_item_show(np->helper_path);
+ } else {
+ sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(np->helper_path), helper_curve);
+ }
+ sp_curve_unref(helper_curve);
+ } else {
+ if (np->helper_path) {
+ GtkObject *temp = np->helper_path;
+ np->helper_path = NULL;
+ gtk_object_destroy(temp);
+ }
+ }
}
/* this function does not work yet */
diff --git a/src/nodepath.h b/src/nodepath.h
index 8f17ecb14..f426d414f 100644
--- a/src/nodepath.h
+++ b/src/nodepath.h
@@ -307,6 +307,7 @@ NR::Rect sp_node_selected_bbox (Inkscape::NodePath::Path *nodepath);
NR::Maybe<NR::Coord> sp_node_selected_common_coord (Inkscape::NodePath::Path *nodepath, NR::Dim2 axis);
void sp_nodepath_show_handles(Inkscape::NodePath::Path *nodepath, bool show);
+void sp_nodepath_show_helperpath(Inkscape::NodePath::Path *nodepath, bool show);
void sp_nodepath_selected_nodes_rotate (Inkscape::NodePath::Path * nodepath, gdouble angle, int which, bool screen);
diff --git a/src/preferences-skeleton.h b/src/preferences-skeleton.h
index 12783c022..b974ce6d2 100644
--- a/src/preferences-skeleton.h
+++ b/src/preferences-skeleton.h
@@ -74,7 +74,7 @@ static char const preferences_skeleton[] =
" <eventcontext id=\"text\" usecurrent=\"0\" gradientdrag=\"1\"\n"
" font_sample=\"AaBbCcIiPpQq12369$\342\202\254\302\242?.;/()\"\n"
" style=\"fill:black;fill-opacity:1;stroke:none;font-family:Bitstream Vera Sans;font-style:normal;font-weight:normal;font-size:40px;\" selcue=\"1\"/>\n"
-" <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" show_handles=\"1\" sculpting_profile=\"1\" />\n"
+" <eventcontext id=\"nodes\" selcue=\"1\" gradientdrag=\"1\" show_handles=\"1\" show_helperpath=\"0\" sculpting_profile=\"1\" />\n"
" <eventcontext id=\"tweak\" selcue=\"0\" gradientdrag=\"0\" show_handles=\"0\" width=\"0.2\" force=\"0.2\" fidelity=\"0.5\" usepressure=\"1\" style=\"fill:red;stroke:none;\" usecurrent=\"0\"/>\n"
" <eventcontext id=\"gradient\" selcue=\"1\"/>\n"
" <eventcontext id=\"zoom\" selcue=\"1\" gradientdrag=\"0\"/>\n"
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index e17452a55..6f038447e 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -86,6 +86,12 @@
#include "live_effects/parameter/path.h"
#include "libnr/nr-convert2geom.h"
+// For clippath editing
+#include "tools-switch.h"
+#include "shape-editor.h"
+#include "node-context.h"
+#include "nodepath.h"
+
using NR::X;
using NR::Y;
@@ -2130,6 +2136,50 @@ void sp_selection_next_patheffect_param(SPDesktop * dt)
}
}
+void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip)
+{
+ if (!dt) return;
+
+ Inkscape::Selection *selection = sp_desktop_selection(dt);
+ if ( selection && !selection->isEmpty() ) {
+ SPItem *item = selection->singleItem();
+ if ( item ) {
+ SPObject *obj = NULL;
+ if (clip)
+ obj = item->clip_ref ? SP_OBJECT(item->clip_ref->getObject()) : NULL;
+ else
+ obj = item->mask_ref ? SP_OBJECT(item->mask_ref->getObject()) : NULL;
+
+ if (obj) {
+ // obj is a group object, the children are the actual clippers
+ for ( SPObject *child = obj->children ; child ; child = child->next ) {
+ if ( SP_IS_ITEM(child) ) {
+ // If not already in nodecontext, goto it!
+ if (!tools_isactive(dt, TOOLS_NODES)) {
+ tools_switch_current(TOOLS_NODES);
+ }
+
+ ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor;
+ shape_editor->set_item(SP_ITEM(child));
+ Inkscape::NodePath::Path *np = shape_editor->get_nodepath();
+ if (np) {
+ np->helperpath_rgba = clip ? 0x0000ffff : 0x800080ff;
+ np->helperpath_width = 1.0;
+ sp_nodepath_show_helperpath(np, true);
+ }
+ break; // break out of for loop after 1st encountered item
+ }
+ }
+ } else if (clip) {
+ dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("The selection has no applied clip path."));
+ } else {
+ dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("The selection has no applied mask."));
+ }
+ }
+ }
+}
+
+
namespace {
template <typename D>
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index 501dcc520..9307fe5c0 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -98,6 +98,8 @@ void sp_selection_item_prev (void);
void sp_selection_next_patheffect_param(SPDesktop * dt);
+void sp_selection_edit_clip_or_mask(SPDesktop * dt, bool clip);
+
void scroll_to_show_item(SPDesktop *desktop, SPItem *item);
void sp_undo (SPDesktop *desktop, SPDocument *doc);
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index 0f630ac50..fbf42eaca 100644
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
@@ -480,6 +480,10 @@ void ShapeEditor::show_handles (bool show) {
sp_nodepath_show_handles (this->nodepath, show);
}
+void ShapeEditor::show_helperpath (bool show) {
+ if (this->nodepath)
+ sp_nodepath_show_helperpath (this->nodepath, show);
+}
void ShapeEditor::flip (NR::Dim2 axis, NR::Maybe<NR::Point> center) {
if (this->nodepath)
diff --git a/src/shape-editor.h b/src/shape-editor.h
index c4271568f..8e563b433 100644
--- a/src/shape-editor.h
+++ b/src/shape-editor.h
@@ -107,6 +107,7 @@ public:
void select_prev ();
void show_handles (bool show);
+ void show_helperpath (bool show);
void flip (NR::Dim2 axis, NR::Maybe<NR::Point> center = NR::Nothing());
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 2902a4a2f..08f1bb124 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -1335,12 +1335,18 @@ ObjectVerb::perform( SPAction *action, void *data, void */*pdata*/ )
case SP_VERB_OBJECT_SET_MASK:
sp_selection_set_mask(false, false);
break;
+ case SP_VERB_OBJECT_EDIT_MASK:
+ sp_selection_edit_clip_or_mask(dt, false);
+ break;
case SP_VERB_OBJECT_UNSET_MASK:
sp_selection_unset_mask(false);
break;
case SP_VERB_OBJECT_SET_CLIPPATH:
sp_selection_set_mask(true, false);
break;
+ case SP_VERB_OBJECT_EDIT_CLIPPATH:
+ sp_selection_edit_clip_or_mask(dt, true);
+ break;
case SP_VERB_OBJECT_UNSET_CLIPPATH:
sp_selection_unset_mask(true);
break;
@@ -2363,10 +2369,14 @@ Verb *Verb::_base_verbs[] = {
"object_flip_ver"),
new ObjectVerb(SP_VERB_OBJECT_SET_MASK, "ObjectSetMask", N_("_Set"),
N_("Apply mask to selection (using the topmost object as mask)"), NULL),
+ new ObjectVerb(SP_VERB_OBJECT_EDIT_MASK, "ObjectEditMask", N_("_Edit"),
+ N_("Edit mask"), NULL),
new ObjectVerb(SP_VERB_OBJECT_UNSET_MASK, "ObjectUnSetMask", N_("_Release"),
N_("Remove mask from selection"), NULL),
new ObjectVerb(SP_VERB_OBJECT_SET_CLIPPATH, "ObjectSetClipPath", N_("_Set"),
N_("Apply clipping path to selection (using the topmost object as clipping path)"), NULL),
+ new ObjectVerb(SP_VERB_OBJECT_EDIT_CLIPPATH, "ObjectEditClipPath", N_("_Edit"),
+ N_("Edit clipping path"), NULL),
new ObjectVerb(SP_VERB_OBJECT_UNSET_CLIPPATH, "ObjectUnSetClipPath", N_("_Release"),
N_("Remove clipping path from selection"), NULL),
diff --git a/src/verbs.h b/src/verbs.h
index b754d3807..6576c9652 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -137,8 +137,10 @@ enum {
SP_VERB_OBJECT_FLIP_HORIZONTAL,
SP_VERB_OBJECT_FLIP_VERTICAL,
SP_VERB_OBJECT_SET_MASK,
+ SP_VERB_OBJECT_EDIT_MASK,
SP_VERB_OBJECT_UNSET_MASK,
SP_VERB_OBJECT_SET_CLIPPATH,
+ SP_VERB_OBJECT_EDIT_CLIPPATH,
SP_VERB_OBJECT_UNSET_CLIPPATH,
/* Tools */
SP_VERB_CONTEXT_SELECT,
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index 8cdf0a07f..fcf3e0ce6 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -250,6 +250,7 @@ static gchar const * ui_descr =
" <toolitem action='StrokeToPath' />"
" <separator />"
" <toolitem action='NodesShowHandlesAction' />"
+ " <toolitem action='NodesShowHelperpath' />"
" <separator />"
" <toolitem action='EditNextLPEParameterAction' />"
" <separator />"
@@ -845,6 +846,13 @@ static void toggle_show_handles (GtkToggleAction *act, gpointer /*data*/) {
if (shape_editor) shape_editor->show_handles(show);
}
+static void toggle_show_helperpath (GtkToggleAction *act, gpointer /*data*/) {
+ bool show = gtk_toggle_action_get_active( act );
+ prefs_set_int_attribute ("tools.nodes", "show_helperpath", show ? 1 : 0);
+ ShapeEditor *shape_editor = get_current_shape_editor();
+ if (shape_editor) shape_editor->show_helperpath(show);
+}
+
void sp_node_path_edit_nextLPEparam (GtkAction */*act*/, gpointer data) {
sp_selection_next_patheffect_param( reinterpret_cast<SPDesktop*>(data) );
}
@@ -1096,6 +1104,17 @@ static void sp_node_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
}
{
+ InkToggleAction* act = ink_toggle_action_new( "NodesShowHelperpath",
+ _("Show Outline"),
+ _("Show the outline of the path"),
+ "nodes_show_helperpath",
+ Inkscape::ICON_SIZE_DECORATION );
+ gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
+ g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(toggle_show_helperpath), desktop );
+ gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs_get_int_attribute( "tools.nodes", "show_helperpath", 0 ) );
+ }
+
+ {
InkAction* inky = ink_action_new( "EditNextLPEParameterAction",
_("Next Path Effect Parameter"),
_("Show next Path Effect parameter for editing"),