1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenodedynamiclistrotateorder.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 "valuenodedynamiclistrotateorder.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::ValueNodeDynamicListRotateOrder);
46 ACTION_SET_NAME(Action::ValueNodeDynamicListRotateOrder,"value_node_dynamic_list_rotate_order");
47 ACTION_SET_LOCAL_NAME(Action::ValueNodeDynamicListRotateOrder,"Rotate Order");
48 ACTION_SET_TASK(Action::ValueNodeDynamicListRotateOrder,"rotate");
49 ACTION_SET_CATEGORY(Action::ValueNodeDynamicListRotateOrder,Action::CATEGORY_VALUEDESC|Action::CATEGORY_VALUENODE);
50 ACTION_SET_PRIORITY(Action::ValueNodeDynamicListRotateOrder,0);
51 ACTION_SET_VERSION(Action::ValueNodeDynamicListRotateOrder,"0.0");
52 ACTION_SET_CVS_ID(Action::ValueNodeDynamicListRotateOrder,"$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::ValueNodeDynamicListRotateOrder::ValueNodeDynamicListRotateOrder()
67 Action::ValueNodeDynamicListRotateOrder::get_param_vocab()
69 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
71 ret.push_back(ParamDesc("value_desc",Param::TYPE_VALUEDESC)
72 .set_local_name(_("ValueDesc"))
79 Action::ValueNodeDynamicListRotateOrder::is_candidate(const ParamList &x)
81 if(candidate_check(get_param_vocab(),x))
83 ValueDesc value_desc(x.find("value_desc")->second.get_value_desc());
84 if(!value_desc.parent_is_value_node() || !ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node()))
93 Action::ValueNodeDynamicListRotateOrder::set_param(const synfig::String& name, const Action::Param ¶m)
95 if(name=="value_desc" && param.get_type()==Param::TYPE_VALUEDESC)
97 ValueDesc value_desc(param.get_value_desc());
99 if(!value_desc.parent_is_value_node())
102 value_node=ValueNode_DynamicList::Handle::cast_dynamic(value_desc.get_parent_value_node());
107 index=value_desc.get_index();
112 return Action::CanvasSpecific::set_param(name,param);
116 Action::ValueNodeDynamicListRotateOrder::is_ready()const
120 return Action::CanvasSpecific::is_ready();
124 Action::ValueNodeDynamicListRotateOrder::prepare()
128 for(int i(0);i<(value_node->link_count()-index)%value_node->link_count();++i)
130 ValueDesc value_desc(value_node,value_node->link_count()-1-i);
131 ValueNode::Handle child(value_desc.get_value_node());
134 Action::Handle action(Action::create("value_node_dynamic_list_remove"));
136 action->set_param("canvas",get_canvas());
137 action->set_param("canvas_interface",get_canvas_interface());
138 action->set_param("value_desc",ValueDesc(value_node,value_node->link_count()-1));
140 assert(action->is_ready());
141 if(!action->is_ready())
142 throw Error(Error::TYPE_NOTREADY);
147 action=Action::create("value_node_dynamic_list_insert");
149 action->set_param("canvas",get_canvas());
150 action->set_param("canvas_interface",get_canvas_interface());
151 action->set_param("value_desc",ValueDesc(value_node,0));
152 action->set_param("item",child);
154 assert(action->is_ready());
155 if(!action->is_ready())
156 throw Error(Error::TYPE_NOTREADY);