From: Carlos Lopez Date: Sun, 8 Aug 2010 10:17:02 +0000 (+0200) Subject: Add "By Layer Default" blend method to the Toolbox Defaults widget. X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=34661891b55d1b54f96955755b4cbd099039acc9;p=synfig.git Add "By Layer Default" blend method to the Toolbox Defaults widget. It allows the user let the layer itself use the blend method defined by the layer by default. For example, blur layer uses Straight blend method by default and Bevel uses Onto. The default blend methods by layer can be discussed or changed later. --- diff --git a/synfig-core/src/modules/lyr_std/xorpattern.cpp b/synfig-core/src/modules/lyr_std/xorpattern.cpp index df7c6bd..4d2a394 100644 --- a/synfig-core/src/modules/lyr_std/xorpattern.cpp +++ b/synfig-core/src/modules/lyr_std/xorpattern.cpp @@ -61,7 +61,7 @@ SYNFIG_LAYER_SET_CVS_ID(XORPattern,"$Id$"); /* === M E T H O D S ======================================================= */ XORPattern::XORPattern(): - Layer_Composite (1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), origin(0.125,0.125), size(0.25,0.25) { diff --git a/synfig-core/src/modules/mod_example/filledrect.cpp b/synfig-core/src/modules/mod_example/filledrect.cpp index 329012f..663c0db 100644 --- a/synfig-core/src/modules/mod_example/filledrect.cpp +++ b/synfig-core/src/modules/mod_example/filledrect.cpp @@ -66,7 +66,7 @@ SYNFIG_LAYER_SET_CVS_ID(FilledRect,"$Id$"); /* === E N T R Y P O I N T ================================================= */ FilledRect::FilledRect(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), color(Color::black()), point1(0,0), point2(1,1), diff --git a/synfig-core/src/modules/mod_example/metaballs.cpp b/synfig-core/src/modules/mod_example/metaballs.cpp index 0cfa6c3..0fe6d5d 100644 --- a/synfig-core/src/modules/mod_example/metaballs.cpp +++ b/synfig-core/src/modules/mod_example/metaballs.cpp @@ -65,7 +65,7 @@ SYNFIG_LAYER_SET_CVS_ID(Metaballs,"$Id$"); /* === E N T R Y P O I N T ================================================= */ Metaballs::Metaballs(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), gradient(Color::black(), Color::white()), threshold(0), threshold2(1), diff --git a/synfig-core/src/modules/mod_example/simplecircle.cpp b/synfig-core/src/modules/mod_example/simplecircle.cpp index e2eb896..f6fc8ef 100644 --- a/synfig-core/src/modules/mod_example/simplecircle.cpp +++ b/synfig-core/src/modules/mod_example/simplecircle.cpp @@ -65,7 +65,7 @@ SYNFIG_LAYER_SET_CVS_ID(SimpleCircle,"$Id$"); /* === E N T R Y P O I N T ================================================= */ SimpleCircle::SimpleCircle(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), color(Color::black()), center(0,0), radius(0.5) diff --git a/synfig-core/src/modules/mod_filter/blur.cpp b/synfig-core/src/modules/mod_filter/blur.cpp index e5104b0..f3af3ea 100644 --- a/synfig-core/src/modules/mod_filter/blur.cpp +++ b/synfig-core/src/modules/mod_filter/blur.cpp @@ -78,7 +78,7 @@ inline void clamp(synfig::Vector &v) } Blur_Layer::Blur_Layer(): - Layer_Composite (1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_STRAIGHT), size(0.1,0.1), type(Blur::FASTGAUSSIAN) { diff --git a/synfig-core/src/modules/mod_filter/radialblur.cpp b/synfig-core/src/modules/mod_filter/radialblur.cpp index 6ecc5bb..2d018a6 100644 --- a/synfig-core/src/modules/mod_filter/radialblur.cpp +++ b/synfig-core/src/modules/mod_filter/radialblur.cpp @@ -64,6 +64,7 @@ SYNFIG_LAYER_SET_CVS_ID(RadialBlur,"$Id$"); /* === E N T R Y P O I N T ================================================= */ RadialBlur::RadialBlur(): + Layer_Composite(1.0,Color::BLEND_STRAIGHT), origin (0,0), size (0.2), fade_out(false) diff --git a/synfig-core/src/modules/mod_geometry/checkerboard.cpp b/synfig-core/src/modules/mod_geometry/checkerboard.cpp index 30bbf8e..d195bc0 100644 --- a/synfig-core/src/modules/mod_geometry/checkerboard.cpp +++ b/synfig-core/src/modules/mod_geometry/checkerboard.cpp @@ -64,14 +64,11 @@ SYNFIG_LAYER_SET_CVS_ID(CheckerBoard,"$Id$"); /* === M E T H O D S ======================================================= */ CheckerBoard::CheckerBoard(): - Layer_Composite (1.0,Color::BLEND_STRAIGHT), + Layer_Composite (1.0,Color::BLEND_COMPOSITE), color (Color::black()), origin (Point(0.125,0.125)), size (Point(0.25,0.25)) -{ - - set_blend_method(Color::BLEND_STRAIGHT); -} +{} inline bool CheckerBoard::point_test(const synfig::Point& getpos)const diff --git a/synfig-core/src/modules/mod_geometry/circle.cpp b/synfig-core/src/modules/mod_geometry/circle.cpp index f5ad99b..d8f51a7 100644 --- a/synfig-core/src/modules/mod_geometry/circle.cpp +++ b/synfig-core/src/modules/mod_geometry/circle.cpp @@ -60,7 +60,7 @@ SYNFIG_LAYER_SET_CVS_ID(Circle,"$Id$"); /* -- F U N C T I O N S ----------------------------------------------------- */ Circle::Circle(): - Layer_Composite (1.0,Color::BLEND_STRAIGHT), + Layer_Composite (1.0,Color::BLEND_COMPOSITE), color (Color::black()), origin (0,0), radius (1), diff --git a/synfig-core/src/modules/mod_geometry/rectangle.cpp b/synfig-core/src/modules/mod_geometry/rectangle.cpp index 374af9c..ef096f7 100644 --- a/synfig-core/src/modules/mod_geometry/rectangle.cpp +++ b/synfig-core/src/modules/mod_geometry/rectangle.cpp @@ -75,7 +75,7 @@ inline int floor_to_int(const double x) { return static_cast(floor(x)); } /* === E N T R Y P O I N T ================================================= */ Rectangle::Rectangle(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), color(Color::black()), point1(0,0), point2(1,1), diff --git a/synfig-core/src/modules/mod_gradient/conicalgradient.cpp b/synfig-core/src/modules/mod_gradient/conicalgradient.cpp index 5bf42a9..7657e4c 100644 --- a/synfig-core/src/modules/mod_gradient/conicalgradient.cpp +++ b/synfig-core/src/modules/mod_gradient/conicalgradient.cpp @@ -65,7 +65,7 @@ SYNFIG_LAYER_SET_CVS_ID(ConicalGradient,"$Id$"); /* === E N T R Y P O I N T ================================================= */ ConicalGradient::ConicalGradient(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), gradient(Color::black(),Color::white()), center(0,0), angle(Angle::zero()), diff --git a/synfig-core/src/modules/mod_gradient/curvegradient.cpp b/synfig-core/src/modules/mod_gradient/curvegradient.cpp index 4fa704e..1d7eb89 100644 --- a/synfig-core/src/modules/mod_gradient/curvegradient.cpp +++ b/synfig-core/src/modules/mod_gradient/curvegradient.cpp @@ -205,6 +205,7 @@ CurveGradient::sync() CurveGradient::CurveGradient(): + Layer_Composite(1.0,Color::BLEND_COMPOSITE), origin(0,0), width(0.25), gradient(Color::black(), Color::white()), diff --git a/synfig-core/src/modules/mod_gradient/lineargradient.cpp b/synfig-core/src/modules/mod_gradient/lineargradient.cpp index be7155a..19b1299 100644 --- a/synfig-core/src/modules/mod_gradient/lineargradient.cpp +++ b/synfig-core/src/modules/mod_gradient/lineargradient.cpp @@ -69,6 +69,7 @@ LinearGradient::sync() LinearGradient::LinearGradient(): + Layer_Composite(1.0,Color::BLEND_COMPOSITE), p1(1,1), p2(-1,-1), gradient(Color::black(), Color::white()), diff --git a/synfig-core/src/modules/mod_gradient/radialgradient.cpp b/synfig-core/src/modules/mod_gradient/radialgradient.cpp index 5c3d20b..e991200 100644 --- a/synfig-core/src/modules/mod_gradient/radialgradient.cpp +++ b/synfig-core/src/modules/mod_gradient/radialgradient.cpp @@ -65,7 +65,7 @@ SYNFIG_LAYER_SET_CVS_ID(RadialGradient,"$Id$"); /* === E N T R Y P O I N T ================================================= */ RadialGradient::RadialGradient(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), gradient(Color::black(),Color::white()), center(0,0), radius(0.5), diff --git a/synfig-core/src/modules/mod_gradient/spiralgradient.cpp b/synfig-core/src/modules/mod_gradient/spiralgradient.cpp index 81bd99d..ac751c4 100644 --- a/synfig-core/src/modules/mod_gradient/spiralgradient.cpp +++ b/synfig-core/src/modules/mod_gradient/spiralgradient.cpp @@ -64,7 +64,7 @@ SYNFIG_LAYER_SET_CVS_ID(SpiralGradient,"$Id$"); /* === E N T R Y P O I N T ================================================= */ SpiralGradient::SpiralGradient(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), gradient(Color::black(),Color::white()), center(0,0), radius(0.5), diff --git a/synfig-core/src/modules/mod_noise/noise.cpp b/synfig-core/src/modules/mod_noise/noise.cpp index 4257a6c..61550f4 100644 --- a/synfig-core/src/modules/mod_noise/noise.cpp +++ b/synfig-core/src/modules/mod_noise/noise.cpp @@ -63,6 +63,7 @@ SYNFIG_LAYER_SET_CVS_ID(Noise,"$Id$"); /* === M E T H O D S ======================================================= */ Noise::Noise(): + Layer_Composite(1.0,Color::BLEND_COMPOSITE), size(1,1), gradient(Color::black(), Color::white()) { diff --git a/synfig-core/src/synfig/color.h b/synfig-core/src/synfig/color.h index d54b0e9..e2499f7 100644 --- a/synfig-core/src/synfig/color.h +++ b/synfig-core/src/synfig/color.h @@ -498,7 +498,9 @@ public: BLEND_ALPHA_DARKEN=15, //!< \deprecated If A is more opaque than B, use B BLEND_ALPHA_OVER=19, //!< \deprecated multiply alphas and then straight blends using the amount - BLEND_END=22 //!< \internal + BLEND_END=22, //!< \internal + BLEND_BY_LAYER=999 //! Used to let the layer decides what Blend Method use by + //! default when the layer is created }; /* Other */ diff --git a/synfig-core/src/synfig/layer_polygon.cpp b/synfig-core/src/synfig/layer_polygon.cpp index 46efffd..299bbbf 100644 --- a/synfig-core/src/synfig/layer_polygon.cpp +++ b/synfig-core/src/synfig/layer_polygon.cpp @@ -67,8 +67,8 @@ SYNFIG_LAYER_SET_CVS_ID(Layer_Polygon,"$Id$"); /* === M E T H O D S ======================================================= */ Layer_Polygon::Layer_Polygon(): - Layer_Shape (1.0,Color::BLEND_COMPOSITE), - vector_list (0) + Layer_Shape(1.0,Color::BLEND_COMPOSITE), + vector_list(0) { vector_list.push_back(Point(0,0.5)); vector_list.push_back(Point(-0.333333,0)); diff --git a/synfig-core/src/synfig/layer_solidcolor.cpp b/synfig-core/src/synfig/layer_solidcolor.cpp index 0b520ad..9b9c2b7 100644 --- a/synfig-core/src/synfig/layer_solidcolor.cpp +++ b/synfig-core/src/synfig/layer_solidcolor.cpp @@ -64,7 +64,7 @@ SYNFIG_LAYER_SET_CVS_ID(Layer_SolidColor,"$Id$"); /* === E N T R Y P O I N T ================================================= */ Layer_SolidColor::Layer_SolidColor(): - Layer_Composite(1.0,Color::BLEND_STRAIGHT), + Layer_Composite(1.0,Color::BLEND_COMPOSITE), color(Color::black()) { } diff --git a/synfig-studio/src/gui/widgets/widget_defaults.cpp b/synfig-studio/src/gui/widgets/widget_defaults.cpp index f9d3fbc..48d7691 100644 --- a/synfig-studio/src/gui/widgets/widget_defaults.cpp +++ b/synfig-studio/src/gui/widgets/widget_defaults.cpp @@ -279,7 +279,10 @@ Widget_Defaults::Widget_Defaults() widget_blend_method=manage(new Widget_Enum()); widget_blend_method->show(); widget_blend_method->signal_activate().connect(sigc::mem_fun(*this,&studio::Widget_Defaults::on_blend_method_changed)); - widget_blend_method->set_param_desc(ParamDesc(Color::BLEND_COMPOSITE,"blend_method")); + widget_blend_method->set_param_desc( + ParamDesc(Color::BLEND_COMPOSITE,"blend_method") + .add_enum_value(Color::BLEND_BY_LAYER,"bylayer", _("By Layer Default")) + ); attach(*widget_blend_method,0, 2, 2, 3, Gtk::EXPAND|Gtk::FILL, Gtk::SHRINK|Gtk::FILL, 1, 1); tooltips_.set_tip(*widget_blend_method,_("Default Blend Method")); diff --git a/synfig-studio/src/synfigapp/canvasinterface.cpp b/synfig-studio/src/synfigapp/canvasinterface.cpp index cfc5db6..a03084e 100644 --- a/synfig-studio/src/synfigapp/canvasinterface.cpp +++ b/synfig-studio/src/synfigapp/canvasinterface.cpp @@ -227,7 +227,8 @@ CanvasInterface::add_layer_to(synfig::String name, synfig::Canvas::Handle canvas layer->set_param("gradient",synfigapp::Main::get_gradient()); if(name!="zoom") layer->set_param("amount",synfigapp::Main::get_opacity()); - layer->set_param("blend_method",synfigapp::Main::get_blend_method()); + if(synfigapp::Main::get_blend_method() != Color::BLEND_BY_LAYER) + layer->set_param("blend_method",synfigapp::Main::get_blend_method()); { // Grab the layer's list of parameters