1 #ifndef __DALI_INTERNAL_ANIMATION_H__
2 #define __DALI_INTERNAL_ANIMATION_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 // http://floralicense.org/license/
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.
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>
42 class AnimationPlaylist;
46 typedef IntrusivePtr<Animation> AnimationPtr;
47 typedef std::vector<AnimationPtr> AnimationContainer;
49 typedef AnimationContainer::iterator AnimationIter;
50 typedef AnimationContainer::const_iterator AnimationConstIter;
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.
57 class Animation : public BaseObject
61 typedef Dali::Animation::AnyFunction AnyFunction;
62 typedef Dali::Animation::EndAction EndAction;
64 typedef void (*FinishedCallback)(Object* object);
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.
71 static AnimationPtr New(float durationSeconds);
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.
80 static AnimationPtr New(float durationSeconds, EndAction endAction, EndAction destroyAction);
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.
90 static AnimationPtr New(float durationSeconds, EndAction endAction, EndAction destroyAction, AlphaFunction alpha);
93 * Set the duration of an animation.
94 * @pre durationSeconds must be greater than zero.
95 * @param[in] seconds The duration in seconds.
97 void SetDuration(float seconds);
100 * Retrieve the duration of an animation.
101 * @return The duration in seconds.
103 float GetDuration() const;
106 * Set whether the animation will loop.
107 * @param[in] looping True if the animation will loop.
109 void SetLooping(bool looping);
112 * Query whether the animation will loop.
113 * @return True if the animation will loop.
115 bool IsLooping() const;
118 * Set the end action of the animation.
119 * @param[in] action The end action.
121 void SetEndAction(EndAction action);
124 * Returns the end action of the animation.
126 EndAction GetEndAction() const;
129 * Set the destroy action of the animation.
130 * @param[in] action The destroy action.
132 void SetDestroyAction(EndAction action);
135 * Returns the destroy action of the animation.
137 EndAction GetDestroyAction() const;
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.
144 void SetDefaultAlphaFunction(AlphaFunction alpha)
146 mDefaultAlpha = alpha;
150 * Retrieve the default alpha function for an animation.
151 * @return The default alpha function.
153 AlphaFunction GetDefaultAlphaFunction() const
155 return mDefaultAlpha;
159 * (Re)start the animation.
164 * Pause the animation.
169 * Stop the animation.
174 * Clear the animation.
175 * This disconnects any objects that were being animated, effectively stopping the animation.
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.
187 * @copydoc Dali::Animation::FinishedSignal()
189 Dali::Animation::AnimationSignalV2& FinishedSignal();
192 * Emit the Finished signal
194 void EmitSignalFinish();
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.
205 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
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
214 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
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.
221 void SetFinishedCallback( FinishedCallback callback, Object* object );
224 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue)
226 void AnimateBy(Property& target, Property::Value& relativeValue);
229 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
231 void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha);
234 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
236 void AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period);
239 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
241 void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period);
244 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue)
246 void AnimateTo(Property& target, Property::Value& destinationValue);
249 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
251 void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha);
254 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
256 void AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period);
259 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
261 void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
264 * Animate a property to a destination value.
265 * @param [in] targetObject The target object to animate.
266 * @param [in] targetPropertyIndex The index of the target property.
267 * @param [in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4
268 * @param [in] destinationValue The destination value.
269 * @param [in] alpha The alpha function to apply.
270 * @param [in] period The effect will occur during this time period.
272 void AnimateTo(ProxyObject& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
276 * Animate a property between the keyframe time / value pairs.
277 * It uses the current duration of the animation to run the key
278 * frame animator. Note, If the animation duration is subsequently
279 * changed, this does not change to match.
281 * @param[in] target The target object + property to animate
282 * @param[in] keyFrames The set of time / value pairs between which to animate.
284 void AnimateBetween(Property target, const KeyFrames& keyFrames);
287 * Animate a property between the keyframe time / value pairs.
288 * @param[in] target The target object + property to animate
289 * @param[in] keyFrames The set of time / value pairs between which to animate.
290 * @param[in] period The effect will occur duing this time period.
292 void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period);
295 * Animate a property between the keyframe time / value pairs.
296 * @param[in] target The target object + property to animate
297 * @param[in] keyFrames The set of time / value pairs between which to animate.
298 * @param[in] alpha The alpha function to apply to the overall progress.
300 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha);
303 * Animate a property between the keyframe time / value pairs.
304 * @param[in] target The target object + property to animate
305 * @param[in] keyFrames The set of time / value pairs between which to animate.
306 * @param[in] alpha The alpha function to apply to the overall progress.
307 * @param[in] period The effect will occur duing this time period.
309 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
312 * @copydoc Dali::Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
314 void Animate( Property& target, Property::Type targetType, AnyFunction& func );
317 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
319 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha );
322 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, TimePeriod period)
324 void Animate( Property& target, Property::Type targetType, AnyFunction& func, TimePeriod period );
327 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period)
329 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha, TimePeriod period );
331 // Action-specific convenience functions
334 * Translate an actor.
335 * The default alpha function will be used.
336 * The translation will start & end when the animation begins & ends.
337 * @param [in] actor The actor to animate.
338 * @param [in] x Translation in the X-direction.
339 * @param [in] y Translation in the Y-direction.
340 * @param [in] z Translation in the Z-direction.
342 void MoveBy(Actor& actor, float x, float y, float z);
345 * Translate an actor. This overload allows the alpha function to be customized.
346 * The translation will start & end when the animation begins & ends.
347 * @param [in] actor The actor to animate.
348 * @param [in] translation The translation.
349 * @param [in] alpha The alpha function to apply.
351 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha);
354 * Translate an actor. This overload allows the translation start & end time to be customized.
355 * @pre delaySeconds must be zero or greater.
356 * @pre durationSeconds must be greater than zero.
357 * @param [in] actor The actor to animate.
358 * @param [in] translation The translation.
359 * @param [in] alpha The alpha function to apply.
360 * @param [in] delaySeconds The initial delay from the start of the animation.
361 * @param [in] durationSeconds The duration of the translation.
363 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
366 * Translate an actor to a target position.
367 * The default alpha function will be used.
368 * The translation will start & end when the animation begins & ends.
369 * @param [in] actor The actor to animate.
370 * @param [in] x Translation in the X-direction.
371 * @param [in] y Translation in the Y-direction.
372 * @param [in] z Translation in the Z-direction.
374 void MoveTo(Actor& actor, float x, float y, float z);
377 * Translate an actor to a target position. This overload allows the alpha function to be customized.
378 * The translation will start & end when the animation begins & ends.
379 * @param [in] actor The actor to animate.
380 * @param [in] translation The translation.
381 * @param [in] alpha The alpha function to apply.
383 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha);
386 * Translate an actor to a target position. This overload allows the translation start & end time to be customized.
387 * @pre delaySeconds must be zero or greater.
388 * @pre durationSeconds must be greater than zero.
389 * @param [in] actor The actor to animate.
390 * @param [in] translation The translation.
391 * @param [in] alpha The alpha function to apply.
392 * @param [in] delaySeconds The initial delay from the start of the animation.
393 * @param [in] durationSeconds The duration of the translation.
395 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
398 * Translate an actor using a custom function.
399 * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
400 * @pre delaySeconds must be zero or greater.
401 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
402 * @param [in] actor The actor to animate.
403 * @param [in] func The function to call during the animation.
404 * @param [in] alpha The alpha function to apply.
405 * @param [in] delaySeconds The initial delay from the start of the animation.
406 * @param [in] durationSeconds The duration of the translation.
408 void Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
411 * Rotate an actor around an arbitrary axis.
412 * The default alpha function will be used.
413 * The rotation will start & end when the animation begins & ends.
414 * @param [in] actor The actor to animate.
415 * @param [in] angle The angle in radians.
416 * @param [in] axis The axis of rotation.
418 void RotateBy(Actor& actor, Radian angle, const Vector3& axis);
421 * Rotate an actor around an arbitrary axis. This overload allows the alpha function to be customized.
422 * The rotation will start & end when the animation begins & ends.
423 * @param [in] actor The actor to animate.
424 * @param [in] angle The angle in radians.
425 * @param [in] axis The axis of rotation.
426 * @param [in] alpha The alpha function to apply.
428 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
431 * Rotate an actor around an arbitrary axis. This overload allows the rotation start & end time to be customized.
432 * @pre delaySeconds must be zero or greater.
433 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
434 * @param [in] actor The actor to animate.
435 * @param [in] angle The angle in radians.
436 * @param [in] axis The axis of rotation.
437 * @param [in] alpha The alpha function to apply.
438 * @param [in] delaySeconds The initial delay from the start of the animation.
439 * @param [in] durationSeconds The duration of the rotation.
441 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
444 * Rotate an actor to a target orientation.
445 * The default alpha function will be used.
446 * The rotation will start & end when the animation begins & ends.
447 * @param [in] actor The actor to animate.
448 * @param [in] angle The target rotation angle in radians.
449 * @param [in] axis The target axis of rotation.
451 void RotateTo(Actor& actor, Radian angle, const Vector3& axis);
454 * Rotate an actor to a target orientation.
455 * The default alpha function will be used.
456 * The rotation will start & end when the animation begins & ends.
457 * @param [in] actor The actor to animate.
458 * @param [in] orientation The target orientation.
460 void RotateTo(Actor& actor, const Quaternion& orientation);
463 * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
464 * The rotation will start & end when the animation begins & ends.
465 * @param [in] actor The actor to animate.
466 * @param [in] angle The target rotation angle in radians.
467 * @param [in] axis The target axis of rotation.
468 * @param [in] alpha The alpha function to apply.
470 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
473 * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
474 * The rotation will start & end when the animation begins & ends.
475 * @param [in] actor The actor to animate.
476 * @param [in] orientation The target orientation.
477 * @param [in] alpha The alpha function to apply.
479 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha);
482 * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
483 * @pre delaySeconds must be zero or greater.
484 * @pre durationSeconds must be greater than zero.
485 * @param [in] actor The actor to animate.
486 * @param [in] orientation The target orientation.
487 * @param [in] alpha The alpha function to apply.
488 * @param [in] delaySeconds The initial delay from the start of the animation.
489 * @param [in] durationSeconds The duration of the rotation.
491 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
494 * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
495 * @pre delaySeconds must be zero or greater.
496 * @pre durationSeconds must be greater than zero.
497 * @param [in] actor The actor to animate.
498 * @param [in] angle The target rotation angle in radians.
499 * @param [in] axis The target axis of rotation.
500 * @param [in] alpha The alpha function to apply.
501 * @param [in] delaySeconds The initial delay from the start of the animation.
502 * @param [in] durationSeconds The duration of the rotation.
504 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
507 * Rotate an actor using a custom function.
508 * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
509 * @pre delaySeconds must be zero or greater.
510 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
511 * @param [in] actor The actor to animate.
512 * @param [in] func The function to call during the animation.
513 * @param [in] alpha The alpha function to apply.
514 * @param [in] delaySeconds The initial delay from the start of the animation.
515 * @param [in] durationSeconds The duration of the translation.
517 void Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
521 * The default alpha function will be used.
522 * The scaling will start & end when the animation begins & ends.
523 * @param [in] actor The actor to animate.
524 * @param [in] x Scale factor in the X-direction.
525 * @param [in] y Scale factor in the Y-direction.
526 * @param [in] z Scale factor in the Z-direction.
528 void ScaleBy(Actor& actor, float x, float y, float z);
531 * Scale an actor. This overload allows the alpha function to be customized.
532 * The scaling will start & end when the animation begins & ends.
533 * @param [in] actor The actor to animate.
534 * @param [in] scale The scale factor.
535 * @param [in] alpha The alpha function to apply.
537 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha);
540 * Scale an actor. This overload allows the translation start & end time to be customized.
541 * @pre delaySeconds must be zero or greater.
542 * @pre durationSeconds must be greater than zero.
543 * @param [in] actor The actor to animate.
544 * @param [in] scale The scale factor.
545 * @param [in] alpha The alpha function to apply.
546 * @param [in] delaySeconds The initial delay from the start of the animation.
547 * @param [in] durationSeconds The duration of the translation.
549 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
552 * Scale an actor to a target scale factor.
553 * The default alpha function will be used.
554 * The scaling will start & end when the animation begins & ends.
555 * @param [in] actor The actor to animate.
556 * @param [in] x Target scale-factor in the X-direction.
557 * @param [in] y Target scale-factor in the Y-direction.
558 * @param [in] z Target scale-factor in the Z-direction.
560 void ScaleTo(Actor& actor, float x, float y, float z);
563 * Scale an actor to a target scale factor. This overload allows the alpha function to be customized.
564 * The scaling will start & end when the animation begins & ends.
565 * @param [in] actor The actor to animate.
566 * @param [in] scale The target scale factor.
567 * @param [in] alpha The alpha function to apply.
569 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha);
572 * Scale an actor to a target scale factor. This overload allows the translation start & end time to be customized.
573 * @pre delaySeconds must be zero or greater.
574 * @pre durationSeconds must be greater than zero.
575 * @param [in] actor The actor to animate.
576 * @param [in] scale The target scale factor.
577 * @param [in] alpha The alpha function to apply.
578 * @param [in] delaySeconds The initial delay from the start of the animation.
579 * @param [in] durationSeconds The duration of the translation.
581 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
584 * Show an actor during the animation.
585 * @param [in] actor The actor to animate.
586 * @param [in] delaySeconds The initial delay from the start of the animation.
588 void Show(Actor& actor, float delaySeconds);
591 * Hide an actor during the animation.
592 * @param [in] actor The actor to animate.
593 * @param [in] delaySeconds The initial delay from the start of the animation.
595 void Hide(Actor& actor, float delaySeconds);
598 * Animate the opacity of an actor.
599 * The default alpha function will be used.
600 * The effect will start & end when the animation begins & ends.
601 * @param [in] actor The actor to animate.
602 * @param [in] opacity The relative change in opacity.
604 void OpacityBy(Actor& actor, float opacity);
607 * Animate the opacity of an actor. This overload allows the alpha function to be customized.
608 * The effect will start & end when the animation begins & ends.
609 * @param [in] actor The actor to animate.
610 * @param [in] opacity The relative change in opacity.
611 * @param [in] alpha The alpha function to apply.
613 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha);
616 * Animate the opacity of an actor. This overload allows the translation start & end time to be customized.
617 * @pre delaySeconds must be zero or greater.
618 * @pre durationSeconds must be greater than zero.
619 * @param [in] actor The actor to animate.
620 * @param [in] opacity The relative change in opacity.
621 * @param [in] alpha The alpha function to apply.
622 * @param [in] delaySeconds The initial delay from the start of the animation.
623 * @param [in] durationSeconds The duration of the translation.
625 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
628 * Animate an actor to a target opacity.
629 * The default alpha function will be used.
630 * The effect will start & end when the animation begins & ends.
631 * @param [in] actor The actor to animate.
632 * @param [in] opacity The target opacity.
634 void OpacityTo(Actor& actor, float opacity);
637 * Animate an actor to a target opacity. This overload allows the alpha function to be customized.
638 * The effect will start & end when the animation begins & ends.
639 * @param [in] actor The actor to animate.
640 * @param [in] opacity The target opacity.
641 * @param [in] alpha The alpha function to apply.
643 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha);
646 * Animate an actor to a target opacity. This overload allows the translation start & end time to be customized.
647 * @pre delaySeconds must be zero or greater.
648 * @pre durationSeconds must be greater than zero.
649 * @param [in] actor The actor to animate.
650 * @param [in] opacity The target opacity.
651 * @param [in] alpha The alpha function to apply.
652 * @param [in] delaySeconds The initial delay from the start of the animation.
653 * @param [in] durationSeconds The duration of the translation.
655 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
658 * Animate the color of an actor.
659 * The default alpha function will be used.
660 * The effect will start & end when the animation begins & ends.
661 * @param [in] actor The actor to animate.
662 * @param [in] color The relative change in color.
664 void ColorBy(Actor& actor, const Vector4& color);
667 * Animate the color of an actor. This overload allows the alpha function to be customized.
668 * The effect will start & end when the animation begins & ends.
669 * @param [in] actor The actor to animate.
670 * @param [in] color The relative change in color.
671 * @param [in] alpha The alpha function to apply.
673 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha);
676 * Animate the color of an actor. This overload allows the translation start & end time to be customized.
677 * @pre delaySeconds must be zero or greater.
678 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
679 * @param [in] actor The actor to animate.
680 * @param [in] color The relative change in color.
681 * @param [in] alpha The alpha function to apply.
682 * @param [in] delaySeconds The initial delay from the start of the animation.
683 * @param [in] durationSeconds The duration of the translation.
685 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
688 * Animate an actor to a target color.
689 * The default alpha function will be used.
690 * The effect will start & end when the animation begins & ends.
691 * @param [in] actor The actor to animate.
692 * @param [in] color The target color.
694 void ColorTo(Actor& actor, const Vector4& color);
697 * Animate an actor to a target color. This overload allows the alpha function to be customized.
698 * The effect will start & end when the animation begins & ends.
699 * @param [in] actor The actor to animate.
700 * @param [in] color The target color.
701 * @param [in] alpha The alpha function to apply.
703 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha);
706 * Animate an actor to a target color. This overload allows the translation start & end time to be customized.
707 * @pre delaySeconds must be zero or greater.
708 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
709 * @param [in] actor The actor to animate.
710 * @param [in] color The target color.
711 * @param [in] alpha The alpha function to apply.
712 * @param [in] delaySeconds The initial delay from the start of the animation.
713 * @param [in] durationSeconds The duration of the translation.
715 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
719 * The default alpha function will be used.
720 * The resizing will start & end when the animation begins & ends.
721 * The depth defaults to the minimum of width & height.
722 * @param [in] actor The actor to animate.
723 * @param [in] width The target width.
724 * @param [in] height The target height.
726 void Resize(Actor& actor, float width, float height);
729 * Resize an actor. This overload allows the alpha function to be customized.
730 * The resizing will start & end when the animation begins & ends.
731 * The depth defaults to the minimum of width & height.
732 * @param [in] actor The actor to animate.
733 * @param [in] width The target width.
734 * @param [in] height The target height.
735 * @param [in] alpha The alpha function to apply.
737 void Resize(Actor& actor, float width, float height, AlphaFunction alpha);
740 * Resize an actor. This overload allows the resizing start & end time to be customized.
741 * The depth defaults to the minimum of width & height.
742 * @pre delaySeconds must be zero or greater.
743 * @pre durationSeconds must be greater than zero.
744 * @param [in] actor The actor to animate.
745 * @param [in] width The target width.
746 * @param [in] height The target height.
747 * @param [in] alpha The alpha function to apply.
748 * @param [in] delaySeconds The initial delay from the start of the animation.
749 * @param [in] durationSeconds The duration of the translation.
751 void Resize(Actor& actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
755 * The default alpha function will be used.
756 * The resizing will start & end when the animation begins & ends.
757 * @param [in] actor The actor to animate.
758 * @param [in] size The target size.
760 void Resize(Actor& actor, const Vector3& size);
763 * Resize an actor. This overload allows the alpha function to be customized.
764 * The resizing will start & end when the animation begins & ends.
765 * @param [in] actor The actor to animate.
766 * @param [in] size The target size.
767 * @param [in] alpha The alpha function to apply.
769 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha);
772 * Resize an actor. This overload allows the resizing start & end time to be customized.
773 * @pre delaySeconds must be zero or greater.
774 * @pre durationSeconds must be greater than zero.
775 * @param [in] actor The actor to animate.
776 * @param [in] size The target size.
777 * @param [in] alpha The alpha function to apply.
778 * @param [in] delaySeconds The initial delay from the start of the animation.
779 * @param [in] durationSeconds The duration of the translation.
781 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
784 * Animate the parent-origin of an actor.
785 * The effect will start & end when the animation begins & ends.
786 * @param [in] actor The actor to animate.
787 * @param [in] parentOrigin The target value.
789 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin);
792 * Animate the parent-origin of an actor.
793 * This overload allows the alpha function to be customized.
794 * The effect will start & end when the animation begins & ends.
795 * @param [in] actor The actor to animate.
796 * @param [in] parentOrigin The target value.
797 * @param [in] alpha The alpha function to apply.
799 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha);
802 * Animate the parent-origin of an actor.
803 * This overload allows the start & end time to be customized.
804 * @pre delaySeconds & durationSeconds must be zero or greater.
805 * @param [in] actor The actor to animate.
806 * @param [in] parentOrigin The target value.
807 * @param [in] alpha The alpha function to apply.
808 * @param [in] delaySeconds The initial delay from the start of the effect.
809 * @param [in] durationSeconds The duration of the effect.
811 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha, float delaySeconds, float durationSeconds);
814 * Animate the anchor-point of an actor.
815 * The effect will start & end when the animation begins & ends.
816 * @param [in] actor The actor to animate.
817 * @param [in] anchorPoint The target value.
819 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint);
822 * Animate the anchor-point of an actor.
823 * This overload allows the alpha function to be customized.
824 * The effect will start & end when the animation begins & ends.
825 * @param [in] actor The actor to animate.
826 * @param [in] anchorPoint The target value.
827 * @param [in] alpha The alpha function to apply.
829 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha);
832 * Animate the anchor-point of an actor.
833 * This overload allows the start & end time to be customized.
834 * @pre delaySeconds & durationSeconds must be zero or greater.
835 * @param [in] actor The actor to animate.
836 * @param [in] anchorPoint The target value.
837 * @param [in] alpha The alpha function to apply.
838 * @param [in] delaySeconds The initial delay from the start of the effect.
839 * @param [in] durationSeconds The duration of the effect.
841 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha, float delaySeconds, float durationSeconds);
844 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value)
846 void AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, float value );
849 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha)
851 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha );
854 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
856 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
859 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value )
861 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value );
864 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha )
866 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha );
869 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
871 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
874 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value )
876 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value );
879 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha )
881 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha );
884 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
886 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
889 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value )
891 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value );
894 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha)
896 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha );
899 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
901 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
903 public: // For connecting animators to animations
906 * Add an animator connector.
907 * @param[in] connector The animator connector.
909 void AddAnimatorConnector( AnimatorConnectorBase* connector );
912 * Retrieve the SceneGraph::Animation object.
913 * @return The animation.
915 const SceneGraph::Animation* GetSceneObject()
921 * Retrieve the UpdateManager associated with this animation.
922 * @return The UpdateManager.
924 SceneGraph::UpdateManager& GetUpdateManager()
926 return mUpdateManager;
932 * Construct a new Animation.
933 * @param[in] updateManager The UpdateManager associated with this animation.
934 * @param[in] playlist The list of currently playing animations.
935 * @param[in] durationSeconds The duration of the animation in seconds.
936 * @param[in] endAction The action to perform when the animation ends.
937 * @param[in] destroyAction The action to perform when the animation is destroyed.
938 * @param[in] defaultAlpha The default alpha function to apply to animators.
940 Animation( SceneGraph::UpdateManager& updateManager,
941 AnimationPlaylist& playlist,
942 float durationSeconds,
944 EndAction destroyAction,
945 AlphaFunction defaultAlpha);
948 * Second-phase constructor.
953 * Helper to create a scene-graph animation
955 void CreateSceneObject();
958 * Helper to create a scene-graph animation
960 void DestroySceneObject();
963 * A reference counted object may only be deleted by calling Unreference()
965 virtual ~Animation();
970 Animation(const Animation&);
973 Animation& operator=(const Animation& rhs);
977 SceneGraph::UpdateManager& mUpdateManager;
978 AnimationPlaylist& mPlaylist;
980 const SceneGraph::Animation* mAnimation;
982 int mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
984 Dali::Animation::AnimationSignalV2 mFinishedSignal;
986 FinishedCallback mFinishedCallback;
987 Object* mFinishedCallbackObject;
989 AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
991 // Cached for public getters
992 float mDurationSeconds;
994 EndAction mEndAction;
995 EndAction mDestroyAction;
996 AlphaFunction mDefaultAlpha;
1000 } // namespace Internal
1002 // Helpers for public-api forwarding methods
1004 inline Internal::Animation& GetImplementation(Dali::Animation& animation)
1006 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1008 BaseObject& handle = animation.GetBaseObject();
1010 return static_cast<Internal::Animation&>(handle);
1013 inline const Internal::Animation& GetImplementation(const Dali::Animation& animation)
1015 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1017 const BaseObject& handle = animation.GetBaseObject();
1019 return static_cast<const Internal::Animation&>(handle);
1024 #endif // __DALI_INTERNAL_ANIMATION_H__