Code

Add checkbox for LPEs to temporarily disable them on canvas (but keep them applied...
authorcilix42 <cilix42@users.sourceforge.net>
Mon, 19 May 2008 17:02:06 +0000 (17:02 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Mon, 19 May 2008 17:02:06 +0000 (17:02 +0000)
src/live_effects/effect.cpp
src/live_effects/effect.h
src/object-edit.cpp
src/shape-editor.cpp
src/sp-lpe-item.cpp

index 2e33098d23fe276583e2b79c1b7d22a8b09a9b91..906955575599d13fac395f6764148d2b7d9cc9c8 100644 (file)
@@ -144,9 +144,11 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj)
 
 Effect::Effect(LivePathEffectObject *lpeobject)
     : oncanvasedit_it(0),
+      is_visible(_("Is visible?"), _("If unchecked, the effect remains applied to the object but is temporarily disabled on canvas"), "is_visible", &wr, this, true),
       lpeobj(lpeobject),
       concatenate_before_pwd2(false)
 {
+    registerParameter( dynamic_cast<Parameter *>(&is_visible) );
 }
 
 Effect::~Effect()
index ad2d5126f3d6addb4b5ae882942822f70b338cb1..1255595d0522fa8804cf9679f08a0c435c1af6cf 100644 (file)
@@ -18,6 +18,7 @@
 #include "util/enums.h"
 #include "sp-lpe-item.h"
 #include "knotholder.h"
+#include "parameter/bool.h"
 
 #define  LPE_CONVERSION_TOLERANCE 0.01    // FIXME: find good solution for this.
 
@@ -75,8 +76,6 @@ enum EffectType {
 extern const Util::EnumData<EffectType> LPETypeData[INVALID_LPE];
 extern const Util::EnumDataConverter<EffectType> LPETypeConverter;
 
-class Parameter;
-
 class Effect {
 public:
     static Effect* New(EffectType lpenr, LivePathEffectObject *lpeobj);
@@ -111,6 +110,8 @@ public:
     void readallParameters(Inkscape::XML::Node * repr);
     void setParameter(const gchar * key, const gchar * new_value);
 
+    inline bool isVisible() { return is_visible; }
+
     void editNextParamOncanvas(SPItem * item, SPDesktop * desktop);
 
 protected:
@@ -135,6 +136,8 @@ protected:
     std::vector<Parameter *> param_vector;
     std::vector<std::pair<SPKnotHolderSetFunc, SPKnotHolderGetFunc> > knotholder_func_vector;
     int oncanvasedit_it;
+    BoolParam is_visible;
+
     Inkscape::UI::Widget::Registry wr;
 
     LivePathEffectObject *lpeobj;
index 46ab877b6e2d39e71a10044c22c7bc90c525a1b1..091c997348abc04b930e8173ddd435b50037d93f 100644 (file)
@@ -73,6 +73,7 @@ SPKnotHolder *
 sp_item_knot_holder(SPItem *item, SPDesktop *desktop)
 {
     if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(item)) &&
+        sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item))->isVisible() &&
         sp_lpe_item_get_livepatheffect(SP_LPE_ITEM(item))->providesKnotholder()) {
         return sp_lpe_knot_holder(item, desktop);
     } else
index f0bec7ba91ac88529a56f2ff098dd740fdbc976e..40e92e0dd0033565fa7b314b5e1e6f2481348db7 100644 (file)
@@ -192,9 +192,10 @@ void ShapeEditor::set_item(SPItem *item) {
     if (item) {
         SPLPEItem *lpeitem = SP_LPE_ITEM(item);
         if (!sp_lpe_item_has_path_effect(lpeitem) ||
+            !sp_lpe_item_get_livepatheffect(lpeitem)->isVisible() ||
             !sp_lpe_item_get_livepatheffect(lpeitem)->providesKnotholder()) {
             // only create nodepath if the item either doesn't have an LPE
-            // or the LPE doesn't provide a knotholder itself
+            // or the LPE is invisible or it doesn't provide a knotholder itself
             this->nodepath =
                 sp_nodepath_new(desktop, item, (prefs_get_int_attribute("tools.nodes", "show_handles", 1) != 0));
         }
index 87e737435ead7e1fcec0e6a8acbbf6adf0e8aa59..f16b455ddf33fe3d8c1a4efb283aa5bef57e853b 100644 (file)
@@ -257,8 +257,10 @@ void sp_lpe_item_perform_path_effect(SPLPEItem *lpeitem, SPCurve *curve) {
 
     if (sp_lpe_item_has_path_effect(lpeitem)) {
         LivePathEffectObject *lpeobj = sp_lpe_item_get_livepatheffectobject(lpeitem);
-        lpeobj->lpe->doBeforeEffect(lpeitem);
-        lpeobj->lpe->doEffect(curve);
+        if (lpeobj->lpe->isVisible()) {
+            lpeobj->lpe->doBeforeEffect(lpeitem);
+            lpeobj->lpe->doEffect(curve);
+        }
     }
 
     SPObject *parent = lpeitem->parent;