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_AnimationGroupImpl.cpp
20 * @brief This file contains implementation of _AnimationGroupImpl class
22 * This file contains implementation _AnimationGroupImpl class.
25 #include <FBaseSysLog.h>
26 #include <FBaseColArrayList.h>
27 #include <FBaseColArrayListT.h>
29 #include <FUiAnimDimensionAnimation.h>
30 #include <FUiAnimFloatAnimation.h>
31 #include <FUiAnimRectangleAnimation.h>
32 #include <FUiAnimIntegerAnimation.h>
33 #include <FUiAnimPointAnimation.h>
34 #include <FUiAnimRotateAnimation.h>
36 #include "FUiAnim_AnimationGroupImpl.h"
39 using namespace Tizen::Ui::Animations;
40 using namespace Tizen::Base;
41 using namespace Tizen::Base::Collection;
42 using namespace Tizen::Ui;
45 namespace Tizen { namespace Ui { namespace Animations
48 _AnimationGroupImpl::_AnimationGroupImpl(AnimationGroup* pAnimationGroup)
49 : __pAnimationGroup(pAnimationGroup)
53 _AnimationGroupImpl::~_AnimationGroupImpl(void)
57 SysTryReturnVoidResult(NID_UI_ANIM, (r == E_SUCCESS), r, "[%s] Propagating.", GetErrorMessage(r));
61 _AnimationGroupImpl::Dispose(void)
65 int index = animationList.GetCount();
69 _AnimationGroupImpl::AnimationStore animStore;
71 r = animationList.GetAt(index - 1, animStore);
73 delete animStore.pAnimationBase;
74 animStore.pAnimationBase = null;
79 animationList.RemoveAll();
85 _AnimationGroupImpl::CloneAnimation(AnimationTargetType animTarget, AnimationBase& animation, result& r)
87 AnimationType animationType = animation.GetType();
91 case ANIMATION_TARGET_SIZE:
93 switch (animationType)
95 case ANIMATION_TYPE_DIMENSION_ANIMATION:
97 DimensionAnimation* pDimValue = dynamic_cast< DimensionAnimation* >(&animation);
98 SysTryReturn(NID_UI_ANIM, (pDimValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not DimensionAnimation.");
100 DimensionAnimation* pAnimValue = new (std::nothrow) DimensionAnimation(*pDimValue);
101 SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
107 case ANIMATION_TYPE_RECTANGLE_ANIMATION:
109 RectangleAnimation* pRectValue = dynamic_cast< RectangleAnimation* >(&animation);
110 SysTryReturn(NID_UI_ANIM, (pRectValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RectangleAnimation.");
112 RectangleAnimation* pAnimValue = new (std::nothrow) RectangleAnimation(*pRectValue);
113 SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
127 case ANIMATION_TARGET_POSITION:
129 switch (animationType)
131 case ANIMATION_TYPE_POINT_ANIMATION:
133 PointAnimation* pPtValue = dynamic_cast< PointAnimation* >(&animation);
134 SysTryReturn(NID_UI_ANIM, (pPtValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not PointAnimation.");
136 PointAnimation* pAnimValue = new (std::nothrow) PointAnimation(*pPtValue);
137 SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
143 case ANIMATION_TYPE_RECTANGLE_ANIMATION:
145 RectangleAnimation* pRectValue = dynamic_cast< RectangleAnimation* >(&animation);
146 SysTryReturn(NID_UI_ANIM, (pRectValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RectangleAnimation.");
148 RectangleAnimation* pAnimValue = new (std::nothrow) RectangleAnimation(*pRectValue);
149 SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
162 case ANIMATION_TARGET_ALPHA:
164 switch (animationType)
166 case ANIMATION_TYPE_FLOAT_ANIMATION:
168 FloatAnimation* pFloatValue = dynamic_cast< FloatAnimation* >(&animation);
169 SysTryReturn(NID_UI_ANIM, (pFloatValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not FloatAnimation.");
171 FloatAnimation* pAnimValue = new (std::nothrow) FloatAnimation(*pFloatValue);
172 SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
178 case ANIMATION_TYPE_INTEGER_ANIMATION:
180 IntegerAnimation* pIntValue = dynamic_cast< IntegerAnimation* >(&animation);
181 SysTryReturn(NID_UI_ANIM, (pIntValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not IntegerAnimation.");
183 IntegerAnimation* pAnimValue = new (std::nothrow) IntegerAnimation(*pIntValue);
184 SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
197 case ANIMATION_TARGET_ROTATION:
199 if (animationType == ANIMATION_TYPE_ROTATE_ANIMATION)
201 RotateAnimation* pRotateValue = dynamic_cast< RotateAnimation* >(&animation);
202 SysTryReturn(NID_UI_ANIM, (pRotateValue), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RotateAnimation.");
204 RotateAnimation* pAnimValue = new (std::nothrow) RotateAnimation(*pRotateValue);
205 SysTryReturn(NID_UI_ANIM, (pAnimValue), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
224 _AnimationGroupImpl::Construct()
226 return animationList.Construct();
230 _AnimationGroupImpl::AnimationStore::operator ==(const AnimationStore& animStore) const
232 if (animTarget != animStore.animTarget)
237 if ((!pAnimationBase) && (!animStore.pAnimationBase))
241 else if (((pAnimationBase == null) && (animStore.pAnimationBase != null)) ||
242 ((pAnimationBase != null) && (animStore.pAnimationBase == null)))
247 if (pAnimationBase->GetType() != animStore.pAnimationBase->GetType())
252 switch (pAnimationBase->GetType())
254 case ANIMATION_TYPE_FLOAT_ANIMATION:
256 FloatAnimation* pFlAnim1 = dynamic_cast< FloatAnimation* >(pAnimationBase);
257 SysTryReturn(NID_UI_ANIM, (pFlAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not FloatAnimation.");
259 FloatAnimation* pFlAnim2 = dynamic_cast< FloatAnimation* >(animStore.pAnimationBase);
260 SysTryReturn(NID_UI_ANIM, (pFlAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not FloatAnimation.");
262 if ((*pFlAnim1) != (*pFlAnim2))
269 case ANIMATION_TYPE_INTEGER_ANIMATION:
271 IntegerAnimation* pIntAnim1 = dynamic_cast< IntegerAnimation* >(pAnimationBase);
272 SysTryReturn(NID_UI_ANIM, (pIntAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not IntegerAnimation.");
274 IntegerAnimation* pIntAnim2 = dynamic_cast< IntegerAnimation* >(animStore.pAnimationBase);
275 SysTryReturn(NID_UI_ANIM, (pIntAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not IntegerAnimation.");
277 if ((*pIntAnim1) != (*pIntAnim2))
284 case ANIMATION_TYPE_DIMENSION_ANIMATION:
286 DimensionAnimation* pDimAnim1 = dynamic_cast< DimensionAnimation* >(pAnimationBase);
287 SysTryReturn(NID_UI_ANIM, (pDimAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not DimensionAnimation.");
289 DimensionAnimation* pDimAnim2 = dynamic_cast< DimensionAnimation* >(animStore.pAnimationBase);
290 SysTryReturn(NID_UI_ANIM, (pDimAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not DimensionAnimation.");
292 if ((*pDimAnim1) != (*pDimAnim2))
299 case ANIMATION_TYPE_RECTANGLE_ANIMATION:
301 RectangleAnimation* pRectAnim1 = dynamic_cast< RectangleAnimation* >(pAnimationBase);
302 SysTryReturn(NID_UI_ANIM, (pRectAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RectangleAnimation.");
304 RectangleAnimation* pRectAnim2 = dynamic_cast< RectangleAnimation* >(animStore.pAnimationBase);
305 SysTryReturn(NID_UI_ANIM, (pRectAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RectangleAnimation.");
307 if ((*pRectAnim1) != (*pRectAnim2))
314 case ANIMATION_TYPE_POINT_ANIMATION:
316 PointAnimation* pPtAnim1 = dynamic_cast< PointAnimation* >(pAnimationBase);
317 SysTryReturn(NID_UI_ANIM, (pPtAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not PointAnimation.");
319 PointAnimation* pPtAnim2 = dynamic_cast< PointAnimation* >(animStore.pAnimationBase);
320 SysTryReturn(NID_UI_ANIM, (pPtAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not PointAnimation.");
322 if ((*pPtAnim1) != (*pPtAnim2))
329 case ANIMATION_TYPE_ROTATE_ANIMATION:
331 RotateAnimation* pRotAnim1 = dynamic_cast< RotateAnimation* >(pAnimationBase);
332 SysTryReturn(NID_UI_ANIM, (pRotAnim1), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RotateAnimation.");
334 RotateAnimation* pRotAnim2 = dynamic_cast< RotateAnimation* >(animStore.pAnimationBase);
335 SysTryReturn(NID_UI_ANIM, (pRotAnim2), false, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not RotateAnimation.");
337 if ((*pRotAnim1) != (*pRotAnim2))
352 _AnimationGroupImpl::AnimationStore::operator !=(const AnimationStore& animStore) const
354 return !(*this == animStore);
357 }}} //Tizen::Ui::Animations