2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://floralicense.org/license/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an AS IS BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiAnim_FrameAnimatorImpl.h
20 * @brief This is the header file for the _FrameAnimatorImpl class.
22 * This header file contains the declarations of the _FrameAnimatorImpl class. @n
25 #ifndef _FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_
26 #define _FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_
28 #include <FUiAnimFrameAnimator.h>
29 #include <FUiAnimVisualElementPropertyAnimation.h>
30 #include <FUiAnimIVisualElementAnimationTimingFunction.h>
32 #include "FUiAnim_ControlVisualElement.h"
35 namespace Tizen { namespace Ui { namespace Animations
39 * @class _FrameAnimatorImpl
40 * @brief This class defines the animation API for Container::Frame
43 * The %_FrameAnimatorImpl class is used to control the animations operated on Tizen::Ui::Controls::Container::Frame
46 class _FrameAnimatorImpl
47 : public Tizen::Base::Object
48 , public IAnimationTransactionEventListener
49 , virtual public Tizen::Base::Runtime::IEventListener
53 * Destructor for %_FrameAnimatorImpl class.
57 ~_FrameAnimatorImpl(void);
60 * Default constructor for %_FrameAnimatorImpl class.
64 _FrameAnimatorImpl(FrameAnimator* pFrameAnimator);
67 * Initializes this %_FrameAnimatorImpl class.
71 * @return An error code
72 * @exception E_SUCCESS The method was successful.
73 * @exception E_OUT_OF_MEMORY Insufficient memory.
75 result Construct(const Tizen::Ui::Controls::Frame& source);
78 * Adds framestatusevent listener to list.
82 * @return An error code
83 * @exception E_SUCCESS The method was successful.
84 * @exception E_SYSTEM System error occurred.
86 result AddFrameAnimatorEventListener(IFrameAnimatorEventListener& listener);
89 * Removes framestatusevent listener from list.
93 * @return An error code
94 * @exception E_SUCCESS The method was successful.
95 * @exception E_SYSTEM System error occurred.
96 * @exception E_OBJ_NOT_FOUND Listener object not found in list.
98 result RemoveFrameAnimatorEventListener(IFrameAnimatorEventListener& listener);
101 * Stops all the animations that are currently playing and jumps to the final frame of the animation.
105 * @return An error code
106 * @exception E_SUCCESS The method is successful.
107 * @exception E_SYSTEM A system error has occurred.
109 result StopAllAnimations(void);
112 * Adds the control at the end of the list maintained by the container with animation.
116 * @return An error code
117 * @param[in] control The control to be added to the container
118 * @exception E_SUCCESS The method is successful.
119 * @exception E_INVALID_ARG The specified input parameter is invalid. @n
120 * The specified @c control is an instance of Window, or this control's parent container.
121 * @exception E_OUT_OF_MEMORY The memory is insufficient.
122 * @exception E_MAX_EXCEEDED The number of child controls has exceeded the maximum limit.
123 * @exception E_SYSTEM A system error has occurred.
124 * @remarks When the control is added, it is placed at the top of the drawing stack maintained by the container.@n
125 * This means the last control added is drawn last
126 * @remarks A control becomes displayable only after it has been added to a displayable container. Some methods may not work normally if the methods
127 * of the control are called before adding the control to a container. After the control is added to a %Container, the OnInitializing()
128 * method of the control are called before adding the control to a container. After the control is added to a Container, the
129 * OnInitializing() method of the control is invoked for the initialization of the control such as creating and adding child controls.
130 * @see Tizen::Ui::Control::OnInitializing()
131 * @see Tizen::Ui::Control::OnTerminating()
133 result AddControl(const Tizen::Ui::Control& control);
136 * Sets the current form with animation.
140 * @return An error code
141 * @exception E_SUCCESS The method was successful.
142 * @exception E_INVALID_ARG A specified input parameter is invalid.
143 * @exception E_INVALID_STATE This instance has already been constructed.
144 * @exception E_OUT_OF_MEMORY Insufficient memory.
145 * @exception E_SYSTEM System error occurred.
147 result SetCurrentForm(const Tizen::Ui::Controls::Form& form);
151 * returns whether animation supported by underlying platform or not
155 * @return An error code
156 * @remarks %This function returns whether animation is supported or not. @n
157 * If @c true, animation supported. @n
158 * If @c false, animation not supported.
160 bool IsAnimationSupported(void) const;
164 * This Callback is called when an animation is started.
168 virtual void OnAnimationTransactionStarted(int transactionId);
172 * This Callback is called when an animation ends.
176 virtual void OnAnimationTransactionStopped(int transactionId);
180 * This Callback is called when an animation ends.
184 virtual void OnAnimationTransactionFinished(int transactionId);
188 * This Callback is called when an animation is started.
192 void OnFrameAnimationStarted(void);
196 * This Callback is called when an animation ends.
200 void OnFrameAnimationStopped(bool completed);
204 * Returns frame animator status.
208 * @return AnimatorStatus for the frameanimator.
211 GetFrameAnimatorStatus(void) const
213 return __frameAnimatorStatus;
217 * Returns frame animator FrameAnimatorFormTransitionAnimation.
221 * @return FrameAnimatorFormTransitionAnimation for the frameanimator.
223 FrameAnimatorFormTransitionAnimation
224 GetAnimationEffectType(void) const
226 return __animationEffectType;
230 * Sets frame animator FrameAnimatorFormTransitionAnimation.
235 SetAnimationEffectType(FrameAnimatorFormTransitionAnimation animationEffectType)
237 __animationEffectType = animationEffectType;
241 * Returns frame animator animation duration.
245 * @return long duration for the frameanimator.
248 GetDuration(void) const
254 * Sets frame animator animation duration.
259 SetDuration(long duration)
261 __duration = duration;
265 * Returns frame animator AnimInterpolatorType.
269 * @return AnimInterpolatorType for the frameanimator.
271 AnimationInterpolatorType
272 GetAnimInterpolatorType(void) const
274 return __animInterpolatorType;
278 * Sets frame animator AnimInterpolatorType.
283 SetAnimInterpolatorType(AnimationInterpolatorType animInterpolatorType)
285 __animInterpolatorType = animInterpolatorType;
289 * Returns frame animator bezier control points.
293 * @return A float type value.
296 GetFormTransitionBezierControlPoints(float& firstTime, float& firstValue, float& secondTime, float& secondValue) const
298 firstTime = __firstBezierControlPointsTime;
299 firstValue = __firstBezierControlPointsValue;
300 secondTime = __secondBezierControlPointsTime;
301 secondValue = __secondBezierControlPointsValue;
305 * Sets frame animator bezier control points.
309 * @return A float type value.
312 SetFormTransitionBezierControlPoints(float firstTime, float firstValue, float secondTime, float secondValue)
314 __firstBezierControlPointsTime = firstTime;
315 __firstBezierControlPointsValue = firstValue;
316 __secondBezierControlPointsTime = secondTime;
317 __secondBezierControlPointsValue = secondValue;
320 static _FrameAnimatorImpl* GetInstance(FrameAnimator& frameAnimator);
321 static const _FrameAnimatorImpl* GetInstance(const FrameAnimator& frameAnimator);
325 * This is the copy constructor for this class. @n
329 _FrameAnimatorImpl(const _FrameAnimatorImpl& rhs);
332 * This is the assignment operator implementation for this class. @n
336 _FrameAnimatorImpl& operator =(const _FrameAnimatorImpl& rhs);
339 * Delete & frees the memory used by the object.
343 * @return An error code
344 * @exception E_SUCCESS The method was successful.
345 * @exception E_SYSTEM Failed to free the resource possessed by this instance.
347 result Dispose(void);
350 * Starts the Layer animation.
354 * @return An error code
355 * @exception E_SUCCESS The method was successful.
356 * @exception E_INVALID_ARG A specified input parameter is invalid.
357 * @exception E_INVALID_STATE This instance has already been constructed.
358 * @exception E_OUT_OF_MEMORY Insufficient memory.
359 * @exception E_SYSTEM System error occurred.
361 result StartLayerAnimation(VisualElement* pLayer, AnimationTargetType animTarget, Variant startValue, Variant endValue, Tizen::Base::String animName);
365 * Adds the %Animation to the ActiveAnimation List.
369 * @return An error code
370 * @param[in] formAnimation %FrameAnimatorFormTransitionAnimation
371 * @param[in] propAnimation An object of VisualElementPropertyAnimation
372 * @param[in] animName Unique animation name
373 * @exception E_SUCCESS The method was successful.
374 * @exception E_SYSTEM A system error occurred.
375 * @exception E_INVALID_ARG A specified input parameter is invalid.
377 result AddFrameActiveAnimation(VisualElement* _pVisualElement, FrameAnimatorFormTransitionAnimation _formAnimation,
378 VisualElementPropertyAnimation* _pPropertyAnimation, IVisualElementAnimationTimingFunction* _pTimingFunction, Tizen::Base::String _animName);
381 * Gets the %Animation from the FrameActiveAnimation List attached against specified index
385 * @return An error code
386 * @param[in] index Value at the index to be retrieved
387 * @param[out] propAnimation An object of VisualElementPropertyAnimation
388 * @exception E_SUCCESS The method was successful.
389 * @exception E_SYSTEM A system error occurred.
390 * @exception E_INVALID_ARG A specified input parameter is invalid.
392 VisualElementPropertyAnimation* GetFrameActiveAnimationAt(int index);
395 * Removes the %Animation from the FrameActiveAnimation List at specified index.
399 * @return An error code
400 * @param[in] index Values at the index to be removed.
401 * @exception E_SUCCESS The method was successful.
402 * @exception E_SYSTEM A system error occurred.
403 * @exception E_INVALID_ARG A specified input parameter is invalid.
405 result RemoveAnimationAt(int index);
408 * Removes all the %Animation from the FrameActiveAnimation List.
412 * @return An error code
413 * @exception E_SUCCESS The method was successful.
414 * @exception E_SYSTEM A system error occurred.
415 * @exception E_INVALID_ARG A specified input parameter is invalid.
417 result RemoveAllAnimations(bool deleteAnimation);
420 * Searches the Frame's children list, for the given form, if present returns true else false.
424 * @return bool True if form is still in the children list, else false.
425 * @exception E_SUCCESS The method was successful.
426 * @exception E_SYSTEM A system error occurred.
427 * @exception E_INVALID_ARG A specified input parameter is invalid.
429 bool IsFormPresent(Tizen::Ui::Controls::Form& pPrevForm) const;
432 * Removes all the %Animation from the FrameActiveAnimation List.
436 * @return An error code
437 * @exception E_SUCCESS The method was successful.
438 * @exception E_SYSTEM A system error occurred.
439 * @exception E_INVALID_ARG A specified input parameter is invalid.
441 result ChangeCurrentForm(Tizen::Ui::Controls::Form* pCurrentForm, Tizen::Ui::Controls::Form& nextForm);
443 result SetAnimations(void);
445 result PrepareCapture(void);
449 * Structure used for storing Frame Active Animations
453 struct FrameActiveAnimation
455 VisualElement* pVisualElement;
456 FrameAnimatorFormTransitionAnimation formTransitionAnimationType;
457 VisualElementPropertyAnimation* pPropertyAnimation;
458 IVisualElementAnimationTimingFunction* pTimingFunction;
459 Tizen::Base::String animName;
460 FrameActiveAnimation(void)
462 pVisualElement = null;
463 formTransitionAnimationType = FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX;
464 pPropertyAnimation = null;
465 pTimingFunction = null;
468 ~FrameActiveAnimation(void)
471 bool operator ==(const FrameActiveAnimation& frameActiveAnim) const;
472 bool operator !=(const FrameActiveAnimation& frameActiveAnim) const;
473 }; // FrameActiveAnimation
477 * This is the object of Frame.
480 * @remark: This object need not be deleted in FrameAnimator scope
482 Tizen::Ui::Controls::Frame* __pFrame;
485 * This is object of FrameAnimator class.
489 FrameAnimator* __pFrameAnimator;
492 * The List maintaining the Frame Active Animations.
496 Tizen::Base::Collection::ArrayListT< FrameActiveAnimation > __frameActiveAnimationList;
499 * This Callback is called when an animation is repeated.
503 Tizen::Base::Collection::LinkedListT< IFrameAnimatorEventListener* > __frameAnimStatusEventListener;
506 * This is transactionID for the Form Transition animation
513 * The animation status (play / stopped)
517 AnimatorStatus __frameAnimatorStatus;
520 * CurrentForm object pointer.
524 Tizen::Ui::Controls::Form* __pCurrentForm;
527 * NextForm object pointer.
531 Tizen::Ui::Controls::Form* __pNextForm;
534 * The VisualElement of CurrentForm.
538 VisualElement* __pCurrentFormVisualElement;
541 * The VisualElement of NextForm.
545 VisualElement* __pNextFormVisualElement;
548 * This is the AnimationFormTransitionEffect used in animation.
552 FrameAnimatorFormTransitionAnimation __animationEffectType;
555 * This is the AnimationInterpolatorType used in animation.
559 AnimationInterpolatorType __animInterpolatorType;
562 * This is the duration of animation.
569 * This is input time1 of Bezier Control point.
573 float __firstBezierControlPointsTime;
576 * This is input value1 of Bezier Control point.
580 float __firstBezierControlPointsValue;
583 * This is input time2 of Bezier Control point.
587 float __secondBezierControlPointsTime;
590 * This is input value2 of Bezier Control point.
594 float __secondBezierControlPointsValue;
597 * This Tizen::Graphics::FloatMatrix4 object to set default transform matrix to current form after animation.
601 Tizen::Graphics::FloatMatrix4 __veDefaultMatrix;
604 * This Tizen::Graphics::FloatRectangle object to set default bounds to forms after animation.
608 Tizen::Graphics::FloatRectangle __veDefaultBounds;
611 * This float value to set default opacity to forms after animation.
615 float __veDefaultOpacity;
618 * Background ControlVisualElement to give a backgroud to Animating forms, so that background forms aren't visible
619 * in case of alpha animation.
623 _ControlVisualElement* __pBgElement;
624 VisualElement* __pCurrentCaptureVisualElement;
625 VisualElement* __pNextCaptureVisualElement;
626 VisualElementSurface* __pDummySurface;
628 }; // _FrameAnimatorImpl
630 }}} // Tizen::Ui::Animations
632 #endif //_FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_