1 #ifndef __DALI_ANIMATION_H__
2 #define __DALI_ANIMATION_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 #include <boost/function.hpp>
25 #include <dali/public-api/animation/alpha-functions.h>
26 #include <dali/public-api/animation/key-frames.h>
27 #include <dali/public-api/animation/time-period.h>
28 #include <dali/public-api/object/any.h>
29 #include <dali/public-api/object/handle.h>
30 #include <dali/public-api/object/property.h>
31 #include <dali/public-api/signals/dali-signal-v2.h>
46 typedef boost::function<bool (float alpha, const bool& current)> AnimatorFunctionBool; ///< Animator function signature for boolean properties.
47 typedef boost::function<float (float alpha, const float& current)> AnimatorFunctionFloat; ///< Animator function signature for float properties.
48 typedef boost::function<int (float alpha, const int& current)> AnimatorFunctionInteger; ///< Animator function signature for integer properties.
49 typedef boost::function<Vector2 (float alpha, const Vector2& current)> AnimatorFunctionVector2; ///< Animator function signature for Vector2 properties.
50 typedef boost::function<Vector3 (float alpha, const Vector3& current)> AnimatorFunctionVector3; ///< Animator function signature for Vector3 properties.
51 typedef boost::function<Vector4 (float alpha, const Vector4& current)> AnimatorFunctionVector4; ///< Animator function signature for Vector4 properties.
52 typedef boost::function<Quaternion (float alpha, const Quaternion& current)> AnimatorFunctionQuaternion;///< Animator function signature for Quaternion properties.
54 namespace Internal DALI_INTERNAL
60 * @brief Dali::Animation can be used to animate the properties of any number of objects, typically Actors.
62 * An example animation setup is shown below:
68 * Actor mActor; // The object we wish to animate
69 * Animation mAnimation; // Keep this to control the animation
72 * // ...To play the animation
74 * mAnimation = Animation::New(3.0f); // duration 3 seconds
75 * mAnimation.MoveTo(mActor, 10.0f, 50.0f, 0.0f);
80 * Dali::Animation supports "fire and forget" behaviour i.e. an animation continues to play if the handle is discarded.
81 * Note that in the following example, the "Finish" signal will be emitted:
85 * void ExampleCallback( Animation& source )
87 * std::cout << "Animation has finished" << std::endl;
90 * void ExampleAnimation( Actor actor )
92 * Animation animation = Animation::New(2.0f); // duration 2 seconds
93 * animation.MoveTo(actor, 10.0f, 50.0f, 0.0f);
94 * animation.FinishedSignal().Connect( ExampleCallback );
96 * } // At this point the animation handle has gone out of scope
98 * Actor actor = Actor::New();
99 * Stage::GetCurrent().Add( actor );
101 * // Fire animation and forget about it
102 * ExampleAnimation( actor );
104 * // However the animation will continue, and "Animation has finished" will be printed after 2 seconds.
108 * If the "Finish" signal is connected to a member function of an object, it must be disconnected before the object is destroyed.
109 * This is typically done in the object destructor, and requires either the Dali::Connection object or Dali::Animation handle to be stored.
111 class DALI_IMPORT_API Animation : public BaseHandle
115 typedef SignalV2< void (Animation&) > AnimationSignalV2; ///< Animation finished signal type
117 typedef Any AnyFunction; ///< Interpolation function
118 typedef boost::function<Vector3 (float alpha, const Vector3& current)> Vector3AnimatorFunc; ///< Interpolation function
119 typedef boost::function<Quaternion (float alpha, const Quaternion& current)> QuaternionAnimatorFunc; ///< Interpolation function
122 * @brief What to do when the animation ends, is stopped or is destroyed
126 Bake, ///< When the animation ends, the animated property values are saved.
127 Discard, ///< When the animation ends, the animated property values are forgotten.
128 BakeFinal ///< If the animation is stopped, the animated property values are saved as if the animation had run to completion, otherwise behaves like Bake.
132 static const char* const SIGNAL_FINISHED; ///< name "finished"
135 static const char* const ACTION_PLAY; ///< name "play"
136 static const char* const ACTION_STOP; ///< name "stop"
137 static const char* const ACTION_PAUSE; ///< name "pause"
140 * @brief Create an uninitialized Animation; this can be initialized with Animation::New().
142 * Calling member functions with an uninitialized Dali::Object is not allowed.
147 * @brief Create an initialized Animation.
149 * The animation will not loop.
150 * The default end action is "Bake".
151 * The default alpha function is linear.
152 * @pre durationSeconds must be greater than zero.
153 * @param [in] durationSeconds The duration in seconds.
154 * @return A handle to a newly allocated Dali resource.
156 static Animation New(float durationSeconds);
159 * @brief Downcast an Object handle to Animation.
161 * If handle points to an Animation object the downcast produces
162 * valid handle. If not the returned handle is left uninitialized.
164 * @param[in] handle to An object
165 * @return handle to a Animation object or an uninitialized handle
167 static Animation DownCast( BaseHandle handle );
172 * This is non-virtual since derived Handle types must not contain data or virtual methods.
177 * @brief This copy constructor is required for (smart) pointer semantics.
179 * @param [in] handle A reference to the copied handle
181 Animation(const Animation& handle);
184 * @brief This assignment operator is required for (smart) pointer semantics.
186 * @param [in] rhs A reference to the copied handle
187 * @return A reference to this
189 Animation& operator=(const Animation& rhs);
192 * @brief Set the duration of an animation.
194 * @pre durationSeconds must be greater than zero.
195 * @param[in] seconds The duration in seconds.
197 void SetDuration(float seconds);
200 * @brief Retrieve the duration of an animation.
202 * @return The duration in seconds.
204 float GetDuration() const;
207 * @brief Set whether the animation will loop.
209 * @param[in] looping True if the animation will loop.
211 void SetLooping(bool looping);
214 * @brief Query whether the animation will loop.
216 * @return True if the animation will loop.
218 bool IsLooping() const;
221 * @brief Set the end action of the animation.
223 * This action is performed when the animation ends or if it is stopped.
224 * Default end action is bake
225 * @param[in] action The end action.
227 void SetEndAction(EndAction action);
230 * @brief Returns the end action of the animation.
232 * @return The end action.
234 EndAction GetEndAction() const;
237 * @brief Set the disconnect action.
239 * If any of the animated property owners are disconnected from the stage while the animation is being played, then this action is performed.
240 * Default action is to BakeFinal.
241 * @param[in] disconnectAction The disconnect action.
243 void SetDisconnectAction( EndAction disconnectAction );
246 * @brief Returns the disconnect action.
248 * @return The disconnect action.
250 EndAction GetDisconnectAction() const;
253 * @brief Set the default alpha function for an animation.
255 * This is applied to individual property animations, if no further alpha functions are supplied.
256 * @param[in] alpha The default alpha function.
258 void SetDefaultAlphaFunction(AlphaFunction alpha);
261 * @brief Retrieve the default alpha function for an animation.
263 * @return The default alpha function.
265 AlphaFunction GetDefaultAlphaFunction() const;
268 * @brief Sets the progress of the animation.
269 * The animation will play (or continue playing) from this point. The progress
270 * must be in the 0-1 interval or in the play range interval if defined ( See SetPlayRange ),
271 * otherwise, it will be ignored.
273 * @param[in] progress The new progress as a normalized value between [0,1] or between the
274 * play range if specified.
276 void SetCurrentProgress( float progress );
279 * @brief Retrieve the current progress of the animation.
281 * @return The current progress as a normalized value between [0,1].
283 float GetCurrentProgress();
286 * @brief Specifies an speed factor for the animation.
288 * The speed factor is a multiplier of the normal velocity of the animation. Values between [0,1] will
289 * slow down the animation and values above one will speed up the animation. It is also possible to specify a negative multiplier
290 * to play the animation in reverse.
292 * @param[in] factor A value which will multiply the velocity.
294 void SetSpeedFactor( float factor );
297 * @brief Retrieve the speed factor of the animation
299 * @return speed factor
301 float GetSpeedFactor() const;
304 * @brief Set the playing range.
305 * Animation will play between the values specified. Both values ( range.x and range.y ) should be between 0-1,
306 * otherwise they will be ignored. If the range provided is not in proper order ( minimum,maximum ), it will be reordered.
308 * @param[in] range Two values between [0,1] to specify minimum and maximum progress. The
309 * animation will play between those values.
311 void SetPlayRange( const Vector2& range );
314 * @brief Get the playing range
316 * @return The play range defined for the animation.
318 Vector2 GetPlayRange() const;
321 * @brief Play the animation.
326 * @brief Play the animation from a given point.
327 * The progress must be in the 0-1 interval or in the play range interval if defined ( See SetPlayRange ),
328 * otherwise, it will be ignored.
330 * @param[in] progress A value between [0,1], or between the play range if specified, form where the animation should start playing
332 void PlayFrom( float progress );
335 * @brief Pause the animation.
340 * @brief Stop the animation.
345 * @brief Clear the animation.
347 * This disconnects any objects that were being animated, effectively stopping the animation.
352 * @brief Connect to this signal to be notified when an Animation's animations have finished.
354 * @return A signal object to Connect() with.
356 AnimationSignalV2& FinishedSignal();
359 * @brief Animate a property value by a relative amount.
361 * The default alpha function will be used.
362 * The effect will start & end when the animation begins & ends.
363 * @param [in] target The target object/property to animate.
364 * @param [in] relativeValue The property value will change by this amount.
366 void AnimateBy(Property target, Property::Value relativeValue);
369 * @brief Animate a property value by a relative amount.
371 * The effect will start & end when the animation begins & ends.
372 * @param [in] target The target object/property to animate.
373 * @param [in] relativeValue The property value will change by this amount.
374 * @param [in] alpha The alpha function to apply.
376 void AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha);
379 * @brief Animate a property value by a relative amount.
381 * The default alpha function will be used.
382 * @param [in] target The target object/property to animate.
383 * @param [in] relativeValue The property value will increase/decrease by this amount.
384 * @param [in] period The effect will occur during this time period.
386 void AnimateBy(Property target, Property::Value relativeValue, TimePeriod period);
389 * @brief Animate a property value by a relative amount.
391 * @param [in] target The target object/property to animate.
392 * @param [in] relativeValue The property value will increase/decrease by this amount.
393 * @param [in] alpha The alpha function to apply.
394 * @param [in] period The effect will occur during this time period.
396 void AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period);
399 * @brief Animate a property to a destination value.
401 * The default alpha function will be used.
402 * The effect will start & end when the animation begins & ends.
403 * @param [in] target The target object/property to animate.
404 * @param [in] destinationValue The destination value.
406 void AnimateTo(Property target, Property::Value destinationValue);
409 * @brief Animate a property to a destination value.
411 * The effect will start & end when the animation begins & ends.
412 * @param [in] target The target object/property to animate.
413 * @param [in] destinationValue The destination value.
414 * @param [in] alpha The alpha function to apply.
416 void AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha);
419 * @brief Animate a property to a destination value.
421 * The default alpha function will be used.
422 * @param [in] target The target object/property to animate.
423 * @param [in] destinationValue The destination value.
424 * @param [in] period The effect will occur during this time period.
426 void AnimateTo(Property target, Property::Value destinationValue, TimePeriod period);
429 * @brief Animate a property to a destination value.
431 * @param [in] target The target object/property to animate.
432 * @param [in] destinationValue The destination value.
433 * @param [in] alpha The alpha function to apply.
434 * @param [in] period The effect will occur during this time period.
436 void AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period);
439 * @brief Animate a property between keyframes.
441 * @param [in] target The target object/property to animate.
442 * @param [in] keyFrames The key frames
444 void AnimateBetween(Property target, KeyFrames& keyFrames);
447 * @brief Animate a property between keyframes.
449 * @param [in] target The target object/property to animate.
450 * @param [in] keyFrames The key frames
451 * @param [in] alpha The alpha function to apply.
453 void AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha);
456 * @brief Animate a property between keyframes.
458 * @param [in] target The target object/property to animate.
459 * @param [in] keyFrames The key frames
460 * @param [in] period The effect will occur during this time period.
462 void AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period);
465 * @brief Animate a property between keyframes.
467 * @param [in] target The target object/property to animate.
468 * @param [in] keyFrames The key frames
469 * @param [in] alpha The alpha function to apply.
470 * @param [in] period The effect will occur during this time period.
472 void AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
475 * @brief Animate a property using a custom function.
477 * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
478 * @pre The property type is equal PropertyTypes::Get<P>().
479 * @param [in] target The target object/property to animate.
480 * @param [in] animatorFunc The function to call during the animation.
483 void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc )
485 Animate( target, PropertyTypes::Get<P>(), animatorFunc );
489 * @brief Animate a property using a custom function.
491 * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
492 * @pre The property type is equal PropertyTypes::Get<P>().
493 * @param [in] target The target object/property to animate.
494 * @param [in] animatorFunc The function to call during the animation.
495 * @param [in] alpha The alpha function to apply.
498 void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, AlphaFunction alpha )
500 Animate( target, PropertyTypes::Get<P>(), animatorFunc, alpha );
504 * @brief Animate a property using a custom function.
506 * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
507 * @pre The property type is equal PropertyTypes::Get<P>().
508 * @param [in] target The target object/property to animate.
509 * @param [in] animatorFunc The function to call during the animation.
510 * @param [in] period The effect will occur during this time period.
513 void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, TimePeriod period )
515 Animate( target, PropertyTypes::Get<P>(), animatorFunc, period );
519 * @brief Animate a property using a custom function.
521 * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
522 * @pre The property type is equal PropertyTypes::Get<P>().
523 * @param [in] target The target object/property to animate.
524 * @param [in] animatorFunc The function to call during the animation.
525 * @param [in] alpha The alpha function to apply.
526 * @param [in] period The effect will occur during this time period.
529 void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, AlphaFunction alpha, TimePeriod period )
531 Animate( target, PropertyTypes::Get<P>(), animatorFunc, alpha, period );
534 // Actor-specific convenience methods
537 * @brief Move an actor relative to its position.
539 * The default alpha function will be used.
540 * The move will start & end when the animation begins & ends.
541 * @param [in] actor The actor to animate.
542 * @param [in] x axis displacement.
543 * @param [in] y axis displacement.
544 * @param [in] z axis displacement.
546 void MoveBy(Actor actor, float x, float y, float z);
549 * @brief Move an actor relative to its position.
551 * This overload allows the alpha function to be customized.
552 * The move will start & end when the animation begins & ends.
553 * @param [in] actor The actor to animate.
554 * @param [in] displacement relative to current position.
555 * @param [in] alpha The alpha function to apply.
557 void MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha);
560 * @brief Move an actor relative to its position.
562 * This overload allows the translation start & end time to be customized.
563 * @pre delaySeconds must be zero or greater.
564 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
565 * @param [in] actor The actor to animate.
566 * @param [in] displacement relative to current position.
567 * @param [in] alpha The alpha function to apply.
568 * @param [in] delaySeconds The initial delay from the start of the animation.
569 * @param [in] durationSeconds The duration of the translation.
571 void MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds);
574 * @brief Move an actor to a target position.
576 * The default alpha function will be used.
577 * The move will start & end when the animation begins & ends.
578 * @param [in] actor The actor to animate.
579 * @param [in] x axis position.
580 * @param [in] y axis position.
581 * @param [in] z axis position.
583 void MoveTo(Actor actor, float x, float y, float z);
586 * @brief Move an actor to a target position.
588 * This overload allows the alpha function to be customized.
589 * The move will start & end when the animation begins & ends.
590 * @param [in] actor The actor to animate.
591 * @param [in] position to move to
592 * @param [in] alpha The alpha function to apply.
594 void MoveTo(Actor actor, Vector3 position, AlphaFunction alpha);
597 * @brief Move an actor to a target position.
599 * This overload allows the translation start & end time to be customized.
600 * @pre delaySeconds must be zero or greater.
601 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
602 * @param [in] actor The actor to animate.
603 * @param [in] position to move to
604 * @param [in] alpha The alpha function to apply.
605 * @param [in] delaySeconds The initial delay from the start of the animation.
606 * @param [in] durationSeconds The duration of the translation.
608 void MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds);
611 * @brief Move an actor using a custom function.
613 * The animatorFunc will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
614 * @pre delaySeconds must be zero or greater.
615 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
616 * @param [in] actor The actor to animate.
617 * @param [in] animatorFunc The function to call during the animation.
618 * @param [in] alpha The alpha function to apply.
619 * @param [in] delaySeconds The initial delay from the start of the animation.
620 * @param [in] durationSeconds The duration of the translation.
622 void Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds);
625 * @brief Rotate an actor around an arbitrary axis.
627 * The default alpha function will be used.
628 * The rotation will start & end when the animation begins & ends.
629 * @param [in] actor The actor to animate.
630 * @param [in] angle The angle in degrees.
631 * @param [in] axis The axis to rotate around
633 void RotateBy(Actor actor, Degree angle, Vector3 axis);
636 * @brief Rotate an actor around an arbitrary axis.
638 * The default alpha function will be used.
639 * The rotation will start & end when the animation begins & ends.
640 * @param [in] actor The actor to animate.
641 * @param [in] angle The angle in radians.
642 * @param [in] axis The axis to rotate around
644 void RotateBy(Actor actor, Radian angle, Vector3 axis);
647 * @brief Rotate an actor around an arbitrary axis.
649 * This overload allows the alpha function to be customized.
650 * The rotation will start & end when the animation begins & ends.
651 * @param [in] actor The actor to animate.
652 * @param [in] angle The angle in radians.
653 * @param [in] axis The axis to rotate around.
654 * @param [in] alpha The alpha function to apply.
656 void RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha);
659 * @brief Rotate an actor around an arbitrary axis.
661 * This overload allows the alpha function to be customized.
662 * The rotation will start & end when the animation begins & ends.
663 * @param [in] actor The actor to animate.
664 * @param [in] angle The angle in radians.
665 * @param [in] axis The axis to rotate around.
666 * @param [in] alpha The alpha function to apply.
668 void RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha);
671 * @brief Rotate an actor around an arbitrary axis.
673 * This overload allows the rotation start & end time to be customized.
674 * @pre delaySeconds must be zero or greater.
675 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
676 * @param [in] actor The actor to animate.
677 * @param [in] angle The angle in degrees.
678 * @param [in] axis The axis to rotate around
679 * @param [in] alpha The alpha function to apply.
680 * @param [in] delaySeconds The initial delay from the start of the animation.
681 * @param [in] durationSeconds The duration of the rotation.
683 void RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
686 * @brief Rotate an actor around an arbitrary axis.
688 * This overload allows the rotation start & end time to be customized.
689 * @pre delaySeconds must be zero or greater.
690 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
691 * @param [in] actor The actor to animate.
692 * @param [in] angle The angle in radians.
693 * @param [in] axis The axis to rotate around
694 * @param [in] alpha The alpha function to apply.
695 * @param [in] delaySeconds The initial delay from the start of the animation.
696 * @param [in] durationSeconds The duration of the rotation.
698 void RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
701 * @brief Rotate an actor to a target orientation.
703 * The default alpha function will be used.
704 * The rotation will start & end when the animation begins & ends.
705 * @param [in] actor The actor to animate.
706 * @param [in] angle The target rotation angle in degrees.
707 * @param [in] axis The target axis of rotation.
709 void RotateTo(Actor actor, Degree angle, Vector3 axis);
712 * @brief Rotate an actor to a target orientation.
714 * The default alpha function will be used.
715 * The rotation will start & end when the animation begins & ends.
716 * @param [in] actor The actor to animate.
717 * @param [in] angle The target rotation angle in radians.
718 * @param [in] axis The target axis of rotation.
720 void RotateTo(Actor actor, Radian angle, Vector3 axis);
723 * @brief Rotate an actor to a target orientation.
725 * The default alpha function will be used.
726 * The rotation will start & end when the animation begins & ends.
727 * @param [in] actor The actor to animate.
728 * @param [in] orientation The target orientation.
730 void RotateTo(Actor actor, Quaternion orientation);
733 * @brief Rotate an actor to a target orientation.
735 * This overload allows the alpha function to be customized.
736 * The rotation will start & end when the animation begins & ends.
737 * @param [in] actor The actor to animate.
738 * @param [in] angle The target rotation angle in degrees.
739 * @param [in] axis The target axis of rotation.
740 * @param [in] alpha The alpha function to apply.
742 void RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha);
745 * @brief Rotate an actor to a target orientation.
747 * This overload allows the alpha function to be customized.
748 * The rotation will start & end when the animation begins & ends.
749 * @param [in] actor The actor to animate.
750 * @param [in] angle The target rotation angle in radians.
751 * @param [in] axis The target axis of rotation.
752 * @param [in] alpha The alpha function to apply.
754 void RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha);
757 * @brief Rotate an actor to a target orientation.
759 * This overload allows the alpha function to be customized.
760 * The rotation will start & end when the animation begins & ends.
761 * @param [in] actor The actor to animate.
762 * @param [in] orientation The target orientation.
763 * @param [in] alpha The alpha function to apply.
765 void RotateTo(Actor actor, Quaternion orientation, AlphaFunction alpha);
768 * @brief Rotate an actor to a target orientation.
770 * This overload allows the rotation start & end time to be customized.
771 * @pre delaySeconds must be zero or greater.
772 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
773 * @param [in] actor The actor to animate.
774 * @param [in] angle The target rotation angle in degrees.
775 * @param [in] axis The target axis of rotation.
776 * @param [in] alpha The alpha function to apply.
777 * @param [in] delaySeconds The initial delay from the start of the animation.
778 * @param [in] durationSeconds The duration of the rotation.
780 void RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
783 * @brief Rotate an actor to a target orientation.
785 * This overload allows the rotation start & end time to be customized.
786 * @pre delaySeconds must be zero or greater.
787 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
788 * @param [in] actor The actor to animate.
789 * @param [in] angle The target rotation angle in radians.
790 * @param [in] axis The target axis of rotation.
791 * @param [in] alpha The alpha function to apply.
792 * @param [in] delaySeconds The initial delay from the start of the animation.
793 * @param [in] durationSeconds The duration of the rotation.
795 void RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
798 * @brief Rotate an actor to a target orientation.
800 * This overload allows the rotation start & end time to be customized.
801 * @pre delaySeconds must be zero or greater.
802 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
803 * @param [in] actor The actor to animate.
804 * @param [in] orientation The target orientation.
805 * @param [in] alpha The alpha function to apply.
806 * @param [in] delaySeconds The initial delay from the start of the animation.
807 * @param [in] durationSeconds The duration of the rotation.
809 void RotateTo(Actor actor, Quaternion orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
812 * @brief Rotate an actor using a custom function.
814 * The animatorFunc will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
815 * @pre delaySeconds must be zero or greater.
816 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
817 * @param [in] actor The actor to animate.
818 * @param [in] animatorFunc The function to call during the animation.
819 * @param [in] alpha The alpha function to apply.
820 * @param [in] delaySeconds The initial delay from the start of the animation.
821 * @param [in] durationSeconds The duration of the rotation.
823 void Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds);
826 * @brief Scale an actor.
828 * The default alpha function will be used.
829 * The scaling will start & end when the animation begins & ends.
830 * @param [in] actor The actor to animate.
831 * @param [in] x Scale factor in the X-direction.
832 * @param [in] y Scale factor in the Y-direction.
833 * @param [in] z Scale factor in the Z-direction.
835 void ScaleBy(Actor actor, float x, float y, float z);
838 * @brief Scale an actor.
840 * This overload allows the alpha function to be customized.
841 * The scaling will start & end when the animation begins & ends.
842 * @param [in] actor The actor to animate.
843 * @param [in] scale The scale factor.
844 * @param [in] alpha The alpha function to apply.
846 void ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha);
849 * @brief Scale an actor.
851 * This overload allows the scaling start & end time to be customized.
852 * @pre delaySeconds must be zero or greater.
853 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
854 * @param [in] actor The actor to animate.
855 * @param [in] scale The scale factor.
856 * @param [in] alpha The alpha function to apply.
857 * @param [in] delaySeconds The initial delay from the start of the animation.
858 * @param [in] durationSeconds The duration of the scaling.
860 void ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
863 * @brief Scale an actor to a target scale factor.
865 * The default alpha function will be used.
866 * The scaling will start & end when the animation begins & ends.
867 * @param [in] actor The actor to animate.
868 * @param [in] x Target scale-factor in the X-direction.
869 * @param [in] y Target scale-factor in the Y-direction.
870 * @param [in] z Target scale-factor in the Z-direction.
872 void ScaleTo(Actor actor, float x, float y, float z);
875 * @brief Scale an actor to a target scale factor.
877 * This overload allows the alpha function to be customized.
878 * The scaling will start & end when the animation begins & ends.
879 * @param [in] actor The actor to animate.
880 * @param [in] scale The target scale factor.
881 * @param [in] alpha The alpha function to apply.
883 void ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha);
886 * @brief Scale an actor to a target scale factor.
888 * This overload allows the scaling start & end time to be customized.
889 * @pre delaySeconds must be zero or greater.
890 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
891 * @param [in] actor The actor to animate.
892 * @param [in] scale The target scale factor.
893 * @param [in] alpha The alpha function to apply.
894 * @param [in] delaySeconds The initial delay from the start of the animation.
895 * @param [in] durationSeconds The duration of the scaling.
897 void ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
900 * @brief Show an actor during the animation.
902 * @param [in] actor The actor to animate.
903 * @param [in] delaySeconds The initial delay from the start of the animation.
905 void Show(Actor actor, float delaySeconds);
908 * @brief Hide an actor during the animation.
910 * @param [in] actor The actor to animate.
911 * @param [in] delaySeconds The initial delay from the start of the animation.
913 void Hide(Actor actor, float delaySeconds);
916 * @brief Animate the opacity of an actor.
918 * The default alpha function will be used.
919 * The effect will start & end when the animation begins & ends.
920 * @param [in] actor The actor to animate.
921 * @param [in] opacity The relative change in opacity.
923 void OpacityBy(Actor actor, float opacity);
926 * @brief Animate the opacity of an actor.
928 * This overload allows the alpha function to be customized.
929 * The effect will start & end when the animation begins & ends.
930 * @param [in] actor The actor to animate.
931 * @param [in] opacity The relative change in opacity.
932 * @param [in] alpha The alpha function to apply.
934 void OpacityBy(Actor actor, float opacity, AlphaFunction alpha);
937 * @brief Animate the opacity of an actor.
939 * This overload allows the animation start & end time to be customized.
940 * @pre delaySeconds must be zero or greater.
941 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
942 * @param [in] actor The actor to animate.
943 * @param [in] opacity The relative change in opacity.
944 * @param [in] alpha The alpha function to apply.
945 * @param [in] delaySeconds The initial delay from the start of the animation.
946 * @param [in] durationSeconds The duration of the opacity animation.
948 void OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
951 * @brief Animate an actor to a target opacity.
953 * The default alpha function will be used.
954 * The effect will start & end when the animation begins & ends.
955 * @param [in] actor The actor to animate.
956 * @param [in] opacity The target opacity.
958 void OpacityTo(Actor actor, float opacity);
961 * @brief Animate an actor to a target opacity.
963 * This overload allows the alpha function to be customized.
964 * The effect will start & end when the animation begins & ends.
965 * @param [in] actor The actor to animate.
966 * @param [in] opacity The target opacity.
967 * @param [in] alpha The alpha function to apply.
969 void OpacityTo(Actor actor, float opacity, AlphaFunction alpha);
972 * @brief Animate an actor to a target opacity.
974 * This overload allows the animation start & end time to be customized.
975 * @pre delaySeconds must be zero or greater.
976 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
977 * @param [in] actor The actor to animate.
978 * @param [in] opacity The target opacity.
979 * @param [in] alpha The alpha function to apply.
980 * @param [in] delaySeconds The initial delay from the start of the animation.
981 * @param [in] durationSeconds The duration of the opacity animation.
983 void OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
986 * @brief Animate the color of an actor.
988 * The default alpha function will be used.
989 * The effect will start & end when the animation begins & ends.
990 * @param [in] actor The actor to animate.
991 * @param [in] color The relative change in color.
993 void ColorBy(Actor actor, Vector4 color);
996 * @brief Animate the color of an actor.
998 * This overload allows the alpha function to be customized.
999 * The effect will start & end when the animation begins & ends.
1000 * @param [in] actor The actor to animate.
1001 * @param [in] color The relative change in color.
1002 * @param [in] alpha The alpha function to apply.
1004 void ColorBy(Actor actor, Vector4 color, AlphaFunction alpha);
1007 * @brief Animate the color of an actor.
1009 * This overload allows the animation start & end time to be customized.
1010 * @pre delaySeconds must be zero or greater.
1011 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1012 * @param [in] actor The actor to animate.
1013 * @param [in] color The relative change in color.
1014 * @param [in] alpha The alpha function to apply.
1015 * @param [in] delaySeconds The initial delay from the start of the animation.
1016 * @param [in] durationSeconds The duration of the color animation.
1018 void ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1021 * @brief Animate an actor to a target color.
1023 * The default alpha function will be used.
1024 * The effect will start & end when the animation begins & ends.
1025 * @param [in] actor The actor to animate.
1026 * @param [in] color The target color.
1028 void ColorTo(Actor actor, Vector4 color);
1031 * @brief Animate an actor to a target color.
1033 * This overload allows the alpha function to be customized.
1034 * The effect will start & end when the animation begins & ends.
1035 * @param [in] actor The actor to animate.
1036 * @param [in] color The target color.
1037 * @param [in] alpha The alpha function to apply.
1039 void ColorTo(Actor actor, Vector4 color, AlphaFunction alpha);
1042 * @brief Animate an actor to a target color.
1044 * This overload allows the animation start & end time to be customized.
1045 * @pre delaySeconds must be zero or greater.
1046 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1047 * @param [in] actor The actor to animate.
1048 * @param [in] color The target color.
1049 * @param [in] alpha The alpha function to apply.
1050 * @param [in] delaySeconds The initial delay from the start of the animation.
1051 * @param [in] durationSeconds The duration of the color animation.
1053 void ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1056 * @brief Resize an actor.
1058 * The default alpha function will be used.
1059 * The resizing will start & end when the animation begins & ends.
1060 * The depth defaults to the minimum of width & height.
1061 * @param [in] actor The actor to animate.
1062 * @param [in] width The target width.
1063 * @param [in] height The target height.
1065 void Resize(Actor actor, float width, float height);
1068 * @brief Resize an actor.
1070 * This overload allows the alpha function to be customized.
1071 * The resizing will start & end when the animation begins & ends.
1072 * The depth defaults to the minimum of width & height.
1073 * @param [in] actor The actor to animate.
1074 * @param [in] width The target width.
1075 * @param [in] height The target height.
1076 * @param [in] alpha The alpha function to apply.
1078 void Resize(Actor actor, float width, float height, AlphaFunction alpha);
1081 * @brief Resize an actor.
1083 * This overload allows the resizing start & end time to be customized.
1084 * The depth defaults to the minimum of width & height.
1085 * @pre delaySeconds must be zero or greater.
1086 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1087 * @param [in] actor The actor to animate.
1088 * @param [in] width The target width.
1089 * @param [in] height The target height.
1090 * @param [in] alpha The alpha function to apply.
1091 * @param [in] delaySeconds The initial delay from the start of the animation.
1092 * @param [in] durationSeconds The duration of the resizing.
1094 void Resize(Actor actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1097 * @brief Resize an actor.
1099 * The default alpha function will be used.
1100 * The resizing will start & end when the animation begins & ends.
1101 * @param [in] actor The actor to animate.
1102 * @param [in] size The target size.
1104 void Resize(Actor actor, Vector3 size);
1107 * @brief Resize an actor.
1109 * This overload allows the alpha function to be customized.
1110 * The resizing will start & end when the animation begins & ends.
1111 * @param [in] actor The actor to animate.
1112 * @param [in] size The target size.
1113 * @param [in] alpha The alpha function to apply.
1115 void Resize(Actor actor, Vector3 size, AlphaFunction alpha);
1118 * @brief Resize an actor.
1120 * This overload allows the resizing start & end time to be customized.
1121 * @pre delaySeconds must be zero or greater.
1122 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1123 * @param [in] actor The actor to animate.
1124 * @param [in] size The target size.
1125 * @param [in] alpha The alpha function to apply.
1126 * @param [in] delaySeconds The initial delay from the start of the animation.
1127 * @param [in] durationSeconds The duration of the resizing.
1129 void Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1131 public: // Not intended for use by Application developers
1134 * @brief This constructor is used by Dali New() methods
1135 * @param [in] animation A pointer to a newly allocated Dali resource
1137 explicit DALI_INTERNAL Animation(Internal::Animation* animation);
1142 * @brief Animate a property using a custom function.
1144 * @pre The property type is equal expectedType.
1145 * @param [in] target The target object/property to animate.
1146 * @param [in] targetType The expected type of the property.
1147 * @param [in] func The function to call during the animation.
1149 void Animate( Property target,
1150 Property::Type targetType,
1154 * @brief Animate a property using a custom function.
1156 * @pre The property type is equal expectedType.
1157 * @param [in] target The target object/property to animate.
1158 * @param [in] targetType The expected type of the property.
1159 * @param [in] func The function to call during the animation.
1160 * @param [in] alpha The alpha function to apply.
1162 void Animate( Property target,
1163 Property::Type targetType,
1165 AlphaFunction alpha );
1168 * @brief Animate a property using a custom function.
1170 * @pre The property type is equal expectedType.
1171 * @param [in] target The target object/property to animate.
1172 * @param [in] targetType The expected type of the property.
1173 * @param [in] func The function to call during the animation.
1174 * @param [in] period The effect will occur during this time period.
1176 void Animate( Property target,
1177 Property::Type targetType,
1179 TimePeriod period );
1182 * @brief Animate a property using a custom function.
1184 * @pre The property type is equal expectedType.
1185 * @param [in] target The target object/property to animate.
1186 * @param [in] targetType The expected type of the property.
1187 * @param [in] func The function to call during the animation.
1188 * @param [in] alpha The alpha function to apply.
1189 * @param [in] period The effect will occur during this time period.
1191 void Animate( Property target,
1192 Property::Type targetType,
1194 AlphaFunction alpha,
1195 TimePeriod period );
1200 #endif // __DALI_ANIMATION_H__