Suit a better way to set/get static parameter option and to fill the static option.
authorCarlos Lopez <genetita@gmail.com>
Sat, 28 Aug 2010 08:44:06 +0000 (10:44 +0200)
committerCarlos Lopez <genetita@gmail.com>
Sat, 28 Aug 2010 08:44:06 +0000 (10:44 +0200)
synfig-core/src/synfig/layer.cpp
synfig-core/src/synfig/layer.h

index 0485b34..3569a5a 100644 (file)
@@ -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 &param, const ValueBase &value)
 bool
 Layer::set_param_static(const String &param, 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 &param) 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 &param) const
+{
 
+       Sparams::const_iterator iter=static_params.find(param);
+       if(iter!=static_params.end())
+               return iter->second;
        return false;
 }
 
index 19faddb..46657f0 100644 (file)
@@ -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<String, bool> Sparams;
        Sparams static_params;
 
@@ -472,6 +471,7 @@ public:
 
        virtual bool set_param_static(const String &param, const bool x);
        virtual bool get_param_static(const String &param) const;
+       virtual void fill_static(Vocab vocab);
 
        //!     Sets a list of parameters
        virtual bool set_param_list(const ParamList &);