From: Carlos Lopez Date: Sat, 28 Aug 2010 08:44:06 +0000 (+0200) Subject: Suit a better way to set/get static parameter option and to fill the static option. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=b56b3e2d45cf281bb0c537f40ab43c908048df01;p=synfig.git Suit a better way to set/get static parameter option and to fill the static option. --- diff --git a/synfig-core/src/synfig/layer.cpp b/synfig-core/src/synfig/layer.cpp index 0485b34..3569a5a 100644 --- a/synfig-core/src/synfig/layer.cpp +++ b/synfig-core/src/synfig/layer.cpp @@ -141,11 +141,7 @@ Layer::Layer(): { _LayerCounter::counter++; Vocab vocab=get_param_vocab(); - Vocab::const_iterator viter; - for(viter=vocab.begin();viter!=vocab.end();viter++) - { - static_params.insert(make_pair(viter->get_name(),false)); - } + fill_static(vocab); } Layer::LooseHandle @@ -306,37 +302,34 @@ Layer::set_param(const String ¶m, const ValueBase &value) bool Layer::set_param_static(const String ¶m, const bool x) { - Sparams::iterator iter; - - for(iter=static_params.begin();iter!=static_params.end();iter++) + Sparams::iterator iter=static_params.find(param); + if(iter!=static_params.end()) { - if(iter->first == param) - { - iter->second = x; - return true; - } + iter->second=x; + return true; } - //SET_STATIC(z_depth,x) - return false; } -bool -Layer::get_param_static(const String ¶m) const +void Layer::fill_static(Vocab vocab) { - - Sparams::const_iterator iter; - - for(iter=static_params.begin();iter!=static_params.end();iter++) + Vocab::const_iterator viter; + for(viter=vocab.begin();viter!=vocab.end();viter++) { - if(iter->first == param) - { - return iter->second; - } + if(static_params.find(viter->get_name())==static_params.end()) + static_params.insert(make_pair(viter->get_name(),false)); } - //GET_STATIC(z_depth); +} + + +bool +Layer::get_param_static(const String ¶m) const +{ + Sparams::const_iterator iter=static_params.find(param); + if(iter!=static_params.end()) + return iter->second; return false; } diff --git a/synfig-core/src/synfig/layer.h b/synfig-core/src/synfig/layer.h index 19faddb..46657f0 100644 --- a/synfig-core/src/synfig/layer.h +++ b/synfig-core/src/synfig/layer.h @@ -273,7 +273,6 @@ private: float z_depth; //! True if zdepth is not affected when in animation mode - //bool z_depth_static; typedef std::map Sparams; Sparams static_params; @@ -472,6 +471,7 @@ public: virtual bool set_param_static(const String ¶m, const bool x); virtual bool get_param_static(const String ¶m) const; + virtual void fill_static(Vocab vocab); //! Sets a list of parameters virtual bool set_param_list(const ParamList &);