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 * Pause the animation.
170 * Stop the animation.
175 * Clear the animation.
176 * This disconnects any objects that were being animated, effectively stopping the animation.
181 * Query whether a Finished signal should be emitted for this animation.
182 * This should only be called by NotificationManager, before signals are emitted.
183 * @post HasFinished() will return false on subsequent calls, until the animation is replayed to completion.
188 * @copydoc Dali::Animation::FinishedSignal()
190 Dali::Animation::AnimationSignalV2& FinishedSignal();
193 * Emit the Finished signal
195 void EmitSignalFinish();
198 * Connects a callback function with the object's signals.
199 * @param[in] object The object providing the signal.
200 * @param[in] tracker Used to disconnect the signal.
201 * @param[in] signalName The signal to connect to.
202 * @param[in] functor A newly allocated FunctorDelegate.
203 * @return True if the signal was connected.
204 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
206 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
209 * Performs actions as requested using the action name.
210 * @param[in] object The object on which to perform the action.
211 * @param[in] actionName The action to perform.
212 * @param[in] attributes The attributes with which to perfrom this action.
213 * @return true if action was done
215 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
218 * This callback is intended for internal use only, to avoid the overhead of using a signal.
219 * @param[in] callback The callback function to connect.
220 * @param[in] object The internal object requesting the callback, or NULL.
222 void SetFinishedCallback( FinishedCallback callback, Object* object );
225 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue)
227 void AnimateBy(Property& target, Property::Value& relativeValue);
230 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
232 void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha);
235 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
237 void AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period);
240 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
242 void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period);
245 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue)
247 void AnimateTo(Property& target, Property::Value& destinationValue);
250 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
252 void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha);
255 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
257 void AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period);
260 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
262 void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
265 * Animate a property to a destination value.
266 * @param [in] targetObject The target object to animate.
267 * @param [in] targetPropertyIndex The index of the target property.
268 * @param [in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4
269 * @param [in] destinationValue The destination value.
270 * @param [in] alpha The alpha function to apply.
271 * @param [in] period The effect will occur during this time period.
273 void AnimateTo(ProxyObject& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
277 * Animate a property between the keyframe time / value pairs.
278 * It uses the current duration of the animation to run the key
279 * frame animator. Note, If the animation duration is subsequently
280 * changed, this does not change to match.
282 * @param[in] target The target object + property to animate
283 * @param[in] keyFrames The set of time / value pairs between which to animate.
285 void AnimateBetween(Property target, const KeyFrames& keyFrames);
288 * Animate a property between the keyframe time / value pairs.
289 * @param[in] target The target object + property to animate
290 * @param[in] keyFrames The set of time / value pairs between which to animate.
291 * @param[in] period The effect will occur duing this time period.
293 void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period);
296 * Animate a property between the keyframe time / value pairs.
297 * @param[in] target The target object + property to animate
298 * @param[in] keyFrames The set of time / value pairs between which to animate.
299 * @param[in] alpha The alpha function to apply to the overall progress.
301 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha);
304 * Animate a property between the keyframe time / value pairs.
305 * @param[in] target The target object + property to animate
306 * @param[in] keyFrames The set of time / value pairs between which to animate.
307 * @param[in] alpha The alpha function to apply to the overall progress.
308 * @param[in] period The effect will occur duing this time period.
310 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
313 * @copydoc Dali::Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
315 void Animate( Property& target, Property::Type targetType, AnyFunction& func );
318 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
320 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha );
323 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, TimePeriod period)
325 void Animate( Property& target, Property::Type targetType, AnyFunction& func, TimePeriod period );
328 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period)
330 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha, TimePeriod period );
332 // Action-specific convenience functions
335 * Translate an actor.
336 * The default alpha function will be used.
337 * The translation will start & end when the animation begins & ends.
338 * @param [in] actor The actor to animate.
339 * @param [in] x Translation in the X-direction.
340 * @param [in] y Translation in the Y-direction.
341 * @param [in] z Translation in the Z-direction.
343 void MoveBy(Actor& actor, float x, float y, float z);
346 * Translate an actor. This overload allows the alpha function to be customized.
347 * The translation will start & end when the animation begins & ends.
348 * @param [in] actor The actor to animate.
349 * @param [in] translation The translation.
350 * @param [in] alpha The alpha function to apply.
352 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha);
355 * Translate an actor. This overload allows the translation start & end time to be customized.
356 * @pre delaySeconds must be zero or greater.
357 * @pre durationSeconds must be greater than zero.
358 * @param [in] actor The actor to animate.
359 * @param [in] translation The translation.
360 * @param [in] alpha The alpha function to apply.
361 * @param [in] delaySeconds The initial delay from the start of the animation.
362 * @param [in] durationSeconds The duration of the translation.
364 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
367 * Translate an actor to a target position.
368 * The default alpha function will be used.
369 * The translation will start & end when the animation begins & ends.
370 * @param [in] actor The actor to animate.
371 * @param [in] x Translation in the X-direction.
372 * @param [in] y Translation in the Y-direction.
373 * @param [in] z Translation in the Z-direction.
375 void MoveTo(Actor& actor, float x, float y, float z);
378 * Translate an actor to a target position. This overload allows the alpha function to be customized.
379 * The translation will start & end when the animation begins & ends.
380 * @param [in] actor The actor to animate.
381 * @param [in] translation The translation.
382 * @param [in] alpha The alpha function to apply.
384 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha);
387 * Translate an actor to a target position. This overload allows the translation start & end time to be customized.
388 * @pre delaySeconds must be zero or greater.
389 * @pre durationSeconds must be greater than zero.
390 * @param [in] actor The actor to animate.
391 * @param [in] translation The translation.
392 * @param [in] alpha The alpha function to apply.
393 * @param [in] delaySeconds The initial delay from the start of the animation.
394 * @param [in] durationSeconds The duration of the translation.
396 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
399 * Translate an actor using a custom function.
400 * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
401 * @pre delaySeconds must be zero or greater.
402 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
403 * @param [in] actor The actor to animate.
404 * @param [in] func The function to call during the animation.
405 * @param [in] alpha The alpha function to apply.
406 * @param [in] delaySeconds The initial delay from the start of the animation.
407 * @param [in] durationSeconds The duration of the translation.
409 void Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
412 * Rotate an actor around an arbitrary axis.
413 * The default alpha function will be used.
414 * The rotation will start & end when the animation begins & ends.
415 * @param [in] actor The actor to animate.
416 * @param [in] angle The angle in radians.
417 * @param [in] axis The axis of rotation.
419 void RotateBy(Actor& actor, Radian angle, const Vector3& axis);
422 * Rotate an actor around an arbitrary axis. This overload allows the alpha function to be customized.
423 * The rotation will start & end when the animation begins & ends.
424 * @param [in] actor The actor to animate.
425 * @param [in] angle The angle in radians.
426 * @param [in] axis The axis of rotation.
427 * @param [in] alpha The alpha function to apply.
429 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
432 * Rotate an actor around an arbitrary axis. This overload allows the rotation start & end time to be customized.
433 * @pre delaySeconds must be zero or greater.
434 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
435 * @param [in] actor The actor to animate.
436 * @param [in] angle The angle in radians.
437 * @param [in] axis The axis of rotation.
438 * @param [in] alpha The alpha function to apply.
439 * @param [in] delaySeconds The initial delay from the start of the animation.
440 * @param [in] durationSeconds The duration of the rotation.
442 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
445 * Rotate an actor to a target orientation.
446 * The default alpha function will be used.
447 * The rotation will start & end when the animation begins & ends.
448 * @param [in] actor The actor to animate.
449 * @param [in] angle The target rotation angle in radians.
450 * @param [in] axis The target axis of rotation.
452 void RotateTo(Actor& actor, Radian angle, const Vector3& axis);
455 * Rotate an actor to a target orientation.
456 * The default alpha function will be used.
457 * The rotation will start & end when the animation begins & ends.
458 * @param [in] actor The actor to animate.
459 * @param [in] orientation The target orientation.
461 void RotateTo(Actor& actor, const Quaternion& orientation);
464 * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
465 * The rotation will start & end when the animation begins & ends.
466 * @param [in] actor The actor to animate.
467 * @param [in] angle The target rotation angle in radians.
468 * @param [in] axis The target axis of rotation.
469 * @param [in] alpha The alpha function to apply.
471 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
474 * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
475 * The rotation will start & end when the animation begins & ends.
476 * @param [in] actor The actor to animate.
477 * @param [in] orientation The target orientation.
478 * @param [in] alpha The alpha function to apply.
480 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha);
483 * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
484 * @pre delaySeconds must be zero or greater.
485 * @pre durationSeconds must be greater than zero.
486 * @param [in] actor The actor to animate.
487 * @param [in] orientation The target orientation.
488 * @param [in] alpha The alpha function to apply.
489 * @param [in] delaySeconds The initial delay from the start of the animation.
490 * @param [in] durationSeconds The duration of the rotation.
492 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
495 * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
496 * @pre delaySeconds must be zero or greater.
497 * @pre durationSeconds must be greater than zero.
498 * @param [in] actor The actor to animate.
499 * @param [in] angle The target rotation angle in radians.
500 * @param [in] axis The target axis of rotation.
501 * @param [in] alpha The alpha function to apply.
502 * @param [in] delaySeconds The initial delay from the start of the animation.
503 * @param [in] durationSeconds The duration of the rotation.
505 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
508 * Rotate an actor using a custom function.
509 * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
510 * @pre delaySeconds must be zero or greater.
511 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
512 * @param [in] actor The actor to animate.
513 * @param [in] func The function to call during the animation.
514 * @param [in] alpha The alpha function to apply.
515 * @param [in] delaySeconds The initial delay from the start of the animation.
516 * @param [in] durationSeconds The duration of the translation.
518 void Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
522 * The default alpha function will be used.
523 * The scaling will start & end when the animation begins & ends.
524 * @param [in] actor The actor to animate.
525 * @param [in] x Scale factor in the X-direction.
526 * @param [in] y Scale factor in the Y-direction.
527 * @param [in] z Scale factor in the Z-direction.
529 void ScaleBy(Actor& actor, float x, float y, float z);
532 * Scale an actor. This overload allows the alpha function to be customized.
533 * The scaling will start & end when the animation begins & ends.
534 * @param [in] actor The actor to animate.
535 * @param [in] scale The scale factor.
536 * @param [in] alpha The alpha function to apply.
538 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha);
541 * Scale an actor. This overload allows the translation start & end time to be customized.
542 * @pre delaySeconds must be zero or greater.
543 * @pre durationSeconds must be greater than zero.
544 * @param [in] actor The actor to animate.
545 * @param [in] scale The scale factor.
546 * @param [in] alpha The alpha function to apply.
547 * @param [in] delaySeconds The initial delay from the start of the animation.
548 * @param [in] durationSeconds The duration of the translation.
550 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
553 * Scale an actor to a target scale factor.
554 * The default alpha function will be used.
555 * The scaling will start & end when the animation begins & ends.
556 * @param [in] actor The actor to animate.
557 * @param [in] x Target scale-factor in the X-direction.
558 * @param [in] y Target scale-factor in the Y-direction.
559 * @param [in] z Target scale-factor in the Z-direction.
561 void ScaleTo(Actor& actor, float x, float y, float z);
564 * Scale an actor to a target scale factor. This overload allows the alpha function to be customized.
565 * The scaling will start & end when the animation begins & ends.
566 * @param [in] actor The actor to animate.
567 * @param [in] scale The target scale factor.
568 * @param [in] alpha The alpha function to apply.
570 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha);
573 * Scale an actor to a target scale factor. This overload allows the translation start & end time to be customized.
574 * @pre delaySeconds must be zero or greater.
575 * @pre durationSeconds must be greater than zero.
576 * @param [in] actor The actor to animate.
577 * @param [in] scale The target scale factor.
578 * @param [in] alpha The alpha function to apply.
579 * @param [in] delaySeconds The initial delay from the start of the animation.
580 * @param [in] durationSeconds The duration of the translation.
582 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
585 * Show an actor during the animation.
586 * @param [in] actor The actor to animate.
587 * @param [in] delaySeconds The initial delay from the start of the animation.
589 void Show(Actor& actor, float delaySeconds);
592 * Hide an actor during the animation.
593 * @param [in] actor The actor to animate.
594 * @param [in] delaySeconds The initial delay from the start of the animation.
596 void Hide(Actor& actor, float delaySeconds);
599 * Animate the opacity of an actor.
600 * The default alpha function will be used.
601 * The effect will start & end when the animation begins & ends.
602 * @param [in] actor The actor to animate.
603 * @param [in] opacity The relative change in opacity.
605 void OpacityBy(Actor& actor, float opacity);
608 * Animate the opacity of an actor. This overload allows the alpha function to be customized.
609 * The effect will start & end when the animation begins & ends.
610 * @param [in] actor The actor to animate.
611 * @param [in] opacity The relative change in opacity.
612 * @param [in] alpha The alpha function to apply.
614 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha);
617 * Animate the opacity of an actor. This overload allows the translation start & end time to be customized.
618 * @pre delaySeconds must be zero or greater.
619 * @pre durationSeconds must be greater than zero.
620 * @param [in] actor The actor to animate.
621 * @param [in] opacity The relative change in opacity.
622 * @param [in] alpha The alpha function to apply.
623 * @param [in] delaySeconds The initial delay from the start of the animation.
624 * @param [in] durationSeconds The duration of the translation.
626 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
629 * Animate an actor to a target opacity.
630 * The default alpha function will be used.
631 * The effect will start & end when the animation begins & ends.
632 * @param [in] actor The actor to animate.
633 * @param [in] opacity The target opacity.
635 void OpacityTo(Actor& actor, float opacity);
638 * Animate an actor to a target opacity. This overload allows the alpha function to be customized.
639 * The effect will start & end when the animation begins & ends.
640 * @param [in] actor The actor to animate.
641 * @param [in] opacity The target opacity.
642 * @param [in] alpha The alpha function to apply.
644 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha);
647 * Animate an actor to a target opacity. This overload allows the translation start & end time to be customized.
648 * @pre delaySeconds must be zero or greater.
649 * @pre durationSeconds must be greater than zero.
650 * @param [in] actor The actor to animate.
651 * @param [in] opacity The target opacity.
652 * @param [in] alpha The alpha function to apply.
653 * @param [in] delaySeconds The initial delay from the start of the animation.
654 * @param [in] durationSeconds The duration of the translation.
656 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
659 * Animate the color of an actor.
660 * The default alpha function will be used.
661 * The effect will start & end when the animation begins & ends.
662 * @param [in] actor The actor to animate.
663 * @param [in] color The relative change in color.
665 void ColorBy(Actor& actor, const Vector4& color);
668 * Animate the color of an actor. This overload allows the alpha function to be customized.
669 * The effect will start & end when the animation begins & ends.
670 * @param [in] actor The actor to animate.
671 * @param [in] color The relative change in color.
672 * @param [in] alpha The alpha function to apply.
674 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha);
677 * Animate the color of an actor. This overload allows the translation start & end time to be customized.
678 * @pre delaySeconds must be zero or greater.
679 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
680 * @param [in] actor The actor to animate.
681 * @param [in] color The relative change in color.
682 * @param [in] alpha The alpha function to apply.
683 * @param [in] delaySeconds The initial delay from the start of the animation.
684 * @param [in] durationSeconds The duration of the translation.
686 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
689 * Animate an actor to a target color.
690 * The default alpha function will be used.
691 * The effect will start & end when the animation begins & ends.
692 * @param [in] actor The actor to animate.
693 * @param [in] color The target color.
695 void ColorTo(Actor& actor, const Vector4& color);
698 * Animate an actor to a target color. This overload allows the alpha function to be customized.
699 * The effect will start & end when the animation begins & ends.
700 * @param [in] actor The actor to animate.
701 * @param [in] color The target color.
702 * @param [in] alpha The alpha function to apply.
704 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha);
707 * Animate an actor to a target color. This overload allows the translation start & end time to be customized.
708 * @pre delaySeconds must be zero or greater.
709 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
710 * @param [in] actor The actor to animate.
711 * @param [in] color The target color.
712 * @param [in] alpha The alpha function to apply.
713 * @param [in] delaySeconds The initial delay from the start of the animation.
714 * @param [in] durationSeconds The duration of the translation.
716 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
720 * The default alpha function will be used.
721 * The resizing will start & end when the animation begins & ends.
722 * The depth defaults to the minimum of width & height.
723 * @param [in] actor The actor to animate.
724 * @param [in] width The target width.
725 * @param [in] height The target height.
727 void Resize(Actor& actor, float width, float height);
730 * Resize an actor. This overload allows the alpha function to be customized.
731 * The resizing will start & end when the animation begins & ends.
732 * The depth defaults to the minimum of width & height.
733 * @param [in] actor The actor to animate.
734 * @param [in] width The target width.
735 * @param [in] height The target height.
736 * @param [in] alpha The alpha function to apply.
738 void Resize(Actor& actor, float width, float height, AlphaFunction alpha);
741 * Resize an actor. This overload allows the resizing start & end time to be customized.
742 * The depth defaults to the minimum of width & height.
743 * @pre delaySeconds must be zero or greater.
744 * @pre durationSeconds must be greater than zero.
745 * @param [in] actor The actor to animate.
746 * @param [in] width The target width.
747 * @param [in] height The target height.
748 * @param [in] alpha The alpha function to apply.
749 * @param [in] delaySeconds The initial delay from the start of the animation.
750 * @param [in] durationSeconds The duration of the translation.
752 void Resize(Actor& actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
756 * The default alpha function will be used.
757 * The resizing will start & end when the animation begins & ends.
758 * @param [in] actor The actor to animate.
759 * @param [in] size The target size.
761 void Resize(Actor& actor, const Vector3& size);
764 * Resize an actor. This overload allows the alpha function to be customized.
765 * The resizing will start & end when the animation begins & ends.
766 * @param [in] actor The actor to animate.
767 * @param [in] size The target size.
768 * @param [in] alpha The alpha function to apply.
770 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha);
773 * Resize an actor. This overload allows the resizing start & end time to be customized.
774 * @pre delaySeconds must be zero or greater.
775 * @pre durationSeconds must be greater than zero.
776 * @param [in] actor The actor to animate.
777 * @param [in] size The target size.
778 * @param [in] alpha The alpha function to apply.
779 * @param [in] delaySeconds The initial delay from the start of the animation.
780 * @param [in] durationSeconds The duration of the translation.
782 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
785 * Animate the parent-origin of an actor.
786 * The effect will start & end when the animation begins & ends.
787 * @param [in] actor The actor to animate.
788 * @param [in] parentOrigin The target value.
790 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin);
793 * Animate the parent-origin of an actor.
794 * This overload allows the alpha function to be customized.
795 * The effect will start & end when the animation begins & ends.
796 * @param [in] actor The actor to animate.
797 * @param [in] parentOrigin The target value.
798 * @param [in] alpha The alpha function to apply.
800 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha);
803 * Animate the parent-origin of an actor.
804 * This overload allows the start & end time to be customized.
805 * @pre delaySeconds & durationSeconds must be zero or greater.
806 * @param [in] actor The actor to animate.
807 * @param [in] parentOrigin The target value.
808 * @param [in] alpha The alpha function to apply.
809 * @param [in] delaySeconds The initial delay from the start of the effect.
810 * @param [in] durationSeconds The duration of the effect.
812 void ParentOriginTo(Actor& actor, const Vector3& parentOrigin, AlphaFunction alpha, float delaySeconds, float durationSeconds);
815 * Animate the anchor-point of an actor.
816 * The effect will start & end when the animation begins & ends.
817 * @param [in] actor The actor to animate.
818 * @param [in] anchorPoint The target value.
820 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint);
823 * Animate the anchor-point of an actor.
824 * This overload allows the alpha function to be customized.
825 * The effect will start & end when the animation begins & ends.
826 * @param [in] actor The actor to animate.
827 * @param [in] anchorPoint The target value.
828 * @param [in] alpha The alpha function to apply.
830 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha);
833 * Animate the anchor-point of an actor.
834 * This overload allows the start & end time to be customized.
835 * @pre delaySeconds & durationSeconds must be zero or greater.
836 * @param [in] actor The actor to animate.
837 * @param [in] anchorPoint The target value.
838 * @param [in] alpha The alpha function to apply.
839 * @param [in] delaySeconds The initial delay from the start of the effect.
840 * @param [in] durationSeconds The duration of the effect.
842 void AnchorPointTo(Actor& actor, const Vector3& anchorPoint, AlphaFunction alpha, float delaySeconds, float durationSeconds);
845 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value)
847 void AnimateProperty( Internal::ShaderEffect& shaderEffect, const std::string& name, float value );
850 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha)
852 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha );
855 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
857 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, float value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
860 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value )
862 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value );
865 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha )
867 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha );
870 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
872 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector2 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
875 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value )
877 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value );
880 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha )
882 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha );
885 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds )
887 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector3 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
890 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value )
892 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value );
895 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha)
897 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha );
900 * @copydoc Dali::Animation::AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds)
902 void AnimateProperty( ShaderEffect& shaderEffect, const std::string& name, Vector4 value, AlphaFunction alpha, float delaySeconds, float durationSeconds );
904 public: // For connecting animators to animations
907 * Add an animator connector.
908 * @param[in] connector The animator connector.
910 void AddAnimatorConnector( AnimatorConnectorBase* connector );
913 * Retrieve the SceneGraph::Animation object.
914 * @return The animation.
916 const SceneGraph::Animation* GetSceneObject()
922 * Retrieve the UpdateManager associated with this animation.
923 * @return The UpdateManager.
925 SceneGraph::UpdateManager& GetUpdateManager()
927 return mUpdateManager;
933 * Construct a new Animation.
934 * @param[in] updateManager The UpdateManager associated with this animation.
935 * @param[in] playlist The list of currently playing animations.
936 * @param[in] durationSeconds The duration of the animation in seconds.
937 * @param[in] endAction The action to perform when the animation ends.
938 * @param[in] destroyAction The action to perform when the animation is destroyed.
939 * @param[in] defaultAlpha The default alpha function to apply to animators.
941 Animation( SceneGraph::UpdateManager& updateManager,
942 AnimationPlaylist& playlist,
943 float durationSeconds,
945 EndAction destroyAction,
946 AlphaFunction defaultAlpha);
949 * Second-phase constructor.
954 * Helper to create a scene-graph animation
956 void CreateSceneObject();
959 * Helper to create a scene-graph animation
961 void DestroySceneObject();
964 * A reference counted object may only be deleted by calling Unreference()
966 virtual ~Animation();
971 Animation(const Animation&);
974 Animation& operator=(const Animation& rhs);
978 SceneGraph::UpdateManager& mUpdateManager;
979 AnimationPlaylist& mPlaylist;
981 const SceneGraph::Animation* mAnimation;
983 int mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
985 Dali::Animation::AnimationSignalV2 mFinishedSignal;
987 FinishedCallback mFinishedCallback;
988 Object* mFinishedCallbackObject;
990 AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
992 // Cached for public getters
993 float mDurationSeconds;
995 EndAction mEndAction;
996 EndAction mDestroyAction;
997 AlphaFunction mDefaultAlpha;
1001 } // namespace Internal
1003 // Helpers for public-api forwarding methods
1005 inline Internal::Animation& GetImplementation(Dali::Animation& animation)
1007 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1009 BaseObject& handle = animation.GetBaseObject();
1011 return static_cast<Internal::Animation&>(handle);
1014 inline const Internal::Animation& GetImplementation(const Dali::Animation& animation)
1016 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
1018 const BaseObject& handle = animation.GetBaseObject();
1020 return static_cast<const Internal::Animation&>(handle);
1025 #endif // __DALI_INTERNAL_ANIMATION_H__