1 /* === S Y N F I G ========================================================= */
2 /*! \file waypointdisconnect.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 "waypointdisconnect.h"
34 #include <synfigapp/canvasinterface.h>
35 #include <synfig/valuenode_const.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::WaypointDisconnect);
50 ACTION_SET_NAME(Action::WaypointDisconnect,"WaypointDisconnect");
51 ACTION_SET_LOCAL_NAME(Action::WaypointDisconnect,N_("Disconnect Waypoint"));
52 ACTION_SET_TASK(Action::WaypointDisconnect,"disconnect");
53 ACTION_SET_CATEGORY(Action::WaypointDisconnect,Action::CATEGORY_WAYPOINT);
54 ACTION_SET_PRIORITY(Action::WaypointDisconnect,0);
55 ACTION_SET_VERSION(Action::WaypointDisconnect,"0.0");
56 ACTION_SET_CVS_ID(Action::WaypointDisconnect,"$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::WaypointDisconnect::WaypointDisconnect():
65 waypoint_time_set(false),
71 Action::WaypointDisconnect::get_param_vocab()
73 ParamVocab ret(Action::CanvasSpecific::get_param_vocab());
75 ret.push_back(ParamDesc("parent_value_node",Param::TYPE_VALUENODE)
76 .set_local_name(_("Parent ValueNode"))
79 ret.push_back(ParamDesc("waypoint_time",Param::TYPE_TIME)
80 .set_local_name(_("Waypoint Time"))
83 ret.push_back(ParamDesc("time",Param::TYPE_TIME)
84 .set_local_name(_("Time"))
92 Action::WaypointDisconnect::is_candidate(const ParamList &x)
94 return candidate_check(get_param_vocab(),x);
98 Action::WaypointDisconnect::set_param(const synfig::String& name, const Action::Param ¶m)
100 if(name=="parent_value_node" && param.get_type()==Param::TYPE_VALUENODE)
102 parent_value_node=ValueNode_Animated::Handle::cast_dynamic(param.get_value_node());
104 return static_cast<bool>(parent_value_node);
107 if(name=="waypoint_time" && param.get_type()==Param::TYPE_TIME)
109 waypoint_time=param.get_time();
110 waypoint_time_set=true;
115 if(name=="time" && param.get_type()==Param::TYPE_TIME)
117 time=param.get_time();
123 return Action::CanvasSpecific::set_param(name,param);
127 Action::WaypointDisconnect::is_ready()const
129 if(!parent_value_node || !waypoint_time_set)
131 return Action::CanvasSpecific::is_ready();
135 Action::WaypointDisconnect::perform()
137 ValueNode_Animated::WaypointList::iterator iter(parent_value_node->find(waypoint_time));
139 old_value_node=iter->get_value_node();
141 iter->set_value_node(ValueNode_Const::create((*old_value_node)(time_set ? time : waypoint_time)));
144 if(get_canvas()->get_time()!=time)
149 if(get_canvas_interface())
151 get_canvas_interface()->signal_value_node_changed()(parent_value_node);
157 Action::WaypointDisconnect::undo()
159 ValueNode_Animated::WaypointList::iterator iter(parent_value_node->find(waypoint_time));
161 iter->set_value_node(old_value_node);
163 /*if(get_canvas()->get_time()!=time)
168 if(get_canvas_interface())
170 get_canvas_interface()->signal_value_node_changed()(parent_value_node);