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>
35 #include <synfigapp/general.h>
41 using namespace synfig;
42 using namespace synfigapp;
43 using namespace Action;
45 /* === M A C R O S ========================================================= */
47 ACTION_INIT(Action::LayerParamSet);
48 ACTION_SET_NAME(Action::LayerParamSet,"layer_param_set");
49 ACTION_SET_LOCAL_NAME(Action::LayerParamSet,N_("Set Layer Parameter"));
50 ACTION_SET_TASK(Action::LayerParamSet,"set");
51 ACTION_SET_CATEGORY(Action::LayerParamSet,Action::CATEGORY_LAYER);
52 ACTION_SET_PRIORITY(Action::LayerParamSet,0);
53 ACTION_SET_VERSION(Action::LayerParamSet,"0.0");
54 ACTION_SET_CVS_ID(Action::LayerParamSet,"$Id$");
56 /* === G L O B A L S ======================================================= */
58 /* === P R O C E D U R E S ================================================= */
60 /* === M E T H O D S ======================================================= */
62 Action::LayerParamSet::LayerParamSet()
67 Action::LayerParamSet::get_param_vocab()
69 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
71 ret.push_back(ParamDesc("layer",Param::TYPE_LAYER)
72 .set_local_name(_("Layer"))
75 ret.push_back(ParamDesc("param",Param::TYPE_STRING)
76 .set_local_name(_("Param"))
79 ret.push_back(ParamDesc("new_value",Param::TYPE_VALUE)
80 .set_local_name(_("ValueBase"))
87 Action::LayerParamSet::is_candidate(const ParamList &x)
89 return candidate_check(get_param_vocab(),x);
93 Action::LayerParamSet::set_param(const synfig::String& name, const Action::Param ¶m)
95 if(name=="layer" && param.get_type()==Param::TYPE_LAYER)
97 layer=param.get_layer();
102 if(name=="new_value" && param.get_type()==Param::TYPE_VALUE)
104 new_value=param.get_value();
109 if(name=="param" && param.get_type()==Param::TYPE_STRING)
111 param_name=param.get_string();
116 return Action::CanvasSpecific::set_param(name,param);
120 Action::LayerParamSet::is_ready()const
122 if(!layer || !new_value.is_valid() || param_name.empty())
124 return Action::CanvasSpecific::is_ready();
128 Action::LayerParamSet::perform()
130 // See if the parameter is dynamic
131 if(layer->dynamic_param_list().count(param_name))
132 throw Error(_("ValueNode attached to Parameter."));
134 old_value=layer->get_param(param_name);
136 if(!layer->set_param(param_name,new_value))
137 throw Error(_("Layer did not accept parameter."));
139 /*if(layer->active())
146 // Signal that a layer has been inserted
147 if(get_canvas_interface())
149 get_canvas_interface()->signal_layer_param_changed()(layer,param_name);
154 Action::LayerParamSet::undo()
156 if(!layer->set_param(param_name,old_value))
157 throw Error(_("Layer did not accept parameter."));
168 // Signal that a layer has been inserted
169 if(get_canvas_interface())
171 get_canvas_interface()->signal_layer_param_changed()(layer,param_name);