They work only only on Layer, Layer_Composite and Circle classes.
It is pending check its functionality and extend to rest of layers parameters.
By default blend_method for Composite and invert and falloff for circles are
now static when creating a new layer.
radius (1),
feather (0),
invert (false),
- falloff (FALLOFF_INTERPOLATION_LINEAR)
+ falloff (FALLOFF_INTERPOLATION_LINEAR),
+ color_static (false),
+ origin_static (false),
+ radius_static (false),
+ feather_static (false),
+ invert_static (true),
+ falloff_static (true)
{
constructcache();
}
return Layer_Composite::get_param(param);
}
+
+bool
+Circle::set_param_static(const String ¶m, const bool x)
+{
+
+ if(param=="color" && color_static!=x)
+ {
+ color_static=x;
+ return true;
+ }
+ if(param=="radius" && radius_static!=x)
+ {
+ radius_static=x;
+ return true;
+ }
+
+ if(param=="origin" && origin_static!=x)
+ {
+ origin_static=x;
+ return true;
+ }
+ if(param=="feather" && feather_static!=x)
+ {
+ feather_static=x;
+ return true;
+ }
+ if(param=="falloff" && falloff_static!=x)
+ {
+ falloff_static=x;
+ return true;
+ }
+
+ return Layer_Composite::set_param_static(param, x);
+}
+
+
+bool
+Circle::get_param_static(const String ¶m) const
+{
+
+ if(param=="color")
+ return color_static;
+ if(param=="radius")
+ return radius_static;
+ if(param=="origin")
+ return origin_static;
+ if(param=="feather")
+ return feather_static;
+ if(param=="falloff")
+ return falloff_static;
+
+ return Layer_Composite::get_param_static(param);
+}
+
+
Layer::Vocab
Circle::get_param_vocab()const
{
bool invert;
int falloff;
+ bool color_static;
+ bool origin_static;
+ bool radius_static;
+ bool feather_static;
+ bool invert_static;
+ bool falloff_static;
+
//Caching system for circle
struct CircleDataCache
{
virtual ValueBase get_param(const String ¶m)const;
+ virtual bool set_param_static(const String ¶m, const bool x);
+ virtual bool get_param_static(const String ¶m) const;
+
virtual Color get_color(Context context, const Point &pos)const;
virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
if(param=="z_depth" && value.same_type_as(z_depth_))
{
z_depth_=value.get(z_depth_);
+ z_depth_static=value.get_static();
return true;
}
return false;
}
+bool
+Layer::set_param_static(const String ¶m, const bool x)
+{
+ if(param=="z_depth" && z_depth_static!=x)
+ {
+ z_depth_static=x;
+ return true;
+ }
+
+ return false;
+}
+
+
+bool
+Layer::get_param_static(const String ¶m) const
+{
+ if(param=="z_depth")
+ return z_depth_static;
+
+ return false;
+}
+
+
etl::handle<Transform>
Layer::get_transform()const
{
Layer::get_param(const String & param)const
{
if(param=="z_depth")
- return get_z_depth();
-
+ {
+ synfig::ValueBase ret(get_z_depth());
+ ret.set_static(z_depth_static);
+ return ret;
+ }
return ValueBase();
}
if (param==#x && value.same_type_as(x)) \
{ \
value.put(&x); \
+ set_param_static(#x,value.get_static()); \
{ \
y; \
} \
if (param==y && value.same_type_as(x)) \
{ \
value.put(&x); \
+ set_param_static(#x,value.get_static()); \
return true; \
}
//! Exports a parameter 'x' if param is same type as given 'y'
#define EXPORT_AS(x,y) \
if (param==y) \
- return ValueBase(x);
+ { \
+ synfig::ValueBase ret(x); \
+ ret.set_static(get_param_static(y)); \
+ return ret; \
+ }
//! Exports a parameter if it is the same type as value
#define EXPORT(x) \
//! The depth parameter of the layer in the layer stack
float z_depth_;
+ //! True if zdepth is not affected when in animation mode
+ bool z_depth_static;
+
//! \writeme
mutable Time dirty_time_;
*/
virtual bool set_param(const String ¶m, const ValueBase &value);
+ virtual bool set_param_static(const String ¶m, const bool x);
+ virtual bool get_param_static(const String ¶m) const;
+
//! Sets a list of parameters
virtual bool set_param_list(const ParamList &);
ValueBase
Layer_Composite::get_param(const String & param)const
{
+
//! First check if the parameter's string is known.
if(param=="amount")
- return get_amount();
+ {
+ synfig::ValueBase ret(get_amount());
+ ret.set_static(amount_static);
+ return ret;
+ }
if(param=="blend_method")
- return static_cast<int>(get_blend_method());
+ {
+ synfig::ValueBase ret(static_cast<int>(get_blend_method()));
+ ret.set_static(blend_method_static);
+ 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);
+}
float amount_;
//! The blend method for the composition
Color::BlendMethod blend_method_;
+ bool amount_static;
+ bool blend_method_static;
protected:
//! Default constructor. Not used directly.
amount_ (amount),
blend_method_ (blend_method),
converted_blend_ (false),
- transparent_color_ (false)
+ transparent_color_ (false),
+ amount_static (false),
+ blend_method_static (true)
{ }
//! Converted blend is used to check if an old version of canvas
//! is used in the composition. Old Straight was used as new Composite
virtual ValueBase get_param(const String ¶m)const;
//!Returns the rectangle that includes the context of the layer and
//! the intersection of the layer in case it is active and not onto
+ virtual bool set_param_static(const String ¶m, const bool x);
+ virtual bool get_param_static(const String ¶m) const;
virtual Rect get_full_bounding_rect(Context context)const;
//! Renders the layer composited on the context and puts it on the target surface.
virtual bool accelerated_render(Context context,Surface *surface,int quality, const RendDesc &renddesc, ProgressCallback *cb)const;
ref_count=x.ref_count;
}
loop_=x.loop_;
+ static_=x.static_;
return *this;
}
etl::reference_counter ref_count;
//! For Values with loop option like TYPE_LIST
bool loop_;
- //! For Values of Constant Value Nodes or Layer parameters
+ //! For Values of Constant Value Nodes
bool static_;
/*
actions/layerparamconnect.h \
actions/layerparamdisconnect.h \
actions/layerparamset.h \
+ actions/layerparamsetstatic.h\
+ actions/layerparamunsetstatic.h\
actions/layerraise.h \
actions/layerremove.h \
actions/layersetdesc.h
actions/layerparamconnect.cpp \
actions/layerparamdisconnect.cpp \
actions/layerparamset.cpp \
+ actions/layerparamsetstatic.cpp\
+ actions/layerparamunsetstatic.cpp\
actions/layerraise.cpp \
actions/layerremove.cpp \
actions/layersetdesc.cpp
#include "actions/layeradd.h"
#include "actions/layeractivate.h"
#include "actions/layerparamset.h"
+#include "actions/layerparamsetstatic.h"
+#include "actions/layerparamunsetstatic.h"
#include "actions/layerparamconnect.h"
#include "actions/layerparamdisconnect.h"
#include "actions/layerencapsulate.h"
ADD_ACTION(Action::LayerAdd);
ADD_ACTION(Action::LayerActivate);
ADD_ACTION(Action::LayerParamSet);
+ ADD_ACTION(Action::LayerParamSetStatic);
+ ADD_ACTION(Action::LayerParamUnSetStatic);
ADD_ACTION(Action::LayerParamConnect);
ADD_ACTION(Action::LayerParamDisconnect);
ADD_ACTION(Action::LayerEncapsulate);
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file layerparamsetstatic.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2010 Carlos López
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "layerparamsetstatic.h"
+#include <synfigapp/canvasinterface.h>
+
+#include <synfigapp/general.h>
+
+#endif
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace synfigapp;
+using namespace Action;
+
+/* === M A C R O S ========================================================= */
+
+ACTION_INIT(Action::LayerParamSetStatic);
+ACTION_SET_NAME(Action::LayerParamSetStatic,"LayerParamSetStatic");
+ACTION_SET_LOCAL_NAME(Action::LayerParamSetStatic,N_("Set Layer Parameter Static"));
+ACTION_SET_TASK(Action::LayerParamSetStatic,"setstatic");
+ACTION_SET_CATEGORY(Action::LayerParamSetStatic,Action::CATEGORY_VALUEDESC);
+ACTION_SET_PRIORITY(Action::LayerParamSetStatic,0);
+ACTION_SET_VERSION(Action::LayerParamSetStatic,"0.0");
+ACTION_SET_CVS_ID(Action::LayerParamSetStatic,"$Id$");
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Action::LayerParamSetStatic::LayerParamSetStatic()
+{
+}
+
+Action::ParamVocab
+Action::LayerParamSetStatic::get_param_vocab()
+{
+ ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
+
+ ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
+ .set_local_name(_("Value Desc"))
+ );
+
+ return ret;
+}
+
+bool
+Action::LayerParamSetStatic::is_candidate(const ParamList &x)
+{
+ if(!candidate_check(get_param_vocab(),x))
+ return false;
+
+ ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
+
+ if(!value_desc.parent_is_layer_param())
+ return false;
+
+ synfig::ValueBase parameter;
+ synfig::Layer::Handle _layer;
+ synfig::String _param_name;
+ _layer = value_desc.get_layer();
+ _param_name = value_desc.get_param_name();
+
+ if(!_layer || _param_name.empty())
+ return false;
+
+ //!Check that the parameter is not Value Node (Const, Animated or Linkable)
+ if(_layer->dynamic_param_list().count(_param_name))
+ return false;
+
+ //! Retrieves the current parameter
+ parameter = _layer->get_param(_param_name);
+ //! Check if it is already static
+ if(parameter.get_static())
+ return false;
+
+ return true;
+
+}
+
+bool
+Action::LayerParamSetStatic::set_param(const synfig::String& name, const Action::Param ¶m)
+{
+
+ if(!layer && name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
+ {
+ ValueDesc value_desc(param.get_value_desc());
+ if(!value_desc.parent_is_layer_param())
+ return false;
+
+ layer=Layer::Handle::cast_dynamic(value_desc.get_layer());
+
+ if(!layer)
+ return false;
+ }
+
+
+ if(param_name.empty() && name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
+ {
+ ValueDesc value_desc(param.get_value_desc());
+ if(!value_desc.parent_is_layer_param())
+ return false;
+
+ param_name=value_desc.get_param_name();
+
+ if(param_name.empty())
+ return false;
+ }
+
+ return Action::CanvasSpecific::set_param(name,param);
+}
+
+bool
+Action::LayerParamSetStatic::is_ready()const
+{
+ if(!layer || param_name.empty())
+ return false;
+
+ return Action::CanvasSpecific::is_ready();
+}
+
+void
+Action::LayerParamSetStatic::perform()
+{
+ //! See if the parameter is dynamic
+ if(layer->dynamic_param_list().count(param_name))
+ throw Error(_("This action is not for Value Nodes!"));
+
+ old_static_value=layer->get_param_static(param_name);
+
+ if(!layer->set_param_static(param_name,true))
+ throw Error(_("Layer did not accept static value."));
+
+ //! Signal layer changed
+ layer->changed();
+ //! Signal that a layer parameter changed
+ if(get_canvas_interface())
+ get_canvas_interface()->signal_layer_param_changed()(layer,param_name);
+}
+
+void
+Action::LayerParamSetStatic::undo()
+{
+ if(!layer->set_param_static(param_name,old_static_value))
+ throw Error(_("Layer did not accept static value."));
+ //! Signal layer changed
+ layer->changed();
+ //! Signal that a layer parameter changed
+ if(get_canvas_interface())
+ get_canvas_interface()->signal_layer_param_changed()(layer,param_name);
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file layerparamsetstatic.h
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2010 Carlos López
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_APP_ACTION_LAYERPARAMSETSTATIC_H
+#define __SYNFIG_APP_ACTION_LAYERPARAMSETSTATIC_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/layer.h>
+#include <synfigapp/action.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfigapp {
+
+class Instance;
+
+namespace Action {
+
+class LayerParamSetStatic :
+ public Undoable,
+ public CanvasSpecific
+{
+private:
+
+ synfig::Layer::Handle layer;
+ synfig::String param_name;
+ bool old_static_value;
+
+
+public:
+
+ LayerParamSetStatic();
+
+ static ParamVocab get_param_vocab();
+ static bool is_candidate(const ParamList &x);
+
+ virtual bool set_param(const synfig::String& name, const Param &);
+ virtual bool is_ready()const;
+
+ virtual void perform();
+ virtual void undo();
+
+ ACTION_MODULE_EXT
+};
+
+}; // END of namespace action
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file layerparamunsetstatic.cpp
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2010 Carlos López
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === H E A D E R S ======================================================= */
+
+#ifdef USING_PCH
+# include "pch.h"
+#else
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "layerparamunsetstatic.h"
+#include <synfigapp/canvasinterface.h>
+
+#include <synfigapp/general.h>
+
+#endif
+
+using namespace std;
+using namespace etl;
+using namespace synfig;
+using namespace synfigapp;
+using namespace Action;
+
+/* === M A C R O S ========================================================= */
+
+ACTION_INIT(Action::LayerParamUnSetStatic);
+ACTION_SET_NAME(Action::LayerParamUnSetStatic,"LayerParamUnSetStatic");
+ACTION_SET_LOCAL_NAME(Action::LayerParamUnSetStatic,N_("UnSet Layer Parameter Static"));
+ACTION_SET_TASK(Action::LayerParamUnSetStatic,"unsetstatic");
+ACTION_SET_CATEGORY(Action::LayerParamUnSetStatic,Action::CATEGORY_VALUEDESC);
+ACTION_SET_PRIORITY(Action::LayerParamUnSetStatic,0);
+ACTION_SET_VERSION(Action::LayerParamUnSetStatic,"0.0");
+ACTION_SET_CVS_ID(Action::LayerParamUnSetStatic,"$Id$");
+
+/* === G L O B A L S ======================================================= */
+
+/* === P R O C E D U R E S ================================================= */
+
+/* === M E T H O D S ======================================================= */
+
+Action::LayerParamUnSetStatic::LayerParamUnSetStatic()
+{
+}
+
+Action::ParamVocab
+Action::LayerParamUnSetStatic::get_param_vocab()
+{
+ ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
+
+ ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
+ .set_local_name(_("Value Desc"))
+ );
+
+ return ret;
+}
+
+bool
+Action::LayerParamUnSetStatic::is_candidate(const ParamList &x)
+{
+ if(!candidate_check(get_param_vocab(),x))
+ return false;
+
+ ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
+
+ if(!value_desc.parent_is_layer_param())
+ return false;
+
+ synfig::ValueBase parameter;
+ synfig::Layer::Handle _layer;
+ synfig::String _param_name;
+ _layer = value_desc.get_layer();
+ _param_name = value_desc.get_param_name();
+
+ if(!_layer || _param_name.empty())
+ return false;
+
+ //!Check that the parameter is not Value Node (Const, Animated or Linkable)
+ if(_layer->dynamic_param_list().count(_param_name))
+ return false;
+
+ //! Retrieves the current parameter
+ parameter = _layer->get_param(_param_name);
+ //! Check if it is not static
+ if(!parameter.get_static())
+ return false;
+
+ return true;
+
+}
+
+bool
+Action::LayerParamUnSetStatic::set_param(const synfig::String& name, const Action::Param ¶m)
+{
+
+ if(!layer && name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
+ {
+ ValueDesc value_desc(param.get_value_desc());
+ if(!value_desc.parent_is_layer_param())
+ return false;
+
+ layer=Layer::Handle::cast_dynamic(value_desc.get_layer());
+
+ if(!layer)
+ return false;
+ }
+
+
+ if(param_name.empty() && name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
+ {
+ ValueDesc value_desc(param.get_value_desc());
+
+ if(!value_desc.parent_is_layer_param())
+ return false;
+
+ param_name=value_desc.get_param_name();
+
+ if(param_name.empty())
+ return false;
+
+ }
+
+ return Action::CanvasSpecific::set_param(name,param);
+}
+
+bool
+Action::LayerParamUnSetStatic::is_ready()const
+{
+ if(!layer || param_name.empty())
+ return false;
+
+ return Action::CanvasSpecific::is_ready();
+}
+
+void
+Action::LayerParamUnSetStatic::perform()
+{
+ //! See if the parameter is dynamic
+ if(layer->dynamic_param_list().count(param_name))
+ throw Error(_("This action is not for Value Nodes!"));
+
+ old_static_value=layer->get_param_static(param_name);
+
+ if(!layer->set_param_static(param_name,false))
+ throw Error(_("Layer did not accept static value."));
+
+ //! Signal layer changed
+ layer->changed();
+ //! Signal that a layer parameter changed
+ if(get_canvas_interface())
+ get_canvas_interface()->signal_layer_param_changed()(layer,param_name);
+}
+
+void
+Action::LayerParamUnSetStatic::undo()
+{
+ if(!layer->set_param(param_name,old_static_value))
+ throw Error(_("Layer did not accept parameter."));
+ //! Signal layer changed
+ layer->changed();
+ //! Signal that a layer parameter changed
+ if(get_canvas_interface())
+ get_canvas_interface()->signal_layer_param_changed()(layer,param_name);
+}
--- /dev/null
+/* === S Y N F I G ========================================================= */
+/*! \file layerparamunsetstatic.h
+** \brief Template File
+**
+** $Id$
+**
+** \legal
+** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2010 Carlos López
+**
+** This package is free software; you can redistribute it and/or
+** modify it under the terms of the GNU General Public License as
+** published by the Free Software Foundation; either version 2 of
+** the License, or (at your option) any later version.
+**
+** This package is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+** General Public License for more details.
+** \endlegal
+*/
+/* ========================================================================= */
+
+/* === S T A R T =========================================================== */
+
+#ifndef __SYNFIG_APP_ACTION_LAYERPARAMUNSETSTATIC_H
+#define __SYNFIG_APP_ACTION_LAYERPARAMUNSETSTATIC_H
+
+/* === H E A D E R S ======================================================= */
+
+#include <synfig/layer.h>
+#include <synfigapp/action.h>
+
+/* === M A C R O S ========================================================= */
+
+/* === T Y P E D E F S ===================================================== */
+
+/* === C L A S S E S & S T R U C T S ======================================= */
+
+namespace synfigapp {
+
+class Instance;
+
+namespace Action {
+
+class LayerParamUnSetStatic :
+ public Undoable,
+ public CanvasSpecific
+{
+private:
+
+ synfig::Layer::Handle layer;
+ synfig::String param_name;
+ bool old_static_value;
+
+public:
+
+ LayerParamUnSetStatic();
+
+ static ParamVocab get_param_vocab();
+ static bool is_candidate(const ParamList &x);
+
+ virtual bool set_param(const synfig::String& name, const Param &);
+ virtual bool is_ready()const;
+
+ virtual void perform();
+ virtual void undo();
+
+ ACTION_MODULE_EXT
+};
+
+}; // END of namespace action
+}; // END of namespace studio
+
+/* === E N D =============================================================== */
+
+#endif