(Animation) Allow the value to be baked upon property owner disconnection, DestroyEnd...
[platform/core/uifw/dali-core.git] / dali / public-api / animation / animation.h
1 #ifndef __DALI_ANIMATION_H__
2 #define __DALI_ANIMATION_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <boost/function.hpp>
23
24 // INTERNAL INCLUDES
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>
32
33 namespace Dali DALI_IMPORT_API
34 {
35
36 class Actor;
37 struct Degree;
38 class Quaternion;
39 struct Radian;
40 class ShaderEffect;
41 struct Property;
42 struct Vector2;
43 struct Vector3;
44 struct Vector4;
45
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.
53
54 namespace Internal DALI_INTERNAL
55 {
56 class Animation;
57 }
58
59 /**
60  * @brief Dali::Animation can be used to animate the properties of any number of objects, typically Actors.
61  *
62  * An example animation setup is shown below:
63  *
64  * @code
65  *
66  * struct MyProgram
67  * {
68  *   Actor mActor; // The object we wish to animate
69  *   Animation mAnimation; // Keep this to control the animation
70  * }
71  *
72  * // ...To play the animation
73  *
74  * mAnimation = Animation::New(3.0f); // duration 3 seconds
75  * mAnimation.MoveTo(mActor, 10.0f, 50.0f, 0.0f);
76  * mAnimation.Play();
77  *
78  * @endcode
79  *
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:
82  *
83  * @code
84  *
85  * void ExampleCallback( Animation& source )
86  * {
87  *   std::cout << "Animation has finished" << std::endl;
88  * }
89  *
90  * void ExampleAnimation( Actor actor )
91  * {
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 );
95  *   animation.Play();
96  * } // At this point the animation handle has gone out of scope
97  *
98  * Actor actor = Actor::New();
99  * Stage::GetCurrent().Add( actor );
100  *
101  * // Fire animation and forget about it
102  * ExampleAnimation( actor );
103  *
104  * // However the animation will continue, and "Animation has finished" will be printed after 2 seconds.
105  *
106  * @endcode
107  *
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.
110  */
111 class DALI_IMPORT_API Animation : public BaseHandle
112 {
113 public:
114
115   typedef SignalV2< void (Animation&) > AnimationSignalV2; ///< Animation finished signal type
116
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
120
121   /**
122    * @brief What to do when the animation ends, is stopped or is destroyed
123    */
124   enum EndAction
125   {
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.
129   };
130
131   //Signal Names
132   static const char* const SIGNAL_FINISHED; ///< name "finished"
133
134   //Action Names
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"
138
139   /**
140    * @brief Create an uninitialized Animation; this can be initialized with Animation::New().
141    *
142    * Calling member functions with an uninitialized Dali::Object is not allowed.
143    */
144   Animation();
145
146   /**
147    * @brief Create an initialized Animation.
148    *
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.
155    */
156   static Animation New(float durationSeconds);
157
158   /**
159    * @brief Downcast an Object handle to Animation.
160    *
161    * If handle points to an Animation object the downcast produces
162    * valid handle. If not the returned handle is left uninitialized.
163    *
164    * @param[in] handle to An object
165    * @return handle to a Animation object or an uninitialized handle
166    */
167   static Animation DownCast( BaseHandle handle );
168
169   /**
170    * @brief Destructor
171    *
172    * This is non-virtual since derived Handle types must not contain data or virtual methods.
173    */
174   ~Animation();
175
176   /**
177    * @brief This copy constructor is required for (smart) pointer semantics.
178    *
179    * @param [in] handle A reference to the copied handle
180    */
181   Animation(const Animation& handle);
182
183   /**
184    * @brief This assignment operator is required for (smart) pointer semantics.
185    *
186    * @param [in] rhs  A reference to the copied handle
187    * @return A reference to this
188    */
189   Animation& operator=(const Animation& rhs);
190
191   /**
192    * @brief This method is defined to allow assignment of the NULL value,
193    * and will throw an exception if passed any other value.
194    *
195    * Assigning to NULL is an alias for Reset().
196    * @param [in] rhs  A NULL pointer
197    * @return A reference to this handle
198    */
199   Animation& operator=(BaseHandle::NullType* rhs);
200
201   /**
202    * @brief Set the duration of an animation.
203    *
204    * @pre durationSeconds must be greater than zero.
205    * @param[in] seconds The duration in seconds.
206    */
207   void SetDuration(float seconds);
208
209   /**
210    * @brief Retrieve the duration of an animation.
211    *
212    * @return The duration in seconds.
213    */
214   float GetDuration() const;
215
216   /**
217    * @brief Set whether the animation will loop.
218    *
219    * @param[in] looping True if the animation will loop.
220    */
221   void SetLooping(bool looping);
222
223   /**
224    * @brief Query whether the animation will loop.
225    *
226    * @return True if the animation will loop.
227    */
228   bool IsLooping() const;
229
230   /**
231    * @brief Set the end action of the animation.
232    *
233    * This action is performed when the animation ends or if it is stopped.
234    * Default end action is bake
235    * @param[in] action The end action.
236    */
237   void SetEndAction(EndAction action);
238
239   /**
240    * @brief Returns the end action of the animation.
241    *
242    * @return The end action.
243    */
244   EndAction GetEndAction() const;
245
246   /**
247    * @brief Deprecated
248    *
249    * @param[in] action The destroy action.
250    *
251    * @deprecated Use SetEndAction
252    */
253   void SetDestroyAction(EndAction action);
254
255   /**
256    * @brief Deprecated
257    *
258    * @return The destroy action.
259    *
260    * @deprecated Use GetEndAction
261    */
262   EndAction GetDestroyAction() const;
263
264   /**
265    * @brief Set the disconnect action.
266    *
267    * If any of the animated property owners are disconnected from the stage, then this action is performed.
268    * Default action is to BakeFinal.
269    * @param[in] disconnectAction The disconnect action.
270    */
271   void SetDisconnectAction( EndAction disconnectAction );
272
273   /**
274    * @brief Returns the disconnect action.
275    *
276    * @return The disconnect action.
277    */
278   EndAction GetDisconnectAction() const;
279
280   /**
281    * @brief Set the default alpha function for an animation.
282    *
283    * This is applied to individual property animations, if no further alpha functions are supplied.
284    * @param[in] alpha The default alpha function.
285    */
286   void SetDefaultAlphaFunction(AlphaFunction alpha);
287
288   /**
289    * @brief Retrieve the default alpha function for an animation.
290    *
291    * @return The default alpha function.
292    */
293   AlphaFunction GetDefaultAlphaFunction() const;
294
295   /*
296    * @brief Sets the progress of the animation.
297    * The animation will play (or continue playing) from this point. The progress
298    * must be in the 0-1 interval or in the play range interval if defined ( See SetPlayRange ),
299    * otherwise, it will be ignored.
300    *
301    * @param[in] progress The new progress as a normalized value between [0,1] or between the
302    * play range if specified.
303    */
304   void SetCurrentProgress( float progress );
305
306   /**
307   * @brief Retrieve the current progress of the animation.
308   *
309   * @return The current progress as a normalized value between [0,1].
310   */
311   float GetCurrentProgress();
312
313   /**
314    * @brief Specifies an speed factor for the animation.
315    *
316    * The speed factor is a multiplier of the normal velocity of the animation. Values between [0,1] will
317    * slow down the animation and values above one will speed up the animation. It is also possible to specify a negative multiplier
318    * to play the animation in reverse.
319    *
320    * @param[in] factor A value which will multiply the velocity.
321    */
322   void SetSpeedFactor( float factor );
323
324   /**
325    * @brief Retrieve the speed factor of the animation
326    *
327    * @return speed factor
328    */
329   float GetSpeedFactor() const;
330
331   /**
332    * @brief Set the playing range.
333    * Animation will play between the values specified. Both values ( range.x and range.y ) should be between 0-1,
334    * otherwise they will be ignored. If the range provided is not in proper order ( minimum,maximum ), it will be reordered.
335    *
336    * @param[in] range Two values between [0,1] to specify minimum and maximum progress. The
337    * animation will play between those values.
338    */
339   void SetPlayRange( const Vector2& range );
340
341   /**
342    * @brief Get the playing range
343    *
344    * @return The play range defined for the animation.
345    */
346   Vector2 GetPlayRange() const;
347
348   /**
349    * @brief Play the animation.
350    */
351   void Play();
352
353   /**
354    * @brief Play the animation from a given point.
355    * The progress must be in the 0-1 interval or in the play range interval if defined ( See SetPlayRange ),
356    * otherwise, it will be ignored.
357    *
358    * @param[in] progress A value between [0,1], or between the play range if specified, form where the animation should start playing
359    */
360   void PlayFrom( float progress );
361
362   /**
363    * @brief Pause the animation.
364    */
365   void Pause();
366
367   /**
368    * @brief Stop the animation.
369    */
370   void Stop();
371
372   /**
373    * @brief Clear the animation.
374    *
375    * This disconnects any objects that were being animated, effectively stopping the animation.
376    */
377   void Clear();
378
379   /**
380    * @brief Connect to this signal to be notified when an Animation's animations have finished.
381    *
382    * @return A signal object to Connect() with.
383    */
384   AnimationSignalV2& FinishedSignal();
385
386   /**
387    * @brief Animate a property value by a relative amount.
388    *
389    * The default alpha function will be used.
390    * The effect will start & end when the animation begins & ends.
391    * @param [in] target The target object/property to animate.
392    * @param [in] relativeValue The property value will change by this amount.
393    */
394   void AnimateBy(Property target, Property::Value relativeValue);
395
396   /**
397    * @brief Animate a property value by a relative amount.
398    *
399    * The effect will start & end when the animation begins & ends.
400    * @param [in] target The target object/property to animate.
401    * @param [in] relativeValue The property value will change by this amount.
402    * @param [in] alpha The alpha function to apply.
403    */
404   void AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha);
405
406   /**
407    * @brief Animate a property value by a relative amount.
408    *
409    * The default alpha function will be used.
410    * @param [in] target The target object/property to animate.
411    * @param [in] relativeValue The property value will increase/decrease by this amount.
412    * @param [in] period The effect will occur during this time period.
413    */
414   void AnimateBy(Property target, Property::Value relativeValue, TimePeriod period);
415
416   /**
417    * @brief Animate a property value by a relative amount.
418    *
419    * @param [in] target The target object/property to animate.
420    * @param [in] relativeValue The property value will increase/decrease by this amount.
421    * @param [in] alpha The alpha function to apply.
422    * @param [in] period The effect will occur during this time period.
423    */
424   void AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period);
425
426   /**
427    * @brief Animate a property to a destination value.
428    *
429    * The default alpha function will be used.
430    * The effect will start & end when the animation begins & ends.
431    * @param [in] target The target object/property to animate.
432    * @param [in] destinationValue The destination value.
433    */
434   void AnimateTo(Property target, Property::Value destinationValue);
435
436   /**
437    * @brief Animate a property to a destination value.
438    *
439    * The effect will start & end when the animation begins & ends.
440    * @param [in] target The target object/property to animate.
441    * @param [in] destinationValue The destination value.
442    * @param [in] alpha The alpha function to apply.
443    */
444   void AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha);
445
446   /**
447    * @brief Animate a property to a destination value.
448    *
449    * The default alpha function will be used.
450    * @param [in] target The target object/property to animate.
451    * @param [in] destinationValue The destination value.
452    * @param [in] period The effect will occur during this time period.
453    */
454   void AnimateTo(Property target, Property::Value destinationValue, TimePeriod period);
455
456   /**
457    * @brief Animate a property to a destination value.
458    *
459    * @param [in] target The target object/property to animate.
460    * @param [in] destinationValue The destination value.
461    * @param [in] alpha The alpha function to apply.
462    * @param [in] period The effect will occur during this time period.
463    */
464   void AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period);
465
466   /**
467    * @brief Animate a property between keyframes.
468    *
469    * @param [in] target The target object/property to animate.
470    * @param [in] keyFrames The key frames
471    */
472   void AnimateBetween(Property target, KeyFrames& keyFrames);
473
474   /**
475    * @brief Animate a property between keyframes.
476    *
477    * @param [in] target The target object/property to animate.
478    * @param [in] keyFrames The key frames
479    * @param [in] alpha The alpha function to apply.
480    */
481   void AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha);
482
483   /**
484    * @brief Animate a property between keyframes.
485    *
486    * @param [in] target The target object/property to animate.
487    * @param [in] keyFrames The key frames
488    * @param [in] period The effect will occur during this time period.
489    */
490   void AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period);
491
492   /**
493    * @brief Animate a property between keyframes.
494    *
495    * @param [in] target The target object/property to animate.
496    * @param [in] keyFrames The key frames
497    * @param [in] alpha The alpha function to apply.
498    * @param [in] period The effect will occur during this time period.
499    */
500   void AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
501
502   /**
503    * @brief Animate a property using a custom function.
504    *
505    * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
506    * @pre The property type is equal PropertyTypes::Get<P>().
507    * @param [in] target The target object/property to animate.
508    * @param [in] animatorFunc The function to call during the animation.
509    */
510   template <class P>
511   void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc )
512   {
513     Animate( target, PropertyTypes::Get<P>(), animatorFunc );
514   }
515
516   /**
517    * @brief Animate a property using a custom function.
518    *
519    * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
520    * @pre The property type is equal PropertyTypes::Get<P>().
521    * @param [in] target The target object/property to animate.
522    * @param [in] animatorFunc The function to call during the animation.
523    * @param [in] alpha The alpha function to apply.
524    */
525   template <class P>
526   void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, AlphaFunction alpha )
527   {
528     Animate( target, PropertyTypes::Get<P>(), animatorFunc, alpha );
529   }
530
531   /**
532    * @brief Animate a property using a custom function.
533    *
534    * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
535    * @pre The property type is equal PropertyTypes::Get<P>().
536    * @param [in] target The target object/property to animate.
537    * @param [in] animatorFunc The function to call during the animation.
538    * @param [in] period The effect will occur during this time period.
539    */
540   template <class P>
541   void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, TimePeriod period )
542   {
543     Animate( target, PropertyTypes::Get<P>(), animatorFunc, period );
544   }
545
546   /**
547    * @brief Animate a property using a custom function.
548    *
549    * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
550    * @pre The property type is equal PropertyTypes::Get<P>().
551    * @param [in] target The target object/property to animate.
552    * @param [in] animatorFunc The function to call during the animation.
553    * @param [in] alpha The alpha function to apply.
554    * @param [in] period The effect will occur during this time period.
555    */
556   template <class P>
557   void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, AlphaFunction alpha, TimePeriod period )
558   {
559     Animate( target, PropertyTypes::Get<P>(), animatorFunc, alpha, period );
560   }
561
562   // Actor-specific convenience methods
563
564   /**
565    * @brief Move an actor relative to its position.
566    *
567    * The default alpha function will be used.
568    * The move will start & end when the animation begins & ends.
569    * @param [in] actor The actor to animate.
570    * @param [in] x axis displacement.
571    * @param [in] y axis displacement.
572    * @param [in] z axis displacement.
573    */
574   void MoveBy(Actor actor, float x, float y, float z);
575
576   /**
577    * @brief Move an actor relative to its position.
578    *
579    * This overload allows the alpha function to be customized.
580    * The move will start & end when the animation begins & ends.
581    * @param [in] actor The actor to animate.
582    * @param [in] displacement relative to current position.
583    * @param [in] alpha The alpha function to apply.
584    */
585   void MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha);
586
587   /**
588    * @brief Move an actor relative to its position.
589    *
590    * This overload allows the translation start & end time to be customized.
591    * @pre delaySeconds must be zero or greater.
592    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
593    * @param [in] actor The actor to animate.
594    * @param [in] displacement relative to current position.
595    * @param [in] alpha The alpha function to apply.
596    * @param [in] delaySeconds The initial delay from the start of the animation.
597    * @param [in] durationSeconds The duration of the translation.
598    */
599   void MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds);
600
601   /**
602    * @brief Move an actor to a target position.
603    *
604    * The default alpha function will be used.
605    * The move will start & end when the animation begins & ends.
606    * @param [in] actor The actor to animate.
607    * @param [in] x axis position.
608    * @param [in] y axis position.
609    * @param [in] z axis position.
610    */
611   void MoveTo(Actor actor, float x, float y, float z);
612
613   /**
614    * @brief Move an actor to a target position.
615    *
616    * This overload allows the alpha function to be customized.
617    * The move will start & end when the animation begins & ends.
618    * @param [in] actor The actor to animate.
619    * @param [in] position to move to
620    * @param [in] alpha The alpha function to apply.
621    */
622   void MoveTo(Actor actor, Vector3 position, AlphaFunction alpha);
623
624   /**
625    * @brief Move an actor to a target position.
626    *
627    * This overload allows the translation start & end time to be customized.
628    * @pre delaySeconds must be zero or greater.
629    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
630    * @param [in] actor The actor to animate.
631    * @param [in] position to move to
632    * @param [in] alpha The alpha function to apply.
633    * @param [in] delaySeconds The initial delay from the start of the animation.
634    * @param [in] durationSeconds The duration of the translation.
635    */
636   void MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds);
637
638   /**
639    * @brief Move an actor using a custom function.
640    *
641    * The animatorFunc will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
642    * @pre delaySeconds must be zero or greater.
643    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
644    * @param [in] actor The actor to animate.
645    * @param [in] animatorFunc The function to call during the animation.
646    * @param [in] alpha The alpha function to apply.
647    * @param [in] delaySeconds The initial delay from the start of the animation.
648    * @param [in] durationSeconds The duration of the translation.
649    */
650   void Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds);
651
652   /**
653    * @brief Rotate an actor around an arbitrary axis.
654    *
655    * The default alpha function will be used.
656    * The rotation will start & end when the animation begins & ends.
657    * @param [in] actor The actor to animate.
658    * @param [in] angle The angle in degrees.
659    * @param [in] axis The axis to rotate around
660    */
661   void RotateBy(Actor actor, Degree angle, Vector3 axis);
662
663   /**
664    * @brief Rotate an actor around an arbitrary axis.
665    *
666    * The default alpha function will be used.
667    * The rotation will start & end when the animation begins & ends.
668    * @param [in] actor The actor to animate.
669    * @param [in] angle The angle in radians.
670    * @param [in] axis The axis to rotate around
671    */
672   void RotateBy(Actor actor, Radian angle, Vector3 axis);
673
674   /**
675    * @brief Rotate an actor around an arbitrary axis.
676    *
677    * This overload allows the alpha function to be customized.
678    * The rotation will start & end when the animation begins & ends.
679    * @param [in] actor The actor to animate.
680    * @param [in] angle The angle in radians.
681    * @param [in] axis The axis to rotate around.
682    * @param [in] alpha The alpha function to apply.
683    */
684   void RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha);
685
686   /**
687    * @brief Rotate an actor around an arbitrary axis.
688    *
689    * This overload allows the alpha function to be customized.
690    * The rotation will start & end when the animation begins & ends.
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    */
696   void RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha);
697
698   /**
699    * @brief Rotate an actor around an arbitrary axis.
700    *
701    * This overload allows the rotation start & end time to be customized.
702    * @pre delaySeconds must be zero or greater.
703    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
704    * @param [in] actor The actor to animate.
705    * @param [in] angle The angle in degrees.
706    * @param [in] axis The axis to rotate around
707    * @param [in] alpha The alpha function to apply.
708    * @param [in] delaySeconds The initial delay from the start of the animation.
709    * @param [in] durationSeconds The duration of the rotation.
710    */
711   void RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
712
713   /**
714    * @brief Rotate an actor around an arbitrary axis.
715    *
716    * This overload allows the rotation start & end time to be customized.
717    * @pre delaySeconds must be zero or greater.
718    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
719    * @param [in] actor The actor to animate.
720    * @param [in] angle The angle in radians.
721    * @param [in] axis The axis to rotate around
722    * @param [in] alpha The alpha function to apply.
723    * @param [in] delaySeconds The initial delay from the start of the animation.
724    * @param [in] durationSeconds The duration of the rotation.
725    */
726   void RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
727
728   /**
729    * @brief Rotate an actor to a target orientation.
730    *
731    * The default alpha function will be used.
732    * The rotation will start & end when the animation begins & ends.
733    * @param [in] actor The actor to animate.
734    * @param [in] angle The target rotation angle in degrees.
735    * @param [in] axis The target axis of rotation.
736    */
737   void RotateTo(Actor actor, Degree angle, Vector3 axis);
738
739   /**
740    * @brief Rotate an actor to a target orientation.
741    *
742    * The default alpha function will be used.
743    * The rotation will start & end when the animation begins & ends.
744    * @param [in] actor The actor to animate.
745    * @param [in] angle The target rotation angle in radians.
746    * @param [in] axis The target axis of rotation.
747    */
748   void RotateTo(Actor actor, Radian angle, Vector3 axis);
749
750   /**
751    * @brief Rotate an actor to a target orientation.
752    *
753    * The default alpha function will be used.
754    * The rotation will start & end when the animation begins & ends.
755    * @param [in] actor The actor to animate.
756    * @param [in] orientation The target orientation.
757    */
758   void RotateTo(Actor actor, Quaternion orientation);
759
760   /**
761    * @brief Rotate an actor to a target orientation.
762    *
763    * This overload allows the alpha function to be customized.
764    * The rotation will start & end when the animation begins & ends.
765    * @param [in] actor The actor to animate.
766    * @param [in] angle The target rotation angle in degrees.
767    * @param [in] axis The target axis of rotation.
768    * @param [in] alpha The alpha function to apply.
769    */
770   void RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha);
771
772   /**
773    * @brief Rotate an actor to a target orientation.
774    *
775    * This overload allows the alpha function to be customized.
776    * The rotation will start & end when the animation begins & ends.
777    * @param [in] actor The actor to animate.
778    * @param [in] angle The target rotation angle in radians.
779    * @param [in] axis The target axis of rotation.
780    * @param [in] alpha The alpha function to apply.
781    */
782   void RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha);
783
784   /**
785    * @brief Rotate an actor to a target orientation.
786    *
787    * This overload allows the alpha function to be customized.
788    * The rotation will start & end when the animation begins & ends.
789    * @param [in] actor The actor to animate.
790    * @param [in] orientation The target orientation.
791    * @param [in] alpha The alpha function to apply.
792    */
793   void RotateTo(Actor actor, Quaternion orientation, AlphaFunction alpha);
794
795   /**
796    * @brief Rotate an actor to a target orientation.
797    *
798    * This overload allows the rotation start & end time to be customized.
799    * @pre delaySeconds must be zero or greater.
800    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
801    * @param [in] actor The actor to animate.
802    * @param [in] angle The target rotation angle in degrees.
803    * @param [in] axis The target axis of rotation.
804    * @param [in] alpha The alpha function to apply.
805    * @param [in] delaySeconds The initial delay from the start of the animation.
806    * @param [in] durationSeconds The duration of the rotation.
807    */
808   void RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
809
810   /**
811    * @brief Rotate an actor to a target orientation.
812    *
813    * This overload allows the rotation start & end time to be customized.
814    * @pre delaySeconds must be zero or greater.
815    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
816    * @param [in] actor The actor to animate.
817    * @param [in] angle The target rotation angle in radians.
818    * @param [in] axis The target axis of rotation.
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.
822    */
823   void RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
824
825   /**
826    * @brief Rotate an actor to a target orientation.
827    *
828    * This overload allows the rotation start & end time to be customized.
829    * @pre delaySeconds must be zero or greater.
830    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
831    * @param [in] actor The actor to animate.
832    * @param [in] orientation The target orientation.
833    * @param [in] alpha The alpha function to apply.
834    * @param [in] delaySeconds The initial delay from the start of the animation.
835    * @param [in] durationSeconds The duration of the rotation.
836    */
837   void RotateTo(Actor actor, Quaternion orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
838
839   /**
840    * @brief Rotate an actor using a custom function.
841    *
842    * The animatorFunc will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
843    * @pre delaySeconds must be zero or greater.
844    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
845    * @param [in] actor The actor to animate.
846    * @param [in] animatorFunc The function to call during the animation.
847    * @param [in] alpha The alpha function to apply.
848    * @param [in] delaySeconds The initial delay from the start of the animation.
849    * @param [in] durationSeconds The duration of the rotation.
850    */
851   void Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds);
852
853   /**
854    * @brief Scale an actor.
855    *
856    * The default alpha function will be used.
857    * The scaling will start & end when the animation begins & ends.
858    * @param [in] actor The actor to animate.
859    * @param [in] x Scale factor in the X-direction.
860    * @param [in] y Scale factor in the Y-direction.
861    * @param [in] z Scale factor in the Z-direction.
862    */
863   void ScaleBy(Actor actor, float x, float y, float z);
864
865   /**
866    * @brief Scale an actor.
867    *
868    * This overload allows the alpha function to be customized.
869    * The scaling will start & end when the animation begins & ends.
870    * @param [in] actor The actor to animate.
871    * @param [in] scale The scale factor.
872    * @param [in] alpha The alpha function to apply.
873    */
874   void ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha);
875
876   /**
877    * @brief Scale an actor.
878    *
879    * This overload allows the scaling start & end time to be customized.
880    * @pre delaySeconds must be zero or greater.
881    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
882    * @param [in] actor The actor to animate.
883    * @param [in] scale The scale factor.
884    * @param [in] alpha The alpha function to apply.
885    * @param [in] delaySeconds The initial delay from the start of the animation.
886    * @param [in] durationSeconds The duration of the scaling.
887    */
888   void ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
889
890   /**
891    * @brief Scale an actor to a target scale factor.
892    *
893    * The default alpha function will be used.
894    * The scaling will start & end when the animation begins & ends.
895    * @param [in] actor The actor to animate.
896    * @param [in] x Target scale-factor in the X-direction.
897    * @param [in] y Target scale-factor in the Y-direction.
898    * @param [in] z Target scale-factor in the Z-direction.
899    */
900   void ScaleTo(Actor actor, float x, float y, float z);
901
902   /**
903    * @brief Scale an actor to a target scale factor.
904    *
905    * This overload allows the alpha function to be customized.
906    * The scaling will start & end when the animation begins & ends.
907    * @param [in] actor The actor to animate.
908    * @param [in] scale The target scale factor.
909    * @param [in] alpha The alpha function to apply.
910    */
911   void ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha);
912
913   /**
914    * @brief Scale an actor to a target scale factor.
915    *
916    * This overload allows the scaling start & end time to be customized.
917    * @pre delaySeconds must be zero or greater.
918    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
919    * @param [in] actor The actor to animate.
920    * @param [in] scale The target scale factor.
921    * @param [in] alpha The alpha function to apply.
922    * @param [in] delaySeconds The initial delay from the start of the animation.
923    * @param [in] durationSeconds The duration of the scaling.
924    */
925   void ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
926
927   /**
928    * @brief Show an actor during the animation.
929    *
930    * @param [in] actor The actor to animate.
931    * @param [in] delaySeconds The initial delay from the start of the animation.
932    */
933   void Show(Actor actor, float delaySeconds);
934
935   /**
936    * @brief Hide an actor during the animation.
937    *
938    * @param [in] actor The actor to animate.
939    * @param [in] delaySeconds The initial delay from the start of the animation.
940    */
941   void Hide(Actor actor, float delaySeconds);
942
943   /**
944    * @brief Animate the opacity of an actor.
945    *
946    * The default alpha function will be used.
947    * The effect will start & end when the animation begins & ends.
948    * @param [in] actor The actor to animate.
949    * @param [in] opacity The relative change in opacity.
950    */
951   void OpacityBy(Actor actor, float opacity);
952
953   /**
954    * @brief Animate the opacity of an actor.
955    *
956    * This overload allows the alpha function to be customized.
957    * The effect will start & end when the animation begins & ends.
958    * @param [in] actor The actor to animate.
959    * @param [in] opacity The relative change in opacity.
960    * @param [in] alpha The alpha function to apply.
961    */
962   void OpacityBy(Actor actor, float opacity, AlphaFunction alpha);
963
964   /**
965    * @brief Animate the opacity of an actor.
966    *
967    * This overload allows the animation start & end time to be customized.
968    * @pre delaySeconds must be zero or greater.
969    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
970    * @param [in] actor The actor to animate.
971    * @param [in] opacity The relative change in opacity.
972    * @param [in] alpha The alpha function to apply.
973    * @param [in] delaySeconds The initial delay from the start of the animation.
974    * @param [in] durationSeconds The duration of the opacity animation.
975    */
976   void OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
977
978   /**
979    * @brief Animate an actor to a target opacity.
980    *
981    * The default alpha function will be used.
982    * The effect will start & end when the animation begins & ends.
983    * @param [in] actor The actor to animate.
984    * @param [in] opacity The target opacity.
985    */
986   void OpacityTo(Actor actor, float opacity);
987
988   /**
989    * @brief Animate an actor to a target opacity.
990    *
991    * This overload allows the alpha function to be customized.
992    * The effect will start & end when the animation begins & ends.
993    * @param [in] actor The actor to animate.
994    * @param [in] opacity The target opacity.
995    * @param [in] alpha The alpha function to apply.
996    */
997   void OpacityTo(Actor actor, float opacity, AlphaFunction alpha);
998
999   /**
1000    * @brief Animate an actor to a target opacity.
1001    *
1002    * This overload allows the animation start & end time to be customized.
1003    * @pre delaySeconds must be zero or greater.
1004    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1005    * @param [in] actor The actor to animate.
1006    * @param [in] opacity The target opacity.
1007    * @param [in] alpha The alpha function to apply.
1008    * @param [in] delaySeconds The initial delay from the start of the animation.
1009    * @param [in] durationSeconds The duration of the opacity animation.
1010    */
1011   void OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1012
1013   /**
1014    * @brief Animate the color of an actor.
1015    *
1016    * The default alpha function will be used.
1017    * The effect will start & end when the animation begins & ends.
1018    * @param [in] actor The actor to animate.
1019    * @param [in] color The relative change in color.
1020    */
1021   void ColorBy(Actor actor, Vector4 color);
1022
1023   /**
1024    * @brief Animate the color of an actor.
1025    *
1026    * This overload allows the alpha function to be customized.
1027    * The effect will start & end when the animation begins & ends.
1028    * @param [in] actor The actor to animate.
1029    * @param [in] color The relative change in color.
1030    * @param [in] alpha The alpha function to apply.
1031    */
1032   void ColorBy(Actor actor, Vector4 color, AlphaFunction alpha);
1033
1034   /**
1035    * @brief Animate the color of an actor.
1036    *
1037    * This overload allows the animation start & end time to be customized.
1038    * @pre delaySeconds must be zero or greater.
1039    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1040    * @param [in] actor The actor to animate.
1041    * @param [in] color The relative change in color.
1042    * @param [in] alpha The alpha function to apply.
1043    * @param [in] delaySeconds The initial delay from the start of the animation.
1044    * @param [in] durationSeconds The duration of the color animation.
1045    */
1046   void ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1047
1048   /**
1049    * @brief Animate an actor to a target color.
1050    *
1051    * The default alpha function will be used.
1052    * The effect will start & end when the animation begins & ends.
1053    * @param [in] actor The actor to animate.
1054    * @param [in] color The target color.
1055    */
1056   void ColorTo(Actor actor, Vector4 color);
1057
1058   /**
1059    * @brief Animate an actor to a target color.
1060    *
1061    * This overload allows the alpha function to be customized.
1062    * The effect will start & end when the animation begins & ends.
1063    * @param [in] actor The actor to animate.
1064    * @param [in] color The target color.
1065    * @param [in] alpha The alpha function to apply.
1066    */
1067   void ColorTo(Actor actor, Vector4 color, AlphaFunction alpha);
1068
1069   /**
1070    * @brief Animate an actor to a target color.
1071    *
1072    * This overload allows the animation start & end time to be customized.
1073    * @pre delaySeconds must be zero or greater.
1074    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1075    * @param [in] actor The actor to animate.
1076    * @param [in] color The target color.
1077    * @param [in] alpha The alpha function to apply.
1078    * @param [in] delaySeconds The initial delay from the start of the animation.
1079    * @param [in] durationSeconds The duration of the color animation.
1080    */
1081   void ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1082
1083   /**
1084    * @brief Resize an actor.
1085    *
1086    * The default alpha function will be used.
1087    * The resizing will start & end when the animation begins & ends.
1088    * The depth defaults to the minimum of width & height.
1089    * @param [in] actor The actor to animate.
1090    * @param [in] width The target width.
1091    * @param [in] height The target height.
1092    */
1093   void Resize(Actor actor, float width, float height);
1094
1095   /**
1096    * @brief Resize an actor.
1097    *
1098    * This overload allows the alpha function to be customized.
1099    * The resizing will start & end when the animation begins & ends.
1100    * The depth defaults to the minimum of width & height.
1101    * @param [in] actor The actor to animate.
1102    * @param [in] width The target width.
1103    * @param [in] height The target height.
1104    * @param [in] alpha The alpha function to apply.
1105    */
1106   void Resize(Actor actor, float width, float height, AlphaFunction alpha);
1107
1108   /**
1109    * @brief Resize an actor.
1110    *
1111    * This overload allows the resizing start & end time to be customized.
1112    * The depth defaults to the minimum of width & height.
1113    * @pre delaySeconds must be zero or greater.
1114    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1115    * @param [in] actor The actor to animate.
1116    * @param [in] width The target width.
1117    * @param [in] height The target height.
1118    * @param [in] alpha The alpha function to apply.
1119    * @param [in] delaySeconds The initial delay from the start of the animation.
1120    * @param [in] durationSeconds The duration of the resizing.
1121    */
1122   void Resize(Actor actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1123
1124   /**
1125    * @brief Resize an actor.
1126    *
1127    * The default alpha function will be used.
1128    * The resizing will start & end when the animation begins & ends.
1129    * @param [in] actor The actor to animate.
1130    * @param [in] size The target size.
1131    */
1132   void Resize(Actor actor, Vector3 size);
1133
1134   /**
1135    * @brief Resize an actor.
1136    *
1137    * This overload allows the alpha function to be customized.
1138    * The resizing will start & end when the animation begins & ends.
1139    * @param [in] actor The actor to animate.
1140    * @param [in] size The target size.
1141    * @param [in] alpha The alpha function to apply.
1142    */
1143   void Resize(Actor actor, Vector3 size, AlphaFunction alpha);
1144
1145   /**
1146    * @brief Resize an actor.
1147    *
1148    * This overload allows the resizing start & end time to be customized.
1149    * @pre delaySeconds must be zero or greater.
1150    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1151    * @param [in] actor The actor to animate.
1152    * @param [in] size The target size.
1153    * @param [in] alpha The alpha function to apply.
1154    * @param [in] delaySeconds The initial delay from the start of the animation.
1155    * @param [in] durationSeconds The duration of the resizing.
1156    */
1157   void Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1158
1159 public: // Not intended for use by Application developers
1160
1161   /**
1162    * @brief This constructor is used by Dali New() methods
1163    * @param [in] animation A pointer to a newly allocated Dali resource
1164    */
1165   explicit DALI_INTERNAL Animation(Internal::Animation* animation);
1166
1167 private:
1168
1169   /**
1170    * @brief Animate a property using a custom function.
1171    *
1172    * @pre The property type is equal expectedType.
1173    * @param [in] target The target object/property to animate.
1174    * @param [in] targetType The expected type of the property.
1175    * @param [in] func The function to call during the animation.
1176    */
1177   void Animate( Property target,
1178                 Property::Type targetType,
1179                 AnyFunction func );
1180
1181   /**
1182    * @brief Animate a property using a custom function.
1183    *
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    */
1190   void Animate( Property target,
1191                 Property::Type targetType,
1192                 AnyFunction func,
1193                 AlphaFunction alpha );
1194
1195   /**
1196    * @brief Animate a property using a custom function.
1197    *
1198    * @pre The property type is equal expectedType.
1199    * @param [in] target The target object/property to animate.
1200    * @param [in] targetType The expected type of the property.
1201    * @param [in] func The function to call during the animation.
1202    * @param [in] period The effect will occur during this time period.
1203    */
1204   void Animate( Property target,
1205                 Property::Type targetType,
1206                 AnyFunction func,
1207                 TimePeriod period );
1208
1209   /**
1210    * @brief Animate a property using a custom function.
1211    *
1212    * @pre The property type is equal expectedType.
1213    * @param [in] target The target object/property to animate.
1214    * @param [in] targetType The expected type of the property.
1215    * @param [in] func The function to call during the animation.
1216    * @param [in] alpha The alpha function to apply.
1217    * @param [in] period The effect will occur during this time period.
1218    */
1219   void Animate( Property target,
1220                 Property::Type targetType,
1221                 AnyFunction func,
1222                 AlphaFunction alpha,
1223                 TimePeriod period );
1224 };
1225
1226 } // namespace Dali
1227
1228 #endif // __DALI_ANIMATION_H__