Dali 3D User Interface Engine
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
Dali::Internal::SceneGraph::Animation Class Reference

Animations are used to change the properties of scene graph objects, as part of a scene managers "update" phase. More...

#include <scene-graph-animation.h>

Collaboration diagram for Dali::Internal::SceneGraph::Animation:
Collaboration graph
[legend]

Public Types

enum  State { Stopped, Playing, Paused, Destroyed }
 
typedef Dali::Animation::EndAction EndAction
 

Public Member Functions

virtual ~Animation ()
 Virtual destructor. More...
 
void operator delete (void *ptr)
 Overriden delete operator Deletes the animation from its global memory pool. More...
 
void SetDuration (float durationSeconds)
 Set the duration of an animation. More...
 
float GetDuration () const
 Retrieve the duration of the animation. More...
 
float GetCurrentProgress () const
 
void SetCurrentProgress (float progress)
 
void SetSpeedFactor (float factor)
 
void SetLoopCount (int loopCount)
 Set the animation loop count. More...
 
bool IsLooping () const
 Query whether the animation will loop. More...
 
int GetLoopCount () const
 
void SetEndAction (EndAction action)
 Set the end action of the animation. More...
 
EndAction GetEndAction ()
 Retrieve the action performed when the animation ends. More...
 
void SetDisconnectAction (EndAction action)
 Set the disconnect action of the animation when connected objects are disconnected. More...
 
EndAction GetDisconnectAction ()
 Retrieve the action performed when the animation is destroyed. More...
 
void SetPlayRange (const Vector2 &range)
 Set the playing range. More...
 
void Play ()
 Play the animation. More...
 
void PlayFrom (float progress)
 
void Pause ()
 Pause the animation. More...
 
bool Stop (BufferIndex bufferIndex)
 Stop the animation. More...
 
void OnDestroy (BufferIndex bufferIndex)
 Called shortly before the animation is destroyed. More...
 
State GetState () const
 Query whether the animation is playing, paused or stopped. More...
 
int GetPlayedCount () const
 Retrive a count of the number of times the animation has been played to completion. More...
 
int GetCurrentLoop () const
 Get the current loop count from zero to GetLoopCount(). More...
 
void AddAnimator (AnimatorBase *animator)
 Add a newly created animator. More...
 
AnimatorContainerGetAnimators ()
 Retrieve the animators from an animation. More...
 
void Update (BufferIndex bufferIndex, float elapsedSeconds, bool &looped, bool &finished)
 This causes the animators to change the properties of objects in the scene graph. More...
 

Static Public Member Functions

static AnimationNew (float durationSeconds, float speedFactor, const Vector2 &playRange, int loopCount, EndAction endAction, EndAction disconnectAction)
 Construct a new Animation. More...
 

Protected Member Functions

 Animation (float durationSeconds, float speedFactor, const Vector2 &playRange, int loopCount, EndAction endAction, EndAction disconnectAction)
 Protected constructor. More...
 

Protected Attributes

float mDurationSeconds
 
float mSpeedFactor
 
EndAction mEndAction
 
EndAction mDisconnectAction
 
State mState
 
float mElapsedSeconds
 
int mPlayedCount
 
int mLoopCount
 
int mCurrentLoop
 
Vector2 mPlayRange
 
AnimatorContainer mAnimators
 

Private Member Functions

void UpdateAnimators (BufferIndex bufferIndex, bool bake, bool animationFinished)
 Helper for Update, also used to bake when the animation is stopped or destroyed. More...
 
void Bake (BufferIndex bufferIndex, EndAction action)
 Helper function to bake the result of the animation when it is stopped or destroyed. More...
 
void SetAnimatorsActive (bool active)
 Helper function to set active state of animators. More...
 
 Animation (const Animation &)
 
Animationoperator= (const Animation &rhs)
 

Detailed Description

Animations are used to change the properties of scene graph objects, as part of a scene managers "update" phase.

An animation is a container of Animator objects; the actual setting of object values is done by the animators.

Definition at line 50 of file scene-graph-animation.h.

Member Typedef Documentation

Definition at line 54 of file scene-graph-animation.h.

Member Enumeration Documentation

Enumerator
Stopped 
Playing 
Paused 
Destroyed 

Definition at line 56 of file scene-graph-animation.h.

Constructor & Destructor Documentation

Dali::Internal::SceneGraph::Animation::~Animation ( )
virtual

Virtual destructor.

Definition at line 75 of file scene-graph-animation.cpp.

Dali::Internal::SceneGraph::Animation::Animation ( float  durationSeconds,
float  speedFactor,
const Vector2 playRange,
int  loopCount,
EndAction  endAction,
EndAction  disconnectAction 
)
protected

Protected constructor.

See New()

Definition at line 61 of file scene-graph-animation.cpp.

Referenced by New().

Here is the caller graph for this function:

Dali::Internal::SceneGraph::Animation::Animation ( const Animation )
private

Member Function Documentation

void Dali::Internal::SceneGraph::Animation::AddAnimator ( AnimatorBase animator)

Add a newly created animator.

Animators are automatically removed, when orphaned from an animatable scene object.

Parameters
[in]animatorThe animator to add.
[in]propertyOwnerThe scene-object that owns the animatable property.
Postcondition
The animator is owned by this animation.

Definition at line 242 of file scene-graph-animation.cpp.

References Dali::Internal::SceneGraph::AnimatorBase::ConnectToSceneGraph(), mAnimators, mDisconnectAction, Dali::Vector< T, IsTrivialType >::PushBack(), and Dali::Internal::SceneGraph::AnimatorBase::SetDisconnectAction().

Referenced by Dali::Internal::SceneGraph::AddAnimatorMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::Bake ( BufferIndex  bufferIndex,
EndAction  action 
)
private

Helper function to bake the result of the animation when it is stopped or destroyed.

Parameters
[in]bufferIndexThe buffer to update.
[in]actionThe end action specified.

Definition at line 168 of file scene-graph-animation.cpp.

References Dali::Animation::BakeFinal, Dali::Math::MACHINE_EPSILON_1, mDurationSeconds, mElapsedSeconds, mPlayRange, mSpeedFactor, UpdateAnimators(), Dali::Vector2::x, and Dali::Vector2::y.

Referenced by OnDestroy(), and Stop().

Here is the call graph for this function:

Here is the caller graph for this function:

AnimatorContainer& Dali::Internal::SceneGraph::Animation::GetAnimators ( )
inline

Retrieve the animators from an animation.

Returns
The container of animators.

Definition at line 265 of file scene-graph-animation.h.

References mAnimators.

int Dali::Internal::SceneGraph::Animation::GetCurrentLoop ( ) const
inline

Get the current loop count from zero to GetLoopCount().

Definition at line 247 of file scene-graph-animation.h.

References mCurrentLoop.

Referenced by Dali::Internal::Animation::HasFinished().

Here is the caller graph for this function:

float Dali::Internal::SceneGraph::Animation::GetCurrentProgress ( ) const
inline

Definition at line 107 of file scene-graph-animation.h.

References mDurationSeconds, and mElapsedSeconds.

Referenced by Dali::Internal::Animation::GetCurrentProgress().

Here is the caller graph for this function:

EndAction Dali::Internal::SceneGraph::Animation::GetDisconnectAction ( )
inline

Retrieve the action performed when the animation is destroyed.

Returns
The destroy action.

Definition at line 183 of file scene-graph-animation.h.

References mDisconnectAction.

float Dali::Internal::SceneGraph::Animation::GetDuration ( ) const
inline

Retrieve the duration of the animation.

Returns
The duration in seconds.

Definition at line 98 of file scene-graph-animation.h.

References mDurationSeconds.

EndAction Dali::Internal::SceneGraph::Animation::GetEndAction ( )
inline

Retrieve the action performed when the animation ends.

Returns
The end action.

Definition at line 166 of file scene-graph-animation.h.

References mEndAction.

int Dali::Internal::SceneGraph::Animation::GetLoopCount ( ) const
inline

Definition at line 151 of file scene-graph-animation.h.

References mLoopCount.

int Dali::Internal::SceneGraph::Animation::GetPlayedCount ( ) const
inline

Retrive a count of the number of times the animation has been played to completion.

This can be used to emit "Finised" signals from the public-api

Definition at line 239 of file scene-graph-animation.h.

References mPlayedCount.

Referenced by Dali::Internal::Animation::HasFinished().

Here is the caller graph for this function:

State Dali::Internal::SceneGraph::Animation::GetState ( ) const
inline

Query whether the animation is playing, paused or stopped.

Note that even when paused, the Update() method should be called, since the current progress must be reapplied each frame.

Definition at line 230 of file scene-graph-animation.h.

References mState.

Referenced by Dali::Internal::SceneGraph::UpdateManager::Animate(), and Dali::Internal::SceneGraph::UpdateManager::RemoveAnimation().

Here is the caller graph for this function:

bool Dali::Internal::SceneGraph::Animation::IsLooping ( ) const
inline

Query whether the animation will loop.

Returns
True if the animation will loop.

Definition at line 142 of file scene-graph-animation.h.

References mLoopCount.

Animation * Dali::Internal::SceneGraph::Animation::New ( float  durationSeconds,
float  speedFactor,
const Vector2 playRange,
int  loopCount,
EndAction  endAction,
EndAction  disconnectAction 
)
static

Construct a new Animation.

Parameters
[in]durationSecondsThe duration of the animation in seconds.
[in]speedFactorMultiplier to the animation velocity.
[in]playRangeMinimum and maximum progress between which the animation will play.
[in]loopCountThe number of times the animation will loop. ( See SetLoopCount() )
[in]endActionThe action to perform when the animation ends.
[in]disconnectActionThe action to perform when the property owner of an animator is disconnected.
Returns
A new Animation

Definition at line 56 of file scene-graph-animation.cpp.

References Animation(), and anonymous_namespace{scene-graph-animation.cpp}::gAnimationMemoryPool.

Referenced by Dali::Internal::Animation::CreateSceneObject().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::OnDestroy ( BufferIndex  bufferIndex)

Called shortly before the animation is destroyed.

Parameters
[in]bufferIndexThe buffer to update when mEndAction == Bake.

Definition at line 223 of file scene-graph-animation.cpp.

References Bake(), Destroyed, Dali::Animation::Discard, mEndAction, mState, Paused, Playing, and SetAnimatorsActive().

Referenced by Dali::Internal::SceneGraph::UpdateManager::RemoveAnimation().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::operator delete ( void *  ptr)

Overriden delete operator Deletes the animation from its global memory pool.

Definition at line 79 of file scene-graph-animation.cpp.

References anonymous_namespace{scene-graph-animation.cpp}::gAnimationMemoryPool.

Animation& Dali::Internal::SceneGraph::Animation::operator= ( const Animation rhs)
private
void Dali::Internal::SceneGraph::Animation::Pause ( )

Pause the animation.

Definition at line 160 of file scene-graph-animation.cpp.

References mState, Paused, and Playing.

Referenced by Dali::Internal::SceneGraph::PauseAnimationMessage().

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::Play ( )

Play the animation.

Definition at line 133 of file scene-graph-animation.cpp.

References mCurrentLoop, mDurationSeconds, mElapsedSeconds, mPlayRange, mSpeedFactor, mState, Playing, SetAnimatorsActive(), Dali::Vector2::x, and Dali::Vector2::y.

Referenced by Dali::Internal::SceneGraph::PlayAnimationMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::PlayFrom ( float  progress)

Definition at line 147 of file scene-graph-animation.cpp.

References mDurationSeconds, mElapsedSeconds, mState, Playing, and SetAnimatorsActive().

Referenced by Dali::Internal::SceneGraph::PlayAnimationFromMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::SetAnimatorsActive ( bool  active)
private

Helper function to set active state of animators.

Parameters
[in]activeEvery animator is set to this state

Definition at line 185 of file scene-graph-animation.cpp.

References Dali::Vector< T, IsTrivialType >::Begin(), Dali::Vector< T, IsTrivialType >::End(), and mAnimators.

Referenced by OnDestroy(), Play(), PlayFrom(), and Stop().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::SetCurrentProgress ( float  progress)
inline

Definition at line 121 of file scene-graph-animation.h.

References mDurationSeconds, and mElapsedSeconds.

Referenced by Dali::Internal::SceneGraph::SetCurrentProgressMessage().

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::SetDisconnectAction ( EndAction  action)

Set the disconnect action of the animation when connected objects are disconnected.

This action is performed during the next update when the connected object is disconnected.

Parameters
[in]actionThe disconnect action.

Definition at line 100 of file scene-graph-animation.cpp.

References Dali::Vector< T, IsTrivialType >::Begin(), Dali::Vector< T, IsTrivialType >::End(), mAnimators, and mDisconnectAction.

Referenced by Dali::Internal::SceneGraph::SetDisconnectActionMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::SetDuration ( float  durationSeconds)

Set the duration of an animation.

Precondition
durationSeconds must be greater than zero.
Parameters
[in]durationSecondsThe duration in seconds.

Definition at line 84 of file scene-graph-animation.cpp.

References mDurationSeconds.

Referenced by Dali::Internal::SceneGraph::SetDurationMessage().

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::SetEndAction ( EndAction  action)

Set the end action of the animation.

Parameters
[in]actionThe end action.

Definition at line 95 of file scene-graph-animation.cpp.

References mEndAction.

Referenced by Dali::Internal::SceneGraph::SetEndActionMessage().

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::SetLoopCount ( int  loopCount)

Set the animation loop count.

0 is loop forever, N loop play N times

Parameters
[in]loopCountThe loop count

Definition at line 89 of file scene-graph-animation.cpp.

References mCurrentLoop, and mLoopCount.

Referenced by Dali::Internal::SceneGraph::SetLoopingMessage().

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::SetPlayRange ( const Vector2 range)

Set the playing range.

The animation will only play between the minimum and maximum progress speficied.

Parameters
[in]rangeTwo values between [0,1] to specify minimum and maximum progress.

Definition at line 113 of file scene-graph-animation.cpp.

References Dali::Clamp(), mDurationSeconds, mElapsedSeconds, mPlayRange, mState, Stopped, Dali::Vector2::x, and Dali::Vector2::y.

Referenced by Dali::Internal::SceneGraph::SetPlayRangeMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::SetSpeedFactor ( float  factor)
inline

Definition at line 126 of file scene-graph-animation.h.

References mSpeedFactor.

Referenced by Dali::Internal::SceneGraph::SetSpeedFactorMessage().

Here is the caller graph for this function:

bool Dali::Internal::SceneGraph::Animation::Stop ( BufferIndex  bufferIndex)

Stop the animation.

Parameters
[in]bufferIndexThe buffer to update when mEndAction == Bake.
Returns
True if the animation has finished (otherwise it wasn't playing)

Definition at line 193 of file scene-graph-animation.cpp.

References Bake(), Dali::Animation::Discard, mCurrentLoop, mDurationSeconds, mElapsedSeconds, mEndAction, mPlayedCount, mPlayRange, mState, Paused, Playing, SetAnimatorsActive(), Stopped, and Dali::Vector2::x.

Referenced by Dali::Internal::SceneGraph::UpdateManager::StopAnimation().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::Update ( BufferIndex  bufferIndex,
float  elapsedSeconds,
bool &  looped,
bool &  finished 
)

This causes the animators to change the properties of objects in the scene graph.

Precondition
The animation is playing or paused.
Parameters
[in]bufferIndexThe buffer to update.
[in]elapsedSecondsThe time elapsed since the previous frame.
[out]loopedTrue if the animation looped
[out]finishedTrue if the animation has finished.

Definition at line 250 of file scene-graph-animation.cpp.

References DALI_ASSERT_DEBUG, Destroyed, Dali::Animation::Discard, mCurrentLoop, mDurationSeconds, mElapsedSeconds, mEndAction, mLoopCount, mPlayedCount, mPlayRange, mSpeedFactor, mState, Playing, Stopped, UpdateAnimators(), anonymous_namespace{scene-graph-animation.cpp}::WrapInPlayRange(), Dali::Vector2::x, and Dali::Vector2::y.

Referenced by Dali::Internal::SceneGraph::UpdateManager::Animate().

Here is the call graph for this function:

Here is the caller graph for this function:

void Dali::Internal::SceneGraph::Animation::UpdateAnimators ( BufferIndex  bufferIndex,
bool  bake,
bool  animationFinished 
)
private

Member Data Documentation

AnimatorContainer Dali::Internal::SceneGraph::Animation::mAnimators
protected
int Dali::Internal::SceneGraph::Animation::mCurrentLoop
protected

Definition at line 331 of file scene-graph-animation.h.

Referenced by GetCurrentLoop(), Play(), SetLoopCount(), Stop(), and Update().

EndAction Dali::Internal::SceneGraph::Animation::mDisconnectAction
protected

Definition at line 324 of file scene-graph-animation.h.

Referenced by AddAnimator(), GetDisconnectAction(), and SetDisconnectAction().

float Dali::Internal::SceneGraph::Animation::mDurationSeconds
protected
float Dali::Internal::SceneGraph::Animation::mElapsedSeconds
protected
EndAction Dali::Internal::SceneGraph::Animation::mEndAction
protected

Definition at line 323 of file scene-graph-animation.h.

Referenced by GetEndAction(), OnDestroy(), SetEndAction(), Stop(), and Update().

int Dali::Internal::SceneGraph::Animation::mLoopCount
protected

Definition at line 330 of file scene-graph-animation.h.

Referenced by GetLoopCount(), IsLooping(), SetLoopCount(), and Update().

int Dali::Internal::SceneGraph::Animation::mPlayedCount
protected

Definition at line 328 of file scene-graph-animation.h.

Referenced by GetPlayedCount(), Stop(), and Update().

Vector2 Dali::Internal::SceneGraph::Animation::mPlayRange
protected

Definition at line 333 of file scene-graph-animation.h.

Referenced by Bake(), Play(), SetPlayRange(), Stop(), Update(), and UpdateAnimators().

float Dali::Internal::SceneGraph::Animation::mSpeedFactor
protected

Definition at line 322 of file scene-graph-animation.h.

Referenced by Bake(), Play(), SetSpeedFactor(), and Update().

State Dali::Internal::SceneGraph::Animation::mState
protected

The documentation for this class was generated from the following files:
Dali Docs Home
Read more about Dali