1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenodeconstset.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 "valuenodeconstset.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::ValueNodeConstSet);
48 ACTION_SET_NAME(Action::ValueNodeConstSet,"value_node_const_set");
49 ACTION_SET_LOCAL_NAME(Action::ValueNodeConstSet,N_("Set ValueNode_Const"));
50 ACTION_SET_TASK(Action::ValueNodeConstSet,"set");
51 ACTION_SET_CATEGORY(Action::ValueNodeConstSet,Action::CATEGORY_VALUENODE);
52 ACTION_SET_PRIORITY(Action::ValueNodeConstSet,0);
53 ACTION_SET_VERSION(Action::ValueNodeConstSet,"0.0");
54 ACTION_SET_CVS_ID(Action::ValueNodeConstSet,"$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::ValueNodeConstSet::ValueNodeConstSet()
68 Action::ValueNodeConstSet::get_param_vocab()
70 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
72 ret.push_back(ParamDesc("value_node",Param::TYPE_VALUENODE)
73 .set_local_name(_("ValueNode_Const"))
76 ret.push_back(ParamDesc("new_value",Param::TYPE_VALUE)
77 .set_local_name(_("ValueBase"))
84 Action::ValueNodeConstSet::is_candidate(const ParamList &x)
86 if(candidate_check(get_param_vocab(),x))
88 if(ValueNode_Const::Handle::cast_dynamic(x.find("value_node")->second.get_value_node()))
95 Action::ValueNodeConstSet::set_param(const synfig::String& name, const Action::Param ¶m)
97 if(name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
99 value_node=ValueNode_Const::Handle::cast_dynamic(param.get_value_node());
101 return (bool)value_node;
104 if(name=="new_value" && param.get_type()==Param::TYPE_VALUE)
106 new_value=param.get_value();
111 return Action::CanvasSpecific::set_param(name,param);
115 Action::ValueNodeConstSet::is_ready()const
117 if(!value_node || !new_value.is_valid())
119 return Action::CanvasSpecific::is_ready();
123 Action::ValueNodeConstSet::perform()
127 old_value=value_node->get_value();
129 value_node->set_value(new_value);
131 // Signal that a layer has been inserted
132 /*if(get_canvas_interface())
134 get_canvas_interface()->signal_value_node_changed()(value_node);
139 Action::ValueNodeConstSet::undo()
143 value_node->set_value(old_value);
145 // Signal that a layer has been inserted
146 /*if(get_canvas_interface())
148 get_canvas_interface()->signal_value_node_changed()(value_node);