AnimationPtr Animation::New(float durationSeconds)
{
- Stage* stage = Stage::GetCurrent();
-
- if( stage )
+ if( durationSeconds < 0.0f )
{
- AnimationPlaylist& playlist = stage->GetAnimationPlaylist();
-
- if( durationSeconds < 0.0f )
- {
- DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
- durationSeconds = 0.0f;
- }
+ DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
+ durationSeconds = 0.0f;
+ }
- AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
+ ThreadLocalStorage& tls = ThreadLocalStorage::Get();
+ AnimationPtr animation = new Animation( tls.GetEventThreadServices(), tls.GetAnimationPlaylist(), durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
- // Second-phase construction
- animation->Initialize();
+ // Second-phase construction
+ animation->Initialize();
- return animation;
- }
- else
- {
- return NULL;
- }
+ return animation;
}
Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
bool Animation::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
- bool connected( true );
+ bool connected( false );
Animation* animation = static_cast< Animation* >(object); // TypeRegistry guarantees that this is the correct type.
if( 0 == signalName.compare( SIGNAL_FINISHED ) )
{
animation->FinishedSignal().Connect( tracker, functor );
- }
- else
- {
- // signalName does not match any signal
- connected = false;
+ connected = true;
}
return connected;
float Animation::GetCurrentProgress()
{
- if( mAnimation )
+ float progress = 0.f;
+ if( mAnimation ) // always exists in practice
{
- return mAnimation->GetCurrentProgress();
+ progress = mAnimation->GetCurrentProgress();
}
- return 0.0f;
+ return progress;
}
void Animation::ExtendDuration( const TimePeriod& timePeriod )