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 FUiAnimParallelAnimationGroup.cpp
20 * @brief This file contains implementation of ParallelAnimationGroup class
22 * This file contains implementation of ParallelAnimationGroup class.
25 #include <FBaseSysLog.h>
26 #include <FBaseColArrayListT.h>
28 #include <FUiAnimParallelAnimationGroup.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::Base;
40 using namespace Tizen::Base::Collection;
43 namespace Tizen { namespace Ui { namespace Animations
46 ParallelAnimationGroup::ParallelAnimationGroup(void)
48 , _pParallelAnimationGroupImpl(null)
52 ParallelAnimationGroup::~ParallelAnimationGroup(void)
56 ParallelAnimationGroup::ParallelAnimationGroup(const ParallelAnimationGroup& animationGroup)
57 : AnimationGroup(animationGroup)
58 , _pParallelAnimationGroupImpl(null)
60 result r = GetLastResult();
61 SysTryReturnVoidResult(NID_UI_ANIM, (_pAnimationGroupImpl), r, "[%s] Propagating.", GetErrorMessage(r));
63 int animationCount = animationGroup._pAnimationGroupImpl->animationList.GetCount();
65 _AnimationGroupImpl::AnimationStore animStore;
67 for (int index = 0; index < animationCount; index++)
69 animationGroup._pAnimationGroupImpl->animationList.GetAt(index, animStore);
71 r = AddAnimation(animStore.animTarget, *(animStore.pAnimationBase));
74 SysLogException(NID_UI_ANIM, r, "[%s] Propagating.", GetErrorMessage(r));
76 delete _pAnimationGroupImpl;
77 _pAnimationGroupImpl = null;
84 ParallelAnimationGroup&
85 ParallelAnimationGroup::operator =(const ParallelAnimationGroup& rhs)
93 // Deleting the contents
94 if (_pAnimationGroupImpl->animationList.GetCount() > 0)
96 int index = _pAnimationGroupImpl->animationList.GetCount();
100 _AnimationGroupImpl::AnimationStore animStore;
102 _pAnimationGroupImpl->animationList.GetAt(index - 1, animStore);
104 if (animStore.pAnimationBase)
106 delete animStore.pAnimationBase;
107 animStore.pAnimationBase = null;
113 _pAnimationGroupImpl->animationList.RemoveAll();
116 // Copying the contents
117 int animationCount = rhs._pAnimationGroupImpl->animationList.GetCount();
119 for (int index = 0; index < animationCount; index++)
121 _AnimationGroupImpl::AnimationStore animStore;
123 rhs._pAnimationGroupImpl->animationList.GetAt(index, animStore);
125 _AnimationGroupImpl::AnimationStore animStoreNew;
126 animStoreNew.animTarget = animStore.animTarget;
128 animStoreNew.pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animStore.animTarget, *(animStore.pAnimationBase), r);
129 SysTryReturn(NID_UI_ANIM, (animStoreNew.pAnimationBase), *this, r, "[%s] Failed to clone animation.", GetErrorMessage(r));
131 r = _pAnimationGroupImpl->animationList.Add(animStoreNew);
132 SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), *this, r, "[%s] Propagating.", GetErrorMessage(r));
140 ParallelAnimationGroup::operator ==(const ParallelAnimationGroup& rhs) const
142 if (_pAnimationGroupImpl->animationList.GetCount() != rhs._pAnimationGroupImpl->animationList.GetCount())
147 int animationCount = rhs._pAnimationGroupImpl->animationList.GetCount();
149 for (int index = 0; index < animationCount; index++)
151 _AnimationGroupImpl::AnimationStore animStore;
153 _pAnimationGroupImpl->animationList.GetAt(index, animStore);
155 if (!(rhs._pAnimationGroupImpl->animationList.Contains(animStore)))
165 ParallelAnimationGroup::operator !=(const ParallelAnimationGroup& rhs) const
167 return !(*this == rhs);
171 ParallelAnimationGroup::Equals(const Object& obj) const
173 const ParallelAnimationGroup* pParallelGrp = dynamic_cast< const ParallelAnimationGroup* >(&obj);
174 if (pParallelGrp == null)
179 return (*this == *pParallelGrp);
183 ParallelAnimationGroup::GetHashCode(void) const
185 return GetAnimationCount();
189 ParallelAnimationGroup::RemoveAllAnimations(void)
191 int index = _pAnimationGroupImpl->animationList.GetCount() - 1;
195 _AnimationGroupImpl::AnimationStore animStore;
197 _pAnimationGroupImpl->animationList.GetAt(index, animStore);
199 delete animStore.pAnimationBase;
200 animStore.pAnimationBase = null;
205 _pAnimationGroupImpl->animationList.RemoveAll();
209 ParallelAnimationGroup::GetAnimationCount(void) const
211 return _pAnimationGroupImpl->animationList.GetCount();
215 ParallelAnimationGroup::AddAnimation(AnimationTargetType animTarget, const AnimationBase& animation)
217 SysTryReturnResult(NID_UI_ANIM, (animTarget >= ANIMATION_TARGET_NONE && animTarget <= ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid.");
219 _AnimationGroupImpl::AnimationStore animStoreNew;
221 animStoreNew.animTarget = animTarget;
223 result r = E_SUCCESS;
225 animStoreNew.pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animTarget, const_cast< AnimationBase& >(animation), r);
226 SysTryReturnResult(NID_UI_ANIM, (animStoreNew.pAnimationBase), r, "Failed to clone animation ");
228 int animationCount = _pAnimationGroupImpl->animationList.GetCount();
231 _AnimationGroupImpl::AnimationStore animStore;
233 for (index = 0; index < animationCount; index++)
235 _pAnimationGroupImpl->animationList.GetAt(index, animStore);
237 if (animStore.animTarget == animTarget)
243 r = _pAnimationGroupImpl->animationList.Add(animStoreNew);
246 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to add animation.");
248 delete animStoreNew.pAnimationBase;
249 animStoreNew.pAnimationBase = null;
254 if (index < animationCount)
256 _pAnimationGroupImpl->animationList.RemoveAt(index);
258 delete animStore.pAnimationBase;
259 animStore.pAnimationBase = null;
266 ParallelAnimationGroup::RemoveAnimation(AnimationTargetType animTarget)
268 SysTryReturnResult(NID_UI_ANIM, (animTarget >= ANIMATION_TARGET_NONE && animTarget <= ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid.");
270 int animationCount = _pAnimationGroupImpl->animationList.GetCount();
271 _AnimationGroupImpl::AnimationStore animStore;
273 for (int index = 0; index < animationCount; index++)
275 _pAnimationGroupImpl->animationList.GetAt(index, animStore);
277 if (animStore.animTarget == animTarget)
279 _pAnimationGroupImpl->animationList.RemoveAt(index);
281 delete animStore.pAnimationBase;
282 animStore.pAnimationBase = null;
288 return E_OBJ_NOT_FOUND;
292 ParallelAnimationGroup::GetAnimationN(AnimationTargetType animTarget) const
294 result r = E_SUCCESS;
296 int animationCount = _pAnimationGroupImpl->animationList.GetCount();
297 _AnimationGroupImpl::AnimationStore animStore;
299 for (int index = 0; index < animationCount; index++)
301 _pAnimationGroupImpl->animationList.GetAt(index, animStore);
303 if (animStore.animTarget == animTarget)
305 SysTryReturn(NID_UI_ANIM, (animStore.pAnimationBase), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is invalid.");
307 AnimationBase *pAnimationBase = _pAnimationGroupImpl->CloneAnimation(animTarget, *(animStore.pAnimationBase), r);
308 SysTryReturn(NID_UI_ANIM, (pAnimationBase), null, r, "[%s] Failed to clone animation.", GetErrorMessage(r));
310 return pAnimationBase;
318 ParallelAnimationGroup::IsAnimationAdded(AnimationTargetType animTarget)
320 int animationCount = _pAnimationGroupImpl->animationList.GetCount();
321 _AnimationGroupImpl::AnimationStore animStore;
323 for (int index = 0; index < animationCount; index++)
325 _pAnimationGroupImpl->animationList.GetAt(index, animStore);
327 if (animStore.animTarget == animTarget)
337 ParallelAnimationGroup::GetType(void) const
339 return ANIMATION_GROUP_TYPE_PARALLEL;
342 }}} // Tizen::Ui::Animations