Code

Activate automatic knotholders for LPE PointParams
authorcilix42 <cilix42@users.sourceforge.net>
Mon, 16 Jun 2008 16:17:27 +0000 (16:17 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Mon, 16 Jun 2008 16:17:27 +0000 (16:17 +0000)
src/live_effects/effect.cpp
src/live_effects/effect.h
src/live_effects/parameter/point.cpp
src/object-edit.cpp

index 164447387a2a80c3989419dc4eb961b089a3b3e1..7e56023a617ddd8f3e197a48633c8917ad9a12ba 100644 (file)
@@ -569,6 +569,23 @@ Effect::transform_multiply(Geom::Matrix const& postmul, bool set)
     }
 }
 
+bool
+Effect::providesKnotholder()
+{
+    // does the effect actively provide any knotholder entities of its own?
+    if (kh_entity_vector.size() > 0)
+        return true;
+
+    // otherwise: are there any PointParams?
+    for (std::vector<Parameter *>::iterator p = param_vector.begin(); p != param_vector.end(); ++p) {
+        if ((*p)->paramType() == Inkscape::LivePathEffect::POINT_PARAM) {
+            return true;
+        }
+    }
+
+    return false;
+}
+
 } /* namespace LivePathEffect */
 
 } /* namespace Inkscape */
index 6eeff94c4e4cccece6a4d42f8f30987cd7485a32..54dcf0c8cdd061cfd44ed47378324e064c6a7be8 100644 (file)
@@ -120,11 +120,12 @@ public:
 
     // TODO: providesKnotholder() is currently used as an indicator of whether a nodepath is
     // created for an item or not. When we allow both at the same time, this needs rethinking!
-    bool providesKnotholder() { return (kh_entity_vector.size() > 0); }
+    bool providesKnotholder();
     // TODO: in view of providesOwnFlashPaths() below, this is somewhat redundant
     //       (but spiro lpe still needs it!)
     virtual LPEPathFlashType pathFlashType() { return DEFAULT; }
     void addHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
+    void addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
 
     void addHelperPaths(SPLPEItem *lpeitem, SPDesktop *desktop);
     inline bool providesOwnFlashPaths() {
@@ -160,7 +161,6 @@ protected:
 
     void registerParameter(Parameter * param);
     void registerKnotHolderHandle(KnotHolderEntity* entity, const char* descr);
-    void addPointParamHandles(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
     Parameter * getNextOncanvasEditableParam();
 
     virtual void addHelperPathsImpl(SPLPEItem *lpeitem, SPDesktop *desktop);
index 502af1f231cfd4cf806d4c13c69f37a0556548d0..be8415d8d576a0b29b1f61a31bc30ffdff3476b7 100644 (file)
@@ -100,7 +100,6 @@ PointParam::param_newWidget(Gtk::Tooltips * tooltips)
     pIcon->show();
     pButton->add(*pIcon);
     pButton->show();
-    pButton->signal_clicked().connect(sigc::mem_fun(*this, &PointParam::on_button_click));
 
     Gtk::HBox * hbox = Gtk::manage( new Gtk::HBox() );
     static_cast<Gtk::HBox*>(hbox)->pack_start(*pButton, true, true);
@@ -165,35 +164,20 @@ PointParam::set_oncanvas_looks(SPKnotShapeType shape, SPKnotModeType mode, guint
 void
 PointParam::knot_set(NR::Point const &p, NR::Point const &origin, guint state)
 {
-    g_print ("PointParam::knot_set() was called!\n");
     param_setValue(p.to_2geom());
+    sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
 }
 
 NR::Point
 PointParam::knot_get()
 {
-    g_print ("PointParam::knot_get() was called.\n");
-    g_print ("We return (%f, %f)\n", (*this)[0], (*this)[1]);
     return *this;
 }
 
 void
 PointParam::knot_click(guint state)
 {
-    g_print ("PointParam::knot_click() was called!\n");
-}
-
-// CALLBACKS:
-
-void
-PointParam::on_button_click()
-{
-    g_print ("PointParam::on_button_click()\n");
-    SPDesktop *desktop = SP_ACTIVE_DESKTOP;
-    SPItem * item = sp_desktop_selection(desktop)->singleItem();
-    if (item != NULL) {
-        param_editOncanvas(item, desktop);
-    }
+    g_print ("This is the handle associated to the parameter '%s'\n", param_key.c_str());
 }
 
 } /* namespace LivePathEffect */
index 94c3c5daf4069487b1cfc9cda1345eef0651ffbe..8f9bf378c706353ed5ee15ad77f739b88f977329 100644 (file)
@@ -56,7 +56,7 @@ static KnotHolder *sp_lpe_knot_holder(SPItem *item, SPDesktop *desktop)
     KnotHolder *knot_holder = new KnotHolder(desktop, item, NULL);
 
     Inkscape::LivePathEffect::Effect *effect = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
-//    effect->addPointParamHandles(knot_holder, desktop, item);
+    effect->addPointParamHandles(knot_holder, desktop, item);
     effect->addHandles(knot_holder, desktop, item);
 
     return knot_holder;