diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2014-06-16 21:39:13 +0000 |
|---|---|---|
| committer | Johan B. C. Engelen <j.b.c.engelen@alumnus.utwente.nl> | 2014-06-16 21:39:13 +0000 |
| commit | b472007094a3724bef949ac45a6294d0e9cb8a01 (patch) | |
| tree | 4d78c464df6757aed1c43f627c6ef48fb304cc40 /src | |
| parent | fixes to LPEKnot, now usable again. (diff) | |
| download | inkscape-b472007094a3724bef949ac45a6294d0e9cb8a01.tar.gz inkscape-b472007094a3724bef949ac45a6294d0e9cb8a01.zip | |
LPEItem enabling/disabling: rewrite mechanism to be more robust. the previous nesting behavior was not used, and code relied on non-nesting behavior.
(bzr r13429)
Diffstat (limited to 'src')
| -rw-r--r-- | src/sp-lpe-item.cpp | 28 | ||||
| -rw-r--r-- | src/sp-lpe-item.h | 11 |
2 files changed, 11 insertions, 28 deletions
diff --git a/src/sp-lpe-item.cpp b/src/sp-lpe-item.cpp index bfecdcf98..ad0902967 100644 --- a/src/sp-lpe-item.cpp +++ b/src/sp-lpe-item.cpp @@ -50,8 +50,6 @@ #include <algorithm> /* LPEItem base class */ -static void sp_lpe_item_enable_path_effects(SPLPEItem *lpeitem, bool enable); - static void lpeobject_ref_modified(SPObject *href, guint flags, SPLPEItem *lpeitem); static void sp_lpe_item_create_original_path_recursive(SPLPEItem *lpeitem); @@ -115,7 +113,7 @@ void SPLPEItem::set(unsigned int key, gchar const* value) { this->current_path_effect = NULL; // Disable the path effects while populating the LPE list - sp_lpe_item_enable_path_effects(this, false); + enablePathEffects(false); // disconnect all modified listeners: for ( std::list<sigc::connection>::iterator mod_it = this->lpe_modified_connection_list->begin(); @@ -168,7 +166,7 @@ void SPLPEItem::set(unsigned int key, gchar const* value) { } } - sp_lpe_item_enable_path_effects(this, true); + enablePathEffects(true); } break; @@ -409,7 +407,7 @@ void SPLPEItem::addPathEffect(gchar *value, bool reset) sp_lpe_item_update_patheffect(this, false, true); // Disable the path effects while preparing the new lpe - sp_lpe_item_enable_path_effects(this, false); + enablePathEffects(false); // Add the new reference to the list of LPE references HRefList hreflist; @@ -446,7 +444,7 @@ void SPLPEItem::addPathEffect(gchar *value, bool reset) } //Enable the path effects now that everything is ready to apply the new path effect - sp_lpe_item_enable_path_effects(this, true); + enablePathEffects(true); // Apply the path effect sp_lpe_item_update_patheffect(this, true, true); @@ -942,24 +940,6 @@ bool SPLPEItem::forkPathEffectsIfNecessary(unsigned int nr_of_allowed_users) return forked; } -// Enable or disable the path effects of the item. -// The counter allows nested calls -static void sp_lpe_item_enable_path_effects(SPLPEItem *lpeitem, bool enable) -{ - if (enable) { - lpeitem->path_effects_enabled++; - } - else { - lpeitem->path_effects_enabled--; - } -} - -// Are the path effects enabled on this item ? -bool SPLPEItem::pathEffectsEnabled() const -{ - return path_effects_enabled > 0; -} - /* Local Variables: mode:c++ diff --git a/src/sp-lpe-item.h b/src/sp-lpe-item.h index 5a38fdd0b..da77ba2ca 100644 --- a/src/sp-lpe-item.h +++ b/src/sp-lpe-item.h @@ -39,11 +39,13 @@ namespace LivePathEffect{ typedef std::list<Inkscape::LivePathEffect::LPEObjectReference *> PathEffectList; class SPLPEItem : public SPItem { +private: + mutable bool path_effects_enabled; // (mutable because preserves logical const-ness) + public: - SPLPEItem(); - virtual ~SPLPEItem(); + SPLPEItem(); + virtual ~SPLPEItem(); - int path_effects_enabled; PathEffectList* path_effect_list; std::list<sigc::connection> *lpe_modified_connection_list; // this list contains the connections for listening to lpeobject parameter changes @@ -72,7 +74,8 @@ public: bool performPathEffect(SPCurve *curve); - bool pathEffectsEnabled() const; + void enablePathEffects(bool enable) const { path_effects_enabled = enable; }; // (const because logically const) + bool pathEffectsEnabled() const { return path_effects_enabled; }; bool hasPathEffect() const; bool hasPathEffectOfType(int const type) const; bool hasPathEffectRecursive() const; |
