1.10
Public Member Functions | Protected Types | Protected Attributes | List of all members
AnimationSequence Class Reference

Series of animations as a single animation. More...

#include <animation.h>

Inheritance diagram for AnimationSequence:
Inheritance graph
[legend]

Public Member Functions

 AnimationSequence (bool loop=false) noexcept
 
virtual void add (const std::shared_ptr< detail::AnimationBase > &animation)
 Add a sub animation to the sequence.
 
template<class T >
void add (const std::shared_ptr< T > &animation)
 Add an animation to the animation sequence.
 
virtual void add (detail::AnimationBase &animation)
 Add an animation to the animation sequence.
 
bool next () override
 Periodic call to the animation.
 
void remove (detail::AnimationBase *animation)
 Remove the first occurence of a sub animation from the sequence.
 
void removeAt (size_t pos)
 Remove the sub animation at the given position from the sequence.
 
void removeLast ()
 Remove the last sub animation from the sequence.
 
void resume () override
 Resume the animation.
 
bool skip ()
 Skip to the next sub animation in the sequence.
 
void start () override
 Start the animation.
 
void stop () override
 Stop the animation.
 
- Public Member Functions inherited from AnimationBase
 AnimationBase ()=default
 
 AnimationBase (AnimationBase &&) noexcept=default
 
 AnimationBase (const AnimationBase &)=delete
 
virtual ~AnimationBase () noexcept=default
 
void add_callback (AnimationCallback callback)
 Register a callback for the animation.
 
void clear_callbacks ()
 Clear all callbacks.
 
AnimationBaseoperator= (AnimationBase &&) noexcept=default
 
AnimationBaseoperator= (const AnimationBase &)=delete
 
virtual EGT_NODISCARD bool running () const
 Returns true if the animation is currently running.
 

Protected Types

using AnimationArray = std::vector< std::shared_ptr< detail::AnimationBase > >
 Helper type for an array of animations.
 

Protected Attributes

AnimationArray m_animations
 The animations of the sequence.
 
size_t m_current {0}
 Index of the current animation.
 
bool m_loop {false}
 Should the animation sequence loop?
 
- Protected Attributes inherited from AnimationBase
std::vector< AnimationCallbackm_callbacks
 Registered callbacks for the animation.
 
bool m_running {false}
 The running state of the animation.
 

Detailed Description

Series of animations as a single animation.

It's often useful to put together a series of animations into a sequence. This class manages a series of animations objects and runs them as one big animation. You can even add animation sequences to other animation sequences to build up complex sequences.

You can skip the current sub-animation, you can restart to the beginning of the sequence, or you can stop the entire thing.

Member Typedef Documentation

◆ AnimationArray

using AnimationArray = std::vector<std::shared_ptr<detail::AnimationBase> >
protected

Helper type for an array of animations.

Constructor & Destructor Documentation

◆ AnimationSequence()

AnimationSequence ( bool  loop = false)
inlineexplicitnoexcept
Parameters
loopShould the animation sequence loop.

Member Function Documentation

◆ add() [1/3]

virtual void add ( const std::shared_ptr< detail::AnimationBase > &  animation)
inlinevirtual

Add a sub animation to the sequence.

Parameters
animationThe animation.

◆ add() [2/3]

template<class T >
void add ( const std::shared_ptr< T > &  animation)
inline

Add an animation to the animation sequence.

This will take a reference to the shared_ptr and manage the lifetime of the animation.

Parameters
animationThe animation.

◆ add() [3/3]

virtual void add ( detail::AnimationBase animation)
inlinevirtual

Add an animation to the animation sequence.

Parameters
animationThe animation.

◆ next()

bool next ( )
inlineoverridevirtual

Periodic call to the animation.

This must be called until it returns false. When it returns false, the animation is done.

Implements AnimationBase.

◆ remove()

void remove ( detail::AnimationBase animation)
inline

Remove the first occurence of a sub animation from the sequence.

Parameters
animationThe animation.

◆ removeAt()

void removeAt ( size_t  pos)
inline

Remove the sub animation at the given position from the sequence.

Parameters
posPosition of the sub animation to remove. pos starts from 0.

◆ removeLast()

void removeLast ( )
inline

Remove the last sub animation from the sequence.

◆ resume()

void resume ( )
inlineoverridevirtual

Resume the animation.

Implements AnimationBase.

◆ skip()

bool skip ( )
inline

Skip to the next sub animation in the sequence.

◆ start()

void start ( )
inlineoverridevirtual

Start the animation.

Implements AnimationBase.

◆ stop()

void stop ( )
inlineoverridevirtual

Stop the animation.

Implements AnimationBase.

Member Data Documentation

◆ m_animations

AnimationArray m_animations
protected

The animations of the sequence.

◆ m_current

size_t m_current {0}
protected

Index of the current animation.

◆ m_loop

bool m_loop {false}
protected

Should the animation sequence loop?