2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <dali/internal/event/animation/animation-impl.h>
20 #include <dali/public-api/object/property-map.h>
25 #include <dali/public-api/animation/alpha-function.h>
26 #include <dali/public-api/animation/time-period.h>
27 #include <dali/public-api/common/dali-common.h>
28 #include <dali/public-api/object/type-registry.h>
29 #include <dali/public-api/math/vector2.h>
30 #include <dali/public-api/math/radian.h>
31 #include <dali/internal/event/animation/animation-playlist.h>
32 #include <dali/internal/event/animation/animator-connector.h>
33 #include <dali/internal/event/common/notification-manager.h>
34 #include <dali/internal/event/common/property-helper.h>
35 #include <dali/internal/event/common/stage-impl.h>
36 #include <dali/internal/event/common/thread-local-storage.h>
37 #include <dali/internal/update/animation/scene-graph-animator.h>
38 #include <dali/internal/update/manager/update-manager.h>
40 using Dali::Internal::SceneGraph::UpdateManager;
41 using Dali::Internal::SceneGraph::AnimatorBase;
42 using Dali::Internal::SceneGraph::Shader;
50 static bool SHOW_VALUE = true;
51 static bool HIDE_VALUE = false;
58 const char* const SIGNAL_FINISHED = "finished";
62 const char* const ACTION_PLAY = "play";
63 const char* const ACTION_STOP = "stop";
64 const char* const ACTION_PAUSE = "pause";
68 return Dali::Animation::New(0.f);
71 TypeRegistration mType( typeid( Dali::Animation ), typeid( Dali::BaseHandle ), Create );
73 SignalConnectorType signalConnector1( mType, SIGNAL_FINISHED, &Animation::DoConnectSignal );
75 TypeAction action1( mType, ACTION_PLAY, &Animation::DoAction );
76 TypeAction action2( mType, ACTION_STOP, &Animation::DoAction );
77 TypeAction action3( mType, ACTION_PAUSE, &Animation::DoAction );
79 const Dali::Animation::EndAction DEFAULT_END_ACTION( Dali::Animation::Bake );
80 const Dali::Animation::EndAction DEFAULT_DISCONNECT_ACTION( Dali::Animation::BakeFinal );
81 const Dali::Animation::Interpolation DEFAULT_INTERPOLATION( Dali::Animation::Linear );
82 const Dali::AlphaFunction DEFAULT_ALPHA_FUNCTION( Dali::AlphaFunction::DEFAULT );
87 AnimationPtr Animation::New(float durationSeconds)
89 Stage* stage = Stage::GetCurrent();
93 AnimationPlaylist& playlist = stage->GetAnimationPlaylist();
95 if( durationSeconds < 0.0f )
97 DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
98 durationSeconds = 0.0f;
101 AnimationPtr animation = new Animation( *stage, playlist, durationSeconds, DEFAULT_END_ACTION, DEFAULT_DISCONNECT_ACTION, DEFAULT_ALPHA_FUNCTION );
103 // Second-phase construction
104 animation->Initialize();
114 Animation::Animation( EventThreadServices& eventThreadServices, AnimationPlaylist& playlist, float durationSeconds, EndAction endAction, EndAction disconnectAction, AlphaFunction defaultAlpha )
115 : mAnimation( NULL ),
116 mEventThreadServices( eventThreadServices ),
117 mPlaylist( playlist ),
120 mConnectorTargetValues(),
121 mPlayRange( Vector2(0.0f,1.0f)),
122 mDurationSeconds( durationSeconds ),
124 mNotificationCount( 0 ),
127 mEndAction( endAction ),
128 mDisconnectAction( disconnectAction ),
129 mDefaultAlpha( defaultAlpha ),
130 mState(Dali::Animation::STOPPED)
134 void Animation::Initialize()
136 // Connect to the animation playlist
137 mPlaylist.AnimationCreated( *this );
144 Animation::~Animation()
146 // Guard to allow handle destruction after Core has been destroyed
147 if ( Stage::IsInstalled() )
149 // Disconnect from the animation playlist
150 mPlaylist.AnimationDestroyed( *this );
152 DestroySceneObject();
158 void Animation::CreateSceneObject()
160 DALI_ASSERT_DEBUG( mAnimation == NULL );
162 // Create a new animation, temporarily owned
163 SceneGraph::Animation* animation = SceneGraph::Animation::New( mDurationSeconds, mSpeedFactor, mPlayRange, mLoopCount, mEndAction, mDisconnectAction );
165 // Keep a const pointer to the animation.
166 mAnimation = animation;
168 // Transfer animation ownership to the update manager through a message
169 AddAnimationMessage( mEventThreadServices.GetUpdateManager(), animation );
172 void Animation::DestroySceneObject()
174 if ( mAnimation != NULL )
176 // Remove animation using a message to the update manager
177 RemoveAnimationMessage( mEventThreadServices.GetUpdateManager(), *mAnimation );
182 void Animation::SetDuration(float seconds)
186 DALI_LOG_WARNING("duration should be greater than 0.0f.\n");
190 // Cache for public getters
191 mDurationSeconds = seconds;
193 // mAnimation is being used in a separate thread; queue a message to set the value
194 SetDurationMessage( mEventThreadServices, *mAnimation, seconds );
197 float Animation::GetDuration() const
199 // This is not animatable; the cached value is up-to-date.
200 return mDurationSeconds;
203 void Animation::SetLooping(bool on)
205 SetLoopCount( on ? 0 : 1 );
208 void Animation::SetLoopCount(int count)
210 // Cache for public getters
213 // mAnimation is being used in a separate thread; queue a message to set the value
214 SetLoopingMessage( mEventThreadServices, *mAnimation, mLoopCount );
217 int Animation::GetLoopCount()
222 int Animation::GetCurrentLoop()
227 bool Animation::IsLooping() const
229 return mLoopCount != 1;
232 void Animation::SetEndAction(EndAction action)
234 // Cache for public getters
237 // mAnimation is being used in a separate thread; queue a message to set the value
238 SetEndActionMessage( mEventThreadServices, *mAnimation, action );
241 Dali::Animation::EndAction Animation::GetEndAction() const
243 // This is not animatable; the cached value is up-to-date.
247 void Animation::SetDisconnectAction(EndAction action)
249 // Cache for public getters
250 mDisconnectAction = action;
252 // mAnimation is being used in a separate thread; queue a message to set the value
253 SetDisconnectActionMessage( mEventThreadServices, *mAnimation, action );
256 Dali::Animation::EndAction Animation::GetDisconnectAction() const
258 // This is not animatable; the cached value is up-to-date.
259 return mDisconnectAction;
262 void Animation::Play()
264 // Update the current playlist
265 mPlaylist.OnPlay( *this );
267 mState = Dali::Animation::PLAYING;
269 if( mEndAction != EndAction::Discard ) // If the animation is discarded, then we do not want to change the target values
271 unsigned int connectorTargetValuesIndex( 0 );
272 unsigned int numberOfConnectorTargetValues = mConnectorTargetValues.size();
275 * Loop through all Animator connectors, if connector index matches the current index stored in mConnectorTargetValues container then
276 * should apply target values for this index to the object.
278 for ( unsigned int connectorIndex = 0; connectorIndex < mConnectors.Count(); connectorIndex ++)
280 // Use index to check if the current connector is next in the mConnectorTargetValues container, meaning targetValues have been pushed in AnimateXXFunction
281 if ( connectorTargetValuesIndex < numberOfConnectorTargetValues )
283 ConnectorTargetValues& connectorPair = mConnectorTargetValues[ connectorTargetValuesIndex ];
285 if ( connectorPair.connectorIndex == connectorIndex )
287 // Current connector index matches next in the stored connectors with target values so apply target value.
288 connectorTargetValuesIndex++; // Found a match for connector so increment index to next one
290 AnimatorConnectorBase* connector = mConnectors[ connectorIndex ];
292 Object* object = connector->GetObject();
295 object->NotifyPropertyAnimation( *this, connector->GetPropertyIndex(), connectorPair.targetValue );
302 // mAnimation is being used in a separate thread; queue a Play message
303 PlayAnimationMessage( mEventThreadServices, *mAnimation );
306 void Animation::PlayFrom( float progress )
308 if( progress >= mPlayRange.x && progress <= mPlayRange.y )
310 // Update the current playlist
311 mPlaylist.OnPlay( *this );
313 mState = Dali::Animation::PLAYING;
315 // mAnimation is being used in a separate thread; queue a Play message
316 PlayAnimationFromMessage( mEventThreadServices, *mAnimation, progress );
320 void Animation::Pause()
322 mState = Dali::Animation::PAUSED;
324 // mAnimation is being used in a separate thread; queue a Pause message
325 PauseAnimationMessage( mEventThreadServices, *mAnimation );
328 Dali::Animation::State Animation::GetState() const
333 void Animation::Stop()
335 mState = Dali::Animation::STOPPED;
337 // mAnimation is being used in a separate thread; queue a Stop message
338 StopAnimationMessage( mEventThreadServices.GetUpdateManager(), *mAnimation );
341 void Animation::Clear()
343 DALI_ASSERT_DEBUG(mAnimation);
345 // Remove all the connectors
348 // Reset the connector target values
349 mConnectorTargetValues.clear();
351 // Replace the old scene-object with a new one
352 DestroySceneObject();
355 // Reset the notification count, since the new scene-object has never been played
356 mNotificationCount = 0;
358 // Update the current playlist
359 mPlaylist.OnClear( *this );
362 void Animation::AnimateBy(Property& target, Property::Value& relativeValue)
364 AnimateBy(target, relativeValue, mDefaultAlpha, TimePeriod(mDurationSeconds));
367 void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha)
369 AnimateBy(target, relativeValue, alpha, TimePeriod(mDurationSeconds));
372 void Animation::AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period)
374 AnimateBy(target, relativeValue, mDefaultAlpha, period);
377 void Animation::AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period)
379 Object& object = GetImplementation( target.object );
380 const Property::Type targetType = object.GetPropertyType( target.propertyIndex );
381 const Property::Type destinationType = relativeValue.GetType();
382 DALI_ASSERT_ALWAYS( targetType == destinationType && "Animated value and Property type don't match" );
384 ExtendDuration( period );
386 switch ( targetType )
388 case Property::BOOLEAN:
390 AddAnimatorConnector( AnimatorConnector<bool>::New( object,
391 target.propertyIndex,
392 target.componentIndex,
393 new AnimateByBoolean(relativeValue.Get<bool>()),
399 case Property::INTEGER:
401 AddAnimatorConnector( AnimatorConnector<int>::New( object,
402 target.propertyIndex,
403 target.componentIndex,
404 new AnimateByInteger(relativeValue.Get<int>()),
410 case Property::FLOAT:
412 AddAnimatorConnector( AnimatorConnector<float>::New( object,
413 target.propertyIndex,
414 target.componentIndex,
415 new AnimateByFloat(relativeValue.Get<float>()),
421 case Property::VECTOR2:
423 AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
424 target.propertyIndex,
425 target.componentIndex,
426 new AnimateByVector2(relativeValue.Get<Vector2>()),
432 case Property::VECTOR3:
434 AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
435 target.propertyIndex,
436 target.componentIndex,
437 new AnimateByVector3(relativeValue.Get<Vector3>()),
443 case Property::VECTOR4:
445 AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
446 target.propertyIndex,
447 target.componentIndex,
448 new AnimateByVector4(relativeValue.Get<Vector4>()),
454 case Property::ROTATION:
456 AngleAxis angleAxis = relativeValue.Get<AngleAxis>();
458 AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
459 target.propertyIndex,
460 target.componentIndex,
461 new RotateByAngleAxis(angleAxis.angle, angleAxis.axis),
469 // non animatable types handled already
474 void Animation::AnimateTo(Property& target, Property::Value& destinationValue)
476 AnimateTo(target, destinationValue, mDefaultAlpha, TimePeriod(mDurationSeconds));
479 void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha)
481 AnimateTo(target, destinationValue, alpha, TimePeriod(mDurationSeconds));
484 void Animation::AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period)
486 AnimateTo(target, destinationValue, mDefaultAlpha, period);
489 void Animation::AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period)
491 Object& object = GetImplementation(target.object);
493 AnimateTo( object, target.propertyIndex, target.componentIndex, destinationValue, alpha, period );
496 void Animation::AnimateTo(Object& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period)
498 Property::Type targetType = targetObject.GetPropertyType(targetPropertyIndex);
499 if( componentIndex != Property::INVALID_COMPONENT_INDEX )
501 if( ( targetType == Property::VECTOR2 ) ||
502 ( targetType == Property::VECTOR3 ) ||
503 ( targetType == Property::VECTOR4 ) )
505 targetType = Property::FLOAT;
508 const Property::Type destinationType = destinationValue.GetType();
509 DALI_ASSERT_ALWAYS( targetType == destinationType && "Animated value and Property type don't match" );
511 ExtendDuration( period );
513 // Store data to later notify the object that its property is being animated
514 ConnectorTargetValues connectorPair;
515 connectorPair.targetValue = destinationValue;
516 connectorPair.connectorIndex = mConnectors.Count();
517 mConnectorTargetValues.push_back( connectorPair );
519 switch ( destinationType )
521 case Property::BOOLEAN:
523 AddAnimatorConnector( AnimatorConnector<bool>::New( targetObject,
526 new AnimateToBoolean( destinationValue.Get<bool>() ),
532 case Property::INTEGER:
534 AddAnimatorConnector( AnimatorConnector<int>::New( targetObject,
537 new AnimateToInteger( destinationValue.Get<int>() ),
543 case Property::FLOAT:
545 AddAnimatorConnector( AnimatorConnector<float>::New( targetObject,
548 new AnimateToFloat( destinationValue.Get<float>() ),
554 case Property::VECTOR2:
556 AddAnimatorConnector( AnimatorConnector<Vector2>::New( targetObject,
559 new AnimateToVector2( destinationValue.Get<Vector2>() ),
565 case Property::VECTOR3:
567 AddAnimatorConnector( AnimatorConnector<Vector3>::New( targetObject,
570 new AnimateToVector3( destinationValue.Get<Vector3>() ),
576 case Property::VECTOR4:
578 AddAnimatorConnector( AnimatorConnector<Vector4>::New( targetObject,
581 new AnimateToVector4( destinationValue.Get<Vector4>() ),
587 case Property::ROTATION:
589 AddAnimatorConnector( AnimatorConnector<Quaternion>::New( targetObject,
592 new RotateToQuaternion( destinationValue.Get<Quaternion>() ),
600 // non animatable types handled already
605 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames)
607 AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION );
610 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, Interpolation interpolation )
612 AnimateBetween(target, keyFrames, mDefaultAlpha, TimePeriod(mDurationSeconds), interpolation );
615 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period)
617 AnimateBetween(target, keyFrames, mDefaultAlpha, period, DEFAULT_INTERPOLATION);
620 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period, Interpolation interpolation)
622 AnimateBetween(target, keyFrames, mDefaultAlpha, period, interpolation);
625 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha)
627 AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), DEFAULT_INTERPOLATION);
630 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, Interpolation interpolation)
632 AnimateBetween(target, keyFrames, alpha, TimePeriod(mDurationSeconds), interpolation);
635 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period)
637 AnimateBetween(target, keyFrames, alpha, period, DEFAULT_INTERPOLATION);
640 void Animation::AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period, Interpolation interpolation)
642 Object& object = GetImplementation( target.object );
644 ExtendDuration( period );
646 switch(keyFrames.GetType())
648 case Dali::Property::BOOLEAN:
650 const KeyFrameBoolean* kf;
651 GetSpecialization(keyFrames, kf);
652 KeyFrameBooleanPtr kfCopy = KeyFrameBoolean::Clone(*kf);
653 AddAnimatorConnector( AnimatorConnector<bool>::New( object,
654 target.propertyIndex,
655 target.componentIndex,
656 new KeyFrameBooleanFunctor(kfCopy),
662 case Dali::Property::INTEGER:
664 const KeyFrameInteger* kf;
665 GetSpecialization(keyFrames, kf);
666 KeyFrameIntegerPtr kfCopy = KeyFrameInteger::Clone(*kf);
667 AddAnimatorConnector( AnimatorConnector<int>::New( object,
668 target.propertyIndex,
669 target.componentIndex,
670 new KeyFrameIntegerFunctor(kfCopy,interpolation),
676 case Dali::Property::FLOAT:
678 const KeyFrameNumber* kf;
679 GetSpecialization(keyFrames, kf);
680 KeyFrameNumberPtr kfCopy = KeyFrameNumber::Clone(*kf);
681 AddAnimatorConnector( AnimatorConnector<float>::New( object,
682 target.propertyIndex,
683 target.componentIndex,
684 new KeyFrameNumberFunctor(kfCopy,interpolation),
690 case Dali::Property::VECTOR2:
692 const KeyFrameVector2* kf;
693 GetSpecialization(keyFrames, kf);
694 KeyFrameVector2Ptr kfCopy = KeyFrameVector2::Clone(*kf);
695 AddAnimatorConnector( AnimatorConnector<Vector2>::New( object,
696 target.propertyIndex,
697 target.componentIndex,
698 new KeyFrameVector2Functor(kfCopy,interpolation),
704 case Dali::Property::VECTOR3:
706 const KeyFrameVector3* kf;
707 GetSpecialization(keyFrames, kf);
708 KeyFrameVector3Ptr kfCopy = KeyFrameVector3::Clone(*kf);
709 AddAnimatorConnector( AnimatorConnector<Vector3>::New( object,
710 target.propertyIndex,
711 target.componentIndex,
712 new KeyFrameVector3Functor(kfCopy,interpolation),
718 case Dali::Property::VECTOR4:
720 const KeyFrameVector4* kf;
721 GetSpecialization(keyFrames, kf);
722 KeyFrameVector4Ptr kfCopy = KeyFrameVector4::Clone(*kf);
723 AddAnimatorConnector( AnimatorConnector<Vector4>::New( object,
724 target.propertyIndex,
725 target.componentIndex,
726 new KeyFrameVector4Functor(kfCopy,interpolation),
732 case Dali::Property::ROTATION:
734 const KeyFrameQuaternion* kf;
735 GetSpecialization(keyFrames, kf);
736 KeyFrameQuaternionPtr kfCopy = KeyFrameQuaternion::Clone(*kf);
737 AddAnimatorConnector( AnimatorConnector<Quaternion>::New( object,
738 target.propertyIndex,
739 target.componentIndex,
740 new KeyFrameQuaternionFunctor(kfCopy),
748 // non animatable types handled by keyframes
753 bool Animation::HasFinished()
755 bool hasFinished(false);
756 const int playedCount(mAnimation->GetPlayedCount());
758 // If the play count has been incremented, then another notification is required
759 mCurrentLoop = mAnimation->GetCurrentLoop();
761 if (playedCount > mNotificationCount)
763 // Note that only one signal is emitted, if the animation has been played repeatedly
764 mNotificationCount = playedCount;
768 mState = Dali::Animation::STOPPED;
774 Dali::Animation::AnimationSignalType& Animation::FinishedSignal()
776 return mFinishedSignal;
779 void Animation::EmitSignalFinish()
781 if ( !mFinishedSignal.Empty() )
783 Dali::Animation handle( this );
784 mFinishedSignal.Emit( handle );
788 bool Animation::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
790 bool connected( true );
791 Animation* animation = static_cast< Animation* >(object); // TypeRegistry guarantees that this is the correct type.
793 if( 0 == signalName.compare( SIGNAL_FINISHED ) )
795 animation->FinishedSignal().Connect( tracker, functor );
799 // signalName does not match any signal
806 void Animation::AddAnimatorConnector( AnimatorConnectorBase* connector )
808 DALI_ASSERT_DEBUG( NULL != connector );
810 connector->SetParent(*this);
812 mConnectors.PushBack( connector );
815 void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward )
817 Animate( actor, path, forward, mDefaultAlpha, TimePeriod(mDurationSeconds) );
820 void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha )
822 Animate( actor, path, forward, alpha, TimePeriod(mDurationSeconds) );
825 void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, TimePeriod period )
827 Animate( actor, path, forward, mDefaultAlpha, period );
830 void Animation::Animate( Actor& actor, const Path& path, const Vector3& forward, AlphaFunction alpha, TimePeriod period)
832 ExtendDuration( period );
834 PathPtr pathCopy = Path::Clone(path);
837 AddAnimatorConnector( AnimatorConnector<Vector3>::New( actor,
838 Dali::Actor::Property::POSITION,
839 Property::INVALID_COMPONENT_INDEX,
840 new PathPositionFunctor( pathCopy ),
844 //If forward is zero, PathRotationFunctor will always return the unit quaternion
845 if( forward != Vector3::ZERO )
848 AddAnimatorConnector( AnimatorConnector<Quaternion>::New( actor,
849 Dali::Actor::Property::ORIENTATION,
850 Property::INVALID_COMPONENT_INDEX,
851 new PathRotationFunctor( pathCopy, forward ),
857 void Animation::Show(Actor& actor, float delaySeconds)
859 ExtendDuration( TimePeriod(delaySeconds, 0) );
861 AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
862 Dali::Actor::Property::VISIBLE,
863 Property::INVALID_COMPONENT_INDEX,
864 new AnimateToBoolean(SHOW_VALUE),
866 TimePeriod(delaySeconds, 0.0f/*immediate*/) ) );
869 void Animation::Hide(Actor& actor, float delaySeconds)
871 ExtendDuration( TimePeriod(delaySeconds, 0) );
873 AddAnimatorConnector( AnimatorConnector<bool>::New( actor,
874 Dali::Actor::Property::VISIBLE,
875 Property::INVALID_COMPONENT_INDEX,
876 new AnimateToBoolean(HIDE_VALUE),
878 TimePeriod(delaySeconds, 0.0f/*immediate*/) ) );
881 bool Animation::DoAction( BaseObject* object, const std::string& actionName, const Property::Map& attributes )
884 Animation* animation = dynamic_cast<Animation*>( object );
888 if( 0 == actionName.compare( ACTION_PLAY ) )
890 if( Property::Value* value = attributes.Find("duration", Property::FLOAT) )
892 animation->SetDuration( value->Get<float>() );
898 else if( 0 == actionName.compare( ACTION_STOP ) )
903 else if( 0 == actionName.compare( ACTION_PAUSE ) )
913 void Animation::SetCurrentProgress(float progress)
915 if( mAnimation && progress >= mPlayRange.x && progress <= mPlayRange.y )
917 // mAnimation is being used in a separate thread; queue a message to set the current progress
918 SetCurrentProgressMessage( mEventThreadServices, *mAnimation, progress );
922 float Animation::GetCurrentProgress()
926 return mAnimation->GetCurrentProgress();
932 void Animation::ExtendDuration( const TimePeriod& timePeriod )
934 float duration = timePeriod.delaySeconds + timePeriod.durationSeconds;
936 if( duration > mDurationSeconds )
938 SetDuration( duration );
942 void Animation::SetSpeedFactor( float factor )
946 mSpeedFactor = factor;
947 SetSpeedFactorMessage( mEventThreadServices, *mAnimation, factor );
951 float Animation::GetSpeedFactor() const
956 void Animation::SetPlayRange( const Vector2& range)
958 //Make sure the range specified is between 0.0 and 1.0
959 if( range.x >= 0.0f && range.x <= 1.0f && range.y >= 0.0f && range.y <= 1.0f )
961 Vector2 orderedRange( range );
962 //If the range is not in order swap values
963 if( range.x > range.y )
965 orderedRange = Vector2(range.y, range.x);
968 // Cache for public getters
969 mPlayRange = orderedRange;
971 // mAnimation is being used in a separate thread; queue a message to set play range
972 SetPlayRangeMessage( mEventThreadServices, *mAnimation, orderedRange );
976 Vector2 Animation::GetPlayRange() const
982 } // namespace Internal