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