Code

move shape_editor from node context to the parent class, event context
[inkscape.git] / src / live_effects / parameter / path.cpp
index e74729b3599e899b9ffafae5e297aec0c8f89490..1214a1766db3281d66926d12c91bcd9475159468 100644 (file)
@@ -8,7 +8,6 @@
 
 #include "live_effects/parameter/path.h"
 #include "live_effects/effect.h"
-#include "libnr/n-art-bpath-2geom.h"
 #include "svg/svg.h"
 #include <2geom/svg-path-parser.h>
 #include <2geom/sbasis-to-bezier.h>
@@ -50,6 +49,7 @@ PathParam::PathParam( const Glib::ustring& label, const Glib::ustring& tip,
                       const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
                       Effect* effect, const gchar * default_value)
     : Parameter(label, tip, key, wr, effect),
+      changed(true),
       _pathvector(),
       _pwd2(),
       must_recalculate_pwd2(false),
@@ -120,7 +120,7 @@ PathParam::param_readSVGValue(const gchar * strvalue)
             _pathvector = sp_svg_read_pathv(strvalue);
         }
 
-        signal_path_changed.emit();
+        emit_changed();
         return true;
     }
 
@@ -197,10 +197,10 @@ PathParam::param_editOncanvas(SPItem * item, SPDesktop * dt)
 {
     // If not already in nodecontext, goto it!
     if (!tools_isactive(dt, TOOLS_NODES)) {
-        tools_switch_current(TOOLS_NODES);
+        tools_switch(dt, TOOLS_NODES);
     }
 
-    ShapeEditor * shape_editor = SP_NODE_CONTEXT( dt->event_context )->shape_editor;
+    ShapeEditor * shape_editor = dt->event_context->shape_editor;
     if (!href) {
         shape_editor->set_item_lpe_path_parameter(item, SP_OBJECT(param_effect->getLPEObj()), param_key.c_str());
     } else {
@@ -255,12 +255,12 @@ PathParam::set_new_value (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & newpa
     } else {
         _pwd2 = newpath;
         must_recalculate_pwd2 = false;
-        signal_path_changed.emit();
+        emit_changed();
     }
 }
 
 /*
- * This method sets new path data. 
+ * This method sets new path data.
  * If this PathParam refers to another path, this link is removed (and replaced with explicit path data).
  *
  * If write_to_svg = true :
@@ -283,7 +283,7 @@ PathParam::set_new_value (std::vector<Geom::Path> const &newpath, bool write_to_
         param_write_to_repr(svgd);
         g_free(svgd);
     } else {
-        signal_path_changed.emit();
+        emit_changed();
     }
 }
 
@@ -300,6 +300,13 @@ PathParam::ensure_pwd2()
     }
 }
 
+void
+PathParam::emit_changed()
+{
+    changed = true;
+    signal_path_changed.emit();
+}
+
 void
 PathParam::start_listening(SPObject * to)
 {
@@ -365,7 +372,7 @@ PathParam::linked_modified(SPObject *linked_obj, guint /*flags*/)
     }
 
     must_recalculate_pwd2 = true;
-    signal_path_changed.emit();
+    emit_changed();
     SP_OBJECT(param_effect->getLPEObj())->requestModified(SP_OBJECT_MODIFIED_FLAG);
 }
 
@@ -382,14 +389,14 @@ PathParam::on_edit_button_click()
 void
 PathParam::paste_param_path(const char *svgd)
 {
-    if (svgd == "")
-        return;
-
-    // remove possible link to path
-    remove_link();
+    // only recognize a non-null, non-empty string
+    if (svgd && *svgd) {
+        // remove possible link to path
+        remove_link();
 
-    param_write_to_repr(svgd);
-    signal_path_pasted.emit();
+        param_write_to_repr(svgd);
+        signal_path_pasted.emit();
+    }
 }
 
 void
@@ -398,7 +405,7 @@ PathParam::on_paste_button_click()
     Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
     Glib::ustring svgd = cm->getPathParameter();
     paste_param_path(svgd.data());
-    sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, 
+    sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
                      _("Paste path parameter"));
 }
 
@@ -430,7 +437,7 @@ PathParam::on_link_button_click()
         // check if linking to object to which LPE is applied (maybe delegated to PathReference
 
         param_write_to_repr(pathid.c_str());
-        sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT, 
+        sp_document_done(param_effect->getSPDoc(), SP_VERB_DIALOG_LIVE_PATH_EFFECT,
                          _("Link path parameter to path"));
     }
 }