1 /* === S Y N F I G ========================================================= */
2 /*! \file layerparamset.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
10 ** This package is free software; you can redistribute it and/or
11 ** modify it under the terms of the GNU General Public License as
12 ** published by the Free Software Foundation; either version 2 of
13 ** the License, or (at your option) any later version.
15 ** This package is distributed in the hope that it will be useful,
16 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 ** General Public License for more details.
21 /* ========================================================================= */
23 /* === H E A D E R S ======================================================= */
32 #include "layerparamset.h"
33 #include <synfigapp/canvasinterface.h>
39 using namespace synfig;
40 using namespace synfigapp;
41 using namespace Action;
43 /* === M A C R O S ========================================================= */
45 ACTION_INIT(Action::LayerParamSet);
46 ACTION_SET_NAME(Action::LayerParamSet,"layer_param_set");
47 ACTION_SET_LOCAL_NAME(Action::LayerParamSet,_("Set Layer Parameter"));
48 ACTION_SET_TASK(Action::LayerParamSet,"set");
49 ACTION_SET_CATEGORY(Action::LayerParamSet,Action::CATEGORY_LAYER);
50 ACTION_SET_PRIORITY(Action::LayerParamSet,0);
51 ACTION_SET_VERSION(Action::LayerParamSet,"0.0");
52 ACTION_SET_CVS_ID(Action::LayerParamSet,"$Id$");
54 /* === G L O B A L S ======================================================= */
56 /* === P R O C E D U R E S ================================================= */
58 /* === M E T H O D S ======================================================= */
60 Action::LayerParamSet::LayerParamSet()
65 Action::LayerParamSet::get_param_vocab()
67 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
69 ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
70 .set_local_name(_("Layer"))
73 ret.push_back(ParamDesc("param",Param::TYPE_STRING)
74 .set_local_name(_("Param"))
77 ret.push_back(ParamDesc("new_value",Param::TYPE_VALUE)
78 .set_local_name(_("ValueBase"))
85 Action::LayerParamSet::is_candidate(const ParamList &x)
87 return candidate_check(get_param_vocab(),x);
91 Action::LayerParamSet::set_param(const synfig::String& name, const Action::Param ¶m)
93 if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
95 layer=param.get_layer();
100 if(name=="new_value" && param.get_type()==Param::TYPE_VALUE)
102 new_value=param.get_value();
107 if(name=="param" && param.get_type()==Param::TYPE_STRING)
109 param_name=param.get_string();
114 return Action::CanvasSpecific::set_param(name,param);
118 Action::LayerParamSet::is_ready()const
120 if(!layer || !new_value.is_valid() || param_name.empty())
122 return Action::CanvasSpecific::is_ready();
126 Action::LayerParamSet::perform()
128 // See if the parameter is dynamic
129 if(layer->dynamic_param_list().count(param_name))
130 throw Error(_("ValueNode attached to Parameter."));
132 old_value=layer->get_param(param_name);
134 if(!layer->set_param(param_name,new_value))
135 throw Error(_("Layer did not accept parameter."));
137 /*if(layer->active())
144 // Signal that a layer has been inserted
145 if(get_canvas_interface())
147 get_canvas_interface()->signal_layer_param_changed()(layer,param_name);
152 Action::LayerParamSet::undo()
154 if(!layer->set_param(param_name,old_value))
155 throw Error(_("Layer did not accept parameter."));
166 // Signal that a layer has been inserted
167 if(get_canvas_interface())
169 get_canvas_interface()->signal_layer_param_changed()(layer,param_name);