[SRUK] Initial copy from Tizen 2.2 version
[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] destinationValue The destination value.
268    * @param [in] alpha The alpha function to apply.
269    * @param [in] period The effect will occur during this time period.
270    */
271   void AnimateTo(ProxyObject& targetObject, Property::Index targetPropertyIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
272
273
274   /**
275    * Animate a property between the keyframe time / value pairs.
276    * It uses the current duration of the animation to run the key
277    * frame animator. Note, If the animation duration is subsequently
278    * changed, this does not change to match.
279    *
280    * @param[in] target The target object + property to animate
281    * @param[in] keyFrames The set of time / value pairs between which to animate.
282    */
283   void AnimateBetween(Property target, const KeyFrames& keyFrames);
284
285   /**
286    * Animate a property between the keyframe time / value pairs.
287    * @param[in] target The target object + property to animate
288    * @param[in] keyFrames The set of time / value pairs between which to animate.
289    * @param[in] period The effect will occur duing this time period.
290    */
291   void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period);
292
293   /**
294    * Animate a property between the keyframe time / value pairs.
295    * @param[in] target The target object + property to animate
296    * @param[in] keyFrames The set of time / value pairs between which to animate.
297    * @param[in] alpha The alpha function to apply to the overall progress.
298    */
299   void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha);
300
301   /**
302    * Animate a property between the keyframe time / value pairs.
303    * @param[in] target The target object + property to animate
304    * @param[in] keyFrames The set of time / value pairs between which to animate.
305    * @param[in] alpha The alpha function to apply to the overall progress.
306    * @param[in] period The effect will occur duing this time period.
307    */
308   void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
309
310   /**
311    * @copydoc Dali::Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
312    */
313   void Animate( Property& target, Property::Type targetType, AnyFunction& func );
314
315   /**
316    * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
317    */
318   void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha );
319
320   /**
321    * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, TimePeriod period)
322    */
323   void Animate( Property& target, Property::Type targetType, AnyFunction& func, TimePeriod period );
324
325   /**
326    * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period)
327    */
328   void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha, TimePeriod period );
329
330   // Action-specific convenience functions
331
332   /**
333    * Translate an actor.
334    * The default alpha function will be used.
335    * The translation will start & end when the animation begins & ends.
336    * @param [in] actor The actor to animate.
337    * @param [in] x Translation in the X-direction.
338    * @param [in] y Translation in the Y-direction.
339    * @param [in] z Translation in the Z-direction.
340    */
341   void MoveBy(Actor& actor, float x, float y, float z);
342
343   /**
344    * Translate an actor. This overload allows the alpha function to be customized.
345    * The translation will start & end when the animation begins & ends.
346    * @param [in] actor The actor to animate.
347    * @param [in] translation The translation.
348    * @param [in] alpha The alpha function to apply.
349    */
350   void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha);
351
352   /**
353    * Translate an actor. This overload allows the translation start & end time to be customized.
354    * @pre delaySeconds must be zero or greater.
355    * @pre durationSeconds must be greater than zero.
356    * @param [in] actor The actor to animate.
357    * @param [in] translation The translation.
358    * @param [in] alpha The alpha function to apply.
359    * @param [in] delaySeconds The initial delay from the start of the animation.
360    * @param [in] durationSeconds The duration of the translation.
361    */
362   void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
363
364   /**
365    * Translate an actor to a target position.
366    * The default alpha function will be used.
367    * The translation will start & end when the animation begins & ends.
368    * @param [in] actor The actor to animate.
369    * @param [in] x Translation in the X-direction.
370    * @param [in] y Translation in the Y-direction.
371    * @param [in] z Translation in the Z-direction.
372    */
373   void MoveTo(Actor& actor, float x, float y, float z);
374
375   /**
376    * Translate an actor to a target position. This overload allows the alpha function to be customized.
377    * The translation will start & end when the animation begins & ends.
378    * @param [in] actor The actor to animate.
379    * @param [in] translation The translation.
380    * @param [in] alpha The alpha function to apply.
381    */
382   void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha);
383
384   /**
385    * Translate an actor to a target position. This overload allows the translation start & end time to be customized.
386    * @pre delaySeconds must be zero or greater.
387    * @pre durationSeconds must be greater than zero.
388    * @param [in] actor The actor to animate.
389    * @param [in] translation The translation.
390    * @param [in] alpha The alpha function to apply.
391    * @param [in] delaySeconds The initial delay from the start of the animation.
392    * @param [in] durationSeconds The duration of the translation.
393    */
394   void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha,  float delaySeconds, float durationSeconds);
395
396   /**
397    * Translate an actor using a custom function.
398    * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
399    * @pre delaySeconds must be zero or greater.
400    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
401    * @param [in] actor The actor to animate.
402    * @param [in] func The function to call during the animation.
403    * @param [in] alpha The alpha function to apply.
404    * @param [in] delaySeconds The initial delay from the start of the animation.
405    * @param [in] durationSeconds The duration of the translation.
406    */
407   void Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
408
409   /**
410    * Rotate an actor around an arbitrary axis.
411    * The default alpha function will be used.
412    * The rotation will start & end when the animation begins & ends.
413    * @param [in] actor The actor to animate.
414    * @param [in] angle The angle in radians.
415    * @param [in] axis The axis of rotation.
416    */
417   void RotateBy(Actor& actor, Radian angle, const Vector3& axis);
418
419   /**
420    * Rotate an actor around an arbitrary axis. This overload allows the alpha function to be customized.
421    * The rotation will start & end when the animation begins & ends.
422    * @param [in] actor The actor to animate.
423    * @param [in] angle The angle in radians.
424    * @param [in] axis The axis of rotation.
425    * @param [in] alpha The alpha function to apply.
426    */
427   void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
428
429   /**
430    * Rotate an actor around an arbitrary axis. This overload allows the rotation start & end time to be customized.
431    * @pre delaySeconds must be zero or greater.
432    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
433    * @param [in] actor The actor to animate.
434    * @param [in] angle The angle in radians.
435    * @param [in] axis The axis of rotation.
436    * @param [in] alpha The alpha function to apply.
437    * @param [in] delaySeconds The initial delay from the start of the animation.
438    * @param [in] durationSeconds The duration of the rotation.
439    */
440   void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
441
442   /**
443    * Rotate an actor to a target orientation.
444    * The default alpha function will be used.
445    * The rotation will start & end when the animation begins & ends.
446    * @param [in] actor The actor to animate.
447    * @param [in] angle The target rotation angle in radians.
448    * @param [in] axis The target axis of rotation.
449    */
450   void RotateTo(Actor& actor, Radian angle, const Vector3& axis);
451
452   /**
453    * Rotate an actor to a target orientation.
454    * The default alpha function will be used.
455    * The rotation will start & end when the animation begins & ends.
456    * @param [in] actor The actor to animate.
457    * @param [in] orientation The target orientation.
458    */
459   void RotateTo(Actor& actor, const Quaternion& orientation);
460
461   /**
462    * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
463    * The rotation will start & end when the animation begins & ends.
464    * @param [in] actor The actor to animate.
465    * @param [in] angle The target rotation angle in radians.
466    * @param [in] axis The target axis of rotation.
467    * @param [in] alpha The alpha function to apply.
468    */
469   void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
470
471   /**
472    * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
473    * The rotation will start & end when the animation begins & ends.
474    * @param [in] actor The actor to animate.
475    * @param [in] orientation The target orientation.
476    * @param [in] alpha The alpha function to apply.
477    */
478   void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha);
479
480   /**
481    * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
482    * @pre delaySeconds must be zero or greater.
483    * @pre durationSeconds must be greater than zero.
484    * @param [in] actor The actor to animate.
485    * @param [in] orientation The target orientation.
486    * @param [in] alpha The alpha function to apply.
487    * @param [in] delaySeconds The initial delay from the start of the animation.
488    * @param [in] durationSeconds The duration of the rotation.
489    */
490   void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
491
492   /**
493    * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
494    * @pre delaySeconds must be zero or greater.
495    * @pre durationSeconds must be greater than zero.
496    * @param [in] actor The actor to animate.
497    * @param [in] angle The target rotation angle in radians.
498    * @param [in] axis The target axis of rotation.
499    * @param [in] alpha The alpha function to apply.
500    * @param [in] delaySeconds The initial delay from the start of the animation.
501    * @param [in] durationSeconds The duration of the rotation.
502    */
503   void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
504
505   /**
506    * Rotate an actor using a custom function.
507    * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
508    * @pre delaySeconds must be zero or greater.
509    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
510    * @param [in] actor The actor to animate.
511    * @param [in] func The function to call during the animation.
512    * @param [in] alpha The alpha function to apply.
513    * @param [in] delaySeconds The initial delay from the start of the animation.
514    * @param [in] durationSeconds The duration of the translation.
515    */
516   void Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
517
518   /**
519    * Scale an actor.
520    * The default alpha function will be used.
521    * The scaling will start & end when the animation begins & ends.
522    * @param [in] actor The actor to animate.
523    * @param [in] x Scale factor in the X-direction.
524    * @param [in] y Scale factor in the Y-direction.
525    * @param [in] z Scale factor in the Z-direction.
526    */
527   void ScaleBy(Actor& actor, float x, float y, float z);
528
529   /**
530    * Scale an actor. This overload allows the alpha function to be customized.
531    * The scaling will start & end when the animation begins & ends.
532    * @param [in] actor The actor to animate.
533    * @param [in] scale The scale factor.
534    * @param [in] alpha The alpha function to apply.
535    */
536   void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha);
537
538   /**
539    * Scale an actor. This overload allows the translation start & end time to be customized.
540    * @pre delaySeconds must be zero or greater.
541    * @pre durationSeconds must be greater than zero.
542    * @param [in] actor The actor to animate.
543    * @param [in] scale The scale factor.
544    * @param [in] alpha The alpha function to apply.
545    * @param [in] delaySeconds The initial delay from the start of the animation.
546    * @param [in] durationSeconds The duration of the translation.
547    */
548   void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
549
550   /**
551    * Scale an actor to a target scale factor.
552    * The default alpha function will be used.
553    * The scaling will start & end when the animation begins & ends.
554    * @param [in] actor The actor to animate.
555    * @param [in] x Target scale-factor in the X-direction.
556    * @param [in] y Target scale-factor in the Y-direction.
557    * @param [in] z Target scale-factor in the Z-direction.
558    */
559   void ScaleTo(Actor& actor, float x, float y, float z);
560
561   /**
562    * Scale an actor to a target scale factor. This overload allows the alpha function to be customized.
563    * The scaling will start & end when the animation begins & ends.
564    * @param [in] actor The actor to animate.
565    * @param [in] scale The target scale factor.
566    * @param [in] alpha The alpha function to apply.
567    */
568   void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha);
569
570   /**
571    * Scale an actor to a target scale factor. This overload allows the translation start & end time to be customized.
572    * @pre delaySeconds must be zero or greater.
573    * @pre durationSeconds must be greater than zero.
574    * @param [in] actor The actor to animate.
575    * @param [in] scale The target scale factor.
576    * @param [in] alpha The alpha function to apply.
577    * @param [in] delaySeconds The initial delay from the start of the animation.
578    * @param [in] durationSeconds The duration of the translation.
579    */
580   void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
581
582   /**
583    * Show an actor during the animation.
584    * @param [in] actor The actor to animate.
585    * @param [in] delaySeconds The initial delay from the start of the animation.
586    */
587   void Show(Actor& actor, float delaySeconds);
588
589   /**
590    * Hide an actor during the animation.
591    * @param [in] actor The actor to animate.
592    * @param [in] delaySeconds The initial delay from the start of the animation.
593    */
594   void Hide(Actor& actor, float delaySeconds);
595
596   /**
597    * Animate the opacity of an actor.
598    * The default alpha function will be used.
599    * The effect will start & end when the animation begins & ends.
600    * @param [in] actor The actor to animate.
601    * @param [in] opacity The relative change in opacity.
602    */
603   void OpacityBy(Actor& actor, float opacity);
604
605   /**
606    * Animate the opacity of an actor. This overload allows the alpha function to be customized.
607    * The effect will start & end when the animation begins & ends.
608    * @param [in] actor The actor to animate.
609    * @param [in] opacity The relative change in opacity.
610    * @param [in] alpha The alpha function to apply.
611    */
612   void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha);
613
614   /**
615    * Animate the opacity of an actor. This overload allows the translation start & end time to be customized.
616    * @pre delaySeconds must be zero or greater.
617    * @pre durationSeconds must be greater than zero.
618    * @param [in] actor The actor to animate.
619    * @param [in] opacity The relative change in opacity.
620    * @param [in] alpha The alpha function to apply.
621    * @param [in] delaySeconds The initial delay from the start of the animation.
622    * @param [in] durationSeconds The duration of the translation.
623    */
624   void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
625
626   /**
627    * Animate an actor to a target opacity.
628    * The default alpha function will be used.
629    * The effect will start & end when the animation begins & ends.
630    * @param [in] actor The actor to animate.
631    * @param [in] opacity The target opacity.
632    */
633   void OpacityTo(Actor& actor, float opacity);
634
635   /**
636    * Animate an actor to a target opacity. This overload allows the alpha function to be customized.
637    * The effect will start & end when the animation begins & ends.
638    * @param [in] actor The actor to animate.
639    * @param [in] opacity The target opacity.
640    * @param [in] alpha The alpha function to apply.
641    */
642   void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha);
643
644   /**
645    * Animate an actor to a target opacity. This overload allows the translation start & end time to be customized.
646    * @pre delaySeconds must be zero or greater.
647    * @pre durationSeconds must be greater than zero.
648    * @param [in] actor The actor to animate.
649    * @param [in] opacity The target opacity.
650    * @param [in] alpha The alpha function to apply.
651    * @param [in] delaySeconds The initial delay from the start of the animation.
652    * @param [in] durationSeconds The duration of the translation.
653    */
654   void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
655
656   /**
657    * Animate the color of an actor.
658    * The default alpha function will be used.
659    * The effect will start & end when the animation begins & ends.
660    * @param [in] actor The actor to animate.
661    * @param [in] color The relative change in color.
662    */
663   void ColorBy(Actor& actor, const Vector4& color);
664
665   /**
666    * Animate the color of an actor. This overload allows the alpha function to be customized.
667    * The effect will start & end when the animation begins & ends.
668    * @param [in] actor The actor to animate.
669    * @param [in] color The relative change in color.
670    * @param [in] alpha The alpha function to apply.
671    */
672   void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha);
673
674   /**
675    * Animate the color of an actor. This overload allows the translation start & end time to be customized.
676    * @pre delaySeconds must be zero or greater.
677    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
678    * @param [in] actor The actor to animate.
679    * @param [in] color The relative change in color.
680    * @param [in] alpha The alpha function to apply.
681    * @param [in] delaySeconds The initial delay from the start of the animation.
682    * @param [in] durationSeconds The duration of the translation.
683    */
684   void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
685
686   /**
687    * Animate an actor to a target color.
688    * The default alpha function will be used.
689    * The effect will start & end when the animation begins & ends.
690    * @param [in] actor The actor to animate.
691    * @param [in] color The target color.
692    */
693   void ColorTo(Actor& actor, const Vector4& color);
694
695   /**
696    * Animate an actor to a target color. This overload allows the alpha function to be customized.
697    * The effect will start & end when the animation begins & ends.
698    * @param [in] actor The actor to animate.
699    * @param [in] color The target color.
700    * @param [in] alpha The alpha function to apply.
701    */
702   void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha);
703
704   /**
705    * Animate an actor to a target color. This overload allows the translation start & end time to be customized.
706    * @pre delaySeconds must be zero or greater.
707    * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
708    * @param [in] actor The actor to animate.
709    * @param [in] color The target color.
710    * @param [in] alpha The alpha function to apply.
711    * @param [in] delaySeconds The initial delay from the start of the animation.
712    * @param [in] durationSeconds The duration of the translation.
713    */
714   void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
715
716   /**
717    * Resize an actor.
718    * The default alpha function will be used.
719    * The resizing will start & end when the animation begins & ends.
720    * The depth defaults to the minimum of width & height.
721    * @param [in] actor The actor to animate.
722    * @param [in] width The target width.
723    * @param [in] height The target height.
724    */
725   void Resize(Actor& actor, float width, float height);
726
727   /**
728    * Resize an actor. This overload allows the alpha function to be customized.
729    * The resizing will start & end when the animation begins & ends.
730    * The depth defaults to the minimum of width & height.
731    * @param [in] actor The actor to animate.
732    * @param [in] width The target width.
733    * @param [in] height The target height.
734    * @param [in] alpha The alpha function to apply.
735    */
736   void Resize(Actor& actor, float width, float height, AlphaFunction alpha);
737
738   /**
739    * Resize an actor. This overload allows the resizing start & end time to be customized.
740    * The depth defaults to the minimum of width & height.
741    * @pre delaySeconds must be zero or greater.
742    * @pre durationSeconds must be greater than zero.
743    * @param [in] actor The actor to animate.
744    * @param [in] width The target width.
745    * @param [in] height The target height.
746    * @param [in] alpha The alpha function to apply.
747    * @param [in] delaySeconds The initial delay from the start of the animation.
748    * @param [in] durationSeconds The duration of the translation.
749    */
750   void Resize(Actor& actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
751
752   /**
753    * Resize an actor.
754    * The default alpha function will be used.
755    * The resizing will start & end when the animation begins & ends.
756    * @param [in] actor The actor to animate.
757    * @param [in] size The target size.
758    */
759   void Resize(Actor& actor, const Vector3& size);
760
761   /**
762    * Resize an actor. This overload allows the alpha function to be customized.
763    * The resizing will start & end when the animation begins & ends.
764    * @param [in] actor The actor to animate.
765    * @param [in] size The target size.
766    * @param [in] alpha The alpha function to apply.
767    */
768   void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha);
769
770   /**
771    * Resize an actor. This overload allows the resizing start & end time to be customized.
772    * @pre delaySeconds must be zero or greater.
773    * @pre durationSeconds must be greater than zero.
774    * @param [in] actor The actor to animate.
775    * @param [in] size The target size.
776    * @param [in] alpha The alpha function to apply.
777    * @param [in] delaySeconds The initial delay from the start of the animation.
778    * @param [in] durationSeconds The duration of the translation.
779    */
780   void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
781
782   /**
783    * Animate the parent-origin of an actor.
784    * The effect will start & end when the animation begins & ends.
785    * @param [in] actor The actor to animate.
786    * @param [in] parentOrigin The target value.
787    */
788   void ParentOriginTo(Actor& actor, const Vector3& parentOrigin);
789
790   /**
791    * Animate the parent-origin of an actor.
792    * This overload allows the alpha function to be customized.
793    * The effect will start & end when the animation begins & ends.
794    * @param [in] actor The actor to animate.
795    * @param [in] parentOrigin The target value.
796    * @param [in] alpha The alpha function to apply.
797    */
798   void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha);
799
800   /**
801    * Animate the parent-origin of an actor.
802    * This overload allows the start & end time to be customized.
803    * @pre delaySeconds & durationSeconds must be zero or greater.
804    * @param [in] actor The actor to animate.
805    * @param [in] parentOrigin The target value.
806    * @param [in] alpha The alpha function to apply.
807    * @param [in] delaySeconds The initial delay from the start of the effect.
808    * @param [in] durationSeconds The duration of the effect.
809    */
810   void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha, float delaySeconds, float durationSeconds);
811
812   /**
813    * Animate the anchor-point of an actor.
814    * The effect will start & end when the animation begins & ends.
815    * @param [in] actor The actor to animate.
816    * @param [in] anchorPoint The target value.
817    */
818   void AnchorPointTo(Actor& actor, const Vector3& anchorPoint);
819
820   /**
821    * Animate the anchor-point of an actor.
822    * This overload allows the alpha function to be customized.
823    * The effect will start & end when the animation begins & ends.
824    * @param [in] actor The actor to animate.
825    * @param [in] anchorPoint The target value.
826    * @param [in] alpha The alpha function to apply.
827    */
828   void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha);
829
830   /**
831    * Animate the anchor-point of an actor.
832    * This overload allows the start & end time to be customized.
833    * @pre delaySeconds & durationSeconds must be zero or greater.
834    * @param [in] actor The actor to animate.
835    * @param [in] anchorPoint The target value.
836    * @param [in] alpha The alpha function to apply.
837    * @param [in] delaySeconds The initial delay from the start of the effect.
838    * @param [in] durationSeconds The duration of the effect.
839    */
840   void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha, float delaySeconds, float durationSeconds);
841
842   /**
843    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value)
844    */
845   void AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, float value );
846
847   /**
848    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha)
849    */
850   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha );
851
852   /**
853    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
854    */
855   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
856
857   /**
858    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value )
859    */
860   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value );
861
862   /**
863    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha )
864    */
865   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha );
866
867   /**
868    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
869    */
870   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
871
872   /**
873    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value )
874    */
875   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value );
876
877   /**
878    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha )
879    */
880   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha );
881
882   /**
883    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
884    */
885   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
886
887   /**
888    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value )
889    */
890   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value );
891
892   /**
893    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha)
894    */
895   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha );
896
897   /**
898    * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
899    */
900   void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
901
902 public: // For connecting animators to animations
903
904   /**
905    * Add an animator connector.
906    * @param[in] connector The animator connector.
907    */
908   void AddAnimatorConnector( AnimatorConnectorBase* connector );
909
910   /**
911    * Retrieve the SceneGraph::Animation object.
912    * @return The animation.
913    */
914   const SceneGraph::Animation* GetSceneObject()
915   {
916     return mAnimation;
917   }
918
919   /**
920    * Retrieve the UpdateManager associated with this animation.
921    * @return The UpdateManager.
922    */
923   SceneGraph::UpdateManager& GetUpdateManager()
924   {
925     return mUpdateManager;
926   }
927
928 protected:
929
930   /**
931    * Construct a new Animation.
932    * @param[in] updateManager The UpdateManager associated with this animation.
933    * @param[in] playlist The list of currently playing animations.
934    * @param[in] durationSeconds The duration of the animation in seconds.
935    * @param[in] endAction The action to perform when the animation ends.
936    * @param[in] destroyAction The action to perform when the animation is destroyed.
937    * @param[in] defaultAlpha The default alpha function to apply to animators.
938    */
939   Animation( SceneGraph::UpdateManager& updateManager,
940              AnimationPlaylist& playlist,
941              float durationSeconds,
942              EndAction endAction,
943              EndAction destroyAction,
944              AlphaFunction defaultAlpha);
945
946   /**
947    * Second-phase constructor.
948    */
949   void Initialize();
950
951   /**
952    * Helper to create a scene-graph animation
953    */
954   void CreateSceneObject();
955
956   /**
957    * Helper to create a scene-graph animation
958    */
959   void DestroySceneObject();
960
961   /**
962    * A reference counted object may only be deleted by calling Unreference()
963    */
964   virtual ~Animation();
965
966 private:
967
968   // Undefined
969   Animation(const Animation&);
970
971   // Undefined
972   Animation& operator=(const Animation& rhs);
973
974 private:
975
976   SceneGraph::UpdateManager& mUpdateManager;
977   AnimationPlaylist& mPlaylist;
978
979   const SceneGraph::Animation* mAnimation;
980
981   int mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
982
983   Dali::Animation::AnimationSignalV2 mFinishedSignal;
984
985   FinishedCallback mFinishedCallback;
986   Object* mFinishedCallbackObject;
987
988   AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
989
990   // Cached for public getters
991   float mDurationSeconds;
992   bool mIsLooping;
993   EndAction mEndAction;
994   EndAction mDestroyAction;
995   AlphaFunction mDefaultAlpha;
996
997 };
998
999 } // namespace Internal
1000
1001 // Helpers for public-api forwarding methods
1002
1003 inline Internal::Animation& GetImplementation(Dali::Animation& animation)
1004 {
1005   DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1006
1007   BaseObject& handle = animation.GetBaseObject();
1008
1009   return static_cast<Internal::Animation&>(handle);
1010 }
1011
1012 inline const Internal::Animation& GetImplementation(const Dali::Animation& animation)
1013 {
1014   DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1015
1016   const BaseObject& handle = animation.GetBaseObject();
1017
1018   return static_cast<const Internal::Animation&>(handle);
1019 }
1020
1021 } // namespace Dali
1022
1023 #endif // __DALI_INTERNAL_ANIMATION_H__