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] 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.
271 void AnimateTo(ProxyObject& targetObject, Property::Index targetPropertyIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
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.
280 * @param[in] target The target object + property to animate
281 * @param[in] keyFrames The set of time / value pairs between which to animate.
283 void AnimateBetween(Property target, const KeyFrames& keyFrames);
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.
291 void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period);
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.
299 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha);
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.
308 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
311 * @copydoc Dali::Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
313 void Animate( Property& target, Property::Type targetType, AnyFunction& func );
316 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
318 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha );
321 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, TimePeriod period)
323 void Animate( Property& target, Property::Type targetType, AnyFunction& func, TimePeriod period );
326 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period)
328 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha, TimePeriod period );
330 // Action-specific convenience functions
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.
341 void MoveBy(Actor& actor, float x, float y, float z);
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.
350 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha);
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.
362 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
373 void MoveTo(Actor& actor, float x, float y, float z);
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.
382 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha);
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.
394 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
407 void Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
417 void RotateBy(Actor& actor, Radian angle, const Vector3& axis);
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.
427 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
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.
440 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
450 void RotateTo(Actor& actor, Radian angle, const Vector3& axis);
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.
459 void RotateTo(Actor& actor, const Quaternion& orientation);
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.
469 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
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.
478 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha);
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.
490 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
503 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
516 void Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
527 void ScaleBy(Actor& actor, float x, float y, float z);
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.
536 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha);
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.
548 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
559 void ScaleTo(Actor& actor, float x, float y, float z);
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.
568 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha);
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.
580 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
587 void Show(Actor& actor, float delaySeconds);
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.
594 void Hide(Actor& actor, float delaySeconds);
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.
603 void OpacityBy(Actor& actor, float opacity);
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.
612 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha);
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.
624 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
633 void OpacityTo(Actor& actor, float opacity);
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.
642 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha);
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.
654 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
663 void ColorBy(Actor& actor, const Vector4& color);
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.
672 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha);
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.
684 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
693 void ColorTo(Actor& actor, const Vector4& color);
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.
702 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha);
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.
714 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
725 void Resize(Actor& actor, float width, float height);
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.
736 void Resize(Actor& actor, float width, float height, AlphaFunction alpha);
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.
750 void Resize(Actor& actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
759 void Resize(Actor& actor, const Vector3& size);
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.
768 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha);
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.
780 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
788 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin);
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.
798 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha);
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.
810 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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.
818 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint);
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.
828 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha);
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.
840 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha, float delaySeconds, float durationSeconds);
843 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value)
845 void AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, float value );
848 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha)
850 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha );
853 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
855 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
858 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value )
860 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value );
863 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha )
865 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha );
868 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
870 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
873 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value )
875 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value );
878 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha )
880 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha );
883 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
885 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
888 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value )
890 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value );
893 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha)
895 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha );
898 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
900 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
902 public: // For connecting animators to animations
905 * Add an animator connector.
906 * @param[in] connector The animator connector.
908 void AddAnimatorConnector( AnimatorConnectorBase* connector );
911 * Retrieve the SceneGraph::Animation object.
912 * @return The animation.
914 const SceneGraph::Animation* GetSceneObject()
920 * Retrieve the UpdateManager associated with this animation.
921 * @return The UpdateManager.
923 SceneGraph::UpdateManager& GetUpdateManager()
925 return mUpdateManager;
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.
939 Animation( SceneGraph::UpdateManager& updateManager,
940 AnimationPlaylist& playlist,
941 float durationSeconds,
943 EndAction destroyAction,
944 AlphaFunction defaultAlpha);
947 * Second-phase constructor.
952 * Helper to create a scene-graph animation
954 void CreateSceneObject();
957 * Helper to create a scene-graph animation
959 void DestroySceneObject();
962 * A reference counted object may only be deleted by calling Unreference()
964 virtual ~Animation();
969 Animation(const Animation&);
972 Animation& operator=(const Animation& rhs);
976 SceneGraph::UpdateManager& mUpdateManager;
977 AnimationPlaylist& mPlaylist;
979 const SceneGraph::Animation* mAnimation;
981 int mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
983 Dali::Animation::AnimationSignalV2 mFinishedSignal;
985 FinishedCallback mFinishedCallback;
986 Object* mFinishedCallbackObject;
988 AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
990 // Cached for public getters
991 float mDurationSeconds;
993 EndAction mEndAction;
994 EndAction mDestroyAction;
995 AlphaFunction mDefaultAlpha;
999 } // namespace Internal
1001 // Helpers for public-api forwarding methods
1003 inline Internal::Animation& GetImplementation(Dali::Animation& animation)
1005 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1007 BaseObject& handle = animation.GetBaseObject();
1009 return static_cast<Internal::Animation&>(handle);
1012 inline const Internal::Animation& GetImplementation(const Dali::Animation& animation)
1014 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1016 const BaseObject& handle = animation.GetBaseObject();
1018 return static_cast<const Internal::Animation&>(handle);
1023 #endif // __DALI_INTERNAL_ANIMATION_H__