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