1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenodedynamiclistremovesmart.cpp
3 ** \brief Template File
8 ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
9 ** Copyright (c) 2008 Chris Moore
11 ** This package is free software; you can redistribute it and/or
12 ** modify it under the terms of the GNU General Public License as
13 ** published by the Free Software Foundation; either version 2 of
14 ** the License, or (at your option) any later version.
16 ** This package is distributed in the hope that it will be useful,
17 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 ** General Public License for more details.
22 /* ========================================================================= */
24 /* === H E A D E R S ======================================================= */
33 #include "valuenodedynamiclistremovesmart.h"
34 #include "valuenodedynamiclistremove.h"
35 #include <synfigapp/canvasinterface.h>
37 #include <synfigapp/general.h>
43 using namespace synfig;
44 using namespace synfigapp;
45 using namespace Action;
47 /* === M A C R O S ========================================================= */
49 ACTION_INIT(Action::ValueNodeDynamicListRemoveSmart);
50 ACTION_SET_NAME(Action::ValueNodeDynamicListRemoveSmart,"ValueNodeDynamicListRemoveSmart");
51 ACTION_SET_LOCAL_NAME(Action::ValueNodeDynamicListRemoveSmart,N_("Remove Item (Smart)"));
52 ACTION_SET_TASK(Action::ValueNodeDynamicListRemoveSmart,"remove");
53 ACTION_SET_CATEGORY(Action::ValueNodeDynamicListRemoveSmart,Action::CATEGORY_VALUEDESC|Action::CATEGORY_VALUENODE);
54 ACTION_SET_PRIORITY(Action::ValueNodeDynamicListRemoveSmart,-19);
55 ACTION_SET_VERSION(Action::ValueNodeDynamicListRemoveSmart,"0.0");
56 ACTION_SET_CVS_ID(Action::ValueNodeDynamicListRemoveSmart,"$Id$");
58 /* === G L O B A L S ======================================================= */
60 /* === P R O C E D U R E S ================================================= */
62 /* === M E T H O D S ======================================================= */
64 Action::ValueNodeDynamicListRemoveSmart::ValueNodeDynamicListRemoveSmart()
73 Action::ValueNodeDynamicListRemoveSmart::get_param_vocab()
75 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
77 ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
78 .set_local_name(_("ValueDesc"))
80 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
81 .set_local_name(_("Time"))
84 ret.push_back(ParamDesc("origin",Param::TYPE_REAL)
85 .set_local_name(_("Origin"))
93 Action::ValueNodeDynamicListRemoveSmart::is_candidate(const ParamList &x)
95 if (!candidate_check(get_param_vocab(),x))
98 ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
100 return (value_desc.parent_is_value_node() &&
101 // We need a dynamic list.
102 ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()));
106 Action::ValueNodeDynamicListRemoveSmart::set_param(const synfig::String& name, const Action::Param ¶m)
108 if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
110 ValueDesc value_desc(param.get_value_desc());
112 if(!value_desc.parent_is_value_node())
115 value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
120 index=value_desc.get_index();
124 if(name=="time" && param.get_type()==Param::TYPE_TIME)
126 time=param.get_time();
130 if(name=="origin" && param.get_type()==Param::TYPE_REAL)
132 origin=param.get_real();
137 return Action::CanvasSpecific::set_param(name,param);
141 Action::ValueNodeDynamicListRemoveSmart::is_ready()const
145 return Action::CanvasSpecific::is_ready();
149 Action::ValueNodeDynamicListRemoveSmart::prepare()
153 // If we are in animate editing mode
154 if(get_edit_mode()&MODE_ANIMATE)
156 Action::Handle action(Action::create("ActivepointSetOff"));
159 throw Error(_("Unable to find action (bug)"));
161 action->set_param("canvas",get_canvas());
162 action->set_param("canvas_interface",get_canvas_interface());
163 action->set_param("time",time);
164 action->set_param("origin",origin);
165 action->set_param("value_desc",ValueDesc(value_node,index));
167 if(!action->is_ready())
168 throw Error(Error::TYPE_NOTREADY);
174 Action::Handle action(Action::create("ValueNodeDynamicListRemove"));
177 throw Error(_("Unable to find action (bug)"));
179 action->set_param("canvas",get_canvas());
180 action->set_param("canvas_interface",get_canvas_interface());
181 action->set_param("time",time);
182 action->set_param("origin",origin);
183 action->set_param("value_desc",ValueDesc(value_node,index));
185 if(!action->is_ready())
186 throw Error(Error::TYPE_NOTREADY);