X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Fsrc%2Fsynfig%2Flayer_composite.cpp;h=2dda09fcb5f33ee43442be28bd97f1893e41d6aa;hb=42e8f249832b9ca81691bbf76a6668aa4612117f;hp=24cae5246d6eea78191b156515dd262f63720919;hpb=e6b894ac0b503008a3e42049aed30d116db28630;p=synfig.git diff --git a/synfig-core/src/synfig/layer_composite.cpp b/synfig-core/src/synfig/layer_composite.cpp index 24cae52..2dda09f 100644 --- a/synfig-core/src/synfig/layer_composite.cpp +++ b/synfig-core/src/synfig/layer_composite.cpp @@ -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,11 +152,13 @@ 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")) + .set_description(_("Alpha channel of the layer")) ); - ret.push_back(ParamDesc(blend_method_,"blend_method") + ret.push_back(ParamDesc(blend_method,"blend_method") .set_local_name(_("Blend Method")) + .set_description(_("The blending method used to composite on the layers below")) ); return ret; @@ -156,21 +167,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_)) - amount_=value.get(amount_); + if(param=="amount" && value.same_type_as(amount)) + { + 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(value.get(int())); + blend_method = static_cast(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) @@ -184,7 +199,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 @@ -210,47 +225,16 @@ 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(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 //! to see if it can handle that parameter's string. return Layer::get_param(param); } - -bool -Layer_Composite::set_param_static(const String ¶m, const bool x) -{ - if(param=="amount" && amount_static!=x) - { - amount_static=x; - return true; - } - if(param=="blend_method" && blend_method_static!=x) - { - blend_method_static=x; - return true; - } - - return Layer::set_param_static(param, x); -} - - -bool -Layer_Composite::get_param_static(const String ¶m) const -{ - - if(param=="amount") - return amount_static; - - if(param=="blend_method") - return blend_method_static; - - return Layer::get_param_static(param); -}