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 FUiAnimControlAnimator.cpp
20 * @brief This file contains implementation of ControlAnimator class
22 * This file contains implementation of ControlAnimator class.
25 #include <FBaseSysLog.h>
27 #include <FUiCustomControlBase.h>
29 #include <FUiAnimControlAnimator.h>
30 #include <FUiAnimAnimationBase.h>
31 #include <FUiAnimDimensionAnimation.h>
32 #include <FUiAnimPointAnimation.h>
33 #include <FUiAnimRectangleAnimation.h>
34 #include <FUiAnimIntegerAnimation.h>
35 #include <FUiAnimFloatAnimation.h>
36 #include <FUiAnimRotateAnimation.h>
38 #include "FUiAnim_ControlAnimatorImpl.h"
41 using namespace Tizen::Base;
42 using namespace Tizen::Base::Collection;
43 using namespace Tizen::Graphics;
44 using namespace Tizen::Ui;
47 namespace Tizen { namespace Ui { namespace Animations
50 ///INIT_SYSCLASSTYPE(ControlAnimator);
52 ControlAnimator::ControlAnimator(void)
53 : _pControlAnimatorImpl(null)
58 ControlAnimator::~ControlAnimator(void)
60 delete _pControlAnimatorImpl;
61 _pControlAnimatorImpl = null;
65 ControlAnimator::Construct(const Control& source)
67 SysAssertf((_pControlAnimatorImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
71 _pControlAnimatorImpl = new (std::nothrow) _ControlAnimatorImpl(this);
72 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl), E_OUT_OF_MEMORY, "Memory allocation failed.");
74 r = _pControlAnimatorImpl->Construct(source);
75 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to construct _ControlAnimatorImpl instance.");
80 delete _pControlAnimatorImpl;
81 _pControlAnimatorImpl = null;
88 ControlAnimator::StartUserAnimation(AnimationTargetType animTarget, const AnimationBase& animationBase)
90 SysTryReturnResult(NID_UI_ANIM, (animTarget > ANIMATION_TARGET_NONE && animTarget < ANIMATION_TARGET_MAX), E_INVALID_ARG,
91 "Invalid argument(s) is used. AnimationTargetType argument is invalid.");
93 SysTryReturnResult(NID_UI_ANIM, !(_pControlAnimatorImpl->IsAnimationTargetAnimating(animTarget)), E_INVALID_OPERATION,
94 "Same AnimationTargetType is being animated.");
97 int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount();
99 AnimationBase* pAnimBase = const_cast< AnimationBase* >(&animationBase);
100 SysTryReturnResult(NID_UI_ANIM, (pAnimBase != null), E_INVALID_ARG, "Invalid argument(s) is used. AnimationBase argument is invalid.");
102 Rectangle rect(0, 0, 0, 0);
104 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimBase)), E_INVALID_ARG,
105 "Invalid argument(s) is used. AnimationBase argument is invalid.");
107 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
109 r = _pControlAnimatorImpl->SetControlProperty(animTarget, *pAnimBase);
110 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to set control property.");
115 AnimationBase* pAnimationBase = null;
116 pAnimationBase = _pControlAnimatorImpl->CloneAnimation(animTarget, *pAnimBase);
117 SysTryReturnResult(NID_UI_ANIM, (pAnimationBase), E_SYSTEM, "A system error has been occurred. Failed to clone animation.");
119 if (animTarget == ANIMATION_TARGET_POSITION || animTarget == ANIMATION_TARGET_SIZE)
121 _pControlAnimatorImpl->SetLogicalBounds(_pControlAnimatorImpl->GetControl().GetBounds());
123 else if (animTarget == ANIMATION_TARGET_ALPHA)
125 _pControlAnimatorImpl->SetShowState(_pControlAnimatorImpl->GetControl().GetShowState());
128 if (animTarget == ANIMATION_TARGET_POSITION || animTarget == ANIMATION_TARGET_SIZE)
130 _pControlAnimatorImpl->SetControlLogicalBounds(animTarget, *pAnimationBase);
132 bool disable = false;
133 bool propagation = false;
135 result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable);
136 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable implicit animation.");
138 r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
139 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable visual element propagation.");
141 r = _pControlAnimatorImpl->GetControl().SetBounds(_pControlAnimatorImpl->GetLogicalBounds());
145 _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
149 _pControlAnimatorImpl->DisableImplicitAnimation(disable);
152 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds.");
155 else if (animTarget == ANIMATION_TARGET_ALPHA)
157 _pControlAnimatorImpl->SetControlShowState(animTarget, *pAnimationBase);
159 bool disable = false;
160 bool propagation = false;
162 result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable);
163 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to enable/disable implicit animation.");
165 r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
166 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to enable/disable visual element propagation.");
168 r = _pControlAnimatorImpl->GetControl().SetShowState((_pControlAnimatorImpl->GetShowState()));
171 _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
175 _pControlAnimatorImpl->DisableImplicitAnimation(disable);
177 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set show state.");
180 //Create and play the Animation
181 r = _pControlAnimatorImpl->SetAnimation(animTarget, *pAnimationBase);
182 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
184 _pControlAnimatorImpl->SetAnimationTargetAnimating(animTarget, true);
189 if (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) != E_SUCCESS)
191 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation.");
198 ControlAnimator::StartUserAnimation(const AnimationGroup& animGroup)
200 result r = E_SUCCESS;
201 bool isAnimating = false;
203 ParallelAnimationGroup* pParallelAnimGrp = null;
204 SequentialAnimationGroup* pSequentialAnimGrp = null;
206 pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(const_cast< AnimationGroup* >(&animGroup));
207 pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(const_cast< AnimationGroup* >(&animGroup));
208 SysTryReturnResult(NID_UI_ANIM, ((pParallelAnimGrp) || (pSequentialAnimGrp)), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid.");
210 if (pParallelAnimGrp)
212 SysTryReturnResult(NID_UI_ANIM, (pParallelAnimGrp->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. No animation found in AnimationGroup.");
214 for (int animType = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); animType < (static_cast< int >(ANIMATION_TARGET_MAX)); animType++)
216 AnimationTargetType animTarget = static_cast< AnimationTargetType >(animType);
217 AnimationBase* pAnimationBase = null;
218 pAnimationBase = pParallelAnimGrp->GetAnimationN(animTarget);
219 if (pAnimationBase != null)
221 isAnimating = _pControlAnimatorImpl->IsAnimationTargetAnimating(animTarget);
223 Rectangle rect(0, 0, 0, 0);
225 bool animatable = _pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimationBase);
227 delete pAnimationBase;
229 SysTryReturnResult(NID_UI_ANIM, (animatable), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid.");
230 //The below check was removed for 2.0
231 SysTryReturnResult(NID_UI_ANIM, !(isAnimating), E_INVALID_OPERATION, "Same AnimationTargetType is being animated.");
235 r = _pControlAnimatorImpl->SetGroupAnimation(pParallelAnimGrp);
237 else //if (pSequentialAnimGrp)
239 SysTryReturnResult(NID_UI_ANIM, (pSequentialAnimGrp->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. No animation found in AnimationGroup.");
241 for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++)
243 AnimationTargetType animTarget = ANIMATION_TARGET_MAX;
244 AnimationBase* pAnimationBase = null;
245 pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index);
246 animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index);
248 if (pAnimationBase != null)
250 isAnimating = _pControlAnimatorImpl->IsAnimationTargetAnimating(animTarget);
252 Rectangle rect(0, 0, 0, 0);
254 bool animatable = _pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimationBase);
256 delete pAnimationBase;
258 SysTryReturnResult(NID_UI_ANIM, (animatable), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid.");
259 //The below check should be removed for 2.0
260 SysTryReturnResult(NID_UI_ANIM, !(isAnimating), E_INVALID_OPERATION, "Same AnimationTargetType is being animated.");
264 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. An animation in sequential group is null.");
269 r = _pControlAnimatorImpl->SetGroupAnimation(pSequentialAnimGrp);
276 ControlAnimator::StopAllAnimations(void)
278 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->GetActiveAnimationListCount() > 0), E_SUCCESS, "No Active Animation.");
280 return _pControlAnimatorImpl->StopAllAnimations();
284 ControlAnimator::StopAnimation(ControlAnimatorTriggerType animTrigger)
286 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl), E_SYSTEM, "A system error has been occurred. Control animator is not constructed properly.");
287 SysTryReturnResult(NID_UI_ANIM, (animTrigger >= ANIMATION_TRIGGER_USER && animTrigger <= ANIMATION_TRIGGER_SHOW_STATE_CHANGE),
288 E_INVALID_ARG, "Invalid argument(s) is used. ControlAnimatorTriggerType argument is invalid.");
290 return _pControlAnimatorImpl->StopAnimation(animTrigger);
294 ControlAnimator::GetStatus(void) const
296 if (_pControlAnimatorImpl->IsAnimationSupported())
298 _pControlAnimatorImpl->SetAnimatorStatus(ANIMATOR_STATUS_STOPPED);
300 for (int animType = ((int) ANIMATION_TARGET_NONE + 1); animType < ((int) ANIMATION_TARGET_MAX); animType++)
302 if (_pControlAnimatorImpl->IsAnimationTargetAnimating(animType) == true)
304 _pControlAnimatorImpl->SetAnimatorStatus(ANIMATOR_STATUS_PLAYING);
308 return _pControlAnimatorImpl->GetAnimatorStatus();
312 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation support is unavailable.");
313 return ANIMATOR_STATUS_STOPPED;
318 ControlAnimator::GetStatus(AnimationTargetType animTarget) const
320 SysTryReturn(NID_UI_ANIM, (animTarget > ANIMATION_TARGET_NONE && animTarget < ANIMATION_TARGET_MAX), ANIMATOR_STATUS_STOPPED, E_INVALID_ARG,
321 "Invalid argument(s) is used. AnimationTargetType argument is invalid.");
323 if (_pControlAnimatorImpl->IsAnimationSupported())
325 if (_pControlAnimatorImpl->IsAnimationTargetAnimating(animTarget) == true)
327 return ANIMATOR_STATUS_PLAYING;
330 return ANIMATOR_STATUS_STOPPED;
334 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation support is unavailable.");
335 return ANIMATOR_STATUS_STOPPED;
340 ControlAnimator::AddControlAnimatorEventListener(IControlAnimatorEventListener& listener)
342 SysTryReturnResult(NID_UI_ANIM, _pControlAnimatorImpl->IsAnimationSupported(), E_UNSUPPORTED_OPERATION, "Animation is unsupported.");
344 return _pControlAnimatorImpl->AddControlAnimatorEventListener(listener);
348 ControlAnimator::RemoveControlAnimatorEventListener(IControlAnimatorEventListener& listener)
350 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationSupported()), E_UNSUPPORTED_OPERATION, "Animation is unsupported.");
352 return _pControlAnimatorImpl->RemoveControlAnimatorEventListener(listener);
356 ControlAnimator::AddControlAnimatorDetailedEventListener(IControlAnimatorDetailedEventListener& listener)
358 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationSupported()), E_UNSUPPORTED_OPERATION, "Animation is unsupported.");
360 return _pControlAnimatorImpl->AddControlAnimatorDetailedEventListener(listener);
364 ControlAnimator::RemoveControlAnimatorDetailedEventListener(IControlAnimatorDetailedEventListener& listener)
366 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationSupported()), E_UNSUPPORTED_OPERATION, "Animation is unsupported.");
368 return _pControlAnimatorImpl->RemoveControlAnimatorDetailedEventListener(listener);
372 ControlAnimator::SetAnimation(ControlAnimatorTriggerType animTrigger, const AnimationGroup* pAnimationGroup)
374 SysTryReturnResult(NID_UI_ANIM, ((animTrigger >= ANIMATION_TRIGGER_POSITION_CHANGE) && (animTrigger <= ANIMATION_TRIGGER_SHOW_STATE_CHANGE)),
375 E_INVALID_ARG, "Invalid argument(s) is used. ControlAnimatorTriggerType argument is invalid.");
377 if (pAnimationGroup == null)
379 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(animTrigger - 1) !=
380 PROPERTY_ANIMATION_GROUP_TYPE_NONE), E_SUCCESS, "No custom implicit animation is set yet.");
381 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)), E_SUCCESS,
382 "No custom implicit animation is set yet against this ControlAnimatorTriggerType.");
384 _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)->RemoveAllAnimations();
386 delete _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1);
387 _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, null);
388 _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_NONE);
393 SequentialAnimationGroup* pSequentialAnimGrp = null;
394 ParallelAnimationGroup* pParallelAnimGrp = null;
395 AnimationTargetType associatedAnimTarget = ANIMATION_TARGET_NONE;
397 pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(const_cast< AnimationGroup* >(pAnimationGroup));
398 pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(const_cast< AnimationGroup* >(pAnimationGroup));
399 SysTryReturnResult(NID_UI_ANIM, ((pSequentialAnimGrp) || (pParallelAnimGrp)), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid.");
400 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup->GetAnimationCount() > 0), E_INVALID_ARG, "Invalid argument(s) is used. No animations added to AnimationGroup.");
402 if (animTrigger == ANIMATION_TRIGGER_POSITION_CHANGE)
404 associatedAnimTarget = ANIMATION_TARGET_POSITION;
406 else if (animTrigger == ANIMATION_TRIGGER_SIZE_CHANGE)
408 associatedAnimTarget = ANIMATION_TARGET_SIZE;
410 else if (animTrigger == ANIMATION_TRIGGER_SHOW_STATE_CHANGE)
412 associatedAnimTarget = ANIMATION_TARGET_ALPHA;
415 if (pSequentialAnimGrp)
418 for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++)
420 AnimationTargetType animTarget = ANIMATION_TARGET_NONE;
421 animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index);
422 SysTryReturnResult(NID_UI_ANIM, ((animTarget > ANIMATION_TARGET_NONE) && (animTarget < ANIMATION_TARGET_MAX)), E_INVALID_ARG,
423 "Invalid argument(s) is used. AnimationTargetType argument is invalid.");
425 if (associatedAnimTarget == animTarget)
430 SysTryReturnResult(NID_UI_ANIM, (targetCount >= 1), E_INVALID_ARG,
431 "Invalid argument(s) is used. AnimationGroup should have at-least one animation of equivalent AnimationTargetType.");
433 //Check for IsAnimatable() of all AnimationBase objects
434 for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++)
436 AnimationTargetType animTarget = ANIMATION_TARGET_NONE;
437 AnimationBase* pAnimationBase = null;
438 pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index);
439 animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index);
441 bool animatable = false;
444 if (associatedAnimTarget != animTarget)
446 Rectangle rect(0, 0, 0, 0);
448 animatable = _pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimationBase);
451 delete pAnimationBase;
453 if ((associatedAnimTarget != animTarget) && (!animatable))
455 SysLogException(NID_UI_ANIM, E_UNSUPPORTED_OPERATION, "[E_UNSUPPORTED_OPERATION] Control is not animable. Animations cannot be set to control.");
456 return E_UNSUPPORTED_OPERATION;
461 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. An animation in sequential group animation is null.");
466 SequentialAnimationGroup* pSequentialAnimationGroup = null;
467 pSequentialAnimationGroup = new (std::nothrow) SequentialAnimationGroup(*pSequentialAnimGrp);
468 SysTryReturnResult(NID_UI_ANIM, (pSequentialAnimationGroup), E_OUT_OF_MEMORY, "Memory allocation failed.");
470 if (pSequentialAnimationGroup->GetAnimationCount() != pSequentialAnimGrp->GetAnimationCount())
472 if (pSequentialAnimationGroup->GetAnimationCount() > 0)
474 pSequentialAnimationGroup->RemoveAllAnimations();
477 delete pSequentialAnimationGroup;
479 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to clone sequential group animation.");
483 if (_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1))
485 _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)->RemoveAllAnimations();
486 delete _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1);
487 _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, null);
488 _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_NONE);
490 _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, pSequentialAnimationGroup);
491 _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL);
495 else //if (pParallelAnimGrp)
497 bool isPresent = false;
499 if (animTrigger == ANIMATION_TRIGGER_POSITION_CHANGE)
501 isPresent = pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_POSITION);
503 else if (animTrigger == ANIMATION_TRIGGER_SIZE_CHANGE)
505 isPresent = pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_SIZE);
507 else if (animTrigger == ANIMATION_TRIGGER_SHOW_STATE_CHANGE)
509 isPresent = pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_ALPHA);
512 SysTryReturnResult(NID_UI_ANIM, (isPresent), E_INVALID_ARG,
513 "Invalid argument(s) is used. AnimationGroup should have one animation of equivalent AnimationTargetType.");
515 //Check for IsAnimatable() of all AnimationBase objects
516 for (int animType = ((int) ANIMATION_TARGET_NONE + 1); animType < ((int) ANIMATION_TARGET_MAX); animType++)
518 AnimationTargetType animTarget = static_cast< AnimationTargetType >(animType);
519 if (pParallelAnimGrp->IsAnimationAdded(animTarget) == false)
523 AnimationBase* pAnimationBase = null;
524 bool animatable = false;
526 pAnimationBase = pParallelAnimGrp->GetAnimationN(animTarget);
529 if (associatedAnimTarget != animTarget)
531 Rectangle rect(0, 0, 0, 0);
533 animatable = _pControlAnimatorImpl->IsAnimatable(animTarget, rect, pAnimationBase);
536 delete pAnimationBase;
538 SysTryReturnResult(NID_UI_ANIM, !((associatedAnimTarget != animTarget) && (!animatable)), E_UNSUPPORTED_OPERATION,
539 "Animations cannot be set to control.");
544 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. An animation in parallel group animation is null.");
549 ParallelAnimationGroup* pParallelAnimationGroup = null;
550 pParallelAnimationGroup = new (std::nothrow) ParallelAnimationGroup(*pParallelAnimGrp);
551 SysTryReturnResult(NID_UI_ANIM, (pParallelAnimationGroup), E_OUT_OF_MEMORY, "Memory allocation failed.");
553 if (pParallelAnimationGroup->GetAnimationCount() != pParallelAnimGrp->GetAnimationCount())
555 if (pParallelAnimationGroup->GetAnimationCount() > 0)
557 pParallelAnimationGroup->RemoveAllAnimations();
560 delete pParallelAnimationGroup;
562 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to clone ParallelAnimationGroup instance.");
566 if (_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1))
568 _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1)->RemoveAllAnimations();
569 delete _pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1);
570 _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, null);
571 _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_NONE);
573 _pControlAnimatorImpl->SetPropertyGroupList(animTrigger - 1, pParallelAnimationGroup);
574 _pControlAnimatorImpl->SetStoredPropertyAnimationGroupType(animTrigger - 1, PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL);
581 ControlAnimator::GetAnimationN(ControlAnimatorTriggerType animTrigger) const
583 SysTryReturn(NID_UI_ANIM, ((animTrigger >= ANIMATION_TRIGGER_POSITION_CHANGE) && (animTrigger <= ANIMATION_TRIGGER_SHOW_STATE_CHANGE)),
584 null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. animTrigger is invalid.");
585 SysTryReturn(NID_UI_ANIM, (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(animTrigger - 1) != PROPERTY_ANIMATION_GROUP_TYPE_NONE),
586 null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. No implicit animations set to control.");
588 if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(animTrigger - 1) == PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL)
590 ParallelAnimationGroup* pTempParallelAnimGroup = dynamic_cast< ParallelAnimationGroup* >(_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1));
591 SysTryReturn(NID_UI_ANIM, (pTempParallelAnimGroup), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get ParallelAnimationGroup instance.");
593 ParallelAnimationGroup* pParallelAnimationGroup = new (std::nothrow) ParallelAnimationGroup(*pTempParallelAnimGroup);
594 SysTryReturn(NID_UI_ANIM, (pParallelAnimationGroup), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
595 SysTryReturn(NID_UI_ANIM, (pParallelAnimationGroup->GetAnimationCount() > 0), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to create ParallelAnimationGroup.");
597 return pParallelAnimationGroup;
599 else if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(animTrigger - 1) == PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL)
601 SequentialAnimationGroup* pTempSequentialAnimGroup = dynamic_cast< SequentialAnimationGroup* >(_pControlAnimatorImpl->GetPropertyGroupList(animTrigger - 1));
602 SysTryReturn(NID_UI_ANIM, (pTempSequentialAnimGroup), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to clone SequentialAnimationGroup.");
604 SequentialAnimationGroup* pSequentialAnimationGroup = new (std::nothrow) SequentialAnimationGroup(*pTempSequentialAnimGroup);
605 SysTryReturn(NID_UI_ANIM, (pSequentialAnimationGroup), null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
606 SysTryReturn(NID_UI_ANIM, (pSequentialAnimationGroup->GetAnimationCount() > 0), null, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to create SequentialAnimationGroup instance.");
608 return pSequentialAnimationGroup;
612 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Invalid property animation group type provided.");
618 ControlAnimator::SetPosition(int x, int y)
620 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_POSITION) == false), E_INVALID_OPERATION, "Same AnimationTargetType is already being animated.");
622 result r = E_SUCCESS;
624 Control& controlRef = _pControlAnimatorImpl->GetControl();
625 Rectangle controlBounds = controlRef.GetBounds();
626 Point newPosition = Point(x, y);
627 Point currentPosition = controlRef.GetPosition();
629 SysTryReturnResult(NID_UI_ANIM, (controlRef.IsMovable()), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified.");
631 //CustomControl s Condition check
632 CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(&controlRef);
636 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(_pControlAnimatorImpl->GetControl());
637 pControlImpl->OnBoundsChanging(Rectangle(x, y, controlRef.GetWidth(), controlRef.GetHeight()));
640 int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount();
641 AnimationBase* pAnimationBase = null;
643 if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_POSITION_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE)
645 if (currentPosition == newPosition)
650 PointAnimation* pPointAnim = new (std::nothrow) PointAnimation(currentPosition, newPosition, 400, ANIMATION_INTERPOLATOR_LINEAR);
651 SysTryReturnResult(NID_UI_ANIM, (pPointAnim), E_OUT_OF_MEMORY, "Memory allocation failed.");
653 pAnimationBase = pPointAnim;
655 Rectangle rect(x, y, 0, 0);
657 if (!(_pControlAnimatorImpl->IsAnimatable(ANIMATION_TARGET_POSITION, rect, pAnimationBase, ANIMATION_TRIGGER_POSITION_CHANGE)))
659 delete pAnimationBase;
661 SysLogException(NID_UI_ANIM, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation type or position is invalid.");
662 return E_INVALID_ARG;
664 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
666 r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_POSITION, *pAnimationBase);
669 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set control property.");
673 delete pAnimationBase;
679 _pControlAnimatorImpl->SetLogicalBounds(controlRef.GetBounds());
680 _pControlAnimatorImpl->SetControlLogicalBounds(ANIMATION_TARGET_POSITION, *pAnimationBase);
682 bool disable = false;
683 bool propagation = false;
685 result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable);
686 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
688 r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
689 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
691 r = controlRef.SetBounds(_pControlAnimatorImpl->GetLogicalBounds());
695 _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
699 _pControlAnimatorImpl->DisableImplicitAnimation(disable);
702 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds.");
703 r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_POSITION, *pAnimationBase, ANIMATION_TRIGGER_POSITION_CHANGE);
704 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
710 Rectangle logicalBounds(x, y, controlBounds.width, controlBounds.height);
712 _pControlAnimatorImpl->SetLogicalBounds(logicalBounds);
714 //Need to call control bounds inside StartCustomImplicitAnimation
715 r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_POSITION_CHANGE, x, y, controlBounds.width,
716 controlBounds.height,
718 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set logical bounds.");
721 //When Control's property is set with End Bounds in Custom Implicit animation params, it should return from here without animation
722 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
727 _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_POSITION_CHANGE);
734 if (_pControlAnimatorImpl->DestroyAnimation(*pAnimationBase, ANIMATION_TARGET_POSITION) == E_SUCCESS)
736 pAnimationBase = null;
740 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation.");
745 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) == E_SUCCESS),
746 E_SYSTEM, "A system error has been occurred. Failed to destroy animation.");
752 ControlAnimator::SetPosition(const Point& Position)
754 return SetPosition(Position.x, Position.y);
758 ControlAnimator::SetSize(int width, int height)
760 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_SIZE) == false), E_INVALID_OPERATION, "Same AnimationTargetType is being animated.");
761 SysTryReturnResult(NID_UI_ANIM, ((width > 0) && (height > 0)), E_INVALID_ARG, "Invalid argument(s) is used. width = %d, height = %d", width, height);
763 result r = E_SUCCESS;
764 Control& controlRef = _pControlAnimatorImpl->GetControl();
765 Rectangle controlBounds = controlRef.GetBounds();
766 Dimension newSize = Dimension(width, height);
767 Dimension currentSize = controlRef.GetSize();
769 SysTryReturnResult(NID_UI_ANIM, (controlRef.IsResizable()), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified.");
771 //CustomControl Bounds Condition check
772 CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(&controlRef);
775 Dimension dim(width, height);
776 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(_pControlAnimatorImpl->GetControl());
777 pControlImpl->OnEvaluateSize(dim);
781 SysTryReturnResult(NID_UI_ANIM, !((width < controlRef.GetMinimumSize().width) ||
782 (height < controlRef.GetMinimumSize().height) ||
783 (width > controlRef.GetMaximumSize().width) ||
784 (height > controlRef.GetMaximumSize().height)), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified.");
787 int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount();
788 AnimationBase* pAnimationBase = null;
790 if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_SIZE_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE)
792 if (currentSize == newSize)
797 DimensionAnimation* pDimensionAnim = new (std::nothrow) DimensionAnimation(currentSize, newSize, 400, ANIMATION_INTERPOLATOR_LINEAR);
798 SysTryReturnResult(NID_UI_ANIM, (pDimensionAnim), E_OUT_OF_MEMORY, "Memory allocation failed.");
800 pAnimationBase = pDimensionAnim;
802 Rectangle rect(0, 0, width, height);
804 if (!(_pControlAnimatorImpl->IsAnimatable(ANIMATION_TARGET_SIZE, rect, pAnimationBase, ANIMATION_TRIGGER_SIZE_CHANGE)))
806 delete pAnimationBase;
808 SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. Animation type or size is invalid.");
809 return E_INVALID_ARG;
812 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
814 r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_SIZE, *pAnimationBase);
818 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Control property is not set.");
822 delete pAnimationBase;
828 _pControlAnimatorImpl->SetLogicalBounds(controlRef.GetBounds());
829 _pControlAnimatorImpl->SetControlLogicalBounds(ANIMATION_TARGET_SIZE, *pAnimationBase);
831 bool disable = false;
832 bool propagation = false;
834 result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable);
835 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
837 r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
838 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
840 r = controlRef.SetBounds(_pControlAnimatorImpl->GetLogicalBounds());
844 _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
848 _pControlAnimatorImpl->DisableImplicitAnimation(disable);
851 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds.");
854 r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_SIZE, *pAnimationBase, ANIMATION_TRIGGER_SIZE_CHANGE);
855 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
860 Rectangle logicalBounds(controlBounds.x, controlBounds.y, width, height);
861 _pControlAnimatorImpl->SetLogicalBounds(logicalBounds);
862 //Call control set bounds inside StartCustomImplicitAnimation
863 //start custom Implicit animation
864 r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_SIZE_CHANGE, controlBounds.x, controlBounds.y, width, height, false);
865 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation.");
867 //When Control's property is set with End Bounds in Custom Implicit animation params, it should return from here without animation
868 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
873 _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_SIZE_CHANGE);
880 if (_pControlAnimatorImpl->DestroyAnimation(*pAnimationBase, ANIMATION_TARGET_SIZE) != E_SUCCESS)
882 pAnimationBase = null;
886 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation.");
891 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) == E_SUCCESS),
892 E_SYSTEM, "A system error has been occurred. Failed to destroy animation.");
898 ControlAnimator::SetSize(const Dimension& size)
900 return SetSize(size.width, size.height);
904 ControlAnimator::SetBounds(int x, int y, int width, int height)
906 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_POSITION) == false), E_INVALID_OPERATION, "Same AnimationTargetType being animated.");
907 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_SIZE) == false), E_INVALID_OPERATION, "Same AnimationTargetType being animated.");
908 SysTryReturnResult(NID_UI_ANIM, (width >= 0 && height >= 0), E_INVALID_ARG, "Invalid argument(s) is used. width = %d, height = %d", width, height);
910 result r = E_SUCCESS;
911 Control& controlRef = _pControlAnimatorImpl->GetControl();
912 Rectangle newBounds = Rectangle(x, y, width, height);
913 Rectangle currentBounds = controlRef.GetBounds();
915 SysTryReturnResult(NID_UI_ANIM, !((controlRef.IsMovable() == false) || (controlRef.IsResizable() == false)), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified.");
917 if (controlRef.IsResizable() == true)
919 //CustomControl Bounds Condition check
920 CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(&controlRef);
924 Rectangle rect(x, y, width, height);
925 _ControlImpl* pControlImpl = _ControlImpl::GetInstance(_pControlAnimatorImpl->GetControl());
926 pControlImpl->OnBoundsChanging(rect);
930 SysTryReturnResult(NID_UI_ANIM, !((width < controlRef.GetMinimumSize().width) ||
931 (height < controlRef.GetMinimumSize().height) ||
932 (width > controlRef.GetMaximumSize().width) ||
933 (height > controlRef.GetMaximumSize().height)), E_UNSUPPORTED_OPERATION, "Bounds cannot be modified.");
937 Point newPosition = Point(x, y);
938 Point currentPosition = controlRef.GetPosition();
939 Dimension newSize = Dimension(width, height);
940 Dimension currentSize = controlRef.GetSize();
941 int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount();
942 AnimationBase* pPointAnimationBase = null;
943 AnimationBase* pDimensionAnimationBase = null;
944 Rectangle logicalBounds(x, y, width, height);
945 _pControlAnimatorImpl->SetLogicalBounds(logicalBounds);
947 if ((_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_POSITION_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE) &&
948 (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_SIZE_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE))
950 if (currentBounds == newBounds)
957 if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_POSITION_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE)
959 pPointAnimationBase = new (std::nothrow) PointAnimation(currentPosition, newPosition, 400, ANIMATION_INTERPOLATOR_LINEAR);
960 SysTryReturnResult(NID_UI_ANIM, (pPointAnimationBase), E_OUT_OF_MEMORY, "Memory allocation failed.");
962 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
964 r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_POSITION, *pPointAnimationBase);
966 delete pPointAnimationBase;
967 pPointAnimationBase = null;
969 //Do not return if success, set size Bounds and then return.
970 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Control property is not set.");
974 //Create and set the animation to the layer
975 _pControlAnimatorImpl->SetControlLogicalBounds(ANIMATION_TARGET_POSITION, *pPointAnimationBase);
977 bool disable = false;
978 bool propagation = false;
980 result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable);
981 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
983 r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
984 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
986 r = controlRef.SetBounds(_pControlAnimatorImpl->GetLogicalBounds());
990 _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
994 _pControlAnimatorImpl->DisableImplicitAnimation(disable);
997 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds.");
999 r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_POSITION, *pPointAnimationBase, ANIMATION_TRIGGER_POSITION_CHANGE);
1000 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1005 //call control Setbounds API inside StartCustomImplicitAnimation
1006 r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_POSITION_CHANGE, x, y, width, height, false);
1007 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation.");
1011 if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_SIZE_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE)
1013 DimensionAnimation* pDimensionAnim = new (std::nothrow) DimensionAnimation(currentSize, newSize, 400, ANIMATION_INTERPOLATOR_LINEAR);
1014 SysTryReturnResult(NID_UI_ANIM, (pDimensionAnim), E_OUT_OF_MEMORY, "Memory allocation failed.");
1015 pDimensionAnimationBase = pDimensionAnim;
1017 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
1019 r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_SIZE, *pDimensionAnimationBase);
1022 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Control property is not set.");
1026 delete pDimensionAnimationBase;
1032 _pControlAnimatorImpl->SetControlLogicalBounds(ANIMATION_TARGET_SIZE, *pDimensionAnimationBase);
1034 bool disable = false;
1035 bool propagation = false;
1037 result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable);
1038 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
1040 r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
1041 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
1043 r = controlRef.SetBounds(_pControlAnimatorImpl->GetLogicalBounds());
1047 _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
1051 _pControlAnimatorImpl->DisableImplicitAnimation(disable);
1054 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds.");
1056 r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_SIZE, *pDimensionAnimationBase, ANIMATION_TRIGGER_SIZE_CHANGE);
1057 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1062 //call control setbounds inside StartCustomImplicitAnimation
1063 r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_SIZE_CHANGE, x, y, width, height, false);
1064 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation.");
1067 //When Control's property is set with End Bounds in Custom Implicit animation params, it should return from here without animation
1068 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
1073 _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_POSITION_CHANGE);
1074 _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_SIZE_CHANGE);
1079 if (pPointAnimationBase)
1081 if (_pControlAnimatorImpl->DestroyAnimation(*pPointAnimationBase, ANIMATION_TARGET_POSITION) != E_SUCCESS)
1083 pPointAnimationBase = null;
1087 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation.");
1091 if (pDimensionAnimationBase)
1093 if (_pControlAnimatorImpl->DestroyAnimation(*pDimensionAnimationBase, ANIMATION_TARGET_SIZE) != E_SUCCESS)
1095 pDimensionAnimationBase = null;
1099 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to destroy animation.");
1104 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) == E_SUCCESS),
1105 E_SYSTEM, "A system error has been occurred. Failed to destroy animation.");
1111 ControlAnimator::SetBounds(const Rectangle& rect)
1113 return SetBounds(rect.x, rect.y, rect.width, rect.height);
1117 ControlAnimator::SetShowState(bool show)
1119 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->IsAnimationTargetAnimating(ANIMATION_TARGET_ALPHA) == false), E_INVALID_OPERATION, "Same AnimationTargetType being animated.");
1121 result r = E_SUCCESS;
1122 Control& controlRef = _pControlAnimatorImpl->GetControl();
1123 int activeAnimationCount = _pControlAnimatorImpl->GetActiveAnimationListCount();
1124 bool currentShowState = controlRef.GetShowState();
1125 bool newShowState = show;
1126 FloatAnimation* pFloatAnim = null;
1127 AnimationBase* pAnimationBase = null;
1129 if (_pControlAnimatorImpl->GetStoredPropertyAnimationGroupType(ANIMATION_TRIGGER_SHOW_STATE_CHANGE - 1) == PROPERTY_ANIMATION_GROUP_TYPE_NONE)
1131 SysTryReturnResult(NID_UI_ANIM, (currentShowState != newShowState), E_SUCCESS, "Current show state of control is same as new show state.");
1133 pFloatAnim = new (std::nothrow) FloatAnimation(((newShowState) ? (0.0f) : (1.0f)), ((newShowState) ? (1.0f) : (0.0f)), 400, ANIMATION_INTERPOLATOR_LINEAR);
1134 SysTryReturnResult(NID_UI_ANIM, (pFloatAnim), E_OUT_OF_MEMORY, "Memory allocation failed.");
1135 pAnimationBase = pFloatAnim;
1137 Rectangle rect(0, 0, 0, 0);
1139 if (!(_pControlAnimatorImpl->IsAnimatable(ANIMATION_TARGET_ALPHA, rect, pAnimationBase, ANIMATION_TRIGGER_SHOW_STATE_CHANGE)))
1141 delete pAnimationBase;
1143 SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. Custom implicit animation parameters are wrong.");
1144 return E_INVALID_ARG;
1146 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
1148 r = _pControlAnimatorImpl->SetControlProperty(ANIMATION_TARGET_ALPHA, *pAnimationBase);
1151 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Control property is not set.");
1155 delete pAnimationBase;
1161 _pControlAnimatorImpl->SetControlShowState(ANIMATION_TARGET_ALPHA, *pAnimationBase);
1164 bool disable = false;
1165 bool propagation = false;
1167 result r = _pControlAnimatorImpl->DisableImplicitAnimation(disable);
1168 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
1170 r = _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
1171 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
1173 r = _pControlAnimatorImpl->GetControl().SetShowState((_pControlAnimatorImpl->GetShowState()));
1177 _pControlAnimatorImpl->DisableVisualElementPropagation(propagation);
1181 _pControlAnimatorImpl->DisableImplicitAnimation(disable);
1184 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set show state.");
1186 r = _pControlAnimatorImpl->SetAnimation(ANIMATION_TARGET_ALPHA, *pAnimationBase, ANIMATION_TRIGGER_SHOW_STATE_CHANGE);
1187 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
1192 _pControlAnimatorImpl->SetShowState(newShowState);
1193 //Call control set show state inside StartCustomImplicitAnimation
1194 r = _pControlAnimatorImpl->StartCustomImplicitAnimation(ANIMATION_TRIGGER_SHOW_STATE_CHANGE, 0, 0, 0, 0, newShowState);
1195 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation.");
1197 //When Control's property is set with End ShowState in Custom Implicit animation params, it should return from here without animation
1198 if (_pControlAnimatorImpl->IsAnimationSupported() == false)
1203 _pControlAnimatorImpl->SetAnimationTargetStatus(ANIMATION_TRIGGER_SHOW_STATE_CHANGE);
1210 if (_pControlAnimatorImpl->DestroyAnimation(*pAnimationBase, ANIMATION_TARGET_ALPHA) != E_SUCCESS)
1212 pAnimationBase = null;
1216 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to deallocate memory.");
1221 if (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) != E_SUCCESS)
1223 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to deallocate memory.");
1226 SysTryReturnResult(NID_UI_ANIM, (_pControlAnimatorImpl->DestroyAnimation(activeAnimationCount) == E_SUCCESS),
1227 E_SYSTEM, "A system error has been occurred. Failed to destroy animation.");
1232 ControlAnimator::IsAnimationSupported(AnimationTargetType animTarget) const
1236 case ANIMATION_TARGET_POSITION:
1237 return _pControlAnimatorImpl->GetControl().IsMovable();
1239 case ANIMATION_TARGET_SIZE:
1240 return _pControlAnimatorImpl->GetControl().IsResizable();
1242 case ANIMATION_TARGET_ALPHA:
1245 case ANIMATION_TARGET_ROTATION:
1254 }}} // Tizen::Ui::Animations