Add LayerParamSetStatic and LayerParamUnSetStatic actions.
authorCarlos Lopez <genetita@gmail.com>
Fri, 20 Aug 2010 16:03:35 +0000 (18:03 +0200)
committerCarlos Lopez <genetita@gmail.com>
Fri, 20 Aug 2010 16:03:35 +0000 (18:03 +0200)
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.

14 files changed:
synfig-core/src/modules/mod_geometry/circle.cpp
synfig-core/src/modules/mod_geometry/circle.h
synfig-core/src/synfig/layer.cpp
synfig-core/src/synfig/layer.h
synfig-core/src/synfig/layer_composite.cpp
synfig-core/src/synfig/layer_composite.h
synfig-core/src/synfig/value.cpp
synfig-core/src/synfig/value.h
synfig-studio/src/synfigapp/Makefile.am
synfig-studio/src/synfigapp/action.cpp
synfig-studio/src/synfigapp/actions/layerparamsetstatic.cpp [new file with mode: 0644]
synfig-studio/src/synfigapp/actions/layerparamsetstatic.h [new file with mode: 0644]
synfig-studio/src/synfigapp/actions/layerparamunsetstatic.cpp [new file with mode: 0644]
synfig-studio/src/synfigapp/actions/layerparamunsetstatic.h [new file with mode: 0644]

index d8f51a7..dcf8cef 100644 (file)
@@ -66,7 +66,13 @@ Circle::Circle():
        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();
 }
@@ -116,6 +122,61 @@ Circle::get_param(const String &param)const
        return Layer_Composite::get_param(param);
 }
 
+
+bool
+Circle::set_param_static(const String &param, 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 &param) 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
 {
index f7cd379..e6624e8 100644 (file)
@@ -53,6 +53,13 @@ private:
        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
        {
@@ -104,6 +111,9 @@ public:
 
        virtual ValueBase get_param(const String &param)const;
 
+       virtual bool set_param_static(const String &param, const bool x);
+       virtual bool get_param_static(const String &param) 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;
index 9d1adf3..3106d8c 100644 (file)
@@ -295,11 +295,35 @@ Layer::set_param(const String &param, const ValueBase &value)
        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 &param, 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 &param) const
+{
+       if(param=="z_depth")
+               return z_depth_static;
+
+       return false;
+}
+
+
 etl::handle<Transform>
 Layer::get_transform()const
 {
@@ -449,8 +473,11 @@ ValueBase
 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();
 }
 
index c002330..51bf681 100644 (file)
@@ -81,6 +81,7 @@
        if (param==#x && value.same_type_as(x))                                                                                         \
        {                                                                                                                                                                       \
                value.put(&x);                                                                                                                                  \
+               set_param_static(#x,value.get_static());                                                                                \
                {                                                                                                                                                               \
                        y;                                                                                                                                                      \
                }                                                                                                                                                               \
@@ -92,6 +93,7 @@
        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)                                                                                                                                              \
@@ -253,6 +259,9 @@ private:
        //! 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_;
 
@@ -446,6 +455,9 @@ public:
        */
        virtual bool set_param(const String &param, const ValueBase &value);
 
+       virtual bool set_param_static(const String &param, const bool x);
+       virtual bool get_param_static(const String &param) const;
+
        //!     Sets a list of parameters
        virtual bool set_param_list(const ParamList &);
 
index 5d03787..24cae52 100644 (file)
@@ -205,12 +205,52 @@ Layer_Composite::set_param(const String & param, const ValueBase &value)
 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 &param, 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 &param) const
+{
+
+       if(param=="amount")
+               return amount_static;
+
+       if(param=="blend_method")
+               return blend_method_static;
+
+       return Layer::get_param_static(param);
+}
index 458bae7..7c94811 100644 (file)
@@ -52,6 +52,8 @@ private:
        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.
@@ -62,7 +64,9 @@ protected:
                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
@@ -93,6 +97,8 @@ public:
        virtual ValueBase get_param(const String &param)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 &param, const bool x);
+       virtual bool get_param_static(const String &param) 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;
index 5e5c333..f9a41b7 100644 (file)
@@ -217,6 +217,7 @@ ValueBase::operator=(const ValueBase& x)
                ref_count=x.ref_count;
        }
        loop_=x.loop_;
+       static_=x.static_;
        return *this;
 }
 
index 62fd04f..c55f4c9 100644 (file)
@@ -123,7 +123,7 @@ protected:
        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_;
 
        /*
index 8ad4090..40d466c 100644 (file)
@@ -17,6 +17,8 @@ LAYER_ACTION_HH = \
        actions/layerparamconnect.h \
        actions/layerparamdisconnect.h \
        actions/layerparamset.h \
+       actions/layerparamsetstatic.h\
+       actions/layerparamunsetstatic.h\
        actions/layerraise.h \
        actions/layerremove.h \
        actions/layersetdesc.h
@@ -31,6 +33,8 @@ LAYER_ACTION_CC = \
        actions/layerparamconnect.cpp \
        actions/layerparamdisconnect.cpp \
        actions/layerparamset.cpp \
+       actions/layerparamsetstatic.cpp\
+       actions/layerparamunsetstatic.cpp\
        actions/layerraise.cpp \
        actions/layerremove.cpp \
        actions/layersetdesc.cpp
index 0e3647a..21d5f0c 100644 (file)
@@ -41,6 +41,8 @@
 #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"
@@ -163,6 +165,8 @@ Action::Main::Main()
        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);
diff --git a/synfig-studio/src/synfigapp/actions/layerparamsetstatic.cpp b/synfig-studio/src/synfigapp/actions/layerparamsetstatic.cpp
new file mode 100644 (file)
index 0000000..24d3be4
--- /dev/null
@@ -0,0 +1,183 @@
+/* === 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 &param)
+{
+
+       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);
+}
diff --git a/synfig-studio/src/synfigapp/actions/layerparamsetstatic.h b/synfig-studio/src/synfigapp/actions/layerparamsetstatic.h
new file mode 100644 (file)
index 0000000..022ef03
--- /dev/null
@@ -0,0 +1,78 @@
+/* === 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
diff --git a/synfig-studio/src/synfigapp/actions/layerparamunsetstatic.cpp b/synfig-studio/src/synfigapp/actions/layerparamunsetstatic.cpp
new file mode 100644 (file)
index 0000000..4012c9e
--- /dev/null
@@ -0,0 +1,185 @@
+/* === 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 &param)
+{
+
+       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);
+}
diff --git a/synfig-studio/src/synfigapp/actions/layerparamunsetstatic.h b/synfig-studio/src/synfigapp/actions/layerparamunsetstatic.h
new file mode 100644 (file)
index 0000000..4b63049
--- /dev/null
@@ -0,0 +1,77 @@
+/* === 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