/* === 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;
//! 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"))
);
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)
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
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
Layer_Composite::set_param_static(const String ¶m, 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);
}
Layer_Composite::get_param_static(const String ¶m) const
{
- GET_STATIC(amount);
- GET_STATIC(blend_method);
+ //GET_STATIC(amount);
+ //GET_STATIC(blend_method);
return Layer::get_param_static(param);
}
{
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
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.