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 * Set the duration of an animation.
76 * @pre durationSeconds must be greater than zero.
77 * @param[in] seconds The duration in seconds.
79 void SetDuration(float seconds);
82 * Retrieve the duration of an animation.
83 * @return The duration in seconds.
85 float GetDuration() const;
88 * Set whether the animation will loop.
89 * @param[in] looping True if the animation will loop.
91 void SetLooping(bool looping);
94 * Query whether the animation will loop.
95 * @return True if the animation will loop.
97 bool IsLooping() const;
100 * Set the end action of the animation.
101 * @param[in] action The end action.
103 void SetEndAction(EndAction action);
106 * Returns the end action of the animation.
108 EndAction GetEndAction() const;
111 * Set the disconnect action of the animation.
112 * @param[in] action The disconnect action.
114 void SetDisconnectAction(EndAction action);
117 * Returns the disconnect action of the animation.
119 EndAction GetDisconnectAction() const;
122 * Set the default alpha function for an animation.
123 * This is applied to individual property animations, if no further alpha functions are supplied.
124 * @param[in] alpha The default alpha function.
126 void SetDefaultAlphaFunction(AlphaFunction alpha)
128 mDefaultAlpha = alpha;
132 * Retrieve the default alpha function for an animation.
133 * @return The default alpha function.
135 AlphaFunction GetDefaultAlphaFunction() const
137 return mDefaultAlpha;
141 * (Re)start the animation.
146 * (Re)start the animation from a given point.
147 * @param[in] progress The progress between [0,1] from where the animation should start
149 void PlayFrom( float progress );
152 * Pause the animation.
157 * Stop the animation.
162 * Clear the animation.
163 * This disconnects any objects that were being animated, effectively stopping the animation.
168 * Query whether a Finished signal should be emitted for this animation.
169 * This should only be called by NotificationManager, before signals are emitted.
170 * @post HasFinished() will return false on subsequent calls, until the animation is replayed to completion.
175 * @copydoc Dali::Animation::FinishedSignal()
177 Dali::Animation::AnimationSignalV2& FinishedSignal();
180 * Emit the Finished signal
182 void EmitSignalFinish();
185 * Connects a callback function with the object's signals.
186 * @param[in] object The object providing the signal.
187 * @param[in] tracker Used to disconnect the signal.
188 * @param[in] signalName The signal to connect to.
189 * @param[in] functor A newly allocated FunctorDelegate.
190 * @return True if the signal was connected.
191 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
193 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
196 * Performs actions as requested using the action name.
197 * @param[in] object The object on which to perform the action.
198 * @param[in] actionName The action to perform.
199 * @param[in] attributes The attributes with which to perfrom this action.
200 * @return true if action was done
202 static bool DoAction(BaseObject* object, const std::string& actionName, const std::vector<Property::Value>& attributes);
205 * This callback is intended for internal use only, to avoid the overhead of using a signal.
206 * @param[in] callback The callback function to connect.
207 * @param[in] object The internal object requesting the callback, or NULL.
209 void SetFinishedCallback( FinishedCallback callback, Object* object );
212 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue)
214 void AnimateBy(Property& target, Property::Value& relativeValue);
217 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha)
219 void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha);
222 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, TimePeriod period)
224 void AnimateBy(Property& target, Property::Value& relativeValue, TimePeriod period);
227 * @copydoc Dali::Animation::AnimateBy(Property target, Property::Value relativeValue, AlphaFunction alpha, TimePeriod period)
229 void AnimateBy(Property& target, Property::Value& relativeValue, AlphaFunction alpha, TimePeriod period);
232 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue)
234 void AnimateTo(Property& target, Property::Value& destinationValue);
237 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha)
239 void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha);
242 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, TimePeriod period)
244 void AnimateTo(Property& target, Property::Value& destinationValue, TimePeriod period);
247 * @copydoc Dali::Animation::AnimateTo(Property target, Property::Value destinationValue, AlphaFunction alpha, TimePeriod period)
249 void AnimateTo(Property& target, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
252 * Animate a property to a destination value.
253 * @param [in] targetObject The target object to animate.
254 * @param [in] targetPropertyIndex The index of the target property.
255 * @param [in] componentIndex Index to a sub component of a property, for use with Vector2, Vector3 and Vector4
256 * @param [in] destinationValue The destination value.
257 * @param [in] alpha The alpha function to apply.
258 * @param [in] period The effect will occur during this time period.
260 void AnimateTo(ProxyObject& targetObject, Property::Index targetPropertyIndex, int componentIndex, Property::Value& destinationValue, AlphaFunction alpha, TimePeriod period);
264 * Animate a property between the keyframe time / value pairs.
265 * It uses the current duration of the animation to run the key
266 * frame animator. Note, If the animation duration is subsequently
267 * changed, this does not change to match.
269 * @param[in] target The target object + property to animate
270 * @param[in] keyFrames The set of time / value pairs between which to animate.
272 void AnimateBetween(Property target, const KeyFrames& keyFrames);
275 * Animate a property between the keyframe time / value pairs.
276 * @param[in] target The target object + property to animate
277 * @param[in] keyFrames The set of time / value pairs between which to animate.
278 * @param[in] period The effect will occur duing this time period.
280 void AnimateBetween(Property target, const KeyFrames& keyFrames, TimePeriod period);
283 * Animate a property between the keyframe time / value pairs.
284 * @param[in] target The target object + property to animate
285 * @param[in] keyFrames The set of time / value pairs between which to animate.
286 * @param[in] alpha The alpha function to apply to the overall progress.
288 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha);
291 * Animate a property between the keyframe time / value pairs.
292 * @param[in] target The target object + property to animate
293 * @param[in] keyFrames The set of time / value pairs between which to animate.
294 * @param[in] alpha The alpha function to apply to the overall progress.
295 * @param[in] period The effect will occur duing this time period.
297 void AnimateBetween(Property target, const KeyFrames& keyFrames, AlphaFunction alpha, TimePeriod period);
300 * @copydoc Dali::Animation::Animate( Property target, Property::Type targetType, AnyFunction func )
302 void Animate( Property& target, Property::Type targetType, AnyFunction& func );
305 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha )
307 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha );
310 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, TimePeriod period)
312 void Animate( Property& target, Property::Type targetType, AnyFunction& func, TimePeriod period );
315 * @copydoc Dali::Animation::Animate(Property target, Property::Type targetType, AnyFunction func, AlphaFunction alpha, TimePeriod period)
317 void Animate( Property& target, Property::Type targetType, AnyFunction& func, AlphaFunction& alpha, TimePeriod period );
319 // Action-specific convenience functions
322 * Translate an actor.
323 * The default alpha function will be used.
324 * The translation will start & end when the animation begins & ends.
325 * @param [in] actor The actor to animate.
326 * @param [in] x Translation in the X-direction.
327 * @param [in] y Translation in the Y-direction.
328 * @param [in] z Translation in the Z-direction.
330 void MoveBy(Actor& actor, float x, float y, float z);
333 * Translate an actor. This overload allows the alpha function to be customized.
334 * The translation will start & end when the animation begins & ends.
335 * @param [in] actor The actor to animate.
336 * @param [in] translation The translation.
337 * @param [in] alpha The alpha function to apply.
339 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha);
342 * Translate an actor. This overload allows the translation start & end time to be customized.
343 * @pre delaySeconds must be zero or greater.
344 * @pre durationSeconds must be greater than zero.
345 * @param [in] actor The actor to animate.
346 * @param [in] translation The translation.
347 * @param [in] alpha The alpha function to apply.
348 * @param [in] delaySeconds The initial delay from the start of the animation.
349 * @param [in] durationSeconds The duration of the translation.
351 void MoveBy(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
354 * Translate an actor to a target position.
355 * The default alpha function will be used.
356 * The translation will start & end when the animation begins & ends.
357 * @param [in] actor The actor to animate.
358 * @param [in] x Translation in the X-direction.
359 * @param [in] y Translation in the Y-direction.
360 * @param [in] z Translation in the Z-direction.
362 void MoveTo(Actor& actor, float x, float y, float z);
365 * Translate an actor to a target position. This overload allows the alpha function to be customized.
366 * The translation will start & end when the animation begins & ends.
367 * @param [in] actor The actor to animate.
368 * @param [in] translation The translation.
369 * @param [in] alpha The alpha function to apply.
371 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha);
374 * Translate an actor to a target position. This overload allows the translation start & end time to be customized.
375 * @pre delaySeconds must be zero or greater.
376 * @pre durationSeconds must be greater than zero.
377 * @param [in] actor The actor to animate.
378 * @param [in] translation The translation.
379 * @param [in] alpha The alpha function to apply.
380 * @param [in] delaySeconds The initial delay from the start of the animation.
381 * @param [in] durationSeconds The duration of the translation.
383 void MoveTo(Actor& actor, const Vector3& translation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
386 * Translate an actor using a custom function.
387 * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
388 * @pre delaySeconds must be zero or greater.
389 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
390 * @param [in] actor The actor to animate.
391 * @param [in] func The function to call during the animation.
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 Move(Actor& actor, AnimatorFunctionVector3 func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
399 * Rotate an actor around an arbitrary axis.
400 * The default alpha function will be used.
401 * The rotation will start & end when the animation begins & ends.
402 * @param [in] actor The actor to animate.
403 * @param [in] angle The angle in radians.
404 * @param [in] axis The axis of rotation.
406 void RotateBy(Actor& actor, Radian angle, const Vector3& axis);
409 * Rotate an actor around an arbitrary axis. This overload allows the alpha function to be customized.
410 * The rotation will start & end when the animation begins & ends.
411 * @param [in] actor The actor to animate.
412 * @param [in] angle The angle in radians.
413 * @param [in] axis The axis of rotation.
414 * @param [in] alpha The alpha function to apply.
416 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
419 * Rotate an actor around an arbitrary axis. This overload allows the rotation start & end time to be customized.
420 * @pre delaySeconds must be zero or greater.
421 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
422 * @param [in] actor The actor to animate.
423 * @param [in] angle The angle in radians.
424 * @param [in] axis The axis of rotation.
425 * @param [in] alpha The alpha function to apply.
426 * @param [in] delaySeconds The initial delay from the start of the animation.
427 * @param [in] durationSeconds The duration of the rotation.
429 void RotateBy(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
432 * Rotate an actor to a target orientation.
433 * The default alpha function will be used.
434 * The rotation will start & end when the animation begins & ends.
435 * @param [in] actor The actor to animate.
436 * @param [in] angle The target rotation angle in radians.
437 * @param [in] axis The target axis of rotation.
439 void RotateTo(Actor& actor, Radian angle, const Vector3& axis);
442 * Rotate an actor to a target orientation.
443 * The default alpha function will be used.
444 * The rotation will start & end when the animation begins & ends.
445 * @param [in] actor The actor to animate.
446 * @param [in] orientation The target orientation.
448 void RotateTo(Actor& actor, const Quaternion& orientation);
451 * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
452 * The rotation will start & end when the animation begins & ends.
453 * @param [in] actor The actor to animate.
454 * @param [in] angle The target rotation angle in radians.
455 * @param [in] axis The target axis of rotation.
456 * @param [in] alpha The alpha function to apply.
458 void RotateTo(Actor& actor, Radian angle, const Vector3& axis, AlphaFunction alpha);
461 * Rotate an actor to a target orientation. This overload allows the alpha function to be customized.
462 * The rotation will start & end when the animation begins & ends.
463 * @param [in] actor The actor to animate.
464 * @param [in] orientation The target orientation.
465 * @param [in] alpha The alpha function to apply.
467 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha);
470 * Rotate an actor to a target orientation. This overload allows the rotation start & end time to be customized.
471 * @pre delaySeconds must be zero or greater.
472 * @pre durationSeconds must be greater than zero.
473 * @param [in] actor The actor to animate.
474 * @param [in] orientation The target orientation.
475 * @param [in] alpha The alpha function to apply.
476 * @param [in] delaySeconds The initial delay from the start of the animation.
477 * @param [in] durationSeconds The duration of the rotation.
479 void RotateTo(Actor& actor, const Quaternion& orientation, AlphaFunction alpha, float delaySeconds, float durationSeconds);
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] angle The target rotation angle in radians.
487 * @param [in] axis The target axis of rotation.
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, Radian angle, const Vector3& axis, AlphaFunction alpha, float delaySeconds, float durationSeconds);
495 * Rotate an actor using a custom function.
496 * The animatorFunc will be called from the rendering thread; it should return quickly, to avoid performance degredation.
497 * @pre delaySeconds must be zero or greater.
498 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
499 * @param [in] actor The actor to animate.
500 * @param [in] func The function to call during the animation.
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 translation.
505 void Rotate(Actor& actor, AnimatorFunctionQuaternion func, AlphaFunction alpha, float delaySeconds, float durationSeconds);
509 * The default alpha function will be used.
510 * The scaling will start & end when the animation begins & ends.
511 * @param [in] actor The actor to animate.
512 * @param [in] x Scale factor in the X-direction.
513 * @param [in] y Scale factor in the Y-direction.
514 * @param [in] z Scale factor in the Z-direction.
516 void ScaleBy(Actor& actor, float x, float y, float z);
519 * Scale an actor. This overload allows the alpha function to be customized.
520 * The scaling will start & end when the animation begins & ends.
521 * @param [in] actor The actor to animate.
522 * @param [in] scale The scale factor.
523 * @param [in] alpha The alpha function to apply.
525 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha);
528 * Scale an actor. This overload allows the translation start & end time to be customized.
529 * @pre delaySeconds must be zero or greater.
530 * @pre durationSeconds must be greater than zero.
531 * @param [in] actor The actor to animate.
532 * @param [in] scale The scale factor.
533 * @param [in] alpha The alpha function to apply.
534 * @param [in] delaySeconds The initial delay from the start of the animation.
535 * @param [in] durationSeconds The duration of the translation.
537 void ScaleBy(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
540 * Scale an actor to a target scale factor.
541 * The default alpha function will be used.
542 * The scaling will start & end when the animation begins & ends.
543 * @param [in] actor The actor to animate.
544 * @param [in] x Target scale-factor in the X-direction.
545 * @param [in] y Target scale-factor in the Y-direction.
546 * @param [in] z Target scale-factor in the Z-direction.
548 void ScaleTo(Actor& actor, float x, float y, float z);
551 * Scale an actor to a target scale factor. This overload allows the alpha function to be customized.
552 * The scaling will start & end when the animation begins & ends.
553 * @param [in] actor The actor to animate.
554 * @param [in] scale The target scale factor.
555 * @param [in] alpha The alpha function to apply.
557 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha);
560 * Scale an actor to a target scale factor. This overload allows the translation start & end time to be customized.
561 * @pre delaySeconds must be zero or greater.
562 * @pre durationSeconds must be greater than zero.
563 * @param [in] actor The actor to animate.
564 * @param [in] scale The target scale factor.
565 * @param [in] alpha The alpha function to apply.
566 * @param [in] delaySeconds The initial delay from the start of the animation.
567 * @param [in] durationSeconds The duration of the translation.
569 void ScaleTo(Actor& actor, const Vector3& scale, AlphaFunction alpha, float delaySeconds, float durationSeconds);
572 * Show an actor during the animation.
573 * @param [in] actor The actor to animate.
574 * @param [in] delaySeconds The initial delay from the start of the animation.
576 void Show(Actor& actor, float delaySeconds);
579 * Hide an actor during the animation.
580 * @param [in] actor The actor to animate.
581 * @param [in] delaySeconds The initial delay from the start of the animation.
583 void Hide(Actor& actor, float delaySeconds);
586 * Animate the opacity of an actor.
587 * The default alpha function will be used.
588 * The effect will start & end when the animation begins & ends.
589 * @param [in] actor The actor to animate.
590 * @param [in] opacity The relative change in opacity.
592 void OpacityBy(Actor& actor, float opacity);
595 * Animate the opacity of an actor. This overload allows the alpha function to be customized.
596 * The effect will start & end when the animation begins & ends.
597 * @param [in] actor The actor to animate.
598 * @param [in] opacity The relative change in opacity.
599 * @param [in] alpha The alpha function to apply.
601 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha);
604 * Animate the opacity of an actor. This overload allows the translation start & end time to be customized.
605 * @pre delaySeconds must be zero or greater.
606 * @pre durationSeconds must be greater than zero.
607 * @param [in] actor The actor to animate.
608 * @param [in] opacity The relative change in opacity.
609 * @param [in] alpha The alpha function to apply.
610 * @param [in] delaySeconds The initial delay from the start of the animation.
611 * @param [in] durationSeconds The duration of the translation.
613 void OpacityBy(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
616 * Animate an actor to a target opacity.
617 * The default alpha function will be used.
618 * The effect will start & end when the animation begins & ends.
619 * @param [in] actor The actor to animate.
620 * @param [in] opacity The target opacity.
622 void OpacityTo(Actor& actor, float opacity);
625 * Animate an actor to a target opacity. This overload allows the alpha function to be customized.
626 * The effect will start & end when the animation begins & ends.
627 * @param [in] actor The actor to animate.
628 * @param [in] opacity The target opacity.
629 * @param [in] alpha The alpha function to apply.
631 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha);
634 * Animate an actor to a target opacity. This overload allows the translation start & end time to be customized.
635 * @pre delaySeconds must be zero or greater.
636 * @pre durationSeconds must be greater than zero.
637 * @param [in] actor The actor to animate.
638 * @param [in] opacity The target opacity.
639 * @param [in] alpha The alpha function to apply.
640 * @param [in] delaySeconds The initial delay from the start of the animation.
641 * @param [in] durationSeconds The duration of the translation.
643 void OpacityTo(Actor& actor, float opacity, AlphaFunction alpha, float delaySeconds, float durationSeconds);
646 * Animate the color of an actor.
647 * The default alpha function will be used.
648 * The effect will start & end when the animation begins & ends.
649 * @param [in] actor The actor to animate.
650 * @param [in] color The relative change in color.
652 void ColorBy(Actor& actor, const Vector4& color);
655 * Animate the color of an actor. This overload allows the alpha function to be customized.
656 * The effect will start & end when the animation begins & ends.
657 * @param [in] actor The actor to animate.
658 * @param [in] color The relative change in color.
659 * @param [in] alpha The alpha function to apply.
661 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha);
664 * Animate the color of an actor. This overload allows the translation start & end time to be customized.
665 * @pre delaySeconds must be zero or greater.
666 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
667 * @param [in] actor The actor to animate.
668 * @param [in] color The relative change in color.
669 * @param [in] alpha The alpha function to apply.
670 * @param [in] delaySeconds The initial delay from the start of the animation.
671 * @param [in] durationSeconds The duration of the translation.
673 void ColorBy(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
676 * Animate an actor to a target color.
677 * The default alpha function will be used.
678 * The effect will start & end when the animation begins & ends.
679 * @param [in] actor The actor to animate.
680 * @param [in] color The target color.
682 void ColorTo(Actor& actor, const Vector4& color);
685 * Animate an actor to a target color. This overload allows the alpha function to be customized.
686 * The effect will start & end when the animation begins & ends.
687 * @param [in] actor The actor to animate.
688 * @param [in] color The target color.
689 * @param [in] alpha The alpha function to apply.
691 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha);
694 * Animate an actor to a target color. This overload allows the translation start & end time to be customized.
695 * @pre delaySeconds must be zero or greater.
696 * @pre durationSeconds must be zero or greater; zero is useful when animating boolean values.
697 * @param [in] actor The actor to animate.
698 * @param [in] color The target color.
699 * @param [in] alpha The alpha function to apply.
700 * @param [in] delaySeconds The initial delay from the start of the animation.
701 * @param [in] durationSeconds The duration of the translation.
703 void ColorTo(Actor& actor, const Vector4& color, AlphaFunction alpha, float delaySeconds, float durationSeconds);
707 * The default alpha function will be used.
708 * The resizing will start & end when the animation begins & ends.
709 * The depth defaults to the minimum of width & height.
710 * @param [in] actor The actor to animate.
711 * @param [in] width The target width.
712 * @param [in] height The target height.
714 void Resize(Actor& actor, float width, float height);
717 * Resize an actor. This overload allows the alpha function to be customized.
718 * The resizing will start & end when the animation begins & ends.
719 * The depth defaults to the minimum of width & height.
720 * @param [in] actor The actor to animate.
721 * @param [in] width The target width.
722 * @param [in] height The target height.
723 * @param [in] alpha The alpha function to apply.
725 void Resize(Actor& actor, float width, float height, AlphaFunction alpha);
728 * Resize an actor. This overload allows the resizing start & end time to be customized.
729 * The depth defaults to the minimum of width & height.
730 * @pre delaySeconds must be zero or greater.
731 * @pre durationSeconds must be greater than zero.
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.
736 * @param [in] delaySeconds The initial delay from the start of the animation.
737 * @param [in] durationSeconds The duration of the translation.
739 void Resize(Actor& actor, float width, float height, AlphaFunction alpha, float delaySeconds, float durationSeconds);
743 * The default alpha function will be used.
744 * The resizing will start & end when the animation begins & ends.
745 * @param [in] actor The actor to animate.
746 * @param [in] size The target size.
748 void Resize(Actor& actor, const Vector3& size);
751 * Resize an actor. This overload allows the alpha function to be customized.
752 * The resizing will start & end when the animation begins & ends.
753 * @param [in] actor The actor to animate.
754 * @param [in] size The target size.
755 * @param [in] alpha The alpha function to apply.
757 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha);
760 * Resize an actor. This overload allows the resizing start & end time to be customized.
761 * @pre delaySeconds must be zero or greater.
762 * @pre durationSeconds must be greater than zero.
763 * @param [in] actor The actor to animate.
764 * @param [in] size The target size.
765 * @param [in] alpha The alpha function to apply.
766 * @param [in] delaySeconds The initial delay from the start of the animation.
767 * @param [in] durationSeconds The duration of the translation.
769 void Resize(Actor& actor, const Vector3& size, AlphaFunction alpha, float delaySeconds, float durationSeconds);
772 * @copydoc Dali::Animation::SetCurrentProgress()
774 void SetCurrentProgress(float progress);
777 * @copydoc Dali::Animation::GetCurrentProgress()
779 float GetCurrentProgress();
782 * @copydoc Dali::Animation::SetSpeedFactor()
784 void SetSpeedFactor( float factor );
787 * @copydoc Dali::Animation::GetSpeedFactor()
789 float GetSpeedFactor() const;
792 * @copydoc Dali::Animation::SetPlayRange()
794 void SetPlayRange( const Vector2& range );
797 * @copydoc Dali::Animation::GetPlayRange
799 Vector2 GetPlayRange() const;
801 public: // For connecting animators to animations
804 * Add an animator connector.
805 * @param[in] connector The animator connector.
807 void AddAnimatorConnector( AnimatorConnectorBase* connector );
810 * Retrieve the SceneGraph::Animation object.
811 * @return The animation.
813 const SceneGraph::Animation* GetSceneObject()
819 * Retrieve the UpdateManager associated with this animation.
820 * @return The UpdateManager.
822 SceneGraph::UpdateManager& GetUpdateManager()
824 return mUpdateManager;
830 * Construct a new Animation.
831 * @param[in] updateManager The UpdateManager associated with this animation.
832 * @param[in] playlist The list of currently playing animations.
833 * @param[in] durationSeconds The duration of the animation in seconds.
834 * @param[in] endAction The action to perform when the animation ends.
835 * @param[in] disconnectAction The action to perform when the property owner of an animator is disconnected.
836 * @param[in] defaultAlpha The default alpha function to apply to animators.
838 Animation( SceneGraph::UpdateManager& updateManager,
839 AnimationPlaylist& playlist,
840 float durationSeconds,
842 EndAction disconnectAction,
843 AlphaFunction defaultAlpha);
846 * Second-phase constructor.
851 * Helper to create a scene-graph animation
853 void CreateSceneObject();
856 * Helper to create a scene-graph animation
858 void DestroySceneObject();
861 * A reference counted object may only be deleted by calling Unreference()
863 virtual ~Animation();
868 * Extends the duration when an animator is added with TimePeriod that exceeds current duration.
869 * @param[in] timePeriod The time period for an animator.
871 void ExtendDuration( const TimePeriod& timePeriod );
874 Animation(const Animation&);
877 Animation& operator=(const Animation& rhs);
881 SceneGraph::UpdateManager& mUpdateManager;
882 AnimationPlaylist& mPlaylist;
884 const SceneGraph::Animation* mAnimation;
886 int mNotificationCount; ///< Keep track of how many Finished signals have been emitted.
888 Dali::Animation::AnimationSignalV2 mFinishedSignal;
890 FinishedCallback mFinishedCallback;
891 Object* mFinishedCallbackObject;
893 AnimatorConnectorContainer mConnectors; ///< Owned by the Animation
895 // Cached for public getters
896 float mDurationSeconds;
900 EndAction mEndAction;
901 EndAction mDisconnectAction;
902 AlphaFunction mDefaultAlpha;
906 } // namespace Internal
908 // Helpers for public-api forwarding methods
910 inline Internal::Animation& GetImplementation(Dali::Animation& animation)
912 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
914 BaseObject& handle = animation.GetBaseObject();
916 return static_cast<Internal::Animation&>(handle);
919 inline const Internal::Animation& GetImplementation(const Dali::Animation& animation)
921 DALI_ASSERT_ALWAYS( animation && "Animation handle is empty" );
923 const BaseObject& handle = animation.GetBaseObject();
925 return static_cast<const Internal::Animation&>(handle);
930 #endif // __DALI_INTERNAL_ANIMATION_H__