1 #ifndef __DALI_INTERNAL_ANIMATION_H__
2 #define __DALI_INTERNAL_ANIMATION_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
43 class AnimationPlaylist;
47 typedef IntrusivePtr<Animation> AnimationPtr;
48 typedef std::vector<AnimationPtr> AnimationContainer;
50 typedef AnimationContainer::iterator AnimationIter;
51 typedef AnimationContainer::const_iterator AnimationConstIter;
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.
58 class Animation : public BaseObject
62 typedef Dali::Animation::AnyFunction AnyFunction;
63 typedef Dali::Animation::EndAction EndAction;
65 typedef void (*FinishedCallback)(Object* object);
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.
72 static AnimationPtr New(float durationSeconds);
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.
81 static AnimationPtr New(float durationSeconds, EndAction endAction, EndAction destroyAction);
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.
91 static AnimationPtr New(float durationSeconds, EndAction endAction, EndAction destroyAction, AlphaFunction alpha);
94 * Set the duration of an animation.
95 * @pre durationSeconds must be greater than zero.
96 * @param[in] seconds The duration in seconds.
98 void SetDuration(float seconds);
101 * Retrieve the duration of an animation.
102 * @return The duration in seconds.
104 float GetDuration() const;
107 * Set whether the animation will loop.
108 * @param[in] looping True if the animation will loop.
110 void SetLooping(bool looping);
113 * Query whether the animation will loop.
114 * @return True if the animation will loop.
116 bool IsLooping() const;
119 * Set the end action of the animation.
120 * @param[in] action The end action.
122 void SetEndAction(EndAction action);
125 * Returns the end action of the animation.
127 EndAction GetEndAction() const;
130 * Set the destroy action of the animation.
131 * @param[in] action The destroy action.
133 void SetDestroyAction(EndAction action);
136 * Returns the destroy action of the animation.
138 EndAction GetDestroyAction() const;
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.
145 void SetDefaultAlphaFunction(AlphaFunction alpha)
147 mDefaultAlpha = alpha;
151 * Retrieve the default alpha function for an animation.
152 * @return The default alpha function.
154 AlphaFunction GetDefaultAlphaFunction() const
156 return mDefaultAlpha;
160 * (Re)start the animation.
165 * (Re)start the animation from a given point.
166 * @param[in] progress The progress between [0,1] from where the animation should start
168 void PlayFrom( float progress );
171 * Pause the animation.
176 * Stop the animation.
181 * Clear the animation.
182 * This disconnects any objects that were being animated, effectively stopping the animation.
187 * Query whether a Finished signal should be emitted for this animation.
188 * This should only be called by NotificationManager, before signals are emitted.
189 * @post HasFinished() will return false on subsequent calls, until the animation is replayed to completion.
194 * @copydoc Dali::Animation::FinishedSignal()
196 Dali::Animation::AnimationSignalV2& FinishedSignal();
199 * Emit the Finished signal
201 void EmitSignalFinish();
204 * Connects a callback function with the object's signals.
205 * @param[in] object The object providing the signal.
206 * @param[in] tracker Used to disconnect the signal.
207 * @param[in] signalName The signal to connect to.
208 * @param[in] functor A newly allocated FunctorDelegate.
209 * @return True if the signal was connected.
210 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
212 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
215 * Performs actions as requested using the action name.
216 * @param[in] object The object on which to perform the action.
217 * @param[in] actionName The action to perform.
218 * @param[in] attributes The attributes with which to perfrom this action.
219 * @return true if action was done
221 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
224 * This callback is intended for internal use only, to avoid the overhead of using a signal.
225 * @param[in] callback The callback function to connect.
226 * @param[in] object The internal object requesting the callback, or NULL.
228 void SetFinishedCallback( FinishedCallback callback, Object* object );
231 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue)
233 void AnimateBy(Property& target, Property::Value& relativeValue);
236 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
238 void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha);
241 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
243 void AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period);
246 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
248 void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period);
251 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue)
253 void AnimateTo(Property& target, Property::Value& destinationValue);
256 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
258 void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha);
261 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
263 void AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period);
266 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
268 void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
271 * Animate a property to a destination value.
272 * @param [in] targetObject The target object to animate.
273 * @param [in] targetPropertyIndex The index of the target property.
274 * @param [in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4
275 * @param [in] destinationValue The destination value.
276 * @param [in] alpha The alpha function to apply.
277 * @param [in] period The effect will occur during this time period.
279 void AnimateTo(ProxyObject& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
283 * Animate a property between the keyframe time / value pairs.
284 * It uses the current duration of the animation to run the key
285 * frame animator. Note, If the animation duration is subsequently
286 * changed, this does not change to match.
288 * @param[in] target The target object + property to animate
289 * @param[in] keyFrames The set of time / value pairs between which to animate.
291 void AnimateBetween(Property target, const KeyFrames& keyFrames);
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] period The effect will occur duing this time period.
299 void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period);
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.
307 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha);
310 * Animate a property between the keyframe time / value pairs.
311 * @param[in] target The target object + property to animate
312 * @param[in] keyFrames The set of time / value pairs between which to animate.
313 * @param[in] alpha The alpha function to apply to the overall progress.
314 * @param[in] period The effect will occur duing this time period.
316 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
319 * @copydoc Dali::Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
321 void Animate( Property& target, Property::Type targetType, AnyFunction& func );
324 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
326 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha );
329 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, TimePeriod period)
331 void Animate( Property& target, Property::Type targetType, AnyFunction& func, TimePeriod period );
334 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period)
336 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha, TimePeriod period );
338 // Action-specific convenience functions
341 * Translate an actor.
342 * The default alpha function will be used.
343 * The translation will start & end when the animation begins & ends.
344 * @param [in] actor The actor to animate.
345 * @param [in] x Translation in the X-direction.
346 * @param [in] y Translation in the Y-direction.
347 * @param [in] z Translation in the Z-direction.
349 void MoveBy(Actor& actor, float x, float y, float z);
352 * Translate an actor. This overload allows the alpha function to be customized.
353 * The translation will start & end when the animation begins & ends.
354 * @param [in] actor The actor to animate.
355 * @param [in] translation The translation.
356 * @param [in] alpha The alpha function to apply.
358 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha);
361 * Translate an actor. This overload allows the translation start & end time to be customized.
362 * @pre delaySeconds must be zero or greater.
363 * @pre durationSeconds must be greater than zero.
364 * @param [in] actor The actor to animate.
365 * @param [in] translation The translation.
366 * @param [in] alpha The alpha function to apply.
367 * @param [in] delaySeconds The initial delay from the start of the animation.
368 * @param [in] durationSeconds The duration of the translation.
370 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
373 * Translate an actor to a target position.
374 * The default alpha function will be used.
375 * The translation will start & end when the animation begins & ends.
376 * @param [in] actor The actor to animate.
377 * @param [in] x Translation in the X-direction.
378 * @param [in] y Translation in the Y-direction.
379 * @param [in] z Translation in the Z-direction.
381 void MoveTo(Actor& actor, float x, float y, float z);
384 * Translate an actor to a target position. This overload allows the alpha function to be customized.
385 * The translation will start & end when the animation begins & ends.
386 * @param [in] actor The actor to animate.
387 * @param [in] translation The translation.
388 * @param [in] alpha The alpha function to apply.
390 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha);
393 * Translate an actor to a target position. This overload allows the translation start & end time to be customized.
394 * @pre delaySeconds must be zero or greater.
395 * @pre durationSeconds must be greater than zero.
396 * @param [in] actor The actor to animate.
397 * @param [in] translation The translation.
398 * @param [in] alpha The alpha function to apply.
399 * @param [in] delaySeconds The initial delay from the start of the animation.
400 * @param [in] durationSeconds The duration of the translation.
402 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
405 * Translate an actor using a custom function.
406 * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
407 * @pre delaySeconds must be zero or greater.
408 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
409 * @param [in] actor The actor to animate.
410 * @param [in] func The function to call during the animation.
411 * @param [in] alpha The alpha function to apply.
412 * @param [in] delaySeconds The initial delay from the start of the animation.
413 * @param [in] durationSeconds The duration of the translation.
415 void Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
418 * Rotate an actor around an arbitrary axis.
419 * The default alpha function will be used.
420 * The rotation will start & end when the animation begins & ends.
421 * @param [in] actor The actor to animate.
422 * @param [in] angle The angle in radians.
423 * @param [in] axis The axis of rotation.
425 void RotateBy(Actor& actor, Radian angle, const Vector3& axis);
428 * Rotate an actor around an arbitrary axis. This overload allows the alpha function to be customized.
429 * The rotation will start & end when the animation begins & ends.
430 * @param [in] actor The actor to animate.
431 * @param [in] angle The angle in radians.
432 * @param [in] axis The axis of rotation.
433 * @param [in] alpha The alpha function to apply.
435 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
438 * Rotate an actor around an arbitrary axis. This overload allows the rotation start & end time to be customized.
439 * @pre delaySeconds must be zero or greater.
440 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
441 * @param [in] actor The actor to animate.
442 * @param [in] angle The angle in radians.
443 * @param [in] axis The axis of rotation.
444 * @param [in] alpha The alpha function to apply.
445 * @param [in] delaySeconds The initial delay from the start of the animation.
446 * @param [in] durationSeconds The duration of the rotation.
448 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
451 * Rotate an actor to a target orientation.
452 * The default alpha function will be used.
453 * The rotation will start & end when the animation begins & ends.
454 * @param [in] actor The actor to animate.
455 * @param [in] angle The target rotation angle in radians.
456 * @param [in] axis The target axis of rotation.
458 void RotateTo(Actor& actor, Radian angle, const Vector3& axis);
461 * Rotate an actor to a target orientation.
462 * The default alpha function will be used.
463 * The rotation will start & end when the animation begins & ends.
464 * @param [in] actor The actor to animate.
465 * @param [in] orientation The target orientation.
467 void RotateTo(Actor& actor, const Quaternion& orientation);
470 * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
471 * The rotation will start & end when the animation begins & ends.
472 * @param [in] actor The actor to animate.
473 * @param [in] angle The target rotation angle in radians.
474 * @param [in] axis The target axis of rotation.
475 * @param [in] alpha The alpha function to apply.
477 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
480 * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
481 * The rotation will start & end when the animation begins & ends.
482 * @param [in] actor The actor to animate.
483 * @param [in] orientation The target orientation.
484 * @param [in] alpha The alpha function to apply.
486 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha);
489 * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
490 * @pre delaySeconds must be zero or greater.
491 * @pre durationSeconds must be greater than zero.
492 * @param [in] actor The actor to animate.
493 * @param [in] orientation The target orientation.
494 * @param [in] alpha The alpha function to apply.
495 * @param [in] delaySeconds The initial delay from the start of the animation.
496 * @param [in] durationSeconds The duration of the rotation.
498 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
501 * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
502 * @pre delaySeconds must be zero or greater.
503 * @pre durationSeconds must be greater than zero.
504 * @param [in] actor The actor to animate.
505 * @param [in] angle The target rotation angle in radians.
506 * @param [in] axis The target axis of rotation.
507 * @param [in] alpha The alpha function to apply.
508 * @param [in] delaySeconds The initial delay from the start of the animation.
509 * @param [in] durationSeconds The duration of the rotation.
511 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
514 * Rotate an actor using a custom function.
515 * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
516 * @pre delaySeconds must be zero or greater.
517 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
518 * @param [in] actor The actor to animate.
519 * @param [in] func The function to call during the animation.
520 * @param [in] alpha The alpha function to apply.
521 * @param [in] delaySeconds The initial delay from the start of the animation.
522 * @param [in] durationSeconds The duration of the translation.
524 void Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
528 * The default alpha function will be used.
529 * The scaling will start & end when the animation begins & ends.
530 * @param [in] actor The actor to animate.
531 * @param [in] x Scale factor in the X-direction.
532 * @param [in] y Scale factor in the Y-direction.
533 * @param [in] z Scale factor in the Z-direction.
535 void ScaleBy(Actor& actor, float x, float y, float z);
538 * Scale an actor. This overload allows the alpha function to be customized.
539 * The scaling will start & end when the animation begins & ends.
540 * @param [in] actor The actor to animate.
541 * @param [in] scale The scale factor.
542 * @param [in] alpha The alpha function to apply.
544 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha);
547 * Scale an actor. This overload allows the translation start & end time to be customized.
548 * @pre delaySeconds must be zero or greater.
549 * @pre durationSeconds must be greater than zero.
550 * @param [in] actor The actor to animate.
551 * @param [in] scale The scale factor.
552 * @param [in] alpha The alpha function to apply.
553 * @param [in] delaySeconds The initial delay from the start of the animation.
554 * @param [in] durationSeconds The duration of the translation.
556 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
559 * Scale an actor to a target scale factor.
560 * The default alpha function will be used.
561 * The scaling will start & end when the animation begins & ends.
562 * @param [in] actor The actor to animate.
563 * @param [in] x Target scale-factor in the X-direction.
564 * @param [in] y Target scale-factor in the Y-direction.
565 * @param [in] z Target scale-factor in the Z-direction.
567 void ScaleTo(Actor& actor, float x, float y, float z);
570 * Scale an actor to a target scale factor. This overload allows the alpha function to be customized.
571 * The scaling will start & end when the animation begins & ends.
572 * @param [in] actor The actor to animate.
573 * @param [in] scale The target scale factor.
574 * @param [in] alpha The alpha function to apply.
576 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha);
579 * Scale an actor to a target scale factor. This overload allows the translation start & end time to be customized.
580 * @pre delaySeconds must be zero or greater.
581 * @pre durationSeconds must be greater than zero.
582 * @param [in] actor The actor to animate.
583 * @param [in] scale The target scale factor.
584 * @param [in] alpha The alpha function to apply.
585 * @param [in] delaySeconds The initial delay from the start of the animation.
586 * @param [in] durationSeconds The duration of the translation.
588 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
591 * Show 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.
595 void Show(Actor& actor, float delaySeconds);
598 * Hide an actor during the animation.
599 * @param [in] actor The actor to animate.
600 * @param [in] delaySeconds The initial delay from the start of the animation.
602 void Hide(Actor& actor, float delaySeconds);
605 * Animate the opacity of an actor.
606 * The default alpha function will be used.
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.
611 void OpacityBy(Actor& actor, float opacity);
614 * Animate the opacity of an actor. This overload allows the alpha function to be customized.
615 * The effect will start & end when the animation begins & ends.
616 * @param [in] actor The actor to animate.
617 * @param [in] opacity The relative change in opacity.
618 * @param [in] alpha The alpha function to apply.
620 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha);
623 * Animate the opacity of an actor. This overload allows the translation start & end time to be customized.
624 * @pre delaySeconds must be zero or greater.
625 * @pre durationSeconds must be greater than zero.
626 * @param [in] actor The actor to animate.
627 * @param [in] opacity The relative change in opacity.
628 * @param [in] alpha The alpha function to apply.
629 * @param [in] delaySeconds The initial delay from the start of the animation.
630 * @param [in] durationSeconds The duration of the translation.
632 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
635 * Animate an actor to a target opacity.
636 * The default alpha function will be used.
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.
641 void OpacityTo(Actor& actor, float opacity);
644 * Animate an actor to a target opacity. This overload allows the alpha function to be customized.
645 * The effect will start & end when the animation begins & ends.
646 * @param [in] actor The actor to animate.
647 * @param [in] opacity The target opacity.
648 * @param [in] alpha The alpha function to apply.
650 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha);
653 * Animate an actor to a target opacity. This overload allows the translation start & end time to be customized.
654 * @pre delaySeconds must be zero or greater.
655 * @pre durationSeconds must be greater than zero.
656 * @param [in] actor The actor to animate.
657 * @param [in] opacity The target opacity.
658 * @param [in] alpha The alpha function to apply.
659 * @param [in] delaySeconds The initial delay from the start of the animation.
660 * @param [in] durationSeconds The duration of the translation.
662 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
665 * Animate the color of an actor.
666 * The default alpha function will be used.
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.
671 void ColorBy(Actor& actor, const Vector4& color);
674 * Animate the color of an actor. This overload allows the alpha function to be customized.
675 * The effect will start & end when the animation begins & ends.
676 * @param [in] actor The actor to animate.
677 * @param [in] color The relative change in color.
678 * @param [in] alpha The alpha function to apply.
680 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha);
683 * Animate the color of an actor. This overload allows the translation start & end time to be customized.
684 * @pre delaySeconds must be zero or greater.
685 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
686 * @param [in] actor The actor to animate.
687 * @param [in] color The relative change in color.
688 * @param [in] alpha The alpha function to apply.
689 * @param [in] delaySeconds The initial delay from the start of the animation.
690 * @param [in] durationSeconds The duration of the translation.
692 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
695 * Animate an actor to a target color.
696 * The default alpha function will be used.
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.
701 void ColorTo(Actor& actor, const Vector4& color);
704 * Animate an actor to a target color. This overload allows the alpha function to be customized.
705 * The effect will start & end when the animation begins & ends.
706 * @param [in] actor The actor to animate.
707 * @param [in] color The target color.
708 * @param [in] alpha The alpha function to apply.
710 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha);
713 * Animate an actor to a target color. This overload allows the translation start & end time to be customized.
714 * @pre delaySeconds must be zero or greater.
715 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
716 * @param [in] actor The actor to animate.
717 * @param [in] color The target color.
718 * @param [in] alpha The alpha function to apply.
719 * @param [in] delaySeconds The initial delay from the start of the animation.
720 * @param [in] durationSeconds The duration of the translation.
722 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
726 * The default alpha function will be used.
727 * The resizing will start & end when the animation begins & ends.
728 * The depth defaults to the minimum of width & height.
729 * @param [in] actor The actor to animate.
730 * @param [in] width The target width.
731 * @param [in] height The target height.
733 void Resize(Actor& actor, float width, float height);
736 * Resize an actor. This overload allows the alpha function to be customized.
737 * The resizing will start & end when the animation begins & ends.
738 * The depth defaults to the minimum of width & height.
739 * @param [in] actor The actor to animate.
740 * @param [in] width The target width.
741 * @param [in] height The target height.
742 * @param [in] alpha The alpha function to apply.
744 void Resize(Actor& actor, float width, float height, AlphaFunction alpha);
747 * Resize an actor. This overload allows the resizing start & end time to be customized.
748 * The depth defaults to the minimum of width & height.
749 * @pre delaySeconds must be zero or greater.
750 * @pre durationSeconds must be greater than zero.
751 * @param [in] actor The actor to animate.
752 * @param [in] width The target width.
753 * @param [in] height The target height.
754 * @param [in] alpha The alpha function to apply.
755 * @param [in] delaySeconds The initial delay from the start of the animation.
756 * @param [in] durationSeconds The duration of the translation.
758 void Resize(Actor& actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
762 * The default alpha function will be used.
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.
767 void Resize(Actor& actor, const Vector3& size);
770 * Resize an actor. This overload allows the alpha function to be customized.
771 * The resizing will start & end when the animation begins & ends.
772 * @param [in] actor The actor to animate.
773 * @param [in] size The target size.
774 * @param [in] alpha The alpha function to apply.
776 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha);
779 * Resize an actor. This overload allows the resizing start & end time to be customized.
780 * @pre delaySeconds must be zero or greater.
781 * @pre durationSeconds must be greater than zero.
782 * @param [in] actor The actor to animate.
783 * @param [in] size The target size.
784 * @param [in] alpha The alpha function to apply.
785 * @param [in] delaySeconds The initial delay from the start of the animation.
786 * @param [in] durationSeconds The duration of the translation.
788 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
791 * @copydoc Dali::Animation::SetCurrentProgress()
793 void SetCurrentProgress(float progress);
796 * @copydoc Dali::Animation::GetCurrentProgress()
798 float GetCurrentProgress();
801 * @copydoc Dali::Animation::SetSpeedFactor()
803 void SetSpeedFactor( float factor );
806 * @copydoc Dali::Animation::GetSpeedFactor()
808 float GetSpeedFactor() const;
811 * @copydoc Dali::Animation::SetPlayRange()
813 void SetPlayRange( const Vector2& range );
816 * @copydoc Dali::Animation::GetPlayRange
818 Vector2 GetPlayRange() const;
820 public: // For connecting animators to animations
823 * Add an animator connector.
824 * @param[in] connector The animator connector.
826 void AddAnimatorConnector( AnimatorConnectorBase* connector );
829 * Retrieve the SceneGraph::Animation object.
830 * @return The animation.
832 const SceneGraph::Animation* GetSceneObject()
838 * Retrieve the UpdateManager associated with this animation.
839 * @return The UpdateManager.
841 SceneGraph::UpdateManager& GetUpdateManager()
843 return mUpdateManager;
849 * Construct a new Animation.
850 * @param[in] updateManager The UpdateManager associated with this animation.
851 * @param[in] playlist The list of currently playing animations.
852 * @param[in] durationSeconds The duration of the animation in seconds.
853 * @param[in] endAction The action to perform when the animation ends.
854 * @param[in] destroyAction The action to perform when the animation is destroyed.
855 * @param[in] defaultAlpha The default alpha function to apply to animators.
857 Animation( SceneGraph::UpdateManager& updateManager,
858 AnimationPlaylist& playlist,
859 float durationSeconds,
861 EndAction destroyAction,
862 AlphaFunction defaultAlpha);
865 * Second-phase constructor.
870 * Helper to create a scene-graph animation
872 void CreateSceneObject();
875 * Helper to create a scene-graph animation
877 void DestroySceneObject();
880 * A reference counted object may only be deleted by calling Unreference()
882 virtual ~Animation();
887 * Extends the duration when an animator is added with TimePeriod that exceeds current duration.
888 * @param[in] timePeriod The time period for an animator.
890 void ExtendDuration( const TimePeriod& timePeriod );
893 Animation(const Animation&);
896 Animation& operator=(const Animation& rhs);
900 SceneGraph::UpdateManager& mUpdateManager;
901 AnimationPlaylist& mPlaylist;
903 const SceneGraph::Animation* mAnimation;
905 int mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
907 Dali::Animation::AnimationSignalV2 mFinishedSignal;
909 FinishedCallback mFinishedCallback;
910 Object* mFinishedCallbackObject;
912 AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
914 // Cached for public getters
915 float mDurationSeconds;
919 EndAction mEndAction;
920 EndAction mDestroyAction;
921 AlphaFunction mDefaultAlpha;
925 } // namespace Internal
927 // Helpers for public-api forwarding methods
929 inline Internal::Animation& GetImplementation(Dali::Animation& animation)
931 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
933 BaseObject& handle = animation.GetBaseObject();
935 return static_cast<Internal::Animation&>(handle);
938 inline const Internal::Animation& GetImplementation(const Dali::Animation& animation)
940 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
942 const BaseObject& handle = animation.GetBaseObject();
944 return static_cast<const Internal::Animation&>(handle);
949 #endif // __DALI_INTERNAL_ANIMATION_H__