|
Carlos Lopez |
a09598 |
/* === S Y N F I G ========================================================= */
|
|
Carlos Lopez |
a09598 |
/*! \file layer_composite.h
|
|
Carlos Lopez |
a09598 |
** \brief Composite Layer Class Implementation
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** $Id$
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** \legal
|
|
Carlos Lopez |
a09598 |
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
|
|
Carlos Lopez |
a09598 |
** Copyright (c) 2007, 2008 Chris Moore
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** This package is free software; you can redistribute it and/or
|
|
Carlos Lopez |
a09598 |
** modify it under the terms of the GNU General Public License as
|
|
Carlos Lopez |
a09598 |
** published by the Free Software Foundation; either version 2 of
|
|
Carlos Lopez |
a09598 |
** the License, or (at your option) any later version.
|
|
Carlos Lopez |
a09598 |
**
|
|
Carlos Lopez |
a09598 |
** This package is distributed in the hope that it will be useful,
|
|
Carlos Lopez |
a09598 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Carlos Lopez |
a09598 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Carlos Lopez |
a09598 |
** General Public License for more details.
|
|
Carlos Lopez |
a09598 |
** \endlegal
|
|
Carlos Lopez |
a09598 |
*/
|
|
Carlos Lopez |
a09598 |
/* ========================================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === S T A R T =========================================================== */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#ifndef __SYNFIG_LAYER_COMPOSITE_H
|
|
Carlos Lopez |
a09598 |
#define __SYNFIG_LAYER_COMPOSITE_H
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === H E A D E R S ======================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Diego Barrios Romero |
dcc14d |
#include <synfig layer.h=""></synfig>
|
|
Diego Barrios Romero |
dcc14d |
#include <synfig color.h=""></synfig>
|
|
Diego Barrios Romero |
dcc14d |
#include <synfig cairo_operators.h=""></synfig>
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === M A C R O S ========================================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === T Y P E D E F S ===================================================== */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === C L A S S E S & S T R U C T S ======================================= */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
namespace synfig {
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
class Layer_NoDeform {};
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/*! \class Layer_Composite
|
|
Carlos Lopez |
a09598 |
** \brief Base class for layers that put stuff on top of lower layers
|
|
Carlos Lopez |
a09598 |
*/
|
|
Carlos Lopez |
a09598 |
class Layer_Composite : public Layer
|
|
Carlos Lopez |
a09598 |
{
|
|
Carlos Lopez |
a09598 |
private:
|
|
Carlos Lopez |
5ea9ef |
//! The amount of composite
|
|
Carlos Lopez |
7d86f4 |
ValueBase param_amount;
|
|
Carlos Lopez |
5ea9ef |
//! The blend method for the composition
|
|
Carlos Lopez |
7d86f4 |
ValueBase param_blend_method;
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
protected:
|
|
Carlos Lopez |
5ea9ef |
//! Default constructor. Not used directly.
|
|
|
e222d9 |
explicit Layer_Composite(Real amount=1.0, Color::BlendMethod blend_method=Color::BLEND_COMPOSITE);
|
|
Carlos Lopez |
18bd95 |
|
|
Carlos Lopez |
5ea9ef |
//! Converted blend is used to check if an old version of canvas
|
|
Carlos Lopez |
5ea9ef |
//! is used in the composition. Old Straight was used as new Composite
|
|
Carlos Lopez |
5ea9ef |
//! \todo verify this
|
|
Carlos Lopez |
a09598 |
bool converted_blend_;
|
|
Carlos Lopez |
5ea9ef |
//! Transparent color is used for old canvas versions.
|
|
Carlos Lopez |
5ea9ef |
//!Old Straight plus transparent color seems to be the same new than alpha over.
|
|
Carlos Lopez |
a09598 |
bool transparent_color_;
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
public:
|
|
Carlos Lopez |
5ea9ef |
//! Gets the amount of the layer
|
|
Carlos Lopez |
7d86f4 |
float get_amount()const { return param_amount.get(Real()); }
|
|
Carlos Lopez |
5ea9ef |
//! Sets the amount of the layer and returns this layer
|
|
Carlos Lopez |
7d86f4 |
Layer_Composite& set_amount(float x) { param_amount.set(x); return *this; }
|
|
Carlos Lopez |
5ea9ef |
//! Gets the blend method of the layer
|
|
Carlos Lopez |
7d86f4 |
Color::BlendMethod get_blend_method()const { return Color::BlendMethod((param_blend_method.get(int()))); }
|
|
Carlos Lopez |
5ea9ef |
//! Sets the blend method of the layer and returns this layer
|
|
|
d89783 |
Layer_Composite& set_blend_method(Color::BlendMethod x) { param_blend_method.set(int(x)); return *this; }
|
|
Carlos Lopez |
5ea9ef |
//! Returns true is amount is 1 and blend method is straight
|
|
Carlos Lopez |
7d86f4 |
virtual bool is_solid_color()const { return param_amount.get(Real())==1.0f && param_blend_method.get(int())==Color::BLEND_STRAIGHT; }
|
|
Carlos Lopez |
5ea9ef |
//! Returns true if the amount is zero.
|
|
Carlos Lopez |
7d86f4 |
bool is_disabled()const { return param_amount.get(Real())==0.0f; }
|
|
luz.paz |
99f3ef |
//! Gets the parameter vocabulary. To be overridden by the derived.
|
|
Carlos Lopez |
a09598 |
virtual Vocab get_param_vocab()const;
|
|
Carlos Lopez |
5ea9ef |
//! Sets the value for the given parameter.
|
|
Carlos Lopez |
a09598 |
virtual bool set_param(const String ¶m, const ValueBase &value);
|
|
Carlos Lopez |
5ea9ef |
//! Gets the value of the given parameter
|
|
Carlos Lopez |
a09598 |
virtual ValueBase get_param(const String ¶m)const;
|
|
Carlos Lopez |
5ea9ef |
//!Returns the rectangle that includes the context of the layer and
|
|
Carlos Lopez |
5ea9ef |
//! the intersection of the layer in case it is active and not onto
|
|
Carlos Lopez |
a09598 |
virtual Rect get_full_bounding_rect(Context context)const;
|
|
|
8bbd89 |
|
|
|
8bbd89 |
protected:
|
|
|
8bbd89 |
virtual rendering::Task::Handle build_composite_task_vfunc(ContextParams context_params)const;
|
|
|
8bbd89 |
virtual rendering::Task::Handle build_rendering_task_vfunc(Context context)const;
|
|
Carlos Lopez |
a09598 |
}; // END of class Layer_Composite
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
}; // END of namespace synfig
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
/* === E N D =============================================================== */
|
|
Carlos Lopez |
a09598 |
|
|
Carlos Lopez |
a09598 |
#endif
|