[dali_1.0.9] Merge branch 'tizen'
[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.
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 Set the destroy action of the animation.
248    *
249    * If the animation is destroyed this action is performed on the following update.
250    * Default destroy action is bake
251    * @param[in] action The destroy action.
252    */
253   void SetDestroyAction(EndAction action);
254
255   /**
256    * @brief Returns the destroy action of the animation.
257    *
258    * @return The destroy action.
259    */
260   EndAction GetDestroyAction() const;
261
262   /**
263    * @brief Set the default alpha function for an animation.
264    *
265    * This is applied to individual property animations, if no further alpha functions are supplied.
266    * @param[in] alpha The default alpha function.
267    */
268   void SetDefaultAlphaFunction(AlphaFunction alpha);
269
270   /**
271    * @brief Retrieve the default alpha function for an animation.
272    *
273    * @return The default alpha function.
274    */
275   AlphaFunction GetDefaultAlphaFunction() const;
276
277   /**
278   * @brief Retrieve the current progress of the animation.
279   *
280   * @return The current progress as a normalized value between [0,1].
281   */
282   float GetCurrentProgress();
283
284   /**
285    * @brief Specifies an speed factor for the animation.
286    *
287    * The speed factor is a multiplier of the normal velocity of the animation. Values between [0,1] will
288    * slow down the animation and values above one will speed up the animation. It is also possible to specify a negative multiplier
289    * to play the animation in reverse.
290    *
291    * @param[in] factor A value which will multiply the velocity.
292    */
293   void SetSpeedFactor( float factor );
294
295   /**
296    * @brief Retrieve the speed factor of the animation
297    *
298    * @return speed factor
299    */
300   float GetSpeedFactor() const;
301
302   /*
303    * @brief Sets the progress of the animation.
304    * The animation will play (or continue playing) from this point
305    *
306    * @param[in] progress The new progress as a normalized value between [0,1].
307    */
308   void SetCurrentProgress( float progress );
309
310   /**
311    * @brief Play the animation.
312    */
313   void Play();
314
315   /**
316    * @brief Play the animation from a given point.
317    * @param[in] progress A value between [0,1] form where the animation should start playing
318    */
319   void PlayFrom( float progress );
320
321   /**
322    * @brief Pause the animation.
323    */
324   void Pause();
325
326   /**
327    * @brief Stop the animation.
328    */
329   void Stop();
330
331   /**
332    * @brief Clear the animation.
333    *
334    * This disconnects any objects that were being animated, effectively stopping the animation.
335    */
336   void Clear();
337
338   /**
339    * @brief Connect to this signal to be notified when an Animation's animations have finished.
340    *
341    * @return A signal object to Connect() with.
342    */
343   AnimationSignalV2& FinishedSignal();
344
345   /**
346    * @brief Animate a property value by a relative amount.
347    *
348    * The default alpha function will be used.
349    * The effect will start & end when the animation begins & ends.
350    * @param [in] target The target object/property to animate.
351    * @param [in] relativeValue The property value will change by this amount.
352    */
353   void AnimateBy(Property target, Property::Value relativeValue);
354
355   /**
356    * @brief Animate a property value by a relative amount.
357    *
358    * The effect will start & end when the animation begins & ends.
359    * @param [in] target The target object/property to animate.
360    * @param [in] relativeValue The property value will change by this amount.
361    * @param [in] alpha The alpha function to apply.
362    */
363   void AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha);
364
365   /**
366    * @brief Animate a property value by a relative amount.
367    *
368    * The default alpha function will be used.
369    * @param [in] target The target object/property to animate.
370    * @param [in] relativeValue The property value will increase/decrease by this amount.
371    * @param [in] period The effect will occur during this time period.
372    */
373   void AnimateBy(Property target, Property::Value relativeValue, TimePeriod period);
374
375   /**
376    * @brief Animate a property value by a relative amount.
377    *
378    * @param [in] target The target object/property to animate.
379    * @param [in] relativeValue The property value will increase/decrease by this amount.
380    * @param [in] alpha The alpha function to apply.
381    * @param [in] period The effect will occur during this time period.
382    */
383   void AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period);
384
385   /**
386    * @brief Animate a property to a destination value.
387    *
388    * The default alpha function will be used.
389    * The effect will start & end when the animation begins & ends.
390    * @param [in] target The target object/property to animate.
391    * @param [in] destinationValue The destination value.
392    */
393   void AnimateTo(Property target, Property::Value destinationValue);
394
395   /**
396    * @brief Animate a property to a destination value.
397    *
398    * The effect will start & end when the animation begins & ends.
399    * @param [in] target The target object/property to animate.
400    * @param [in] destinationValue The destination value.
401    * @param [in] alpha The alpha function to apply.
402    */
403   void AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha);
404
405   /**
406    * @brief Animate a property to a destination value.
407    *
408    * The default alpha function will be used.
409    * @param [in] target The target object/property to animate.
410    * @param [in] destinationValue The destination value.
411    * @param [in] period The effect will occur during this time period.
412    */
413   void AnimateTo(Property target, Property::Value destinationValue, TimePeriod period);
414
415   /**
416    * @brief Animate a property to a destination value.
417    *
418    * @param [in] target The target object/property to animate.
419    * @param [in] destinationValue The destination value.
420    * @param [in] alpha The alpha function to apply.
421    * @param [in] period The effect will occur during this time period.
422    */
423   void AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period);
424
425   /**
426    * @brief Animate a property between keyframes.
427    *
428    * @param [in] target The target object/property to animate.
429    * @param [in] keyFrames The key frames
430    */
431   void AnimateBetween(Property target, KeyFrames& keyFrames);
432
433   /**
434    * @brief Animate a property between keyframes.
435    *
436    * @param [in] target The target object/property to animate.
437    * @param [in] keyFrames The key frames
438    * @param [in] alpha The alpha function to apply.
439    */
440   void AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha);
441
442   /**
443    * @brief Animate a property between keyframes.
444    *
445    * @param [in] target The target object/property to animate.
446    * @param [in] keyFrames The key frames
447    * @param [in] period The effect will occur during this time period.
448    */
449   void AnimateBetween(Property target, KeyFrames& keyFrames, TimePeriod period);
450
451   /**
452    * @brief Animate a property between keyframes.
453    *
454    * @param [in] target The target object/property to animate.
455    * @param [in] keyFrames The key frames
456    * @param [in] alpha The alpha function to apply.
457    * @param [in] period The effect will occur during this time period.
458    */
459   void AnimateBetween(Property target, KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
460
461   /**
462    * @brief Animate a property using a custom function.
463    *
464    * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
465    * @pre The property type is equal PropertyTypes::Get<P>().
466    * @param [in] target The target object/property to animate.
467    * @param [in] animatorFunc The function to call during the animation.
468    */
469   template <class P>
470   void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc )
471   {
472     Animate( target, PropertyTypes::Get<P>(), animatorFunc );
473   }
474
475   /**
476    * @brief Animate a property using a custom function.
477    *
478    * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
479    * @pre The property type is equal PropertyTypes::Get<P>().
480    * @param [in] target The target object/property to animate.
481    * @param [in] animatorFunc The function to call during the animation.
482    * @param [in] alpha The alpha function to apply.
483    */
484   template <class P>
485   void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, AlphaFunction alpha )
486   {
487     Animate( target, PropertyTypes::Get<P>(), animatorFunc, alpha );
488   }
489
490   /**
491    * @brief Animate a property using a custom function.
492    *
493    * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
494    * @pre The property type is equal PropertyTypes::Get<P>().
495    * @param [in] target The target object/property to animate.
496    * @param [in] animatorFunc The function to call during the animation.
497    * @param [in] period The effect will occur during this time period.
498    */
499   template <class P>
500   void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, TimePeriod period )
501   {
502     Animate( target, PropertyTypes::Get<P>(), animatorFunc, period );
503   }
504
505   /**
506    * @brief Animate a property using a custom function.
507    *
508    * The function will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
509    * @pre The property type is equal PropertyTypes::Get<P>().
510    * @param [in] target The target object/property to animate.
511    * @param [in] animatorFunc The function to call during the animation.
512    * @param [in] alpha The alpha function to apply.
513    * @param [in] period The effect will occur during this time period.
514    */
515   template <class P>
516   void Animate( Property target, boost::function<P (float alpha, const P& current)> animatorFunc, AlphaFunction alpha, TimePeriod period )
517   {
518     Animate( target, PropertyTypes::Get<P>(), animatorFunc, alpha, period );
519   }
520
521   // Actor-specific convenience methods
522
523   /**
524    * @brief Move an actor relative to its position.
525    *
526    * The default alpha function will be used.
527    * The move will start & end when the animation begins & ends.
528    * @param [in] actor The actor to animate.
529    * @param [in] x axis displacement.
530    * @param [in] y axis displacement.
531    * @param [in] z axis displacement.
532    */
533   void MoveBy(Actor actor, float x, float y, float z);
534
535   /**
536    * @brief Move an actor relative to its position.
537    *
538    * This overload allows the alpha function to be customized.
539    * The move will start & end when the animation begins & ends.
540    * @param [in] actor The actor to animate.
541    * @param [in] displacement relative to current position.
542    * @param [in] alpha The alpha function to apply.
543    */
544   void MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha);
545
546   /**
547    * @brief Move an actor relative to its position.
548    *
549    * This overload allows the translation start & end time to be customized.
550    * @pre delaySeconds must be zero or greater.
551    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
552    * @param [in] actor The actor to animate.
553    * @param [in] displacement relative to current position.
554    * @param [in] alpha The alpha function to apply.
555    * @param [in] delaySeconds The initial delay from the start of the animation.
556    * @param [in] durationSeconds The duration of the translation.
557    */
558   void MoveBy(Actor actor, Vector3 displacement, AlphaFunction alpha, float delaySeconds, float durationSeconds);
559
560   /**
561    * @brief Move an actor to a target position.
562    *
563    * The default alpha function will be used.
564    * The move will start & end when the animation begins & ends.
565    * @param [in] actor The actor to animate.
566    * @param [in] x axis position.
567    * @param [in] y axis position.
568    * @param [in] z axis position.
569    */
570   void MoveTo(Actor actor, float x, float y, float z);
571
572   /**
573    * @brief Move an actor to a target position.
574    *
575    * This overload allows the alpha function to be customized.
576    * The move will start & end when the animation begins & ends.
577    * @param [in] actor The actor to animate.
578    * @param [in] position to move to
579    * @param [in] alpha The alpha function to apply.
580    */
581   void MoveTo(Actor actor, Vector3 position, AlphaFunction alpha);
582
583   /**
584    * @brief Move an actor to a target position.
585    *
586    * This overload allows the translation start & end time to be customized.
587    * @pre delaySeconds must be zero or greater.
588    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
589    * @param [in] actor The actor to animate.
590    * @param [in] position to move to
591    * @param [in] alpha The alpha function to apply.
592    * @param [in] delaySeconds The initial delay from the start of the animation.
593    * @param [in] durationSeconds The duration of the translation.
594    */
595   void MoveTo(Actor actor, Vector3 position, AlphaFunction alpha, float delaySeconds, float durationSeconds);
596
597   /**
598    * @brief Move an actor using a custom function.
599    *
600    * The animatorFunc will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
601    * @pre delaySeconds must be zero or greater.
602    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
603    * @param [in] actor The actor to animate.
604    * @param [in] animatorFunc The function to call during the animation.
605    * @param [in] alpha The alpha function to apply.
606    * @param [in] delaySeconds The initial delay from the start of the animation.
607    * @param [in] durationSeconds The duration of the translation.
608    */
609   void Move(Actor actor, AnimatorFunctionVector3 animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds);
610
611   /**
612    * @brief Rotate an actor around an arbitrary axis.
613    *
614    * The default alpha function will be used.
615    * The rotation will start & end when the animation begins & ends.
616    * @param [in] actor The actor to animate.
617    * @param [in] angle The angle in degrees.
618    * @param [in] axis The axis to rotate around
619    */
620   void RotateBy(Actor actor, Degree angle, Vector3 axis);
621
622   /**
623    * @brief Rotate an actor around an arbitrary axis.
624    *
625    * The default alpha function will be used.
626    * The rotation will start & end when the animation begins & ends.
627    * @param [in] actor The actor to animate.
628    * @param [in] angle The angle in radians.
629    * @param [in] axis The axis to rotate around
630    */
631   void RotateBy(Actor actor, Radian angle, Vector3 axis);
632
633   /**
634    * @brief Rotate an actor around an arbitrary axis.
635    *
636    * This overload allows the alpha function to be customized.
637    * The rotation will start & end when the animation begins & ends.
638    * @param [in] actor The actor to animate.
639    * @param [in] angle The angle in radians.
640    * @param [in] axis The axis to rotate around.
641    * @param [in] alpha The alpha function to apply.
642    */
643   void RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha);
644
645   /**
646    * @brief Rotate an actor around an arbitrary axis.
647    *
648    * This overload allows the alpha function to be customized.
649    * The rotation will start & end when the animation begins & ends.
650    * @param [in] actor The actor to animate.
651    * @param [in] angle The angle in radians.
652    * @param [in] axis The axis to rotate around.
653    * @param [in] alpha The alpha function to apply.
654    */
655   void RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha);
656
657   /**
658    * @brief Rotate an actor around an arbitrary axis.
659    *
660    * This overload allows the rotation start & end time to be customized.
661    * @pre delaySeconds must be zero or greater.
662    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
663    * @param [in] actor The actor to animate.
664    * @param [in] angle The angle in degrees.
665    * @param [in] axis The axis to rotate around
666    * @param [in] alpha The alpha function to apply.
667    * @param [in] delaySeconds The initial delay from the start of the animation.
668    * @param [in] durationSeconds The duration of the rotation.
669    */
670   void RotateBy(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
671
672   /**
673    * @brief Rotate an actor around an arbitrary axis.
674    *
675    * This overload allows the rotation start & end time to be customized.
676    * @pre delaySeconds must be zero or greater.
677    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
678    * @param [in] actor The actor to animate.
679    * @param [in] angle The angle in radians.
680    * @param [in] axis The axis to rotate around
681    * @param [in] alpha The alpha function to apply.
682    * @param [in] delaySeconds The initial delay from the start of the animation.
683    * @param [in] durationSeconds The duration of the rotation.
684    */
685   void RotateBy(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
686
687   /**
688    * @brief Rotate an actor to a target orientation.
689    *
690    * The default alpha function will be used.
691    * The rotation will start & end when the animation begins & ends.
692    * @param [in] actor The actor to animate.
693    * @param [in] angle The target rotation angle in degrees.
694    * @param [in] axis The target axis of rotation.
695    */
696   void RotateTo(Actor actor, Degree angle, Vector3 axis);
697
698   /**
699    * @brief Rotate an actor to a target orientation.
700    *
701    * The default alpha function will be used.
702    * The rotation will start & end when the animation begins & ends.
703    * @param [in] actor The actor to animate.
704    * @param [in] angle The target rotation angle in radians.
705    * @param [in] axis The target axis of rotation.
706    */
707   void RotateTo(Actor actor, Radian angle, Vector3 axis);
708
709   /**
710    * @brief Rotate an actor to a target orientation.
711    *
712    * The default alpha function will be used.
713    * The rotation will start & end when the animation begins & ends.
714    * @param [in] actor The actor to animate.
715    * @param [in] orientation The target orientation.
716    */
717   void RotateTo(Actor actor, Quaternion orientation);
718
719   /**
720    * @brief Rotate an actor to a target orientation.
721    *
722    * This overload allows the alpha function to be customized.
723    * The rotation will start & end when the animation begins & ends.
724    * @param [in] actor The actor to animate.
725    * @param [in] angle The target rotation angle in degrees.
726    * @param [in] axis The target axis of rotation.
727    * @param [in] alpha The alpha function to apply.
728    */
729   void RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha);
730
731   /**
732    * @brief Rotate an actor to a target orientation.
733    *
734    * This overload allows the alpha function to be customized.
735    * The rotation will start & end when the animation begins & ends.
736    * @param [in] actor The actor to animate.
737    * @param [in] angle The target rotation angle in radians.
738    * @param [in] axis The target axis of rotation.
739    * @param [in] alpha The alpha function to apply.
740    */
741   void RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha);
742
743   /**
744    * @brief Rotate an actor to a target orientation.
745    *
746    * This overload allows the alpha function to be customized.
747    * The rotation will start & end when the animation begins & ends.
748    * @param [in] actor The actor to animate.
749    * @param [in] orientation The target orientation.
750    * @param [in] alpha The alpha function to apply.
751    */
752   void RotateTo(Actor actor, Quaternion orientation, AlphaFunction alpha);
753
754   /**
755    * @brief Rotate an actor to a target orientation.
756    *
757    * This overload allows the rotation start & end time to be customized.
758    * @pre delaySeconds must be zero or greater.
759    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
760    * @param [in] actor The actor to animate.
761    * @param [in] angle The target rotation angle in degrees.
762    * @param [in] axis The target axis of rotation.
763    * @param [in] alpha The alpha function to apply.
764    * @param [in] delaySeconds The initial delay from the start of the animation.
765    * @param [in] durationSeconds The duration of the rotation.
766    */
767   void RotateTo(Actor actor, Degree angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
768
769   /**
770    * @brief Rotate an actor to a target orientation.
771    *
772    * This overload allows the rotation start & end time to be customized.
773    * @pre delaySeconds must be zero or greater.
774    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
775    * @param [in] actor The actor to animate.
776    * @param [in] angle The target rotation angle in radians.
777    * @param [in] axis The target axis of rotation.
778    * @param [in] alpha The alpha function to apply.
779    * @param [in] delaySeconds The initial delay from the start of the animation.
780    * @param [in] durationSeconds The duration of the rotation.
781    */
782   void RotateTo(Actor actor, Radian angle, Vector3 axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
783
784   /**
785    * @brief Rotate an actor to a target orientation.
786    *
787    * This overload allows the rotation start & end time to be customized.
788    * @pre delaySeconds must be zero or greater.
789    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
790    * @param [in] actor The actor to animate.
791    * @param [in] orientation The target orientation.
792    * @param [in] alpha The alpha function to apply.
793    * @param [in] delaySeconds The initial delay from the start of the animation.
794    * @param [in] durationSeconds The duration of the rotation.
795    */
796   void RotateTo(Actor actor, Quaternion orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
797
798   /**
799    * @brief Rotate an actor using a custom function.
800    *
801    * The animatorFunc will be called from a separate animation-thread; it should return quickly, to avoid performance degredation.
802    * @pre delaySeconds must be zero or greater.
803    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
804    * @param [in] actor The actor to animate.
805    * @param [in] animatorFunc The function to call during the animation.
806    * @param [in] alpha The alpha function to apply.
807    * @param [in] delaySeconds The initial delay from the start of the animation.
808    * @param [in] durationSeconds The duration of the rotation.
809    */
810   void Rotate(Actor actor, AnimatorFunctionQuaternion animatorFunc, AlphaFunction alpha, float delaySeconds, float durationSeconds);
811
812   /**
813    * @brief Scale an actor.
814    *
815    * The default alpha function will be used.
816    * The scaling will start & end when the animation begins & ends.
817    * @param [in] actor The actor to animate.
818    * @param [in] x Scale factor in the X-direction.
819    * @param [in] y Scale factor in the Y-direction.
820    * @param [in] z Scale factor in the Z-direction.
821    */
822   void ScaleBy(Actor actor, float x, float y, float z);
823
824   /**
825    * @brief Scale an actor.
826    *
827    * This overload allows the alpha function to be customized.
828    * The scaling will start & end when the animation begins & ends.
829    * @param [in] actor The actor to animate.
830    * @param [in] scale The scale factor.
831    * @param [in] alpha The alpha function to apply.
832    */
833   void ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha);
834
835   /**
836    * @brief Scale an actor.
837    *
838    * This overload allows the scaling start & end time to be customized.
839    * @pre delaySeconds must be zero or greater.
840    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
841    * @param [in] actor The actor to animate.
842    * @param [in] scale The scale factor.
843    * @param [in] alpha The alpha function to apply.
844    * @param [in] delaySeconds The initial delay from the start of the animation.
845    * @param [in] durationSeconds The duration of the scaling.
846    */
847   void ScaleBy(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
848
849   /**
850    * @brief Scale an actor to a target scale factor.
851    *
852    * The default alpha function will be used.
853    * The scaling will start & end when the animation begins & ends.
854    * @param [in] actor The actor to animate.
855    * @param [in] x Target scale-factor in the X-direction.
856    * @param [in] y Target scale-factor in the Y-direction.
857    * @param [in] z Target scale-factor in the Z-direction.
858    */
859   void ScaleTo(Actor actor, float x, float y, float z);
860
861   /**
862    * @brief Scale an actor to a target scale factor.
863    *
864    * This overload allows the alpha function to be customized.
865    * The scaling will start & end when the animation begins & ends.
866    * @param [in] actor The actor to animate.
867    * @param [in] scale The target scale factor.
868    * @param [in] alpha The alpha function to apply.
869    */
870   void ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha);
871
872   /**
873    * @brief Scale an actor to a target scale factor.
874    *
875    * This overload allows the scaling start & end time to be customized.
876    * @pre delaySeconds must be zero or greater.
877    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
878    * @param [in] actor The actor to animate.
879    * @param [in] scale The target scale factor.
880    * @param [in] alpha The alpha function to apply.
881    * @param [in] delaySeconds The initial delay from the start of the animation.
882    * @param [in] durationSeconds The duration of the scaling.
883    */
884   void ScaleTo(Actor actor, Vector3 scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
885
886   /**
887    * @brief Show an actor during the animation.
888    *
889    * @param [in] actor The actor to animate.
890    * @param [in] delaySeconds The initial delay from the start of the animation.
891    */
892   void Show(Actor actor, float delaySeconds);
893
894   /**
895    * @brief Hide an actor during the animation.
896    *
897    * @param [in] actor The actor to animate.
898    * @param [in] delaySeconds The initial delay from the start of the animation.
899    */
900   void Hide(Actor actor, float delaySeconds);
901
902   /**
903    * @brief Animate the opacity of an actor.
904    *
905    * The default alpha function will be used.
906    * The effect will start & end when the animation begins & ends.
907    * @param [in] actor The actor to animate.
908    * @param [in] opacity The relative change in opacity.
909    */
910   void OpacityBy(Actor actor, float opacity);
911
912   /**
913    * @brief Animate the opacity of an actor.
914    *
915    * This overload allows the alpha function to be customized.
916    * The effect will start & end when the animation begins & ends.
917    * @param [in] actor The actor to animate.
918    * @param [in] opacity The relative change in opacity.
919    * @param [in] alpha The alpha function to apply.
920    */
921   void OpacityBy(Actor actor, float opacity, AlphaFunction alpha);
922
923   /**
924    * @brief Animate the opacity of an actor.
925    *
926    * This overload allows the animation start & end time to be customized.
927    * @pre delaySeconds must be zero or greater.
928    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
929    * @param [in] actor The actor to animate.
930    * @param [in] opacity The relative change in opacity.
931    * @param [in] alpha The alpha function to apply.
932    * @param [in] delaySeconds The initial delay from the start of the animation.
933    * @param [in] durationSeconds The duration of the opacity animation.
934    */
935   void OpacityBy(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
936
937   /**
938    * @brief Animate an actor to a target opacity.
939    *
940    * The default alpha function will be used.
941    * The effect will start & end when the animation begins & ends.
942    * @param [in] actor The actor to animate.
943    * @param [in] opacity The target opacity.
944    */
945   void OpacityTo(Actor actor, float opacity);
946
947   /**
948    * @brief Animate an actor to a target opacity.
949    *
950    * This overload allows the alpha function to be customized.
951    * The effect will start & end when the animation begins & ends.
952    * @param [in] actor The actor to animate.
953    * @param [in] opacity The target opacity.
954    * @param [in] alpha The alpha function to apply.
955    */
956   void OpacityTo(Actor actor, float opacity, AlphaFunction alpha);
957
958   /**
959    * @brief Animate an actor to a target opacity.
960    *
961    * This overload allows the animation start & end time to be customized.
962    * @pre delaySeconds must be zero or greater.
963    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
964    * @param [in] actor The actor to animate.
965    * @param [in] opacity The target opacity.
966    * @param [in] alpha The alpha function to apply.
967    * @param [in] delaySeconds The initial delay from the start of the animation.
968    * @param [in] durationSeconds The duration of the opacity animation.
969    */
970   void OpacityTo(Actor actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
971
972   /**
973    * @brief Animate the color of an actor.
974    *
975    * The default alpha function will be used.
976    * The effect will start & end when the animation begins & ends.
977    * @param [in] actor The actor to animate.
978    * @param [in] color The relative change in color.
979    */
980   void ColorBy(Actor actor, Vector4 color);
981
982   /**
983    * @brief Animate the color of an actor.
984    *
985    * This overload allows the alpha function to be customized.
986    * The effect will start & end when the animation begins & ends.
987    * @param [in] actor The actor to animate.
988    * @param [in] color The relative change in color.
989    * @param [in] alpha The alpha function to apply.
990    */
991   void ColorBy(Actor actor, Vector4 color, AlphaFunction alpha);
992
993   /**
994    * @brief Animate the color of an actor.
995    *
996    * This overload allows the animation start & end time to be customized.
997    * @pre delaySeconds must be zero or greater.
998    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
999    * @param [in] actor The actor to animate.
1000    * @param [in] color The relative change in color.
1001    * @param [in] alpha The alpha function to apply.
1002    * @param [in] delaySeconds The initial delay from the start of the animation.
1003    * @param [in] durationSeconds The duration of the color animation.
1004    */
1005   void ColorBy(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1006
1007   /**
1008    * @brief Animate an actor to a target color.
1009    *
1010    * The default alpha function will be used.
1011    * The effect will start & end when the animation begins & ends.
1012    * @param [in] actor The actor to animate.
1013    * @param [in] color The target color.
1014    */
1015   void ColorTo(Actor actor, Vector4 color);
1016
1017   /**
1018    * @brief Animate an actor to a target color.
1019    *
1020    * This overload allows the alpha function to be customized.
1021    * The effect will start & end when the animation begins & ends.
1022    * @param [in] actor The actor to animate.
1023    * @param [in] color The target color.
1024    * @param [in] alpha The alpha function to apply.
1025    */
1026   void ColorTo(Actor actor, Vector4 color, AlphaFunction alpha);
1027
1028   /**
1029    * @brief Animate an actor to a target color.
1030    *
1031    * This overload allows the animation start & end time to be customized.
1032    * @pre delaySeconds must be zero or greater.
1033    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1034    * @param [in] actor The actor to animate.
1035    * @param [in] color The target color.
1036    * @param [in] alpha The alpha function to apply.
1037    * @param [in] delaySeconds The initial delay from the start of the animation.
1038    * @param [in] durationSeconds The duration of the color animation.
1039    */
1040   void ColorTo(Actor actor, Vector4 color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1041
1042   /**
1043    * @brief Resize an actor.
1044    *
1045    * The default alpha function will be used.
1046    * The resizing will start & end when the animation begins & ends.
1047    * The depth defaults to the minimum of width & height.
1048    * @param [in] actor The actor to animate.
1049    * @param [in] width The target width.
1050    * @param [in] height The target height.
1051    */
1052   void Resize(Actor actor, float width, float height);
1053
1054   /**
1055    * @brief Resize an actor.
1056    *
1057    * This overload allows the alpha function to be customized.
1058    * The resizing will start & end when the animation begins & ends.
1059    * The depth defaults to the minimum of width & height.
1060    * @param [in] actor The actor to animate.
1061    * @param [in] width The target width.
1062    * @param [in] height The target height.
1063    * @param [in] alpha The alpha function to apply.
1064    */
1065   void Resize(Actor actor, float width, float height, AlphaFunction alpha);
1066
1067   /**
1068    * @brief Resize an actor.
1069    *
1070    * This overload allows the resizing start & end time to be customized.
1071    * The depth defaults to the minimum of width & height.
1072    * @pre delaySeconds must be zero or greater.
1073    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1074    * @param [in] actor The actor to animate.
1075    * @param [in] width The target width.
1076    * @param [in] height The target height.
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 resizing.
1080    */
1081   void Resize(Actor actor, float width, float height, 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    * @param [in] actor The actor to animate.
1089    * @param [in] size The target size.
1090    */
1091   void Resize(Actor actor, Vector3 size);
1092
1093   /**
1094    * @brief Resize an actor.
1095    *
1096    * This overload allows the alpha function to be customized.
1097    * The resizing will start & end when the animation begins & ends.
1098    * @param [in] actor The actor to animate.
1099    * @param [in] size The target size.
1100    * @param [in] alpha The alpha function to apply.
1101    */
1102   void Resize(Actor actor, Vector3 size, AlphaFunction alpha);
1103
1104   /**
1105    * @brief Resize an actor.
1106    *
1107    * This overload allows the resizing start & end time to be customized.
1108    * @pre delaySeconds must be zero or greater.
1109    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
1110    * @param [in] actor The actor to animate.
1111    * @param [in] size The target size.
1112    * @param [in] alpha The alpha function to apply.
1113    * @param [in] delaySeconds The initial delay from the start of the animation.
1114    * @param [in] durationSeconds The duration of the resizing.
1115    */
1116   void Resize(Actor actor, Vector3 size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
1117
1118 public: // Not intended for use by Application developers
1119
1120   /**
1121    * @brief This constructor is used by Dali New() methods
1122    * @param [in] animation A pointer to a newly allocated Dali resource
1123    */
1124   explicit DALI_INTERNAL Animation(Internal::Animation* animation);
1125
1126 private:
1127
1128   /**
1129    * @brief Animate a property using a custom function.
1130    *
1131    * @pre The property type is equal expectedType.
1132    * @param [in] target The target object/property to animate.
1133    * @param [in] targetType The expected type of the property.
1134    * @param [in] func The function to call during the animation.
1135    */
1136   void Animate( Property target,
1137                 Property::Type targetType,
1138                 AnyFunction func );
1139
1140   /**
1141    * @brief Animate a property using a custom function.
1142    *
1143    * @pre The property type is equal expectedType.
1144    * @param [in] target The target object/property to animate.
1145    * @param [in] targetType The expected type of the property.
1146    * @param [in] func The function to call during the animation.
1147    * @param [in] alpha The alpha function to apply.
1148    */
1149   void Animate( Property target,
1150                 Property::Type targetType,
1151                 AnyFunction func,
1152                 AlphaFunction alpha );
1153
1154   /**
1155    * @brief Animate a property using a custom function.
1156    *
1157    * @pre The property type is equal expectedType.
1158    * @param [in] target The target object/property to animate.
1159    * @param [in] targetType The expected type of the property.
1160    * @param [in] func The function to call during the animation.
1161    * @param [in] period The effect will occur during this time period.
1162    */
1163   void Animate( Property target,
1164                 Property::Type targetType,
1165                 AnyFunction func,
1166                 TimePeriod period );
1167
1168   /**
1169    * @brief Animate a property using a custom function.
1170    *
1171    * @pre The property type is equal expectedType.
1172    * @param [in] target The target object/property to animate.
1173    * @param [in] targetType The expected type of the property.
1174    * @param [in] func The function to call during the animation.
1175    * @param [in] alpha The alpha function to apply.
1176    * @param [in] period The effect will occur during this time period.
1177    */
1178   void Animate( Property target,
1179                 Property::Type targetType,
1180                 AnyFunction func,
1181                 AlphaFunction alpha,
1182                 TimePeriod period );
1183 };
1184
1185 } // namespace Dali
1186
1187 #endif // __DALI_ANIMATION_H__