summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2007-10-28 16:03:07 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2007-10-28 16:03:07 +0000
commit96b65f32d922a989131ae91798801ea54c4e8b10 (patch)
tree627327d9468b399e064111734831864c4730bc2a /src
parentadded perfectboundcover.inx to translatable extensions (diff)
downloadinkscape-96b65f32d922a989131ae91798801ea54c4e8b10.tar.gz
inkscape-96b65f32d922a989131ae91798801ea54c4e8b10.zip
LPE: implement 'edit next LPE parameter'. Accessible through key '7'.
(bzr r3968)
Diffstat (limited to 'src')
-rw-r--r--src/live_effects/effect.cpp41
-rw-r--r--src/live_effects/effect.h8
-rw-r--r--src/live_effects/parameter/parameter.cpp1
-rw-r--r--src/live_effects/parameter/parameter.h7
-rw-r--r--src/live_effects/parameter/path.cpp36
-rw-r--r--src/live_effects/parameter/path.h2
-rw-r--r--src/selection-chemistry.cpp18
-rw-r--r--src/selection-chemistry.h2
-rw-r--r--src/sp-shape.cpp8
-rw-r--r--src/sp-shape.h3
-rw-r--r--src/verbs.cpp11
11 files changed, 114 insertions, 23 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index cfabc88b4..3802066ec 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -90,6 +90,7 @@ Effect::Effect(LivePathEffectObject *lpeobject)
vbox = NULL;
tooltips = NULL;
lpeobj = lpeobject;
+ oncanvasedit_it = param_map.begin();
}
Effect::~Effect()
@@ -261,6 +262,46 @@ Effect::getSPDoc()
return SP_OBJECT_DOCUMENT(lpeobj);
}
+Parameter *
+Effect::getNextOncanvasEditableParam()
+{
+ oncanvasedit_it++;
+ if (oncanvasedit_it == param_map.end()) {
+ oncanvasedit_it = param_map.begin();
+ }
+ param_map_type::iterator old_it = oncanvasedit_it;
+
+ do {
+ Parameter * param = oncanvasedit_it->second;
+ if(param->oncanvas_editable) {
+ return param;
+ } else {
+ oncanvasedit_it++;
+ if (oncanvasedit_it == param_map.end()) { // loop round the map
+ oncanvasedit_it = param_map.begin();
+ }
+ }
+ } while (oncanvasedit_it != old_it); // iterate until complete loop through map has been made
+
+ return NULL;
+}
+
+void
+Effect::editNextParamOncanvas(SPItem * item, SPDesktop * desktop)
+{
+ if (!desktop) return;
+
+ Parameter * param = getNextOncanvasEditableParam();
+ if (param) {
+ param->param_editOncanvas(item, desktop);
+ gchar *message = g_strdup_printf(_("Editing parameter <b>%s</b>."), param->param_label.c_str());
+ desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, message);
+ g_free(message);
+ } else {
+ desktop->messageStack()->flash( Inkscape::WARNING_MESSAGE,
+ _("None of the applied path effect's parameters can be edited on-canvas.") );
+ }
+}
} /* namespace LivePathEffect */
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 8c647e599..844a158b5 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -21,8 +21,9 @@
//#define LPE_ENABLE_TEST_EFFECTS
-struct SPShape;
struct SPDocument;
+struct SPDesktop;
+struct SPItem;
class NArtBpath;
struct LivePathEffectObject;
@@ -75,6 +76,8 @@ public:
void readallParameters(Inkscape::XML::Node * repr);
void setParameter(const gchar * key, const gchar * new_value);
+ void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
+
protected:
Effect(LivePathEffectObject *lpeobject);
@@ -91,6 +94,7 @@ protected:
doEffect (Geom::Piecewise<Geom::D2<Geom::SBasis> > & pwd2_in);
void registerParameter(Parameter * param);
+ Parameter * getNextOncanvasEditableParam();
typedef std::map<Glib::ustring, Parameter *> param_map_type;
param_map_type param_map;
@@ -101,6 +105,8 @@ protected:
LivePathEffectObject *lpeobj;
+ param_map_type::iterator oncanvasedit_it;
+
private:
Effect(const Effect&);
Effect& operator=(const Effect&);
diff --git a/src/live_effects/parameter/parameter.cpp b/src/live_effects/parameter/parameter.cpp
index efca9908d..9ee7faae4 100644
--- a/src/live_effects/parameter/parameter.cpp
+++ b/src/live_effects/parameter/parameter.cpp
@@ -28,6 +28,7 @@ namespace LivePathEffect {
Parameter::Parameter( const Glib::ustring& label, const Glib::ustring& tip,
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
Effect* effect )
+ : oncanvas_editable(false)
{
param_label = label;
param_tooltip = tip;
diff --git a/src/live_effects/parameter/parameter.h b/src/live_effects/parameter/parameter.h
index a6b05bf36..a41d5f7c6 100644
--- a/src/live_effects/parameter/parameter.h
+++ b/src/live_effects/parameter/parameter.h
@@ -16,6 +16,9 @@
#include "ui/widget/registry.h"
#include "ui/widget/registered-widget.h"
+struct SPDesktop;
+struct SPItem;
+
namespace Gtk {
class Widget;
}
@@ -45,10 +48,14 @@ public:
virtual Gtk::Widget * param_getWidget() = 0;
virtual Glib::ustring * param_getTooltip() { return &param_tooltip; };
+ virtual void param_editOncanvas(SPItem * item, SPDesktop * dt) { return; };
+
Glib::ustring param_key;
Inkscape::UI::Widget::Registry * param_wr;
Glib::ustring param_label;
+ bool oncanvas_editable;
+
protected:
Glib::ustring param_tooltip;
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index db1064511..2b558d2dd 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -46,6 +46,7 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
edit_button = NULL;
defvalue = g_strdup(default_value);
param_readSVGValue(defvalue);
+ oncanvas_editable = true;
}
PathParam::~PathParam()
@@ -128,18 +129,35 @@ PathParam::param_getWidget()
}
void
-PathParam::on_edit_button_click()
+PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt)
{
- // Switch to node edit tool:
- tools_switch_current(TOOLS_NODES);
+ // If not already in nodecontext, goto it!
+ if (!tools_isactive(dt, TOOLS_NODES)) {
+ tools_switch_current(TOOLS_NODES);
+ }
- // set this parameter to edit:
- ShapeEditor * shape_editor = SP_NODE_CONTEXT( SP_ACTIVE_DESKTOP->event_context )->shape_editor;
- SPItem * item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
+ ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor;
shape_editor->set_item_livepatheffect_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str());
}
void
+PathParam::param_write_to_repr(const char * svgd)
+{
+ param_effect->getRepr()->setAttribute(param_key.c_str(), svgd);
+}
+
+
+/* CALLBACK FUNCTIONS FOR THE BUTTONS */
+void
+PathParam::on_edit_button_click()
+{
+ SPItem * item = sp_desktop_selection(SP_ACTIVE_DESKTOP)->singleItem();
+ if (item != NULL) {
+ param_editOncanvas(item, SP_ACTIVE_DESKTOP);
+ }
+}
+
+void
PathParam::on_paste_button_click()
{
// check if something is in the clipboard
@@ -170,12 +188,6 @@ PathParam::on_paste_button_click()
}
}
-void
-PathParam::param_write_to_repr(const char * svgd)
-{
- param_effect->getRepr()->setAttribute(param_key.c_str(), svgd);
-}
-
} /* namespace LivePathEffect */
diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h
index 14387f419..6ba6e7e4b 100644
--- a/src/live_effects/parameter/path.h
+++ b/src/live_effects/parameter/path.h
@@ -44,6 +44,8 @@ public:
void param_set_default();
+ void param_editOncanvas(SPItem * item, SPDesktop * dt);
+
sigc::signal <void> signal_path_pasted;
sigc::signal <void> signal_path_changed;
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index 8d0aa4e79..d97bcfc08 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -2005,6 +2005,24 @@ sp_selection_item_prev(void)
}
}
+void sp_selection_next_patheffect_param(SPDesktop * dt)
+{
+ if (!dt) return;
+
+ Inkscape::Selection *selection = sp_desktop_selection(dt);
+ if ( selection && !selection->isEmpty() ) {
+ SPItem *item = selection->singleItem();
+ if ( item && SP_IS_SHAPE(item)) {
+ SPShape *shape = SP_SHAPE(item);
+ if (sp_shape_has_path_effect(shape)) {
+ sp_shape_edit_next_param_oncanvas(shape, dt);
+ } else {
+ dt->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("The selection has no applied path effect."));
+ }
+ }
+ }
+}
+
namespace {
template <typename D>
diff --git a/src/selection-chemistry.h b/src/selection-chemistry.h
index 66aab7d77..09f957332 100644
--- a/src/selection-chemistry.h
+++ b/src/selection-chemistry.h
@@ -88,6 +88,8 @@ void sp_selection_move_screen (gdouble dx, gdouble dy);
void sp_selection_item_next (void);
void sp_selection_item_prev (void);
+void sp_selection_next_patheffect_param(SPDesktop * dt);
+
void scroll_to_show_item(SPDesktop *desktop, SPItem *item);
void sp_undo (SPDesktop *desktop, SPDocument *doc);
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 511081b4c..ddec7aecc 100644
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -1214,6 +1214,14 @@ bool sp_shape_has_path_effect(SPShape *shape)
return (shape->path_effect_href != NULL);
}
+void sp_shape_edit_next_param_oncanvas(SPShape *shape, SPDesktop *dt)
+{
+ LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(shape);
+ if (lpeobj && lpeobj->lpe) {
+ lpeobj->lpe->editNextParamOncanvas(SP_ITEM(shape), dt);
+ }
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/sp-shape.h b/src/sp-shape.h
index 7563e2c7d..eb7d01245 100644
--- a/src/sp-shape.h
+++ b/src/sp-shape.h
@@ -27,6 +27,7 @@
#define SP_SHAPE_WRITE_PATH (1 << 2)
+struct SPDesktop;
struct LivePathEffectObject;
namespace Inkscape{
namespace LivePathEffect{
@@ -84,4 +85,6 @@ void sp_shape_set_path_effect(SPShape *shape, gchar *value);
void sp_shape_remove_path_effect(SPShape *shape);
bool sp_shape_has_path_effect(SPShape *shape);
+void sp_shape_edit_next_param_oncanvas(SPShape *shape, SPDesktop *dt);
+
#endif
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 32e0c46af..cc3adb8e2 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -1001,16 +1001,7 @@ EditVerb::perform(SPAction *action, void *data, void *pdata)
break;
case SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER:
- //FACTOR OUT THIS CODE TO SOMEWHERE ELSE!
- // if(selection has LPE) {
- // If not already in nodecontext, goto it!
- // if (!tools_isactive(dt, TOOLS_NODES)) {
- // tools_switch_current(TOOLS_NODES);
- // }
- // add goto next code here:
- //} else {
- // statusbar message: selection has no path effect applied.
- //}
+ sp_selection_next_patheffect_param(dt);
break;
default:
break;