Use a map of static values instead of hard coded names.
[synfig.git] / synfig-core / src / synfig / layer.cpp
index 2a5a90b..0485b34 100644 (file)
@@ -135,11 +135,17 @@ Layer::subsys_stop()
 
 Layer::Layer():
        active_(true),
-       z_depth_(0.0f),
-       dirty_time_(Time::end()),
-       z_depth_static(false)
+       z_depth(0.0f),
+       dirty_time_(Time::end())//,
+       //z_depth_static(false)
 {
        _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));
+       }
 }
 
 Layer::LooseHandle
@@ -293,21 +299,24 @@ Layer::on_changed()
 bool
 Layer::set_param(const String &param, const ValueBase &value)
 {
-/*     if(param=="z_depth" && value.same_type_as(z_depth_))
-       {
-               z_depth_=value.get(z_depth_);
-               set_param_static(param, value.get_static());
-               return true;
-       }
-       */
-       IMPORT_AS(z_depth_,"z_depth")
+       IMPORT(z_depth)
        return false;
 }
 
 bool
 Layer::set_param_static(const String &param, const bool x)
 {
-       SET_STATIC(z_depth,x)
+       Sparams::iterator iter;
+
+       for(iter=static_params.begin();iter!=static_params.end();iter++)
+       {
+               if(iter->first == param)
+               {
+                       iter->second = x;
+                       return true;
+               }
+       }
+       //SET_STATIC(z_depth,x)
 
        return false;
 }
@@ -316,7 +325,17 @@ Layer::set_param_static(const String &param, const bool x)
 bool
 Layer::get_param_static(const String &param) const
 {
-       GET_STATIC(z_depth);
+
+       Sparams::const_iterator iter;
+
+       for(iter=static_params.begin();iter!=static_params.end();iter++)
+       {
+               if(iter->first == param)
+               {
+                       return iter->second;
+               }
+       }
+       //GET_STATIC(z_depth);
 
        return false;
 }
@@ -332,7 +351,7 @@ float
 Layer::get_z_depth(const synfig::Time& t)const
 {
        if(!dynamic_param_list().count("z_depth"))
-               return z_depth_;
+               return z_depth;
        return (*dynamic_param_list().find("z_depth")->second)(t).get(Real());
 }
 
@@ -473,7 +492,7 @@ Layer::get_param(const String & param)const
        if(param=="z_depth")
        {
                synfig::ValueBase ret(get_z_depth());
-               ret.set_static(z_depth_static);
+               ret.set_static(get_param_static(param));
                return ret;
        }
        return ValueBase();
@@ -569,7 +588,7 @@ Layer::get_param_vocab()const
 {
        Layer::Vocab ret;
 
-       ret.push_back(ParamDesc(z_depth_,"z_depth")
+       ret.push_back(ParamDesc(z_depth,"z_depth")
                .set_local_name(_("Z Depth"))
                .set_animation_only(true)
        );