Antkeeper
0.0.1
|
Timeline which executes cues (scheduled functions) when advanced over their respective positions in time. More...
#include <timeline.hpp>
Public Types | |
typedef std::tuple< float, std::function< void()> > | cue |
Scheduled function consisting of a time and function object. More... | |
typedef std::list< cue > | sequence |
List of cues. More... | |
Public Member Functions | |
timeline () | |
Creates a timeline. More... | |
void | advance (float dt) |
Advances the timeline position (t) by dt , triggering any cues scheduled between t and dt . More... | |
void | seek (float t) |
Sets the timeline position to t . More... | |
void | add_cue (const cue &c) |
Adds a cue to the timeline. More... | |
void | remove_cue (const cue &c) |
Removes a cue from the timeline. More... | |
void | remove_cues (float start, float end) |
Removes all cues on [start, end) . More... | |
void | add_sequence (const sequence &s) |
Adds a sequence of cues to the timeline. More... | |
void | remove_sequence (const sequence &s) |
Removes a sequence of cues from the timeline. More... | |
void | clear () |
Removes all cues from the timeline. More... | |
void | set_autoremove (bool enabled) |
If enabled, cues will be automatically removed from the timeline when they are triggered. More... | |
float | get_position () const |
Returns the current position in time on the timeline. More... | |
sequence | get_cues (float start, float end) const |
Returns all the cues on [start, end) . More... | |
Timeline which executes cues (scheduled functions) when advanced over their respective positions in time.
Definition at line 30 of file timeline.hpp.
typedef std::tuple<float, std::function<void()> > timeline::cue |
Scheduled function consisting of a time and function object.
Definition at line 34 of file timeline.hpp.
typedef std::list<cue> timeline::sequence |
List of cues.
Definition at line 37 of file timeline.hpp.
timeline::timeline | ( | ) |
Creates a timeline.
Definition at line 27 of file timeline.cpp.
void timeline::add_cue | ( | const cue & | c | ) |
void timeline::add_sequence | ( | const sequence & | s | ) |
Adds a sequence of cues to the timeline.
s | Sequence of cues to add. |
Definition at line 73 of file timeline.cpp.
void timeline::advance | ( | float | dt | ) |
Advances the timeline position (t) by dt
, triggering any cues scheduled between t
and dt
.
If autoremove is enabled, triggered cues will be removed.
dt | Delta time by which the timeline position will be advanced. |
Definition at line 33 of file timeline.cpp.
void timeline::clear | ( | ) |
Removes all cues from the timeline.
Definition at line 89 of file timeline.cpp.
timeline::sequence timeline::get_cues | ( | float | start, |
float | end | ||
) | const |
Returns all the cues on [start, end)
.
start | Starting position in time (inclusive). |
end | Ending position in time (non-inclusive). |
[start, end)
. Definition at line 99 of file timeline.cpp.
|
inline |
Returns the current position in time on the timeline.
Definition at line 126 of file timeline.hpp.
void timeline::remove_cue | ( | const cue & | c | ) |
Removes a cue from the timeline.
If there are multiple identical cues (same time and function), they will all be removed.
c | Cue to remove. |
Definition at line 61 of file timeline.cpp.
void timeline::remove_cues | ( | float | start, |
float | end | ||
) |
Removes all cues on [start, end)
.
start | Starting position in time (inclusive). |
end | Ending position in time (non-inclusive). |
Definition at line 66 of file timeline.cpp.
void timeline::remove_sequence | ( | const sequence & | s | ) |
Removes a sequence of cues from the timeline.
s | Sequence of cues to remove. |
Definition at line 81 of file timeline.cpp.
void timeline::seek | ( | float | t | ) |
Sets the timeline position to t
.
t | Position in time to which the timeline position will be set. |
Definition at line 51 of file timeline.cpp.
void timeline::set_autoremove | ( | bool | enabled | ) |
If enabled, cues will be automatically removed from the timeline when they are triggered.
enabled | Whether to enable autoremove. |
Definition at line 94 of file timeline.cpp.