1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenodedynamiclistloop.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 "valuenodedynamiclistloop.h"
34 #include <synfigapp/canvasinterface.h>
36 #include <synfigapp/general.h>
42 using namespace synfig;
43 using namespace synfigapp;
44 using namespace Action;
46 /* === M A C R O S ========================================================= */
48 ACTION_INIT(Action::ValueNodeDynamicListLoop);
49 ACTION_SET_NAME(Action::ValueNodeDynamicListLoop,"value_node_dynamic_list_loop");
50 ACTION_SET_LOCAL_NAME(Action::ValueNodeDynamicListLoop,N_("Loop"));
51 ACTION_SET_TASK(Action::ValueNodeDynamicListLoop,"loop");
52 ACTION_SET_CATEGORY(Action::ValueNodeDynamicListLoop,Action::CATEGORY_VALUEDESC|Action::CATEGORY_VALUENODE);
53 ACTION_SET_PRIORITY(Action::ValueNodeDynamicListLoop,0);
54 ACTION_SET_VERSION(Action::ValueNodeDynamicListLoop,"0.0");
55 ACTION_SET_CVS_ID(Action::ValueNodeDynamicListLoop,"$Id$");
57 /* === G L O B A L S ======================================================= */
59 /* === P R O C E D U R E S ================================================= */
61 /* === M E T H O D S ======================================================= */
63 Action::ValueNodeDynamicListLoop::ValueNodeDynamicListLoop()
68 Action::ValueNodeDynamicListLoop::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"))
80 Action::ValueNodeDynamicListLoop::is_candidate(const ParamList &x)
82 if (!candidate_check(get_param_vocab(),x))
85 ValueNode::Handle value_node;
86 ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
88 if(value_desc.parent_is_value_node())
89 value_node = value_desc.get_parent_value_node();
91 value_node = x.find("value_node")->second.get_value_node();
93 // We need a dynamic list.
94 return (ValueNode_DynamicList::Handle::cast_dynamic(value_node) &&
95 // We need the list not to be looped.
96 !ValueNode_DynamicList::Handle::cast_dynamic(value_node)->get_loop());
100 Action::ValueNodeDynamicListLoop::set_param(const synfig::String& name, const Action::Param ¶m)
102 if(!value_node && name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
104 ValueDesc value_desc(param.get_value_desc());
106 if(!value_desc.parent_is_value_node())
109 value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
117 if(!value_node && name=="value_node" && param.get_type()==Param::TYPE_VALUENODE)
119 value_node=ValueNode_DynamicList::Handle::cast_dynamic(param.get_value_node());
127 return Action::CanvasSpecific::set_param(name,param);
131 Action::ValueNodeDynamicListLoop::is_ready()const
135 return Action::CanvasSpecific::is_ready();
139 Action::ValueNodeDynamicListLoop::perform()
141 old_loop_value=value_node->get_loop();
143 if(old_loop_value==true)
149 value_node->set_loop(true);
151 value_node->changed();
152 /*_if(get_canvas_interface())
154 get_canvas_interface()->signal_value_node_changed()(value_node);
156 else synfig::warning("CanvasInterface not set on action");*/
160 Action::ValueNodeDynamicListLoop::undo()
162 if(old_loop_value==value_node->get_loop())
168 value_node->set_loop(old_loop_value);
170 value_node->changed();
171 /*_if(get_canvas_interface())
173 get_canvas_interface()->signal_value_node_changed()(value_node);
175 else synfig::warning("CanvasInterface not set on action");*/