modify Klockwork bug
[platform/framework/native/uifw.git] / src / ui / animations / FUiAnim_FrameAnimatorImpl.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0/
10 //
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.
16 //
17
18 /**
19  * @file        FUiAnim_FrameAnimatorImpl.h
20  * @brief       This is the header file for the _FrameAnimatorImpl class.
21  *
22  * This header file contains the declarations of the _FrameAnimatorImpl class. @n
23  */
24
25 #ifndef _FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_
26 #define _FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_
27
28 #include <FUiAnimFrameAnimator.h>
29 #include <FUiAnimVisualElementPropertyAnimation.h>
30 #include <FUiAnimIVisualElementAnimationTimingFunction.h>
31
32 #include "FUiAnim_ControlVisualElement.h"
33
34
35 namespace Tizen { namespace Ui { namespace Animations
36 {
37
38 class _FrameAnimatorImpl
39         : public Tizen::Base::Object
40         , public IAnimationTransactionEventListener
41         , virtual public Tizen::Base::Runtime::IEventListener
42 {
43 public:
44         _FrameAnimatorImpl(FrameAnimator* pFrameAnimator);
45         ~_FrameAnimatorImpl(void);
46
47         result Construct(const Tizen::Ui::Controls::Frame& source);
48
49         result AddFrameAnimatorEventListener(IFrameAnimatorEventListener& listener);
50         result RemoveFrameAnimatorEventListener(IFrameAnimatorEventListener& listener);
51
52         result StopAllAnimations(void);
53
54         result AddControl(const Tizen::Ui::Control& control);
55         result SetCurrentForm(const Tizen::Ui::Controls::Form& form);
56
57         bool IsAnimationSupported(void) const;
58
59         virtual void OnAnimationTransactionStarted(int transactionId);
60         virtual void OnAnimationTransactionStopped(int transactionId);
61         virtual void OnAnimationTransactionFinished(int transactionId);
62
63         void OnFrameAnimationStarted(void);
64         void OnFrameAnimationStopped(bool completed);
65
66         AnimatorStatus
67         GetFrameAnimatorStatus(void) const
68         {
69                 return __frameAnimatorStatus;
70         }
71
72         FrameAnimatorFormTransitionAnimation
73         GetAnimationEffectType(void) const
74         {
75                 return __animationEffectType;
76         }
77
78         void
79         SetAnimationEffectType(FrameAnimatorFormTransitionAnimation animationEffectType)
80         {
81                 __animationEffectType = animationEffectType;
82         }
83
84         long
85         GetDuration(void) const
86         {
87                 return __duration;
88         }
89
90         void
91         SetDuration(long duration)
92         {
93                 __duration = duration;
94         }
95
96         AnimationInterpolatorType
97         GetAnimInterpolatorType(void) const
98         {
99                 return __animInterpolatorType;
100         }
101
102         void
103         SetAnimInterpolatorType(AnimationInterpolatorType animInterpolatorType)
104         {
105                 __animInterpolatorType = animInterpolatorType;
106         }
107
108         void
109         GetFormTransitionBezierControlPoints(float& firstTime, float& firstValue, float& secondTime, float& secondValue) const
110         {
111                 firstTime = __firstBezierControlPointsTime;
112                 firstValue = __firstBezierControlPointsValue;
113                 secondTime = __secondBezierControlPointsTime;
114                 secondValue = __secondBezierControlPointsValue;
115         }
116
117         void
118         SetFormTransitionBezierControlPoints(float firstTime, float firstValue, float secondTime, float secondValue)
119         {
120                 __firstBezierControlPointsTime = firstTime;
121                 __firstBezierControlPointsValue = firstValue;
122                 __secondBezierControlPointsTime = secondTime;
123                 __secondBezierControlPointsValue = secondValue;
124         }
125
126         static _FrameAnimatorImpl* GetInstance(FrameAnimator& frameAnimator);
127         static const _FrameAnimatorImpl* GetInstance(const FrameAnimator& frameAnimator);
128
129 private:
130         _FrameAnimatorImpl(const _FrameAnimatorImpl& rhs);
131         _FrameAnimatorImpl& operator =(const _FrameAnimatorImpl& rhs);
132
133         result Dispose(void);
134
135         result StartLayerAnimation(VisualElement* pLayer, AnimationTargetType animTarget, Variant startValue, Variant endValue, Tizen::Base::String animName);
136         result AddFrameActiveAnimation(VisualElement* _pVisualElement, FrameAnimatorFormTransitionAnimation _formAnimation,
137                         VisualElementPropertyAnimation* _pPropertyAnimation, IVisualElementAnimationTimingFunction* _pTimingFunction, Tizen::Base::String _animName);
138
139         VisualElementPropertyAnimation* GetFrameActiveAnimationAt(int index);
140         result RemoveAnimationAt(int index);
141         result RemoveAllAnimations(bool deleteAnimation);
142
143         bool IsFormPresent(Tizen::Ui::Controls::Form& pPrevForm) const;
144
145         result ChangeCurrentForm(Tizen::Ui::Controls::Form* pCurrentForm, Tizen::Ui::Controls::Form& nextForm);
146
147         result SetAnimations(void);
148
149         result PrepareCapture(void);
150
151 private:
152         /**
153          * Structure used for storing Frame Active Animations
154          *
155          * @since               2.0
156          */
157         struct FrameActiveAnimation
158         {
159                 VisualElement* pVisualElement;
160                 FrameAnimatorFormTransitionAnimation formTransitionAnimationType;
161                 VisualElementPropertyAnimation* pPropertyAnimation;
162                 IVisualElementAnimationTimingFunction* pTimingFunction;
163                 Tizen::Base::String animName;
164                 FrameActiveAnimation(void)
165                 {
166                         pVisualElement = null;
167                         formTransitionAnimationType = FRAME_ANIMATOR_FORM_TRANSITION_ANIMATION_MAX;
168                         pPropertyAnimation = null;
169                         pTimingFunction = null;
170                         animName = "";
171                 }
172                 ~FrameActiveAnimation(void)
173                 {
174                 }
175                 bool operator ==(const FrameActiveAnimation& frameActiveAnim) const;
176                 bool operator !=(const FrameActiveAnimation& frameActiveAnim) const;
177         };      // FrameActiveAnimation
178
179 private:
180         /**
181          * This is the object of Frame.
182          *
183          * @since               2.0
184          * @remark: This object need not be deleted in FrameAnimator scope
185          */
186         Tizen::Ui::Controls::Frame* __pFrame;
187
188         /**
189          * This is object of FrameAnimator class.
190          *
191          * @since               2.0
192          */
193         FrameAnimator* __pFrameAnimator;
194
195         /**
196          *      The List maintaining the Frame Active Animations.
197          *
198          *      @since          2.0
199          */
200         Tizen::Base::Collection::ArrayListT< FrameActiveAnimation > __frameActiveAnimationList;
201
202         /**
203          * This Callback is called when an animation is repeated.
204          *
205          * @since 2.0
206          */
207         Tizen::Base::Collection::LinkedListT< IFrameAnimatorEventListener* > __frameAnimStatusEventListener;
208
209         /**
210          * This is transactionID for the Form Transition animation
211          *
212          * @since               2.0
213          */
214         int __transactionId;
215
216         /**
217          * The animation status (play / stopped)
218          *
219          * @since               2.0
220          */
221         AnimatorStatus __frameAnimatorStatus;
222
223         /**
224          * CurrentForm object pointer.
225          *
226          * @since               2.0
227          */
228         Tizen::Ui::Controls::Form* __pCurrentForm;
229
230         /**
231          * NextForm object pointer.
232          *
233          * @since               2.0
234          */
235         Tizen::Ui::Controls::Form* __pNextForm;
236
237         /**
238          * The VisualElement of CurrentForm.
239          *
240          * @since 2.0
241          */
242         VisualElement* __pCurrentFormVisualElement;
243
244         /**
245          * The VisualElement of NextForm.
246          *
247          * @since 2.0
248          */
249         VisualElement* __pNextFormVisualElement;
250
251         /**
252          * This is the AnimationFormTransitionEffect used in animation.
253          *
254          * @since               2.0
255          */
256         FrameAnimatorFormTransitionAnimation __animationEffectType;
257
258         /**
259          * This is the AnimationInterpolatorType used in animation.
260          *
261          * @since               2.0
262          */
263         AnimationInterpolatorType __animInterpolatorType;
264
265         /**
266          * This is the duration of animation.
267          *
268          * @since               2.0
269          */
270         long __duration;
271
272         /**
273          * This is input time1 of Bezier Control point.
274          *
275          * @since               2.0
276          */
277         float __firstBezierControlPointsTime;
278
279         /**
280          * This is input value1 of Bezier Control point.
281          *
282          * @since               2.0
283          */
284         float __firstBezierControlPointsValue;
285
286         /**
287          * This is input time2 of Bezier Control point.
288          *
289          * @since               2.0
290          */
291         float __secondBezierControlPointsTime;
292
293         /**
294          * This is input value2 of Bezier Control point.
295          *
296          * @since               2.0
297          */
298         float __secondBezierControlPointsValue;
299
300         /**
301          * This Tizen::Graphics::FloatMatrix4 object to set default transform matrix to current form after animation.
302          *
303          * @since 2.0
304          */
305         Tizen::Graphics::FloatMatrix4 __veDefaultMatrix;
306
307         /**
308          * This Tizen::Graphics::FloatRectangle object to set default bounds to forms after animation.
309          *
310          * @since 2.0
311          */
312         Tizen::Graphics::FloatRectangle __veDefaultBounds;
313
314         /**
315          * This float value to set default opacity to forms after animation.
316          *
317          * @since 2.0
318          */
319         float __veDefaultOpacity;
320
321         /**
322          * Background ControlVisualElement to give a backgroud to Animating forms, so that background forms aren't visible
323          * in case of alpha animation.
324          *
325          * @since 2.0
326          */
327         _ControlVisualElement* __pBgElement;
328         VisualElement* __pCurrentCaptureVisualElement;
329         VisualElement* __pNextCaptureVisualElement;
330         VisualElementSurface* __pDummySurface;
331
332 };          // _FrameAnimatorImpl
333
334 }}}     // Tizen::Ui::Animations
335
336 #endif  //_FUI_ANIM_INTERNAL_FRAME_ANIMATOR_IMPL_H_