1 /* === S Y N F I G ========================================================= */
2 /*! \file valuenode_animated.h
3 ** \brief Header file for implementation of the "Animated" valuenode conversion.
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 /* === S T A R T =========================================================== */
25 #ifndef __SYNFIG_VALUENODE_ANIMATED_H
26 #define __SYNFIG_VALUENODE_ANIMATED_H
28 /* === H E A D E R S ======================================================= */
32 #include "valuenode.h"
36 /* === M A C R O S ========================================================= */
38 /* === C L A S S E S & S T R U C T S ======================================= */
42 /*! \class ValueNode_Animated
43 * \brief Virtual class for the derived ValueNode Animated implementations.
45 * It stores the list of waypoints and defines the base methods for:
46 * add a given waypoint, return a new waypoint at a given time, some find
47 * functions to find waypoints in the list, and to create a handles to
48 * ValueNode_Animated based on the ValueBase Type of the given value node.
49 * Also defines virtual methods to add a new waypoint at a given time using
50 * a value node. They must be redefined by the inherited classes and will
51 * be different depending on the type of value being animated.
53 struct ValueNode_Animated : public ValueNode
56 typedef etl::handle<ValueNode_Animated> Handle;
57 typedef etl::handle<const ValueNode_Animated> ConstHandle;
59 typedef synfig::Waypoint Waypoint;
60 typedef synfig::WaypointList WaypointList;
62 typedef std::pair<WaypointList::iterator,bool> findresult;
63 typedef std::pair<WaypointList::const_iterator,bool> const_findresult;
66 WaypointList waypoint_list_;
69 WaypointList &waypoint_list() { return waypoint_list_; }
71 const WaypointList &waypoint_list()const { return waypoint_list_; }
73 //! Creates a new waypoint at a Time \t with a given ValueBase \value
74 //! Must be redefined in the inherited class
75 virtual WaypointList::iterator new_waypoint(Time t, ValueBase value)=0;
76 //! Creates a new waypoint at a Time \t with a given ValueNode handle \value_node
77 //! Must be redefined in the inherited class
78 virtual WaypointList::iterator new_waypoint(Time t, ValueNode::Handle value_node)=0;
80 //! Returns a new waypoint at a given time but it is not inserted in the Waypoint List.
81 /*! \note this does not add any waypoint to the ValueNode! */
82 Waypoint new_waypoint_at_time(const Time& t)const;
84 //! Adds a waypoint \x
85 //! \see : Waypoint new_waypoint_at_time(const Time& t)const;
86 WaypointList::iterator add(const Waypoint &x);
88 //! Removes a waypoint based on its UniqueId from the waypoint list
89 void erase(const UniqueID &x);
91 //! Finds Waypoint iterator and associated boolean if found. Find by UniqueID
92 findresult find_uid(const UniqueID &x);
93 //! Finds Waypoint iterator and associated boolean if found. Find by UniqueID
94 const_findresult find_uid(const UniqueID &x)const;
95 //! Finds Waypoint iterator and associated boolean if found. Find by Time
96 findresult find_time(const Time &x);
97 //! Finds Waypoint iterator and associated boolean if found. Find by Time
98 const_findresult find_time(const Time &x)const;
100 //! Finds a Waypoint by given UniqueID \x
101 WaypointList::iterator find(const UniqueID &x);
102 //! Finds a Waypoint by given UniqueID \x
103 WaypointList::const_iterator find(const UniqueID &x)const;
104 //! Finds a Waypoint by given Time \x
105 WaypointList::iterator find(const Time &x);
106 //! Finds a Waypoint by given Time \x
107 WaypointList::const_iterator find(const Time &x)const;
109 //! Finds next Waypoint at a given time \x starting from current waypoint
110 WaypointList::iterator find_next(const Time &x);
111 //! Finds next Waypoint at a given time \x starting from current waypoint
112 WaypointList::const_iterator find_next(const Time &x)const;
113 //! Finds previous Waypoint at a given time \x starting from current waypoint
114 WaypointList::iterator find_prev(const Time &x);
115 //! Finds previous Waypoint at a given time \x starting from current waypoint
116 WaypointList::const_iterator find_prev(const Time &x)const;
118 virtual ~ValueNode_Animated();
120 virtual String get_name()const;
121 virtual String get_local_name()const;
123 //! Creates a Valuenode_Animated by type
124 static Handle create(ValueBase::Type type);
125 //! Creates a Valuenode_Animated by ValueBase and Time
126 static Handle create(const ValueBase& value, const Time& time);
127 //! Creates a Valuenode_Animated by ValueNode and Time
128 static Handle create(ValueNode::Handle value_node, const Time& time);
130 //! Fills the \list with the waypoints between \begin and \end
131 int find(const Time& begin,const Time& end,std::vector<Waypoint*>& list);
133 //! Inserts time \delta from time \location to the waypoints.
134 //! used to move waypoints in the time line.
135 void insert_time(const Time& location, const Time& delta);
138 ValueNode_Animated();
140 void set_type(ValueBase::Type t);
141 virtual void get_times_vfunc(Node::time_set &set) const;
144 }; // END of namespace synfig
146 /* === E N D =============================================================== */