Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
cinder::Timeline Class Reference

#include <Timeline.h>

Inheritance diagram for cinder::Timeline:
[legend]

Public Member Functions

void step (float timestep)
 Advances time a specified amount and evaluates items. More...
 
void stepTo (float absoluteTime)
 Goes to a specific time and evaluates items. More...
 
float getCurrentTime () const
 Returns the timeline's most recent current time. More...
 
template<typename T >
Tween< T >::Options apply (Anim< T > *target, T endValue, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
 Replaces any existing tweens on the target with a new tween at the timeline's current time. More...
 
template<typename T >
Tween< T >::Options apply (Anim< T > *target, T startValue, T endValue, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
 Replaces any existing tweens on the target with a new tween at the timeline's current time. More...
 
template<typename T >
Tween< T >::Options appendTo (Anim< T > *target, T endValue, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
 Creates a new tween and adds it to the end of the last tween on target, or if no existing tween matches the target, the current time. More...
 
template<typename T >
Tween< T >::Options appendTo (Anim< T > *target, T startValue, T endValue, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
 Creates a new tween and adds it to the end of the last tween on target, or if no existing tween matches the target, the current time. More...
 
template<typename T >
Tween< T >::Options applyPtr (T *target, T endValue, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
 Replaces any existing tweens on the target with a new tween at the timeline's current time. Consider the apply( Anim<T>* ) variant unless you have an advanced use case. More...
 
template<typename T >
Tween< T >::Options applyPtr (T *target, T startValue, T endValue, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
 Replaces any existing tweens on the target with a new tween at the timeline's current time. Consider the apply( Anim<T>* ) variant unless you have an advanced use case. More...
 
template<typename T >
Tween< T >::Options appendToPtr (T *target, T endValue, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
 Creates a new tween and adds it to the end of the last tween on target, or if no existing tween matches the target, the current time. Consider the appendTo( Anim<T>* ) variant unless you have an advanced use case. More...
 
template<typename T >
Tween< T >::Options appendToPtr (T *target, T startValue, T endValue, float duration, EaseFn easeFunction=easeNone, typename Tween< T >::LerpFn lerpFunction=&tweenLerp< T >)
 Creates a new tween and adds it to the end of the last tween on target, or if no existing tween matches the target, the current time. Consider the appendTo( Anim<T>* ) variant unless you have an advanced use case. More...
 
CueRef add (const std::function< void()> &action, float atTime)
 add a cue to the Timeline add the start-time atTime More...
 
template<typename T >
FnTweenRef< T > applyFn (const std::function< void(T)> &fn, T startValue, T endValue, float duration, const EaseFn &easeFunction=easeNone, const typename Tween< T >::LerpFn &lerpFunction=&tweenLerp< T >)
 
void appendPingPong ()
 Appends to the end of the timeline mirror images of all items. More...
 
void apply (TimelineItemRef item)
 Replaces any existing TimelineItems that match item's target and adds item to the timeline. Safe to use from callback fn's. More...
 
void add (TimelineItemRef item)
 add an item to the timeline at the current time. Safe to use from callback fn's. More...
 
void insert (TimelineItemRef item)
 adds an item to the timeline. Its start time is not modified. Safe to use from callback fn's. More...
 
void insert (TimelineItemRef item, float atTime)
 adds an item to the timeline, setting its startTime to be at atTime. Safe to use from callback fn's. More...
 
size_t getNumItems () const
 Returns the number of items in the Timeline. More...
 
bool empty () const
 Returns true if there are no items in the Timeline. More...
 
TimelineItemRef find (void *target) const
 Returns the first item in the timeline the target of which matches target. More...
 
TimelineItemRef findLast (void *target) const
 Returns the latest-starting item in the timeline the target of which matches target. More...
 
TimelineItemRef findLastEnd (void *target) const
 Returns the latest-end item in the timeline the target of which matches target. More...
 
float findEndTimeOf (void *target, bool *found=NULL) const
 Returns the end of the latest-ending item in the timeline the target of which matches target, or the current time if it's not found. found can store whether a related item was found. More...
 
void remove (TimelineItemRef item)
 Removes the TimelineItem item from the Timeline. Safe to use from callback fn's. More...
 
void removeTarget (void *target)
 Removes all TimelineItems whose target matches target. More...
 
void cloneAndReplaceTarget (void *target, void *replacementTarget)
 Clones all TimelineItems whose target matches target, but replacing their target with replacementTarget. More...
 
void replaceTarget (void *target, void *replacementTarget)
 Replaces the target of all TimelineItems whose target matches target, with replacementTarget. More...
 
void clear ()
 Remove all tweens from the Timeline. Do not call from callback fn's. More...
 
void reset (bool unsetStarted=false)
 Sets the time to zero, marks all tweens as not completed, and if unsetStarted, marks the tweens as not started. Do not call from callback fn's. More...
 
void setDefaultAutoRemove (bool defaultAutoRemove)
 Sets the default autoRemove value for all future TimelineItems added to the Timeline. More...
 
bool getDefaultAutoRemove () const
 Returns the default autoRemove value for all future TimelineItems added to the Timeline. More...
 
void itemTimeChanged (TimelineItem *item)
 Call this to notify the Timeline if the item's start-time or duration has changed. Advanced use cases only. More...
 
TimelineRef thisRef ()
 
voidgetTarget () const
 Returns the item's target pointer. More...
 
float getStartTime () const
 Returns the item's start time. More...
 
void setStartTime (float newTime)
 Set the items's start time to newTime. More...
 
float getDuration () const
 Returns the item's duration. More...
 
void setDuration (float newDuration)
 Sets the item's duration to newDuration. More...
 
bool getLoop () const
 Returns whether the item starts over when it is complete. More...
 
void setLoop (bool doLoop=true)
 Sets whether the item starts over when it is complete. More...
 
bool getPingPong () const
 Returns whether the item alternates between forward and reverse. Overrides loop when true. More...
 
void setPingPong (bool pingPong=true)
 Sets whether the item alternates between forward and reverse. Overrides loop when true. More...
 
bool getInfinite () const
 Returns whether the item ever is marked as complete. More...
 
void setInfinite (bool infinite=true)
 Sets whether the item ever is marked as complete. More...
 
float getEndTime () const
 Returns the time of the item's competion, equivalent to getStartTime() + getDuration(). More...
 
class TimelinegetParent () const
 Returns a pointer to the item's parent Timeline. More...
 
void removeSelf ()
 Removes the item from its parent Timeline. More...
 
bool hasStarted () const
 Returns whether the item has started. More...
 
bool isComplete ()
 Returns whether the item has completed. More...
 
bool getAutoRemove () const
 Should the item remove itself from the Timeline when it is complete. More...
 
void setAutoRemove (bool autoRemove=true)
 Sets whether the item will remove itself from the Timeline when it is complete. More...
 
virtual bool updateAtLoopStart ()
 Call update() only at the beginning of each loop (for example Cues exhibit require this behavior) More...
 
void stepTo (float time, bool reverse)
 go to a specific time, generally called by the parent Timeline only. If reverse then playhead is interpreted as retreating rather than advancing. More...
 

Static Public Member Functions

static TimelineRef create ()
 Creates a new timeline, defaulted to infinite. More...
 

Protected Member Functions

 Timeline ()
 
virtual void reverse ()
 
virtual TimelineItemRef cloneReverse () const
 Creates a cloned item which runs in reverse relative to a timeline of duration timelineDuration. More...
 
virtual TimelineItemRef clone () const
 Creates a clone of the item. More...
 
virtual void start (bool reverse)
 
virtual void loopStart ()
 
virtual void update (float absTime)
 
virtual void complete (bool reverse)
 
void eraseMarked ()
 
virtual float calcDuration () const
 
void setDurationDirty ()
 
void updateDuration () const
 
float loopTime (float absTime)
 Converts time from absolute to absolute based on item's looping attributes. More...
 
void setTarget (void *target)
 

Protected Attributes

bool mDefaultAutoRemove
 
float mCurrentTime
 
std::multimap< void
*, TimelineItemRef
mItems
 
class TimelinemParent
 
voidmTarget
 
float mStartTime
 
bool mHasStarted
 
bool mHasReverseStarted
 
bool mComplete
 
bool mReverseComplete
 
bool mMarkedForRemoval
 
bool mInfinite
 
bool mLoop
 
bool mPingPong
 
bool mUseAbsoluteTime
 
bool mAutoRemove
 
int32_t mLastLoopIteration
 

Constructor & Destructor Documentation

cinder::Timeline::Timeline ( )
protected

Member Function Documentation

static TimelineRef cinder::Timeline::create ( )
static

Creates a new timeline, defaulted to infinite.

void cinder::Timeline::step ( float  timestep)

Advances time a specified amount and evaluates items.

void cinder::Timeline::stepTo ( float  absoluteTime)

Goes to a specific time and evaluates items.

float cinder::Timeline::getCurrentTime ( ) const

Returns the timeline's most recent current time.

template<typename T >
Tween<T>::Options cinder::Timeline::apply ( Anim< T > *  target,
endValue,
float  duration,
EaseFn  easeFunction = easeNone,
typename Tween< T >::LerpFn  lerpFunction = &tweenLerp<T> 
)

Replaces any existing tweens on the target with a new tween at the timeline's current time.

template<typename T >
Tween<T>::Options cinder::Timeline::apply ( Anim< T > *  target,
startValue,
endValue,
float  duration,
EaseFn  easeFunction = easeNone,
typename Tween< T >::LerpFn  lerpFunction = &tweenLerp<T> 
)

Replaces any existing tweens on the target with a new tween at the timeline's current time.

template<typename T >
Tween<T>::Options cinder::Timeline::appendTo ( Anim< T > *  target,
endValue,
float  duration,
EaseFn  easeFunction = easeNone,
typename Tween< T >::LerpFn  lerpFunction = &tweenLerp<T> 
)

Creates a new tween and adds it to the end of the last tween on target, or if no existing tween matches the target, the current time.

template<typename T >
Tween<T>::Options cinder::Timeline::appendTo ( Anim< T > *  target,
startValue,
endValue,
float  duration,
EaseFn  easeFunction = easeNone,
typename Tween< T >::LerpFn  lerpFunction = &tweenLerp<T> 
)

Creates a new tween and adds it to the end of the last tween on target, or if no existing tween matches the target, the current time.

template<typename T >
Tween<T>::Options cinder::Timeline::applyPtr ( T *  target,
endValue,
float  duration,
EaseFn  easeFunction = easeNone,
typename Tween< T >::LerpFn  lerpFunction = &tweenLerp<T> 
)

Replaces any existing tweens on the target with a new tween at the timeline's current time. Consider the apply( Anim<T>* ) variant unless you have an advanced use case.

template<typename T >
Tween<T>::Options cinder::Timeline::applyPtr ( T *  target,
startValue,
endValue,
float  duration,
EaseFn  easeFunction = easeNone,
typename Tween< T >::LerpFn  lerpFunction = &tweenLerp<T> 
)

Replaces any existing tweens on the target with a new tween at the timeline's current time. Consider the apply( Anim<T>* ) variant unless you have an advanced use case.

template<typename T >
Tween<T>::Options cinder::Timeline::appendToPtr ( T *  target,
endValue,
float  duration,
EaseFn  easeFunction = easeNone,
typename Tween< T >::LerpFn  lerpFunction = &tweenLerp<T> 
)

Creates a new tween and adds it to the end of the last tween on target, or if no existing tween matches the target, the current time. Consider the appendTo( Anim<T>* ) variant unless you have an advanced use case.

template<typename T >
Tween<T>::Options cinder::Timeline::appendToPtr ( T *  target,
startValue,
endValue,
float  duration,
EaseFn  easeFunction = easeNone,
typename Tween< T >::LerpFn  lerpFunction = &tweenLerp<T> 
)

Creates a new tween and adds it to the end of the last tween on target, or if no existing tween matches the target, the current time. Consider the appendTo( Anim<T>* ) variant unless you have an advanced use case.

CueRef cinder::Timeline::add ( const std::function< void()> &  action,
float  atTime 
)

add a cue to the Timeline add the start-time atTime

template<typename T >
FnTweenRef<T> cinder::Timeline::applyFn ( const std::function< void(T)> &  fn,
startValue,
endValue,
float  duration,
const EaseFn easeFunction = easeNone,
const typename Tween< T >::LerpFn &  lerpFunction = &tweenLerp<T> 
)
void cinder::Timeline::appendPingPong ( )

Appends to the end of the timeline mirror images of all items.

void cinder::Timeline::apply ( TimelineItemRef  item)

Replaces any existing TimelineItems that match item's target and adds item to the timeline. Safe to use from callback fn's.

void cinder::Timeline::add ( TimelineItemRef  item)

add an item to the timeline at the current time. Safe to use from callback fn's.

void cinder::Timeline::insert ( TimelineItemRef  item)

adds an item to the timeline. Its start time is not modified. Safe to use from callback fn's.

void cinder::Timeline::insert ( TimelineItemRef  item,
float  atTime 
)

adds an item to the timeline, setting its startTime to be at atTime. Safe to use from callback fn's.

size_t cinder::Timeline::getNumItems ( ) const

Returns the number of items in the Timeline.

bool cinder::Timeline::empty ( ) const

Returns true if there are no items in the Timeline.

TimelineItemRef cinder::Timeline::find ( void target) const

Returns the first item in the timeline the target of which matches target.

TimelineItemRef cinder::Timeline::findLast ( void target) const

Returns the latest-starting item in the timeline the target of which matches target.

TimelineItemRef cinder::Timeline::findLastEnd ( void target) const

Returns the latest-end item in the timeline the target of which matches target.

float cinder::Timeline::findEndTimeOf ( void target,
bool *  found = NULL 
) const

Returns the end of the latest-ending item in the timeline the target of which matches target, or the current time if it's not found. found can store whether a related item was found.

void cinder::Timeline::remove ( TimelineItemRef  item)

Removes the TimelineItem item from the Timeline. Safe to use from callback fn's.

void cinder::Timeline::removeTarget ( void target)

Removes all TimelineItems whose target matches target.

void cinder::Timeline::cloneAndReplaceTarget ( void target,
void replacementTarget 
)

Clones all TimelineItems whose target matches target, but replacing their target with replacementTarget.

void cinder::Timeline::replaceTarget ( void target,
void replacementTarget 
)

Replaces the target of all TimelineItems whose target matches target, with replacementTarget.

void cinder::Timeline::clear ( )

Remove all tweens from the Timeline. Do not call from callback fn's.

void cinder::Timeline::reset ( bool  unsetStarted = false)
virtual

Sets the time to zero, marks all tweens as not completed, and if unsetStarted, marks the tweens as not started. Do not call from callback fn's.

Reimplemented from cinder::TimelineItem.

void cinder::Timeline::setDefaultAutoRemove ( bool  defaultAutoRemove)

Sets the default autoRemove value for all future TimelineItems added to the Timeline.

bool cinder::Timeline::getDefaultAutoRemove ( ) const

Returns the default autoRemove value for all future TimelineItems added to the Timeline.

void cinder::Timeline::itemTimeChanged ( TimelineItem item)

Call this to notify the Timeline if the item's start-time or duration has changed. Advanced use cases only.

TimelineRef cinder::Timeline::thisRef ( )
void cinder::Timeline::reverse ( )
protectedvirtual

Implements cinder::TimelineItem.

TimelineItemRef cinder::Timeline::cloneReverse ( ) const
protectedvirtual

Creates a cloned item which runs in reverse relative to a timeline of duration timelineDuration.

Implements cinder::TimelineItem.

TimelineItemRef cinder::Timeline::clone ( ) const
protectedvirtual

Creates a clone of the item.

Implements cinder::TimelineItem.

virtual void cinder::Timeline::start ( bool  reverse)
protectedvirtual

Implements cinder::TimelineItem.

void cinder::Timeline::loopStart ( )
protectedvirtual

Reimplemented from cinder::TimelineItem.

void cinder::Timeline::update ( float  absTime)
protectedvirtual

Implements cinder::TimelineItem.

virtual void cinder::Timeline::complete ( bool  reverse)
protectedvirtual

Implements cinder::TimelineItem.

void cinder::Timeline::eraseMarked ( )
protected
float cinder::Timeline::calcDuration ( ) const
protectedvirtual

Reimplemented from cinder::TimelineItem.

void* cinder::TimelineItem::getTarget ( ) const
inherited

Returns the item's target pointer.

float cinder::TimelineItem::getStartTime ( ) const
inherited

Returns the item's start time.

void cinder::TimelineItem::setStartTime ( float  newTime)
inherited

Set the items's start time to newTime.

float cinder::TimelineItem::getDuration ( ) const
inherited

Returns the item's duration.

void cinder::TimelineItem::setDuration ( float  newDuration)
inherited

Sets the item's duration to newDuration.

bool cinder::TimelineItem::getLoop ( ) const
inherited

Returns whether the item starts over when it is complete.

void cinder::TimelineItem::setLoop ( bool  doLoop = true)
inherited

Sets whether the item starts over when it is complete.

bool cinder::TimelineItem::getPingPong ( ) const
inherited

Returns whether the item alternates between forward and reverse. Overrides loop when true.

void cinder::TimelineItem::setPingPong ( bool  pingPong = true)
inherited

Sets whether the item alternates between forward and reverse. Overrides loop when true.

bool cinder::TimelineItem::getInfinite ( ) const
inherited

Returns whether the item ever is marked as complete.

void cinder::TimelineItem::setInfinite ( bool  infinite = true)
inherited

Sets whether the item ever is marked as complete.

float cinder::TimelineItem::getEndTime ( ) const
inherited

Returns the time of the item's competion, equivalent to getStartTime() + getDuration().

class Timeline* cinder::TimelineItem::getParent ( ) const
inherited

Returns a pointer to the item's parent Timeline.

void cinder::TimelineItem::removeSelf ( )
inherited

Removes the item from its parent Timeline.

bool cinder::TimelineItem::hasStarted ( ) const
inherited

Returns whether the item has started.

bool cinder::TimelineItem::isComplete ( )
inherited

Returns whether the item has completed.

bool cinder::TimelineItem::getAutoRemove ( ) const
inherited

Should the item remove itself from the Timeline when it is complete.

void cinder::TimelineItem::setAutoRemove ( bool  autoRemove = true)
inherited

Sets whether the item will remove itself from the Timeline when it is complete.

virtual bool cinder::TimelineItem::updateAtLoopStart ( )
virtualinherited

Call update() only at the beginning of each loop (for example Cues exhibit require this behavior)

Reimplemented in cinder::Cue.

void cinder::TimelineItem::stepTo ( float  time,
bool  reverse 
)
inherited

go to a specific time, generally called by the parent Timeline only. If reverse then playhead is interpreted as retreating rather than advancing.

void cinder::TimelineItem::setDurationDirty ( )
protectedinherited
void cinder::TimelineItem::updateDuration ( ) const
protectedinherited
float cinder::TimelineItem::loopTime ( float  absTime)
protectedinherited

Converts time from absolute to absolute based on item's looping attributes.

void cinder::TimelineItem::setTarget ( void target)
protectedinherited

Member Data Documentation

bool cinder::Timeline::mDefaultAutoRemove
protected
float cinder::Timeline::mCurrentTime
protected
std::multimap<void*,TimelineItemRef> cinder::Timeline::mItems
protected
class Timeline* cinder::TimelineItem::mParent
protectedinherited
void* cinder::TimelineItem::mTarget
protectedinherited
float cinder::TimelineItem::mStartTime
protectedinherited
bool cinder::TimelineItem::mHasStarted
protectedinherited
bool cinder::TimelineItem::mHasReverseStarted
protectedinherited
bool cinder::TimelineItem::mComplete
protectedinherited
bool cinder::TimelineItem::mReverseComplete
protectedinherited
bool cinder::TimelineItem::mMarkedForRemoval
protectedinherited
bool cinder::TimelineItem::mInfinite
protectedinherited
bool cinder::TimelineItem::mLoop
protectedinherited
bool cinder::TimelineItem::mPingPong
protectedinherited
bool cinder::TimelineItem::mUseAbsoluteTime
protectedinherited
bool cinder::TimelineItem::mAutoRemove
protectedinherited
int32_t cinder::TimelineItem::mLastLoopIteration
protectedinherited

The documentation for this class was generated from the following files: