Use new method for static options in Layer Composite
authorCarlos Lopez <genetita@gmail.com>
Sat, 28 Aug 2010 08:44:33 +0000 (10:44 +0200)
committerCarlos Lopez <genetita@gmail.com>
Sat, 28 Aug 2010 08:44:33 +0000 (10:44 +0200)
synfig-core/src/synfig/layer_composite.cpp
synfig-core/src/synfig/layer_composite.h

index 7b9e0bf..2e9daeb 100644 (file)
@@ -59,13 +59,22 @@ using namespace synfig;
 /* === P R O C E D U R E S ================================================= */
 
 /* === M E T H O D S ======================================================= */
+Layer_Composite::Layer_Composite(float         a, Color::BlendMethod   bm):
+               amount                          (a),
+               blend_method            (bm),
+               converted_blend_        (false),
+               transparent_color_      (false)
+       {
+               Layer::Vocab voc(get_param_vocab());
+               Layer::fill_static(voc);
+       }
 
 bool
 Layer_Composite::accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc_, ProgressCallback *cb)  const
 {
        RendDesc renddesc(renddesc_);
 
-       if(!amount_)
+       if(!amount)
                return context.accelerated_render(surface,quality,renddesc,cb);
 
        CanvasBase image;
@@ -143,10 +152,10 @@ Layer_Composite::get_param_vocab()const
        //! First fills the returning vocabulary with the ancestor class
        Layer::Vocab ret(Layer::get_param_vocab());
        //! Now inserts the two parameters that this layer knows.
-       ret.push_back(ParamDesc(amount_,"amount")
+       ret.push_back(ParamDesc(amount,"amount")
                .set_local_name(_("Amount"))
        );
-       ret.push_back(ParamDesc(blend_method_,"blend_method")
+       ret.push_back(ParamDesc(blend_method,"blend_method")
                .set_local_name(_("Blend Method"))
        );
 
@@ -156,25 +165,25 @@ Layer_Composite::get_param_vocab()const
 bool
 Layer_Composite::set_param(const String & param, const ValueBase &value)
 {
-       if(param=="amount" && value.same_type_as(amount_))
+       if(param=="amount" && value.same_type_as(amount))
        {
-               amount_=value.get(amount_);
-               amount_static=value.get_static();
+               amount=value.get(amount);
+               set_param_static(param,value.get_static());
        }
        else
        if(param=="blend_method" && value.same_type_as(int()))
        {
-               blend_method_ = static_cast<Color::BlendMethod>(value.get(int()));
-               blend_method_static=value.get_static();
+               blend_method = static_cast<Color::BlendMethod>(value.get(int()));
+               set_param_static(param,value.get_static());
 
-               if (blend_method_ < 0 || blend_method_ >= Color::BLEND_END)
+               if (blend_method < 0 || blend_method >= Color::BLEND_END)
                {
-                       warning("illegal value (%d) for blend_method - using Composite instead", blend_method_);
-                       blend_method_ = Color::BLEND_COMPOSITE;
+                       warning("illegal value (%d) for blend_method - using Composite instead", blend_method);
+                       blend_method = Color::BLEND_COMPOSITE;
                        return false;
                }
 
-               if (blend_method_ == Color::BLEND_STRAIGHT && !reads_context())
+               if (blend_method == Color::BLEND_STRAIGHT && !reads_context())
                {
                        Canvas::Handle canvas(get_canvas());
                        if (canvas)
@@ -188,7 +197,7 @@ Layer_Composite::set_param(const String & param, const ValueBase &value)
                                                                version.c_str(), get_non_empty_description().c_str());
                                        else
                                        {
-                                               blend_method_ = Color::BLEND_COMPOSITE;
+                                               blend_method = Color::BLEND_COMPOSITE;
                                                converted_blend_ = true;
 
                                                // if this layer has a transparent color, go back and set the color again
@@ -214,13 +223,13 @@ Layer_Composite::get_param(const String & param)const
        if(param=="amount")
        {
                synfig::ValueBase ret(get_amount());
-               ret.set_static(amount_static);
+               ret.set_static(get_param_static(param));
                return ret;
        }
        if(param=="blend_method")
        {
                synfig::ValueBase ret(static_cast<int>(get_blend_method()));
-               ret.set_static(blend_method_static);
+               ret.set_static(get_param_static(param));
                return ret;
        }
        //! If it is unknown then call the ancestor's get param member
@@ -232,8 +241,8 @@ bool
 Layer_Composite::set_param_static(const String &param, const bool x)
 {
 
-       SET_STATIC(amount, x)
-       SET_STATIC(blend_method, x)
+       //SET_STATIC(amount, x)
+       //SET_STATIC(blend_method, x)
 
        return Layer::set_param_static(param, x);
 }
@@ -243,8 +252,8 @@ bool
 Layer_Composite::get_param_static(const String &param) const
 {
 
-       GET_STATIC(amount);
-       GET_STATIC(blend_method);
+       //GET_STATIC(amount);
+       //GET_STATIC(blend_method);
 
        return Layer::get_param_static(param);
 }
index 7c94811..b173cfd 100644 (file)
@@ -49,25 +49,14 @@ class Layer_Composite : public Layer
 {
 private:
        //! The amount of composite
-       float amount_;
+       float amount;
        //! The blend method for the composition
-       Color::BlendMethod blend_method_;
-       bool amount_static;
-       bool blend_method_static;
+       Color::BlendMethod blend_method;
 
 protected:
        //! Default constructor. Not used directly.
-       Layer_Composite(
-               float   amount=1.0,
-               Color::BlendMethod      blend_method=Color::BLEND_COMPOSITE
-       ):
-               amount_                         (amount),
-               blend_method_           (blend_method),
-               converted_blend_        (false),
-               transparent_color_      (false),
-               amount_static           (false),
-               blend_method_static     (true)
-       { }
+       Layer_Composite(float amount=1.0, Color::BlendMethod blend_method=Color::BLEND_COMPOSITE);
+
        //! Converted blend is used to check if an old version of canvas
        //! is used in the composition. Old Straight was used as new Composite
        //! \todo verify this
@@ -78,17 +67,17 @@ protected:
 
 public:
        //! Gets the amount of the layer
-       float get_amount()const { return amount_; }
+       float get_amount()const { return amount; }
        //! Sets the amount of the layer and returns this layer
-       Layer_Composite& set_amount(float x) { amount_=x; return *this; }
+       Layer_Composite& set_amount(float x) { amount=x; return *this; }
        //! Gets the blend method of the layer
-       Color::BlendMethod get_blend_method()const { return blend_method_; }
+       Color::BlendMethod get_blend_method()const { return blend_method; }
        //! Sets the blend method of the layer and returns this layer
-       Layer_Composite& set_blend_method(Color::BlendMethod x) { blend_method_=x; return *this; }
+       Layer_Composite& set_blend_method(Color::BlendMethod x) { blend_method=x; return *this; }
        //! Returns true is amount is 1 and blend method is straight
-       virtual bool is_solid_color()const { return amount_==1.0f && blend_method_==Color::BLEND_STRAIGHT; }
+       virtual bool is_solid_color()const { return amount==1.0f && blend_method==Color::BLEND_STRAIGHT; }
        //! Returns true if the amount is zero.
-       bool is_disabled()const { return amount_==0.0f; }
+       bool is_disabled()const { return amount==0.0f; }
        //! Gets the parameter vocabulary. To be overrided by the derived.
        virtual Vocab get_param_vocab()const;
        //! Sets the value for the given parameter.