Revert "License conversion from Flora to Apache 2.0"
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / animation-impl.h
1 #ifndef __DALI_INTERNAL_ANIMATION_H__
2 #define __DALI_INTERNAL_ANIMATION_H__
3
4 //
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
6 //
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/common/vector-wrapper.h>
22 #include <dali/public-api/object/ref-object.h>
23 #include <dali/public-api/animation/animation.h>
24 #include <dali/public-api/object/base-object.h>
25 #include <dali/internal/event/animation/animator-connector-base.h>
26 #include <dali/internal/event/animation/key-frames-impl.h>
27
28 namespace Dali
29 {
30
31 namespace Internal
32 {
33
34 namespace SceneGraph
35 {
36 class Animation;
37 class UpdateManager;
38 }
39
40 class Actor;
41 class Animation;
42 class AnimationPlaylist;
43 class ProxyObject;
44 class ShaderEffect;
45
46 typedef IntrusivePtr<Animation> AnimationPtr;
47 typedef std::vector<AnimationPtr> AnimationContainer;
48
49 typedef AnimationContainer::iterator AnimationIter;
50 typedef AnimationContainer::const_iterator AnimationConstIter;
51
52 /**
53  * Animation is a proxy for a SceneGraph::Animation object.
54  * The UpdateManager owns the Animation object, but the lifetime of the animation is
55  * indirectly controlled by the Animation.
56  */
57 class Animation : public BaseObject
58 {
59 public:
60
61   typedef Dali::Animation::AnyFunction AnyFunction;
62   typedef Dali::Animation::EndAction EndAction;
63
64   typedef void (*FinishedCallback)(Object* object);
65
66   /**
67    * Create a new Animation object.
68    * @param[in] durationSeconds The duration of the animation.
69    * @return A smart-pointer to the newly allocated Animation.
70    */
71   static AnimationPtr New(float durationSeconds);
72
73   /**
74    * Create a new Animation object.
75    * @param[in] durationSeconds The duration of the animation.
76    * @param[in] endAction The action to perform when the animation ends.
77    * @param[in] destroyAction The action to perform when the animation ends.
78    * @return A smart-pointer to the newly allocated Animation.
79    */
80   static AnimationPtr New(float durationSeconds, EndAction endAction, EndAction destroyAction);
81
82   /**
83    * Create a new Animation object.
84    * @param[in] durationSeconds The duration of the animation.
85    * @param[in] endAction The action to perform when the animation ends.
86    * @param[in] destroyAction The action to perform when the animation ends.
87    * @param[in] alpha The default alpha function to apply to animators.
88    * @return A smart-pointer to the newly allocated Animation.
89    */
90   static AnimationPtr New(float durationSeconds, EndAction endAction, EndAction destroyAction, AlphaFunction alpha);
91
92   /**
93    * Set the duration of an animation.
94    * @pre durationSeconds must be greater than zero.
95    * @param[in] seconds The duration in seconds.
96    */
97   void SetDuration(float seconds);
98
99   /**
100    * Retrieve the duration of an animation.
101    * @return The duration in seconds.
102    */
103   float GetDuration() const;
104
105   /**
106    * Set whether the animation will loop.
107    * @param[in] looping True if the animation will loop.
108    */
109   void SetLooping(bool looping);
110
111   /**
112    * Query whether the animation will loop.
113    * @return True if the animation will loop.
114    */
115   bool IsLooping() const;
116
117   /**
118    * Set the end action of the animation.
119    * @param[in] action The end action.
120    */
121   void SetEndAction(EndAction action);
122
123   /**
124    * Returns the end action of the animation.
125    */
126   EndAction GetEndAction() const;
127
128   /**
129    * Set the destroy action of the animation.
130    * @param[in] action The destroy action.
131    */
132   void SetDestroyAction(EndAction action);
133
134   /**
135    * Returns the destroy action of the animation.
136    */
137   EndAction GetDestroyAction() const;
138
139   /**
140    * Set the default alpha function for an animation.
141    * This is applied to individual property animations, if no further alpha functions are supplied.
142    * @param[in] alpha The default alpha function.
143    */
144   void SetDefaultAlphaFunction(AlphaFunction alpha)
145   {
146     mDefaultAlpha = alpha;
147   }
148
149   /**
150    * Retrieve the default alpha function for an animation.
151    * @return The default alpha function.
152    */
153   AlphaFunction GetDefaultAlphaFunction() const
154   {
155     return mDefaultAlpha;
156   }
157
158   /**
159    * (Re)start the animation.
160    */
161   void Play();
162
163   /**
164    * Pause the animation.
165    */
166   void Pause();
167
168   /**
169    * Stop the animation.
170    */
171   void Stop();
172
173   /**
174    * Clear the animation.
175    * This disconnects any objects that were being animated, effectively stopping the animation.
176    */
177   void Clear();
178
179   /**
180    * Query whether a Finished signal should be emitted for this animation.
181    * This should only be called by NotificationManager, before signals are emitted.
182    * @post HasFinished() will return false on subsequent calls, until the animation is replayed to completion.
183    */
184   bool HasFinished();
185
186   /**
187    * @copydoc Dali::Animation::FinishedSignal()
188    */
189   Dali::Animation::AnimationSignalV2& FinishedSignal();
190
191   /**
192    * Emit the Finished signal
193    */
194   void EmitSignalFinish();
195
196   /**
197    * Connects a callback function with the object's signals.
198    * @param[in] object The object providing the signal.
199    * @param[in] tracker Used to disconnect the signal.
200    * @param[in] signalName The signal to connect to.
201    * @param[in] functor A newly allocated FunctorDelegate.
202    * @return True if the signal was connected.
203    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
204    */
205   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
206
207   /**
208    * Performs actions as requested using the action name.
209    * @param[in] object The object on which to perform the action.
210    * @param[in] actionName The action to perform.
211    * @param[in] attributes The attributes with which to perfrom this action.
212    * @return true if action was done
213    */
214   static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
215
216   /**
217    * This callback is intended for internal use only, to avoid the overhead of using a signal.
218    * @param[in] callback The callback function to connect.
219    * @param[in] object The internal object requesting the callback, or NULL.
220    */
221   void SetFinishedCallback( FinishedCallback callback, Object* object );
222
223   /**
224    * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue)
225    */
226   void AnimateBy(Property& target, Property::Value& relativeValue);
227
228   /**
229    * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
230    */
231   void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha);
232
233   /**
234    * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
235    */
236   void AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period);
237
238   /**
239    * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
240    */
241   void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period);
242
243   /**
244    * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue)
245    */
246   void AnimateTo(Property& target, Property::Value& destinationValue);
247
248   /**
249    * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
250    */
251   void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha);
252
253   /**
254    * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
255    */
256   void AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period);
257
258   /**
259    * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
260    */
261   void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
262
263   /**
264    * Animate a property to a destination value.
265    * @param [in] targetObject The target object to animate.
266    * @param [in] targetPropertyIndex The index of the target property.
267    * @param [in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4
268    * @param [in] destinationValue The destination value.
269    * @param [in] alpha The alpha function to apply.
270    * @param [in] period The effect will occur during this time period.
271    */
272   void AnimateTo(ProxyObject& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
273
274
275   /**
276    * Animate a property between the keyframe time / value pairs.
277    * It uses the current duration of the animation to run the key
278    * frame animator. Note, If the animation duration is subsequently
279    * changed, this does not change to match.
280    *
281    * @param[in] target The target object + property to animate
282    * @param[in] keyFrames The set of time / value pairs between which to animate.
283    */
284   void AnimateBetween(Property target, const KeyFrames& keyFrames);
285
286   /**
287    * Animate a property between the keyframe time / value pairs.
288    * @param[in] target The target object + property to animate
289    * @param[in] keyFrames The set of time / value pairs between which to animate.
290    * @param[in] period The effect will occur duing this time period.
291    */
292   void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period);
293
294   /**
295    * Animate a property between the keyframe time / value pairs.
296    * @param[in] target The target object + property to animate
297    * @param[in] keyFrames The set of time / value pairs between which to animate.
298    * @param[in] alpha The alpha function to apply to the overall progress.
299    */
300   void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha);
301
302   /**
303    * Animate a property between the keyframe time / value pairs.
304    * @param[in] target The target object + property to animate
305    * @param[in] keyFrames The set of time / value pairs between which to animate.
306    * @param[in] alpha The alpha function to apply to the overall progress.
307    * @param[in] period The effect will occur duing this time period.
308    */
309   void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
310
311   /**
312    * @copydoc Dali::Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
313    */
314   void Animate( Property& target, Property::Type targetType, AnyFunction& func );
315
316   /**
317    * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
318    */
319   void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha );
320
321   /**
322    * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, TimePeriod period)
323    */
324   void Animate( Property& target, Property::Type targetType, AnyFunction& func, TimePeriod period );
325
326   /**
327    * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period)
328    */
329   void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha, TimePeriod period );
330
331   // Action-specific convenience functions
332
333   /**
334    * Translate an actor.
335    * The default alpha function will be used.
336    * The translation will start & end when the animation begins & ends.
337    * @param [in] actor The actor to animate.
338    * @param [in] x Translation in the X-direction.
339    * @param [in] y Translation in the Y-direction.
340    * @param [in] z Translation in the Z-direction.
341    */
342   void MoveBy(Actor& actor, float x, float y, float z);
343
344   /**
345    * Translate an actor. This overload allows the alpha function to be customized.
346    * The translation will start & end when the animation begins & ends.
347    * @param [in] actor The actor to animate.
348    * @param [in] translation The translation.
349    * @param [in] alpha The alpha function to apply.
350    */
351   void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha);
352
353   /**
354    * Translate an actor. This overload allows the translation start & end time to be customized.
355    * @pre delaySeconds must be zero or greater.
356    * @pre durationSeconds must be greater than zero.
357    * @param [in] actor The actor to animate.
358    * @param [in] translation The translation.
359    * @param [in] alpha The alpha function to apply.
360    * @param [in] delaySeconds The initial delay from the start of the animation.
361    * @param [in] durationSeconds The duration of the translation.
362    */
363   void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
364
365   /**
366    * Translate an actor to a target position.
367    * The default alpha function will be used.
368    * The translation will start & end when the animation begins & ends.
369    * @param [in] actor The actor to animate.
370    * @param [in] x Translation in the X-direction.
371    * @param [in] y Translation in the Y-direction.
372    * @param [in] z Translation in the Z-direction.
373    */
374   void MoveTo(Actor& actor, float x, float y, float z);
375
376   /**
377    * Translate an actor to a target position. This overload allows the alpha function to be customized.
378    * The translation will start & end when the animation begins & ends.
379    * @param [in] actor The actor to animate.
380    * @param [in] translation The translation.
381    * @param [in] alpha The alpha function to apply.
382    */
383   void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha);
384
385   /**
386    * Translate an actor to a target position. This overload allows the translation start & end time to be customized.
387    * @pre delaySeconds must be zero or greater.
388    * @pre durationSeconds must be greater than zero.
389    * @param [in] actor The actor to animate.
390    * @param [in] translation The translation.
391    * @param [in] alpha The alpha function to apply.
392    * @param [in] delaySeconds The initial delay from the start of the animation.
393    * @param [in] durationSeconds The duration of the translation.
394    */
395   void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha,  float delaySeconds, float durationSeconds);
396
397   /**
398    * Translate an actor using a custom function.
399    * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
400    * @pre delaySeconds must be zero or greater.
401    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
402    * @param [in] actor The actor to animate.
403    * @param [in] func The function to call during the animation.
404    * @param [in] alpha The alpha function to apply.
405    * @param [in] delaySeconds The initial delay from the start of the animation.
406    * @param [in] durationSeconds The duration of the translation.
407    */
408   void Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
409
410   /**
411    * Rotate an actor around an arbitrary axis.
412    * The default alpha function will be used.
413    * The rotation will start & end when the animation begins & ends.
414    * @param [in] actor The actor to animate.
415    * @param [in] angle The angle in radians.
416    * @param [in] axis The axis of rotation.
417    */
418   void RotateBy(Actor& actor, Radian angle, const Vector3& axis);
419
420   /**
421    * Rotate an actor around an arbitrary axis. This overload allows the alpha function to be customized.
422    * The rotation will start & end when the animation begins & ends.
423    * @param [in] actor The actor to animate.
424    * @param [in] angle The angle in radians.
425    * @param [in] axis The axis of rotation.
426    * @param [in] alpha The alpha function to apply.
427    */
428   void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
429
430   /**
431    * Rotate an actor around an arbitrary axis. This overload allows the rotation start & end time to be customized.
432    * @pre delaySeconds must be zero or greater.
433    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
434    * @param [in] actor The actor to animate.
435    * @param [in] angle The angle in radians.
436    * @param [in] axis The axis of rotation.
437    * @param [in] alpha The alpha function to apply.
438    * @param [in] delaySeconds The initial delay from the start of the animation.
439    * @param [in] durationSeconds The duration of the rotation.
440    */
441   void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
442
443   /**
444    * Rotate an actor to a target orientation.
445    * The default alpha function will be used.
446    * The rotation will start & end when the animation begins & ends.
447    * @param [in] actor The actor to animate.
448    * @param [in] angle The target rotation angle in radians.
449    * @param [in] axis The target axis of rotation.
450    */
451   void RotateTo(Actor& actor, Radian angle, const Vector3& axis);
452
453   /**
454    * Rotate an actor to a target orientation.
455    * The default alpha function will be used.
456    * The rotation will start & end when the animation begins & ends.
457    * @param [in] actor The actor to animate.
458    * @param [in] orientation The target orientation.
459    */
460   void RotateTo(Actor& actor, const Quaternion& orientation);
461
462   /**
463    * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
464    * The rotation will start & end when the animation begins & ends.
465    * @param [in] actor The actor to animate.
466    * @param [in] angle The target rotation angle in radians.
467    * @param [in] axis The target axis of rotation.
468    * @param [in] alpha The alpha function to apply.
469    */
470   void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
471
472   /**
473    * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
474    * The rotation will start & end when the animation begins & ends.
475    * @param [in] actor The actor to animate.
476    * @param [in] orientation The target orientation.
477    * @param [in] alpha The alpha function to apply.
478    */
479   void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha);
480
481   /**
482    * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
483    * @pre delaySeconds must be zero or greater.
484    * @pre durationSeconds must be greater than zero.
485    * @param [in] actor The actor to animate.
486    * @param [in] orientation The target orientation.
487    * @param [in] alpha The alpha function to apply.
488    * @param [in] delaySeconds The initial delay from the start of the animation.
489    * @param [in] durationSeconds The duration of the rotation.
490    */
491   void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
492
493   /**
494    * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
495    * @pre delaySeconds must be zero or greater.
496    * @pre durationSeconds must be greater than zero.
497    * @param [in] actor The actor to animate.
498    * @param [in] angle The target rotation angle in radians.
499    * @param [in] axis The target axis of rotation.
500    * @param [in] alpha The alpha function to apply.
501    * @param [in] delaySeconds The initial delay from the start of the animation.
502    * @param [in] durationSeconds The duration of the rotation.
503    */
504   void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
505
506   /**
507    * Rotate an actor using a custom function.
508    * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
509    * @pre delaySeconds must be zero or greater.
510    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
511    * @param [in] actor The actor to animate.
512    * @param [in] func The function to call during the animation.
513    * @param [in] alpha The alpha function to apply.
514    * @param [in] delaySeconds The initial delay from the start of the animation.
515    * @param [in] durationSeconds The duration of the translation.
516    */
517   void Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
518
519   /**
520    * Scale an actor.
521    * The default alpha function will be used.
522    * The scaling will start & end when the animation begins & ends.
523    * @param [in] actor The actor to animate.
524    * @param [in] x Scale factor in the X-direction.
525    * @param [in] y Scale factor in the Y-direction.
526    * @param [in] z Scale factor in the Z-direction.
527    */
528   void ScaleBy(Actor& actor, float x, float y, float z);
529
530   /**
531    * Scale an actor. This overload allows the alpha function to be customized.
532    * The scaling will start & end when the animation begins & ends.
533    * @param [in] actor The actor to animate.
534    * @param [in] scale The scale factor.
535    * @param [in] alpha The alpha function to apply.
536    */
537   void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha);
538
539   /**
540    * Scale an actor. This overload allows the translation start & end time to be customized.
541    * @pre delaySeconds must be zero or greater.
542    * @pre durationSeconds must be greater than zero.
543    * @param [in] actor The actor to animate.
544    * @param [in] scale The scale factor.
545    * @param [in] alpha The alpha function to apply.
546    * @param [in] delaySeconds The initial delay from the start of the animation.
547    * @param [in] durationSeconds The duration of the translation.
548    */
549   void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
550
551   /**
552    * Scale an actor to a target scale factor.
553    * The default alpha function will be used.
554    * The scaling will start & end when the animation begins & ends.
555    * @param [in] actor The actor to animate.
556    * @param [in] x Target scale-factor in the X-direction.
557    * @param [in] y Target scale-factor in the Y-direction.
558    * @param [in] z Target scale-factor in the Z-direction.
559    */
560   void ScaleTo(Actor& actor, float x, float y, float z);
561
562   /**
563    * Scale an actor to a target scale factor. This overload allows the alpha function to be customized.
564    * The scaling will start & end when the animation begins & ends.
565    * @param [in] actor The actor to animate.
566    * @param [in] scale The target scale factor.
567    * @param [in] alpha The alpha function to apply.
568    */
569   void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha);
570
571   /**
572    * Scale an actor to a target scale factor. This overload allows the translation start & end time to be customized.
573    * @pre delaySeconds must be zero or greater.
574    * @pre durationSeconds must be greater than zero.
575    * @param [in] actor The actor to animate.
576    * @param [in] scale The target scale factor.
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 ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
582
583   /**
584    * Show an actor during the animation.
585    * @param [in] actor The actor to animate.
586    * @param [in] delaySeconds The initial delay from the start of the animation.
587    */
588   void Show(Actor& actor, float delaySeconds);
589
590   /**
591    * Hide an actor during the animation.
592    * @param [in] actor The actor to animate.
593    * @param [in] delaySeconds The initial delay from the start of the animation.
594    */
595   void Hide(Actor& actor, float delaySeconds);
596
597   /**
598    * Animate the opacity of an actor.
599    * The default alpha function will be used.
600    * The effect will start & end when the animation begins & ends.
601    * @param [in] actor The actor to animate.
602    * @param [in] opacity The relative change in opacity.
603    */
604   void OpacityBy(Actor& actor, float opacity);
605
606   /**
607    * Animate the opacity of an actor. This overload allows the alpha function to be customized.
608    * The effect will start & end when the animation begins & ends.
609    * @param [in] actor The actor to animate.
610    * @param [in] opacity The relative change in opacity.
611    * @param [in] alpha The alpha function to apply.
612    */
613   void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha);
614
615   /**
616    * Animate the opacity of an actor. This overload allows the translation start & end time to be customized.
617    * @pre delaySeconds must be zero or greater.
618    * @pre durationSeconds must be greater than zero.
619    * @param [in] actor The actor to animate.
620    * @param [in] opacity The relative change in opacity.
621    * @param [in] alpha The alpha function to apply.
622    * @param [in] delaySeconds The initial delay from the start of the animation.
623    * @param [in] durationSeconds The duration of the translation.
624    */
625   void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
626
627   /**
628    * Animate an actor to a target opacity.
629    * The default alpha function will be used.
630    * The effect will start & end when the animation begins & ends.
631    * @param [in] actor The actor to animate.
632    * @param [in] opacity The target opacity.
633    */
634   void OpacityTo(Actor& actor, float opacity);
635
636   /**
637    * Animate an actor to a target opacity. This overload allows the alpha function to be customized.
638    * The effect will start & end when the animation begins & ends.
639    * @param [in] actor The actor to animate.
640    * @param [in] opacity The target opacity.
641    * @param [in] alpha The alpha function to apply.
642    */
643   void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha);
644
645   /**
646    * Animate an actor to a target opacity. This overload allows the translation start & end time to be customized.
647    * @pre delaySeconds must be zero or greater.
648    * @pre durationSeconds must be greater than zero.
649    * @param [in] actor The actor to animate.
650    * @param [in] opacity The target opacity.
651    * @param [in] alpha The alpha function to apply.
652    * @param [in] delaySeconds The initial delay from the start of the animation.
653    * @param [in] durationSeconds The duration of the translation.
654    */
655   void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
656
657   /**
658    * Animate the color of an actor.
659    * The default alpha function will be used.
660    * The effect will start & end when the animation begins & ends.
661    * @param [in] actor The actor to animate.
662    * @param [in] color The relative change in color.
663    */
664   void ColorBy(Actor& actor, const Vector4& color);
665
666   /**
667    * Animate the color of an actor. This overload allows the alpha function to be customized.
668    * The effect will start & end when the animation begins & ends.
669    * @param [in] actor The actor to animate.
670    * @param [in] color The relative change in color.
671    * @param [in] alpha The alpha function to apply.
672    */
673   void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha);
674
675   /**
676    * Animate the color of an actor. This overload allows the translation start & end time to be customized.
677    * @pre delaySeconds must be zero or greater.
678    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
679    * @param [in] actor The actor to animate.
680    * @param [in] color The relative change in color.
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 translation.
684    */
685   void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
686
687   /**
688    * Animate an actor to a target color.
689    * The default alpha function will be used.
690    * The effect will start & end when the animation begins & ends.
691    * @param [in] actor The actor to animate.
692    * @param [in] color The target color.
693    */
694   void ColorTo(Actor& actor, const Vector4& color);
695
696   /**
697    * Animate an actor to a target color. This overload allows the alpha function to be customized.
698    * The effect will start & end when the animation begins & ends.
699    * @param [in] actor The actor to animate.
700    * @param [in] color The target color.
701    * @param [in] alpha The alpha function to apply.
702    */
703   void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha);
704
705   /**
706    * Animate an actor to a target color. This overload allows the translation start & end time to be customized.
707    * @pre delaySeconds must be zero or greater.
708    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
709    * @param [in] actor The actor to animate.
710    * @param [in] color The target color.
711    * @param [in] alpha The alpha function to apply.
712    * @param [in] delaySeconds The initial delay from the start of the animation.
713    * @param [in] durationSeconds The duration of the translation.
714    */
715   void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
716
717   /**
718    * Resize an actor.
719    * The default alpha function will be used.
720    * The resizing will start & end when the animation begins & ends.
721    * The depth defaults to the minimum of width & height.
722    * @param [in] actor The actor to animate.
723    * @param [in] width The target width.
724    * @param [in] height The target height.
725    */
726   void Resize(Actor& actor, float width, float height);
727
728   /**
729    * Resize an actor. This overload allows the alpha function to be customized.
730    * The resizing will start & end when the animation begins & ends.
731    * The depth defaults to the minimum of width & height.
732    * @param [in] actor The actor to animate.
733    * @param [in] width The target width.
734    * @param [in] height The target height.
735    * @param [in] alpha The alpha function to apply.
736    */
737   void Resize(Actor& actor, float width, float height, AlphaFunction alpha);
738
739   /**
740    * Resize an actor. This overload allows the resizing start & end time to be customized.
741    * The depth defaults to the minimum of width & height.
742    * @pre delaySeconds must be zero or greater.
743    * @pre durationSeconds must be greater than zero.
744    * @param [in] actor The actor to animate.
745    * @param [in] width The target width.
746    * @param [in] height The target height.
747    * @param [in] alpha The alpha function to apply.
748    * @param [in] delaySeconds The initial delay from the start of the animation.
749    * @param [in] durationSeconds The duration of the translation.
750    */
751   void Resize(Actor& actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
752
753   /**
754    * Resize an actor.
755    * The default alpha function will be used.
756    * The resizing will start & end when the animation begins & ends.
757    * @param [in] actor The actor to animate.
758    * @param [in] size The target size.
759    */
760   void Resize(Actor& actor, const Vector3& size);
761
762   /**
763    * Resize an actor. This overload allows the alpha function to be customized.
764    * The resizing will start & end when the animation begins & ends.
765    * @param [in] actor The actor to animate.
766    * @param [in] size The target size.
767    * @param [in] alpha The alpha function to apply.
768    */
769   void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha);
770
771   /**
772    * Resize an actor. This overload allows the resizing start & end time to be customized.
773    * @pre delaySeconds must be zero or greater.
774    * @pre durationSeconds must be greater than zero.
775    * @param [in] actor The actor to animate.
776    * @param [in] size The target size.
777    * @param [in] alpha The alpha function to apply.
778    * @param [in] delaySeconds The initial delay from the start of the animation.
779    * @param [in] durationSeconds The duration of the translation.
780    */
781   void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
782
783   /**
784    * Animate the parent-origin of an actor.
785    * The effect will start & end when the animation begins & ends.
786    * @param [in] actor The actor to animate.
787    * @param [in] parentOrigin The target value.
788    */
789   void ParentOriginTo(Actor& actor, const Vector3& parentOrigin);
790
791   /**
792    * Animate the parent-origin of an actor.
793    * This overload allows the alpha function to be customized.
794    * The effect will start & end when the animation begins & ends.
795    * @param [in] actor The actor to animate.
796    * @param [in] parentOrigin The target value.
797    * @param [in] alpha The alpha function to apply.
798    */
799   void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha);
800
801   /**
802    * Animate the parent-origin of an actor.
803    * This overload allows the start & end time to be customized.
804    * @pre delaySeconds & durationSeconds must be zero or greater.
805    * @param [in] actor The actor to animate.
806    * @param [in] parentOrigin The target value.
807    * @param [in] alpha The alpha function to apply.
808    * @param [in] delaySeconds The initial delay from the start of the effect.
809    * @param [in] durationSeconds The duration of the effect.
810    */
811   void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha, float delaySeconds, float durationSeconds);
812
813   /**
814    * Animate the anchor-point of an actor.
815    * The effect will start & end when the animation begins & ends.
816    * @param [in] actor The actor to animate.
817    * @param [in] anchorPoint The target value.
818    */
819   void AnchorPointTo(Actor& actor, const Vector3& anchorPoint);
820
821   /**
822    * Animate the anchor-point of an actor.
823    * This overload allows the alpha function to be customized.
824    * The effect will start & end when the animation begins & ends.
825    * @param [in] actor The actor to animate.
826    * @param [in] anchorPoint The target value.
827    * @param [in] alpha The alpha function to apply.
828    */
829   void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha);
830
831   /**
832    * Animate the anchor-point of an actor.
833    * This overload allows the start & end time to be customized.
834    * @pre delaySeconds & durationSeconds must be zero or greater.
835    * @param [in] actor The actor to animate.
836    * @param [in] anchorPoint The target value.
837    * @param [in] alpha The alpha function to apply.
838    * @param [in] delaySeconds The initial delay from the start of the effect.
839    * @param [in] durationSeconds The duration of the effect.
840    */
841   void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha, float delaySeconds, float durationSeconds);
842
843   /**
844    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value)
845    */
846   void AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, float value );
847
848   /**
849    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha)
850    */
851   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha );
852
853   /**
854    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
855    */
856   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
857
858   /**
859    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value )
860    */
861   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value );
862
863   /**
864    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha )
865    */
866   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha );
867
868   /**
869    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
870    */
871   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
872
873   /**
874    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value )
875    */
876   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value );
877
878   /**
879    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha )
880    */
881   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha );
882
883   /**
884    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
885    */
886   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
887
888   /**
889    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value )
890    */
891   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value );
892
893   /**
894    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha)
895    */
896   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha );
897
898   /**
899    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
900    */
901   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
902
903 public: // For connecting animators to animations
904
905   /**
906    * Add an animator connector.
907    * @param[in] connector The animator connector.
908    */
909   void AddAnimatorConnector( AnimatorConnectorBase* connector );
910
911   /**
912    * Retrieve the SceneGraph::Animation object.
913    * @return The animation.
914    */
915   const SceneGraph::Animation* GetSceneObject()
916   {
917     return mAnimation;
918   }
919
920   /**
921    * Retrieve the UpdateManager associated with this animation.
922    * @return The UpdateManager.
923    */
924   SceneGraph::UpdateManager& GetUpdateManager()
925   {
926     return mUpdateManager;
927   }
928
929 protected:
930
931   /**
932    * Construct a new Animation.
933    * @param[in] updateManager The UpdateManager associated with this animation.
934    * @param[in] playlist The list of currently playing animations.
935    * @param[in] durationSeconds The duration of the animation in seconds.
936    * @param[in] endAction The action to perform when the animation ends.
937    * @param[in] destroyAction The action to perform when the animation is destroyed.
938    * @param[in] defaultAlpha The default alpha function to apply to animators.
939    */
940   Animation( SceneGraph::UpdateManager& updateManager,
941              AnimationPlaylist& playlist,
942              float durationSeconds,
943              EndAction endAction,
944              EndAction destroyAction,
945              AlphaFunction defaultAlpha);
946
947   /**
948    * Second-phase constructor.
949    */
950   void Initialize();
951
952   /**
953    * Helper to create a scene-graph animation
954    */
955   void CreateSceneObject();
956
957   /**
958    * Helper to create a scene-graph animation
959    */
960   void DestroySceneObject();
961
962   /**
963    * A reference counted object may only be deleted by calling Unreference()
964    */
965   virtual ~Animation();
966
967 private:
968
969   // Undefined
970   Animation(const Animation&);
971
972   // Undefined
973   Animation& operator=(const Animation& rhs);
974
975 private:
976
977   SceneGraph::UpdateManager& mUpdateManager;
978   AnimationPlaylist& mPlaylist;
979
980   const SceneGraph::Animation* mAnimation;
981
982   int mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
983
984   Dali::Animation::AnimationSignalV2 mFinishedSignal;
985
986   FinishedCallback mFinishedCallback;
987   Object* mFinishedCallbackObject;
988
989   AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
990
991   // Cached for public getters
992   float mDurationSeconds;
993   bool mIsLooping;
994   EndAction mEndAction;
995   EndAction mDestroyAction;
996   AlphaFunction mDefaultAlpha;
997
998 };
999
1000 } // namespace Internal
1001
1002 // Helpers for public-api forwarding methods
1003
1004 inline Internal::Animation& GetImplementation(Dali::Animation& animation)
1005 {
1006   DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1007
1008   BaseObject& handle = animation.GetBaseObject();
1009
1010   return static_cast<Internal::Animation&>(handle);
1011 }
1012
1013 inline const Internal::Animation& GetImplementation(const Dali::Animation& animation)
1014 {
1015   DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1016
1017   const BaseObject& handle = animation.GetBaseObject();
1018
1019   return static_cast<const Internal::Animation&>(handle);
1020 }
1021
1022 } // namespace Dali
1023
1024 #endif // __DALI_INTERNAL_ANIMATION_H__