diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2007-10-20 15:43:07 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2007-10-20 15:43:07 +0000 |
| commit | 82a86b15d8cdd5040d65fa27ea59237d6e7c7ed3 (patch) | |
| tree | f2607d956b1ce9c96bf57193b77913e074039ea9 /src/live_effects | |
| parent | Adding config option to block use of libpoppler-cairo (for misdetected situta... (diff) | |
| download | inkscape-82a86b15d8cdd5040d65fa27ea59237d6e7c7ed3.tar.gz inkscape-82a86b15d8cdd5040d65fa27ea59237d6e7c7ed3.zip | |
LPE: add on-canvas editing of path parameters!
(bzr r3934)
Diffstat (limited to 'src/live_effects')
| -rw-r--r-- | src/live_effects/effect.cpp | 8 | ||||
| -rw-r--r-- | src/live_effects/effect.h | 3 | ||||
| -rw-r--r-- | src/live_effects/lpeobject.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.cpp | 22 | ||||
| -rw-r--r-- | src/live_effects/parameter/path.h | 6 |
5 files changed, 30 insertions, 11 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 1c0f5318f..cfabc88b4 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -186,14 +186,15 @@ Effect::readallParameters(Inkscape::XML::Node * repr) const gchar * key = (*it).first.c_str(); const gchar * value = repr->attribute(key); if(value) { - setParameter(repr, key, NULL, value); + setParameter(key, value); } it++; } } +/* This function does not and SHOULD NOT write to XML */ void -Effect::setParameter(Inkscape::XML::Node * repr, const gchar * key, const gchar * old_value, const gchar * new_value) +Effect::setParameter(const gchar * key, const gchar * new_value) { Glib::ustring stringkey(key); @@ -203,9 +204,6 @@ Effect::setParameter(Inkscape::XML::Node * repr, const gchar * key, const gchar bool accepted = it->second->param_readSVGValue(new_value); if (!accepted) { g_warning("Effect::setParameter - '%s' not accepted for %s", new_value, key); - // change was not accepted, so change it back. - // think: can this backfire and create infinite loop when started with unacceptable old_value? - // repr->setAttribute(key, old_value); } } else { // set default value diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h index 5169ff22f..8c647e599 100644 --- a/src/live_effects/effect.h +++ b/src/live_effects/effect.h @@ -70,9 +70,10 @@ public: Inkscape::XML::Node * getRepr(); SPDocument * getSPDoc(); + LivePathEffectObject * getLPEObj() {return lpeobj;}; void readallParameters(Inkscape::XML::Node * repr); - void setParameter(Inkscape::XML::Node * repr, const gchar * key, const gchar * old_value, const gchar * new_value); + void setParameter(const gchar * key, const gchar * new_value); protected: Effect(LivePathEffectObject *lpeobject); diff --git a/src/live_effects/lpeobject.cpp b/src/live_effects/lpeobject.cpp index a8321b72d..90a49e2ff 100644 --- a/src/live_effects/lpeobject.cpp +++ b/src/live_effects/lpeobject.cpp @@ -246,7 +246,7 @@ livepatheffect_on_repr_attr_changed ( Inkscape::XML::Node * repr, if (!lpeobj->lpe) return; - lpeobj->lpe->setParameter(repr, key, oldval, newval); + lpeobj->lpe->setParameter(key, newval); lpeobj->requestModified(SP_OBJECT_MODIFIED_FLAG); } diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index ff596bfc6..15ba663be 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -25,7 +25,12 @@ #include "verbs.h" #include "document.h" -#define noLPEPATHPARAM_DEBUG +#define LPEPATHPARAM_DEBUG +#include "tools-switch.h" +#include "shape-editor.h" +#include "node-context.h" +#include "desktop-handles.h" +#include "selection.h" namespace Inkscape { @@ -38,6 +43,7 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip, { _widget = NULL; _tooltips = NULL; + edit_button = NULL; defvalue = g_strdup(default_value); param_readSVGValue(defvalue); } @@ -103,8 +109,9 @@ PathParam::param_getWidget() pButton->signal_clicked().connect(sigc::mem_fun(*this, &PathParam::on_edit_button_click)); static_cast<Gtk::HBox*>(_widget)->pack_start(*pButton, true, true); _tooltips->set_tip(*pButton, _("Edit on-canvas")); + edit_button = pButton; #ifndef LPEPATHPARAM_DEBUG - pButton->set_sensitive(false); + edit_button->set_sensitive(false); #endif pIcon = Gtk::manage( sp_icon_get_icon( GTK_STOCK_PASTE, Inkscape::ICON_SIZE_BUTTON) ); @@ -126,7 +133,13 @@ PathParam::param_getWidget() void PathParam::on_edit_button_click() { - g_message("give this path to edit on canvas!"); + // Switch to node edit tool: + 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(); + shape_editor->set_item_livepatheffect_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str()); } void @@ -146,6 +159,7 @@ PathParam::on_paste_button_click() if (strchr(svgd,'A')) { // FIXME: temporary hack until 2Geom supports arcs in SVGD SP_ACTIVE_DESKTOP->messageStack()->flash( Inkscape::WARNING_MESSAGE, _("This effect does not support arcs yet, try to convert to path.") ); + return; } else { param_write_to_repr(svgd); signal_path_pasted.emit(); @@ -155,8 +169,8 @@ PathParam::on_paste_button_click() } } else { SP_ACTIVE_DESKTOP->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Clipboard does not contain a path.")); + return; } - } void diff --git a/src/live_effects/parameter/path.h b/src/live_effects/parameter/path.h index e966b7ebd..14387f419 100644 --- a/src/live_effects/parameter/path.h +++ b/src/live_effects/parameter/path.h @@ -19,6 +19,10 @@ #include <sigc++/sigc++.h> +namespace Gtk { + class Button; +} + namespace Inkscape { namespace LivePathEffect { @@ -56,6 +60,8 @@ private: void on_paste_button_click(); gchar * defvalue; + + Gtk::Button * edit_button; }; |
