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_ControlAnimatorImpl.cpp
20 * @brief This file contains implementation of _ControlAnimatorImpl class
22 * This file contains implementation _ControlAnimatorImpl class.
25 #include <FBaseSysLog.h>
26 #include <FBaseTypes.h>
28 #include <FUiControl.h>
29 #include <FUiCtrlForm.h>
30 #include <FUiCtrlFrame.h>
31 #include <FUiCustomControlBase.h>
33 #include <FUiAnimDimensionAnimation.h>
34 #include <FUiAnimPointAnimation.h>
35 #include <FUiAnimRectangleAnimation.h>
36 #include <FUiAnimIntegerAnimation.h>
37 #include <FUiAnimFloatAnimation.h>
38 #include <FUiAnimRotateAnimation.h>
39 #include <FUiAnimVisualElement.h>
40 #include <FUiAnimVisualElementPropertyAnimation.h>
41 #include <FUiAnimVisualElementAnimationGroup.h>
42 #include <FUiAnimBezierTimingFunction.h>
44 #include "FUi_ControlImplManager.h"
45 #include "FUi_WindowImpl.h"
46 #include "FUiAnim_ControlAnimatorImpl.h"
47 #include "FUiAnim_VisualElement.h"
48 #include "FUiAnim_VisualElementImpl.h"
49 #include "FUiAnim_VisualElementAnimationImpl.h"
50 #include "FUiAnim_VisualElementAnimationKeyFrame.h"
51 #include "FUiAnim_AnimationManager.h"
52 #include "FUiAnim_MatrixUtil.h"
55 using namespace Tizen::Base;
56 using namespace Tizen::Base::Collection;
57 using namespace Tizen::Graphics;
58 using namespace Tizen::Ui;
59 using namespace Tizen::Ui::Controls;
62 #define TRANSACTION "TRANSACTION"
64 #define POSITION "POS"
65 #define DIMENSION "DIM"
67 #define ROTATION "ROT"
70 namespace Tizen { namespace Ui { namespace Animations
73 ///INIT_SYSCLASSTYPE(_ControlAnimatorImpl);
75 _ControlAnimatorImpl::_ControlAnimatorImpl(ControlAnimator* pControlAnimator)
76 : __pActiveAnimationList(null)
78 , __pControlImpl(null)
79 , __animatorStatus(ANIMATOR_STATUS_STOPPED)
80 , __logicalBoundsHolder(0, 0, 0, 0)
81 , __showStateHolder(true)
83 , __prevAnimationBoundsHolder(0, 0, 0, 0)
84 , __sequentialGroupAnimation(false)
86 , __pControlAnimator(pControlAnimator)
87 , __pVisualElement(null)
88 , __pAnimStatusEventListener(null)
89 , __pAnimDetailedEventListener(null)
92 , __presentationBounds(0.0f, 0.0f, 0.0f, 0.0f)
94 for (int animTarget = 0; animTarget < ANIMATION_TARGET_MAX; animTarget++)
96 __isAnimationTargetAnimating[animTarget] = false;
99 for (int property = 0; property < ANIMATION_TRIGGER_SHOW_STATE_CHANGE; property++)
101 __pPropertyAnimationGroupList[property] = null;
102 __propertyAnimationGroupType[property] = PROPERTY_ANIMATION_GROUP_TYPE_NONE;
107 _ControlAnimatorImpl::Construct(const Control& source)
109 result r = E_SUCCESS;
111 SysAssertf((__pControl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
113 __pControl = const_cast< Control* >(&source);
114 __pActiveAnimationList = new (std::nothrow) ArrayListT< ActiveAnimation >();
115 SysTryCatch(NID_UI_ANIM, __pActiveAnimationList != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
117 r = __pActiveAnimationList->Construct();
118 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] Failed to construct _ControlAnimatorImpl instance.");
120 __pControlImpl = _ControlImpl::GetInstance(*__pControl);
121 __pVisualElement = __pControlImpl->GetCore().GetVisualElement();
131 _ControlAnimatorImpl::~_ControlAnimatorImpl()
133 result r = E_SUCCESS;
139 SysLogException(NID_UI_ANIM, r, "[%s] Propagating.", GetErrorMessage(r));
142 for (int animTrigger = 0; animTrigger < ANIMATION_TRIGGER_SHOW_STATE_CHANGE; animTrigger++)
144 if (__pPropertyAnimationGroupList[animTrigger])
146 __pPropertyAnimationGroupList[animTrigger]->RemoveAllAnimations();
147 delete __pPropertyAnimationGroupList[animTrigger];
148 __pPropertyAnimationGroupList[animTrigger] = null;
152 delete __pAnimStatusEventListener;
153 __pAnimStatusEventListener = null;
154 delete __pAnimDetailedEventListener;
155 __pAnimDetailedEventListener = null;
159 _ControlAnimatorImpl::Dispose(void)
161 result r = E_SUCCESS;
163 if (__pActiveAnimationList)
165 r = RemoveAllAnimations();
168 SysLogException(NID_UI_ANIM, r, "[%s] Failed to remove all animations.", GetErrorMessage(r));
171 __pActiveAnimationList->RemoveAll();
173 delete __pActiveAnimationList;
174 __pActiveAnimationList = null;
181 _ControlAnimatorImpl::ActiveAnimation::operator ==(const _ControlAnimatorImpl::ActiveAnimation& rhs) const
183 if ((animTarget == rhs.animTarget) && (pAnimationBase == rhs.pAnimationBase))
192 _ControlAnimatorImpl::ActiveAnimation::operator !=(const _ControlAnimatorImpl::ActiveAnimation& rhs) const
194 if ((animTarget != rhs.animTarget) || (pAnimationBase != rhs.pAnimationBase))
203 _ControlAnimatorImpl::SetAnimation(AnimationTargetType animTarget, AnimationBase& animationBase, ControlAnimatorTriggerType triggerType, VisualElementAnimationGroup* pAnimationGroup)
205 result r = E_SUCCESS;
206 AnimationBase* pAnimationBase = const_cast< AnimationBase* >(&animationBase);
207 String animIdentifier;
208 const IVisualElementAnimationTimingFunction* pTimingFunction = null;
209 BezierTimingFunction* pBezierTimingFunction = null;
211 SysTryReturnResult(NID_UI_ANIM, (animTarget > ANIMATION_TARGET_NONE && animTarget < ANIMATION_TARGET_MAX), E_INVALID_OPERATION, "Invalid Argument is used. animTarget is invalid.");
213 switch (pAnimationBase->GetInterpolatorType())
215 case ANIMATION_INTERPOLATOR_LINEAR:
217 pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_LINEAR);
221 case ANIMATION_INTERPOLATOR_EASE_IN:
223 pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEIN);
227 case ANIMATION_INTERPOLATOR_EASE_OUT:
229 pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEOUT);
233 case ANIMATION_INTERPOLATOR_EASE_IN_OUT:
235 pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_EASEINOUT);
239 case ANIMATION_INTERPOLATOR_DISCRETE:
241 pTimingFunction = VisualElementAnimation::GetTimingFunctionByName(INTERPOLATOR_DISCRETE);
245 case ANIMATION_INTERPOLATOR_BEZIER:
248 float cpValue1 = 0.0;
250 float cpValue2 = 0.0;
252 r = pAnimationBase->GetBezierControlPoints(cpTime1, cpValue1, cpTime2, cpValue2);
253 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get bezier points.");
255 pBezierTimingFunction = new (std::nothrow) BezierTimingFunction();
256 SysTryReturnResult(NID_UI_ANIM, (pBezierTimingFunction), E_OUT_OF_MEMORY, "Memory allocation failed.");
258 pBezierTimingFunction->SetControlPoints(cpTime1, cpValue1, cpTime2, cpValue2);
259 pTimingFunction = pBezierTimingFunction;
265 SysTryReturnResult(NID_UI_ANIM, (pTimingFunction != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
267 VisualElementPropertyAnimation* pAnimation = null;
268 VisualElementValueAnimation* pBoundsAnimation = null;
269 VisualElementValueAnimation* pBaseAnimation = null;
271 if (animTarget == ANIMATION_TARGET_SIZE)
273 pBoundsAnimation = new (std::nothrow) VisualElementValueAnimation(); //deletion will happen in catch/ in Destroy animation
274 SysTryCatch(NID_UI_ANIM, (pBoundsAnimation), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
276 pBoundsAnimation->SetTimingFunction(pTimingFunction);
280 pAnimation = new (std::nothrow) VisualElementPropertyAnimation(); //deletion will happen in catch/ in Destroy animation
281 SysTryCatch(NID_UI_ANIM, (pAnimation), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
283 pAnimation->SetTimingFunction(pTimingFunction);
288 case ANIMATION_TARGET_SIZE:
290 DimensionAnimation* pDimensionAnim = null;
291 RectangleAnimation* pRectangleAnim = null;
293 pDimensionAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase);
294 pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
296 SysTryCatch(NID_UI_ANIM, ((pDimensionAnim) || (pRectangleAnim)), ,
297 E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid.");
299 Dimension controlSize;
300 Dimension controlPrevSize;
301 float anchorX = 0.0f;
302 float anchorY = 0.0f;
304 float startWidth = 0.0f;
305 float startHeight = 0.0f;
306 float endWidth = 0.0f;
307 float endHeight = 0.0f;
309 controlSize = __pControl->GetSize();
310 controlPrevSize.width = __prevAnimationBoundsHolder.width;
311 controlPrevSize.height = __prevAnimationBoundsHolder.height;
315 pDimensionAnim->GetAnchor(anchorX, anchorY);
317 Dimension startSize = pDimensionAnim->GetStartValue();
318 Dimension endSize = pDimensionAnim->GetEndValue();
320 startWidth = static_cast< float >(startSize.width);
321 startHeight = static_cast< float >(startSize.height);
322 endWidth = static_cast< float >(endSize.width);
323 endHeight = static_cast< float >(endSize.height);
325 if (__sequentialGroupAnimation)
327 controlSize = controlPrevSize;
331 Dimension StartDim = _CoordinateSystemUtils::Transform(StartSize);
332 Dimension EndDim = _CoordinateSystemUtils::Transform(EndSize);
333 Dimension ControlDim = _CoordinateSystemUtils::Transform(ControlSize);
335 Dimension ControlPrevDim = _CoordinateSystemUtils::Transform(ControlPrevSize);
336 ControlPrevSize = ControlPrevDim;
338 StartSize = StartDim;
340 ControlSize = ControlDim;
345 pRectangleAnim->GetAnchor(anchorX, anchorY);
347 Rectangle startSize = pRectangleAnim->GetStartValue();
348 Rectangle endSize = pRectangleAnim->GetEndValue();
350 if (__sequentialGroupAnimation)
352 controlSize = controlPrevSize;
355 startWidth = static_cast< float >(startSize.width);
356 startHeight = static_cast< float >(startSize.height);
357 endWidth = static_cast< float >(endSize.width);
358 endHeight = static_cast< float >(endSize.height);
361 Rectangle StartRect = _CoordinateSystemUtils::Transform(StartSize);
362 Rectangle EndRect = _CoordinateSystemUtils::Transform(EndSize);
363 Dimension ControlDim = _CoordinateSystemUtils::Transform(ControlSize);
365 Dimension ControlPrevDim = _CoordinateSystemUtils::Transform(ControlPrevSize);
366 ControlPrevSize = ControlPrevDim;
368 StartSize = StartRect;
370 ControlSize = ControlDim;
374 FloatRectangle presentationBounds = const_cast<VisualElement*>((__pVisualElement)->AcquirePresentationInstance())->GetBounds();
375 FloatRectangle modelBounds = __pVisualElement->GetBounds();
377 __presentationBounds = presentationBounds;
379 float currentAnchorX = presentationBounds.width * anchorX;
380 float currentAnchorY = presentationBounds.height * anchorY;
382 float startAnchorX = startWidth * anchorX;
383 float startAnchorY = startHeight * anchorY;
385 float endAnchorX = endWidth * anchorX;
386 float endAnchorY = endHeight * anchorY;
388 float startX = presentationBounds.x + (currentAnchorX - startAnchorX);
389 float startY = presentationBounds.y + (currentAnchorY - startAnchorY);
391 float endX = modelBounds.x + (currentAnchorX - endAnchorX);
392 float endY = modelBounds.y + (currentAnchorY - endAnchorY);
394 pBoundsAnimation->SetStartValue(Variant(FloatRectangle(startX, startY, startWidth, startHeight)));
395 pBoundsAnimation->SetEndValue(Variant(FloatRectangle(endX, endY, endWidth, endHeight)));
396 pBoundsAnimation->SetVisualElementAnimationTickEventListener(this);
397 animIdentifier.Append(DIMENSION);
399 __pVisualElement->ReleasePresentationInstance();
403 case ANIMATION_TARGET_POSITION:
405 PointAnimation* pPointAnim = null;
406 RectangleAnimation* pRectangleAnim = null;
408 pPointAnim = dynamic_cast< PointAnimation* >(pAnimationBase);
409 pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
411 SysTryCatch(NID_UI_ANIM, ((pPointAnim) || (pRectangleAnim)), , E_INVALID_ARG,
412 "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid.");
415 float absStartX = 0.0f;
416 float absStartY = 0.0f;
417 float absEndX = 0.0f;
418 float absEndY = 0.0f;
420 controlPos = __pControl->GetPosition();
422 Point parentPosition(0, 0);
424 if (__pControlImpl->GetParent())
426 parentPosition.x = __pControlImpl->GetParent()->GetClientBounds().x;
427 parentPosition.y = __pControlImpl->GetParent()->GetClientBounds().y;
432 Point startPos = pPointAnim->GetStartValue();
433 Point endPos = pPointAnim->GetEndValue();
435 absStartX = (static_cast< float >(parentPosition.x) + static_cast< float >(startPos.x));
436 absStartY = (static_cast< float >(parentPosition.y) + static_cast< float >(startPos.y));
438 absEndX = (static_cast< float >(parentPosition.x) + static_cast< float >(endPos.x));
439 absEndY = (static_cast< float >(parentPosition.y) + static_cast< float >(endPos.y));
441 //Todo : below API's are unavailable now
443 Point StartPt = _CoordinateSystemUtils::Transform(StartPos);
444 Point EndPt = _CoordinateSystemUtils::Transform(EndPos);
445 Point ControlPt = _CoordinateSystemUtils::Transform(controlPos);
448 controlPos = ControlPt;
453 Rectangle startPos = pRectangleAnim->GetStartValue();
454 Rectangle endPos = pRectangleAnim->GetEndValue();
456 absStartX = (static_cast< float >(parentPosition.x) + static_cast< float >(startPos.x));
457 absStartY = (static_cast< float >(parentPosition.y) + static_cast< float >(startPos.y));
459 absEndX = (static_cast< float >(parentPosition.x) + static_cast< float >(endPos.x));
460 absEndY = (static_cast< float >(parentPosition.y) + static_cast< float >(endPos.y));
463 Rectangle StartRect = _CoordinateSystemUtils::Transform(StartPos);
464 Rectangle EndRect = _CoordinateSystemUtils::Transform(EndPos);
465 Point ControlPt = _CoordinateSystemUtils::Transform(controlPos);
466 StartPos = StartRect;
468 controlPos = ControlPt;
472 pAnimation->SetPropertyName(VeSubPropBoundsPosition);
474 Variant startPosition(FloatPoint(absStartX, absStartY));
475 Variant endPosition(FloatPoint(absEndX, absEndY));
477 pAnimation->SetStartValue(startPosition);
478 pAnimation->SetEndValue(endPosition);
479 animIdentifier.Append(POSITION);
483 case ANIMATION_TARGET_ALPHA:
485 IntegerAnimation* pIntegerAnim = null;
486 FloatAnimation* pFloatAnim = null;
488 pIntegerAnim = dynamic_cast< IntegerAnimation* >(pAnimationBase);
489 pFloatAnim = dynamic_cast< FloatAnimation* >(pAnimationBase);
491 SysTryCatch(NID_UI_ANIM, ((pIntegerAnim) || (pFloatAnim)), , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid.");
493 pAnimation->SetPropertyName(VePrivPropShowOpacity); // need to change this with show state
500 startAlpha = pIntegerAnim->GetStartValue();
501 endAlpha = pIntegerAnim->GetEndValue();
503 Variant startOpacityInt(static_cast< float >(startAlpha));
504 Variant endOpacityInt(static_cast< float >(endAlpha));
506 pAnimation->SetStartValue(startOpacityInt);
507 pAnimation->SetEndValue(endOpacityInt);
511 float startAlpha = 0.0;
512 float endAlpha = 1.0;
514 startAlpha = static_cast< float >(pFloatAnim->GetStartValue());
515 endAlpha = static_cast< float >(pFloatAnim->GetEndValue());
517 Variant startOpacityFloat(startAlpha);
518 Variant endOpacityFloat(endAlpha);
520 pAnimation->SetStartValue(startOpacityFloat);
521 pAnimation->SetEndValue(endOpacityFloat);
523 animIdentifier.Append(ALPHA);
527 case ANIMATION_TARGET_ROTATION:
529 RotateAnimation* pRotateAnim = null;
530 float anchorX = 0.0f;
531 float anchorY = 0.0f;
533 pRotateAnim = dynamic_cast< RotateAnimation* >(pAnimationBase);
534 SysTryCatch(NID_UI_ANIM, (pRotateAnim), , E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid.");
536 pAnimation->SetPropertyName(VeSubPropTransformRotationZ); //check this :Todo
537 pRotateAnim->GetAnchor(anchorX, anchorY);
539 _VisualElementImpl::GetInstance(*__pVisualElement)->SetAnchor(FloatPoint(anchorX, anchorY));
541 pAnimation->SetStartValue(Variant(pRotateAnim->GetStartValue()));
542 pAnimation->SetEndValue(Variant(pRotateAnim->GetEndValue()));
543 animIdentifier.Append(ROTATION);
548 SysAssertf(false, "Animation type is invalid!");
552 if (animTarget == ANIMATION_TARGET_SIZE)
554 pBaseAnimation = pBoundsAnimation;
558 pBaseAnimation = pAnimation;
561 //Set the Animation values and start the Animation
562 pBaseAnimation->SetRepeatCount(pAnimationBase->GetRepeatCount());
563 pBaseAnimation->SetEndValueApplied(pAnimationBase->IsHoldEndEnabled());
564 pBaseAnimation->SetAutoReverseEnabled(pAnimationBase->IsAutoReverseEnabled());
565 pBaseAnimation->SetScaleRatio(pAnimationBase->GetScaleRatio());
566 pBaseAnimation->SetDuration(pAnimationBase->GetDuration());
567 pBaseAnimation->SetOffset(pAnimationBase->GetOffset());
568 pBaseAnimation->SetDelay(pAnimationBase->GetDelay());
569 pBaseAnimation->SetVisualElementAnimationStatusEventListener(this);
571 if (__sequentialGroupAnimation)
573 pBaseAnimation->SetDelay(pAnimationBase->GetDelay() + __sequelDelay);
576 if (pAnimationBase->GetKeyFrameCount() > 0)
578 r = SetKeyFrameAnimation(animTarget, pAnimationBase, pTimingFunction, pBaseAnimation);
581 animIdentifier.Append(__animId);
583 if (_AnimationManager::GetInstance()->GetCurrentTransaction() != null)
585 animIdentifier.Append(TRANSACTION);
590 if (pAnimationGroup == null)
592 r = __pVisualElement->AddAnimation(animIdentifier, *pBaseAnimation);
593 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation could not be started.");
594 r = AddActiveAnimation(animTarget, *pAnimationBase, *pBaseAnimation, triggerType, animIdentifier, pBezierTimingFunction); //Todo : check this
595 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation could not be added to playlist.");
599 String* pAnimName = new (std::nothrow) String(animIdentifier.GetLength() + __groupName.GetLength());
600 SysTryCatch(NID_UI_ANIM, (pAnimName != null), , E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
602 *pAnimName = animIdentifier;
604 pAnimName->Append(__groupName);
606 pBaseAnimation->SetUserData((void*) (pAnimName));
608 r = pAnimationGroup->AddAnimation(*pBaseAnimation);
609 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation could not be added to the group.");
610 r = AddActiveAnimation(animTarget, *pAnimationBase, *pBaseAnimation, triggerType, *pAnimName, pBezierTimingFunction);
611 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation could not be added to playlist.");
617 //In case of error: free pAnimationBase if not added to ActiveAnimList. If added, its freed in Destroy Animation.
618 delete pAnimationBase;
620 delete pBoundsAnimation;
621 delete pBezierTimingFunction;
627 _ControlAnimatorImpl::SetCustomImplicitAnimationParams(ControlAnimatorTriggerType triggerType, AnimationBase& animationBase, Rectangle& bounds, bool showState, bool lastTargetOccurence)
629 result r = E_SUCCESS;
631 AnimationBase* pAnimationBase = const_cast< AnimationBase* >(&animationBase);
633 if ((__targetCount == 1) || ((__targetCount > 1) && lastTargetOccurence))
635 pAnimationBase->SetHoldEndEnabled(true);
636 pAnimationBase->SetAutoReverseEnabled(false);
639 if (triggerType == ANIMATION_TRIGGER_POSITION_CHANGE)
641 Point newPosition = Point(bounds.x, bounds.y);
642 Point currentPosition = __pControl->GetPosition();
644 PointAnimation* pPointAnim = null;
645 RectangleAnimation* pRectangleAnim = null;
647 pPointAnim = dynamic_cast< PointAnimation* >(pAnimationBase);
648 pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
649 SysTryReturnResult(NID_UI_ANIM, ((pPointAnim) || (pRectangleAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
653 if (__targetCount == 1)
655 pPointAnim->SetStartValue(currentPosition);
656 pPointAnim->SetEndValue(newPosition);
658 else //__targetCount > 1
660 (lastTargetOccurence) ? (pPointAnim->SetEndValue(newPosition)) : (pPointAnim->SetStartValue(currentPosition));
662 pAnimationBase = pPointAnim;
664 else //if (pRectangleAnim)
666 Rectangle newRectangle = Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
667 Rectangle currentRectangle = Rectangle(__pControl->GetBounds());
669 if (__targetCount == 1)
671 pRectangleAnim->SetStartValue(currentRectangle);
672 pRectangleAnim->SetEndValue(newRectangle);
674 else //__targetCount > 1
676 (lastTargetOccurence) ? (pRectangleAnim->SetEndValue(newRectangle)) : (pRectangleAnim->SetStartValue(currentRectangle));
678 pAnimationBase = pRectangleAnim;
681 else if (triggerType == ANIMATION_TRIGGER_SIZE_CHANGE)
683 Dimension newSize = Dimension(bounds.width, bounds.height);
684 Dimension currentSize = __pControl->GetSize();
686 DimensionAnimation* pDimensionAnim = null;
687 RectangleAnimation* pRectangleAnim = null;
689 pDimensionAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase);
690 pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
691 SysTryReturnResult(NID_UI_ANIM, ((pDimensionAnim) || (pRectangleAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
695 if (__targetCount == 1)
697 pDimensionAnim->SetStartValue(currentSize);
698 pDimensionAnim->SetEndValue(newSize);
700 else //__targetCount > 1
702 (lastTargetOccurence) ? (pDimensionAnim->SetEndValue(newSize)) : (pDimensionAnim->SetStartValue(currentSize));
704 pAnimationBase = pDimensionAnim;
706 else //if (pRectangleAnim)
708 Rectangle newRectangle = Rectangle(bounds.x, bounds.y, bounds.width, bounds.height);
709 Rectangle currentRectangle = Rectangle(__pControl->GetBounds());
711 if (__targetCount == 1)
713 pRectangleAnim->SetStartValue(currentRectangle);
714 pRectangleAnim->SetEndValue(newRectangle);
716 else //__targetCount > 1
718 (lastTargetOccurence) ? (pRectangleAnim->SetEndValue(newRectangle)) : (pRectangleAnim->SetStartValue(currentRectangle));
720 pAnimationBase = pRectangleAnim;
723 if (triggerType == ANIMATION_TRIGGER_SHOW_STATE_CHANGE)
725 FloatAnimation* pFloatAnim = null;
726 IntegerAnimation* pIntegerAnim = null;
728 pFloatAnim = dynamic_cast< FloatAnimation* >(pAnimationBase);
729 pIntegerAnim = dynamic_cast< IntegerAnimation* >(pAnimationBase);
730 SysTryReturnResult(NID_UI_ANIM, ((pFloatAnim) || (pIntegerAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
732 float newShowState = 0.0f;
733 float currentShowState = 0.0f;
734 int inewShowState = 0;
735 int icurrentShowState = 0;
739 newShowState = ((showState) ? (1.0f) : (0.0f));
740 currentShowState = ((showState) ? (0.0f) : (1.0f));
742 else //if (pIntegerAnim)
744 inewShowState = ((showState) ? (1) : (0));
745 icurrentShowState = ((showState) ? (0) : (1));
750 if (__targetCount == 1)
752 pFloatAnim->SetStartValue(currentShowState);
753 pFloatAnim->SetEndValue(newShowState);
755 else //__targetCount > 1
757 (lastTargetOccurence) ? (pFloatAnim->SetEndValue(newShowState)) : (pFloatAnim->SetStartValue(currentShowState));
759 pAnimationBase = pFloatAnim;
761 else //if (pIntegerAnim)
763 if (__targetCount == 1)
765 pIntegerAnim->SetStartValue(icurrentShowState);
766 pIntegerAnim->SetEndValue(inewShowState);
768 else //__targetCount > 1
770 (lastTargetOccurence) ? (pIntegerAnim->SetEndValue(inewShowState)) : (pIntegerAnim->SetStartValue(icurrentShowState));
772 pAnimationBase = pIntegerAnim;
779 _ControlAnimatorImpl::StartCustomImplicitAnimation(ControlAnimatorTriggerType triggerType, int x, int y, int width, int height, bool showState)
781 result r = E_SUCCESS;
782 SysTryReturnResult(NID_UI_ANIM, (triggerType == ANIMATION_TRIGGER_POSITION_CHANGE ||
783 triggerType == ANIMATION_TRIGGER_SIZE_CHANGE ||
784 triggerType == ANIMATION_TRIGGER_SHOW_STATE_CHANGE), E_INVALID_ARG, "Invalid argument(s) is used. Trigger type is invalid.");
788 long groupDuration = 0;
790 AnimationTargetType equivalentAnimTarget = ANIMATION_TARGET_NONE;
792 VisualElementAnimationGroup* pAnimationGroup = null;
795 pAnimationGroup = new (std::nothrow) VisualElementAnimationGroup();
796 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
798 if (triggerType == ANIMATION_TRIGGER_POSITION_CHANGE)
800 equivalentAnimTarget = ANIMATION_TARGET_POSITION;
802 else if (triggerType == ANIMATION_TRIGGER_SIZE_CHANGE)
804 equivalentAnimTarget = ANIMATION_TARGET_SIZE;
808 equivalentAnimTarget = ANIMATION_TARGET_ALPHA;
811 ParallelAnimationGroup* pParallelAnimGrp = null;
812 SequentialAnimationGroup* pSequentialAnimGrp = null;
813 String animIdentifier;
816 animIdentifier.Append(GROUP);
817 animIdentifier.Append(__animId);
820 __groupName = animIdentifier;
822 if (__propertyAnimationGroupType[triggerType - 1] == PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL)
824 pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(__pPropertyAnimationGroupList[triggerType - 1]);
825 if (pSequentialAnimGrp)
827 for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++)
829 AnimationTargetType animTgt = ANIMATION_TARGET_NONE;
831 animTgt = pSequentialAnimGrp->GetAnimationTargetTypeAt(index);
832 if (animTgt > ANIMATION_TARGET_NONE && animTgt < ANIMATION_TARGET_MAX)
834 if (__isAnimationTargetAnimating[animTgt])
836 SysLogException(NID_UI_ANIM, E_INVALID_OPERATION, "[E_INVALID_OPERATION] Same AnimationTargetType is being animated.");
837 delete pAnimationGroup;
838 return E_INVALID_OPERATION;
843 for (int index = pSequentialAnimGrp->GetAnimationCount() - 1; index >= 0; index--)
845 if (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == equivalentAnimTarget)
851 //Overwrite last Animation in AnimationGroup and check for IsAnimatable
852 bool verified = false;
853 for (int count = pSequentialAnimGrp->GetAnimationCount() - 1; count >= 0; count--)
855 AnimationTargetType animTgt = ANIMATION_TARGET_NONE;
856 animTgt = pSequentialAnimGrp->GetAnimationTargetTypeAt(count);
857 if (animTgt == equivalentAnimTarget)
859 bool animatable = false;
860 AnimationBase* pAnimBase = null;
861 pAnimBase = pSequentialAnimGrp->GetAnimationAtN(count);
865 Rectangle rect(x, y, width, height);
867 r = SetCustomImplicitAnimationParams(triggerType, *pAnimBase, rect, showState, true);
869 //Comment: Only the last associated TGT_TYPE is checked for IsAnimatable as the rest is checked in ControlAnimator::SetAnimation().
870 animatable = IsAnimatable(animTgt, rect, pAnimBase);
875 if ((!animatable) || (r != E_SUCCESS))
877 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set custom implicit animation.");
878 delete pAnimationGroup;
879 return E_INVALID_ARG;
889 int firstOccurence = -1;
890 int lastOccurence = -1;
892 for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++)
894 if (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == equivalentAnimTarget)
896 firstOccurence = index;
901 for (int index = pSequentialAnimGrp->GetAnimationCount() - 1; index >= 0; index--)
903 if (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == equivalentAnimTarget)
905 lastOccurence = index;
910 if (!(firstOccurence >= 0 && lastOccurence >= 0))
912 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start custom implicit animation.");
913 delete pAnimationGroup;
917 __prevAnimationBoundsHolder = __pControl->GetBounds();
918 for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++)
920 AnimationTargetType animTarget = ANIMATION_TARGET_MAX;
921 AnimationBase* pAnimationBase = null;
922 pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index);
923 animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index);
926 if (animTarget == equivalentAnimTarget)
928 Rectangle rect(x, y, width, height);
930 if (firstOccurence == lastOccurence) // (or) __targetCount==1
932 r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, true);
936 if (index == firstOccurence)
938 r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, false);
940 else if (index == lastOccurence)
942 r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, true);
947 delete pAnimationBase;
948 delete pAnimationGroup;
950 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation.");
954 if (!IsAnimationSupported())
956 if (animTarget == equivalentAnimTarget)
958 if (index == lastOccurence)
960 Rectangle rect(x, y, width, height);
962 r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, true);
966 delete pAnimationBase;
967 delete pAnimationGroup;
969 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation.");
974 r = SetControlProperty(animTarget, *pAnimationBase);
976 delete pAnimationBase;
977 delete pAnimationGroup;
981 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set control property.");
993 __sequentialGroupAnimation = true;
994 r = SetAnimation(animTarget, *pAnimationBase, triggerType, pAnimationGroup); //check this group animation
995 __sequentialGroupAnimation = false;
997 delay = pAnimationBase->GetDelay() + totalDelay;
998 totalDelay = delay + (pAnimationBase->GetDuration() * pAnimationBase->GetRepeatCount());
999 totalDelay = totalDelay - (pAnimationBase->GetOffset());
1000 __sequelDelay = totalDelay;
1001 groupDuration = groupDuration + __sequelDelay * pAnimationBase->GetScaleRatio();
1005 delete pAnimationBase;
1006 delete pAnimationGroup;
1008 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation.");
1013 if (animTarget == ANIMATION_TARGET_SIZE)
1015 if (SetPrevAnimationBoundsProperty(animTarget, *pAnimationBase) != E_SUCCESS)
1017 delete pAnimationBase;
1018 delete pAnimationGroup;
1020 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to store previous animation bounds.");
1030 else if (__propertyAnimationGroupType[triggerType - 1] == PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL)
1032 pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(__pPropertyAnimationGroupList[triggerType - 1]);
1033 if (pParallelAnimGrp)
1035 for (int target = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); target < (static_cast< int >(ANIMATION_TARGET_MAX)); target++)
1038 AnimationTargetType animTgt = static_cast< AnimationTargetType >(target);
1040 if (pParallelAnimGrp->IsAnimationAdded(animTgt) && __isAnimationTargetAnimating[animTgt])
1042 SysLogException(NID_UI_ANIM, E_INVALID_OPERATION, " [E_INVALID_OPERATION] Same AnimationTargetType is being animated.");
1043 delete pAnimationGroup;
1045 return E_INVALID_OPERATION;
1050 for (int target = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); target < (static_cast< int >(ANIMATION_TARGET_MAX)); target++)
1052 AnimationTargetType animTgt = static_cast< AnimationTargetType >(target);
1053 AnimationBase* pAnimBase = null;
1054 pAnimBase = pParallelAnimGrp->GetAnimationN(animTgt);
1055 if (pAnimBase != null)
1057 bool animatable = false;
1058 if (animTgt == equivalentAnimTarget)
1060 Rectangle rect(x, y, width, height);
1062 r = SetCustomImplicitAnimationParams(triggerType, *pAnimBase, rect, showState);
1063 //Comment: Only associated TGT_TYPE is checked for IsAnimatable as the rest is checked in ControlAnimator::SetAnimation().
1064 animatable = IsAnimatable(animTgt, rect, pAnimBase);
1069 if (((animTgt == equivalentAnimTarget) && (!animatable)) || (r != E_SUCCESS))
1071 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set custom implicit animation.");
1072 delete pAnimationGroup;
1074 return E_INVALID_ARG;
1079 AnimationTargetType animTargetArray[ANIMATION_TARGET_MAX] =
1081 ANIMATION_TARGET_ROTATION,
1082 ANIMATION_TARGET_SIZE,
1083 ANIMATION_TARGET_POSITION,
1084 ANIMATION_TARGET_ALPHA
1087 for (int target = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); target < (static_cast< int >(ANIMATION_TARGET_MAX)); target++)
1089 AnimationTargetType _animTarget = animTargetArray[target];
1090 AnimationBase* pAnimationBase = null;
1091 pAnimationBase = pParallelAnimGrp->GetAnimationN(_animTarget);
1094 long duration = pAnimationBase->GetDuration();
1096 duration = (duration * (pAnimationBase->GetRepeatCount()) * (pAnimationBase->GetScaleRatio())) + (pAnimationBase->GetDelay()) - (pAnimationBase->GetOffset()* pAnimationBase->GetScaleRatio());
1098 if (duration > groupDuration)
1100 groupDuration = duration;
1103 Rectangle rect(x, y, width, height);
1105 if (_animTarget == equivalentAnimTarget)
1107 r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState);
1110 delete pAnimationBase;
1111 delete pAnimationGroup;
1113 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation.");
1118 if (IsAnimationSupported() == false)
1120 if (_animTarget == equivalentAnimTarget)
1122 r = SetCustomImplicitAnimationParams(triggerType, *pAnimationBase, rect, showState, true);
1125 delete pAnimationBase;
1126 delete pAnimationGroup;
1128 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set parameters for custom implicit animation.");
1132 r = SetControlProperty(_animTarget, *pAnimationBase);
1134 delete pAnimationBase;
1135 delete pAnimationGroup;
1139 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set control property.");
1150 //Create and set the animation to the layer
1151 //Comment: Deep copy need not be done here as AnimationGroup did.
1152 r = SetAnimation(_animTarget, *pAnimationBase, triggerType, pAnimationGroup);
1155 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start the animation.");
1156 delete pAnimationGroup;
1166 if (equivalentAnimTarget != ANIMATION_TARGET_ALPHA)
1168 bool disable = false;
1169 bool propagation = false;
1171 result r = DisableImplicitAnimation(disable);
1172 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
1174 r = DisableVisualElementPropagation(propagation);
1175 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
1177 r = __pControl->SetBounds(x, y, width, height);
1181 DisableVisualElementPropagation(propagation);
1185 DisableImplicitAnimation(disable);
1188 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds.");
1192 bool disable = false;
1193 bool propagation = false;
1195 result r = DisableImplicitAnimation(disable);
1196 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
1198 r = DisableVisualElementPropagation(propagation);
1199 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
1201 r = __pControl->SetShowState(showState);
1205 DisableVisualElementPropagation(propagation);
1209 DisableImplicitAnimation(disable);
1212 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set show state.");
1216 __pControlImpl->SetBoundsAndUpdateLayout(__pControlImpl->GetBounds());
1218 pAnimationGroup->SetDuration(groupDuration);
1219 __pVisualElement->AddAnimation(animIdentifier, *pAnimationGroup);
1222 delete pAnimationGroup;
1223 pAnimationGroup = null;
1230 _ControlAnimatorImpl::AddActiveAnimation(AnimationTargetType animTarget, AnimationBase& animBase, VisualElementAnimation& animNative,
1231 ControlAnimatorTriggerType triggerType,
1232 const String& animName, BezierTimingFunction* pBezierTiming)
1234 SysTryReturnResult(NID_UI_ANIM, (animTarget > ANIMATION_TARGET_NONE && animTarget < ANIMATION_TARGET_MAX), E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid.");
1236 result r = E_SUCCESS;
1237 ActiveAnimation activeAnim;
1239 activeAnim.animType = triggerType;
1240 activeAnim.animTarget = animTarget;
1241 activeAnim.pAnimationBase = (&animBase);
1242 activeAnim.pAnimation = (&animNative);
1243 activeAnim.animName = animName;
1244 activeAnim.pBezierTimingFunction = pBezierTiming;
1246 r = __pActiveAnimationList->Add(activeAnim);
1247 SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to add animations to active play list.");
1253 _ControlAnimatorImpl::GetActiveAnimationAt(int index) const
1255 SysTryReturn(NID_UI_ANIM, (index > 0 && __pActiveAnimationList->GetCount() > 0 && index < __pActiveAnimationList->GetCount()),
1256 null, E_OUT_OF_RANGE, "[E_OUT_OF_RANGE] Index (%d) is out of range.", index);
1258 ActiveAnimation activeAnim;
1260 if (__pActiveAnimationList->GetAt(index, activeAnim) == E_SUCCESS)
1262 return activeAnim.animName;
1271 _ControlAnimatorImpl::GetActiveAnimationAt(int index, ControlAnimatorTriggerType animTrigger) const
1273 if (!((__pActiveAnimationList->GetCount() > 0) && (index < __pActiveAnimationList->GetCount()) && (index >= 0)))
1275 SysLog(NID_UI_ANIM, "[E_SYSTEM] A system error has been occurred. index (%d) is invalid.", index);
1277 return String(empty);
1280 ActiveAnimation activeAnim;
1282 if (__pActiveAnimationList->GetAt(index, activeAnim) == E_SUCCESS)
1284 if (animTrigger == activeAnim.animType)
1286 return activeAnim.animName;
1293 SysLog(NID_UI_ANIM, "[E_SYSTEM] A system error has been occurred. Failed to get from list for index = %d", index);
1299 _ControlAnimatorImpl::GetActiveAnimationListCount(void) const
1301 return __pActiveAnimationList->GetCount();
1305 _ControlAnimatorImpl::GetActiveAnimationListCount(AnimationTargetType animTarget) const
1307 result r = E_SUCCESS;
1310 for (int count = __pActiveAnimationList->GetCount() - 1; count >= 0; count--)
1312 ActiveAnimation activeAnim;
1313 r = __pActiveAnimationList->GetAt(count, activeAnim);
1314 SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), -1, r, "[%s] Failed to retrieve active animation from list.", GetErrorMessage(r));
1315 if (activeAnim.animTarget == animTarget)
1325 _ControlAnimatorImpl::RemoveAnimationAt(int index)
1327 SysTryReturnResult(NID_UI_ANIM,
1328 (index >= 0 && index < __pActiveAnimationList->GetCount()), E_OUT_OF_RANGE, "Index (%d) is out of range.", index);
1330 result r = E_SUCCESS;
1331 ActiveAnimation activeAnim;
1333 r = __pActiveAnimationList->GetAt(index, activeAnim);
1334 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Failed to retrieve active animation from list.");
1336 r = __pActiveAnimationList->Remove(activeAnim);
1337 SysTryReturnResult(NID_UI_ANIM, r == E_SUCCESS, E_SYSTEM, "A system error has been occurred. Failed to remove animation from play list.");
1339 delete activeAnim.pAnimationBase;
1340 activeAnim.pAnimationBase = null;
1341 delete activeAnim.pAnimation;
1342 activeAnim.pAnimation = null;
1343 delete activeAnim.pBezierTimingFunction;
1344 activeAnim.pBezierTimingFunction = null;
1350 _ControlAnimatorImpl::RemoveAllAnimations(void)
1352 result r = E_SUCCESS;
1354 for (int count = __pActiveAnimationList->GetCount() - 1; count >= 0; count--)
1356 r = RemoveAnimationAt(count);
1357 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_OBJ_NOT_FOUND, "Failed to remove animation. index = %d", count);
1364 _ControlAnimatorImpl::DestroyAnimation(int preActiveAnimationCount)
1366 result r = E_SUCCESS;
1368 for (int count = GetActiveAnimationListCount() - 1; count >= preActiveAnimationCount; count--)
1372 animName = GetActiveAnimationAt(count);
1373 r = __pVisualElement->RemoveAnimation(animName);
1374 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Failed to remove animation. keyName = %ls", animName.GetPointer());
1376 if (RemoveAnimationAt(count) != E_SUCCESS)
1378 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to remove animation. index = %d", count);
1387 _ControlAnimatorImpl::DestroyAnimation(AnimationBase& animBase, AnimationTargetType animTarget)
1389 result r = E_SUCCESS;
1392 ActiveAnimation activeAnim;
1394 activeAnim.animTarget = animTarget;
1395 activeAnim.pAnimationBase = (dynamic_cast< AnimationBase* >(&animBase));
1396 r = __pActiveAnimationList->IndexOf(activeAnim, index);
1397 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Failed to retrieve active animation from list.");
1399 r = RemoveAnimationAt(index);
1400 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Failed to remove animation from play list.");
1406 _ControlAnimatorImpl::SetControlProperty(AnimationTargetType animTarget, AnimationBase& animationBase)
1408 result r = E_SUCCESS;
1410 if (animationBase.IsHoldEndEnabled() == true)
1414 case ANIMATION_TARGET_SIZE:
1416 DimensionAnimation* pDimAnim = null;
1417 RectangleAnimation* pRectAnim = null;
1419 pDimAnim = dynamic_cast< DimensionAnimation* >(const_cast< AnimationBase* >(&animationBase));
1420 pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase));
1421 SysTryReturnResult(NID_UI_ANIM, ((pDimAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
1425 Dimension dimVal(0, 0);
1427 (animationBase.IsAutoReverseEnabled()) ? (dimVal = pDimAnim->GetStartValue()) : (dimVal = pDimAnim->GetEndValue());
1428 r = (__pControl)->SetSize(dimVal.width, dimVal.height);
1430 else //if (pRectAnim)
1432 Rectangle rectVal(0, 0, 0, 0);
1434 (animationBase.IsAutoReverseEnabled()) ? (rectVal = pRectAnim->GetStartValue()) : (rectVal = pRectAnim->GetEndValue());
1435 r = (__pControl)->SetSize(rectVal.width, rectVal.height);
1440 case ANIMATION_TARGET_POSITION:
1442 PointAnimation* pPointAnim = null;
1443 RectangleAnimation* pRectAnim = null;
1445 pPointAnim = dynamic_cast< PointAnimation* >(const_cast< AnimationBase* >(&animationBase));
1446 pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase));
1447 SysTryReturnResult(NID_UI_ANIM, ((pPointAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
1453 (animationBase.IsAutoReverseEnabled()) ? (val = pPointAnim->GetStartValue()) : (val = pPointAnim->GetEndValue());
1454 r = (__pControl)->SetPosition(val.x, val.y);
1456 else //if (pRectAnim)
1458 Rectangle rectVal(0, 0, 0, 0);
1460 (animationBase.IsAutoReverseEnabled()) ? (rectVal = pRectAnim->GetStartValue()) : (rectVal = pRectAnim->GetEndValue());
1461 r = (__pControl)->SetPosition(rectVal.x, rectVal.y);
1466 case ANIMATION_TARGET_ALPHA:
1468 FloatAnimation* pFloatAnim = null;
1469 IntegerAnimation* pIntegerAnim = null;
1471 pFloatAnim = dynamic_cast< FloatAnimation* >(const_cast< AnimationBase* >(&animationBase));
1472 pIntegerAnim = dynamic_cast< IntegerAnimation* >(const_cast< AnimationBase* >(&animationBase));
1473 SysTryReturnResult(NID_UI_ANIM, ((pFloatAnim) || (pIntegerAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
1477 float floatVal = 0.0f;
1479 (animationBase.IsAutoReverseEnabled()) ? (floatVal = pFloatAnim->GetStartValue()) : (floatVal = pFloatAnim->GetEndValue());
1481 if (!(Float::Compare(floatVal, 1.0)))
1483 r = __pControl->SetShowState(true);
1487 r = __pControl->SetShowState(false);
1491 else //if (pIntegerAnim)
1495 (animationBase.IsAutoReverseEnabled()) ? (intVal = pIntegerAnim->GetStartValue()) : (intVal = pIntegerAnim->GetEndValue());
1499 r = __pControl->SetShowState(true);
1503 r = __pControl->SetShowState(false);
1509 case ANIMATION_TARGET_ROTATION:
1511 //Comment: The Control's property will be the same even after the rotate animation is completed.
1512 //So, no need to update the window property.
1518 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid.");
1525 if (IsAnimationSupported() == false)
1527 _WindowImpl* pWindow = null;
1528 pWindow = _ControlImplManager::GetInstance()->GetCurrentFrame();
1529 SysTryReturnResult(NID_UI_ANIM, (pWindow), E_SYSTEM, "A system error has been occurred. Failed to get current frame.");
1531 pWindow->GetPublic().Draw();
1532 __isAnimationTargetAnimating[animTarget] = false;
1539 _ControlAnimatorImpl::SetControlShowState(AnimationTargetType animTarget, AnimationBase& animationBase)
1541 SysTryReturnResult(NID_UI_ANIM, (animTarget == ANIMATION_TARGET_ALPHA), E_SYSTEM, "animTarget is invalid.");
1543 if (animationBase.IsHoldEndEnabled() == true)
1545 IntegerAnimation* pIntAnim = dynamic_cast< IntegerAnimation* >(const_cast< AnimationBase* >(&animationBase));
1546 FloatAnimation* pFloatAnim = dynamic_cast< FloatAnimation* >(const_cast< AnimationBase* >(&animationBase));
1548 SysTryReturnResult(NID_UI_ANIM, (pIntAnim || pFloatAnim), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
1554 if (animationBase.IsAutoReverseEnabled() == false)
1556 endVal = static_cast< float >(pIntAnim->GetEndValue());
1557 __showStateHolder = ((endVal == 1) ? (true) : (false));
1560 else //if (pFloatAnim)
1562 float endVal = -1.0f;
1564 if (animationBase.IsAutoReverseEnabled() == false)
1566 endVal = (static_cast< float >(pFloatAnim->GetEndValue()));
1567 __showStateHolder = (((!(Float::Compare(endVal, 1.0)))) ? (true) : (false));
1572 if ((__pControl->GetShowState() == false) && ((animationBase.IsAutoReverseEnabled()) || (animationBase.IsHoldEndEnabled() == false)))
1574 __pVisualElement->SetShowState(true);
1575 __pVisualElement->Draw();
1576 __pVisualElement->SetShowState(false);
1583 _ControlAnimatorImpl::SetControlLogicalBounds(AnimationTargetType animTarget, AnimationBase& animationBase)
1585 result r = E_SUCCESS;
1587 if (animationBase.IsHoldEndEnabled() == true)
1591 case ANIMATION_TARGET_SIZE:
1593 DimensionAnimation* pDimAnim = dynamic_cast< DimensionAnimation* >(const_cast< AnimationBase* >(&animationBase));
1594 RectangleAnimation* pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase));
1595 SysTryReturnResult(NID_UI_ANIM, ((pDimAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
1599 Dimension dimVal(0, 0);
1600 if (animationBase.IsAutoReverseEnabled() == false)
1602 dimVal = pDimAnim->GetEndValue();
1603 __logicalBoundsHolder.width = dimVal.width;
1604 __logicalBoundsHolder.height = dimVal.height;
1607 else //if (pRectAnim)
1609 Rectangle rectVal(0, 0, 0, 0);
1610 if (animationBase.IsAutoReverseEnabled() == false)
1612 rectVal = pRectAnim->GetEndValue();
1613 __logicalBoundsHolder.width = rectVal.width;
1614 __logicalBoundsHolder.height = rectVal.height;
1620 case ANIMATION_TARGET_POSITION:
1622 PointAnimation* pPointAnim = dynamic_cast< PointAnimation* >(const_cast< AnimationBase* >(&animationBase));
1623 RectangleAnimation* pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase));
1624 SysTryReturnResult(NID_UI_ANIM, ((pPointAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
1630 if (animationBase.IsAutoReverseEnabled() == false)
1632 val = pPointAnim->GetEndValue();
1633 __logicalBoundsHolder.x = val.x;
1634 __logicalBoundsHolder.y = val.y;
1639 Rectangle rectVal(0, 0, 0, 0);
1641 if (animationBase.IsAutoReverseEnabled() == false)
1643 rectVal = pRectAnim->GetEndValue();
1644 __logicalBoundsHolder.x = rectVal.x;
1645 __logicalBoundsHolder.y = rectVal.y;
1653 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid.");
1663 _ControlAnimatorImpl::CloneAnimation(AnimationTargetType animTarget, AnimationBase& animationBase)
1665 AnimationBase* pAnimationBase = null;
1667 //Comment: Deep copy animation object & pass to SetAnimation, which will store in list of structures
1670 case ANIMATION_TARGET_SIZE:
1672 DimensionAnimation* pDimAnim = null;
1673 RectangleAnimation* pRectAnim = null;
1675 pDimAnim = dynamic_cast< DimensionAnimation* >(&animationBase);
1676 pRectAnim = dynamic_cast< RectangleAnimation* >(&animationBase);
1677 SysTryReturn(NID_UI_ANIM, ((pDimAnim) || (pRectAnim)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid.");
1681 DimensionAnimation* pDimValue = new (std::nothrow) DimensionAnimation(*pDimAnim);
1682 pAnimationBase = pDimValue;
1686 RectangleAnimation* pRectValue = new (std::nothrow) RectangleAnimation(*pRectAnim);
1687 pAnimationBase = pRectValue;
1692 case ANIMATION_TARGET_POSITION:
1694 PointAnimation* pPointAnim = null;
1695 RectangleAnimation* pRectAnim = null;
1697 pPointAnim = dynamic_cast< PointAnimation* >(&animationBase);
1698 pRectAnim = dynamic_cast< RectangleAnimation* >(&animationBase);
1699 SysTryReturn(NID_UI_ANIM, ((pPointAnim) || (pRectAnim)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid.");
1703 PointAnimation* pPointValue = new (std::nothrow) PointAnimation(*pPointAnim);
1704 pAnimationBase = pPointValue;
1708 RectangleAnimation* pRectValue = new (std::nothrow) RectangleAnimation(*pRectAnim);
1709 pAnimationBase = pRectValue;
1714 case ANIMATION_TARGET_ALPHA:
1716 FloatAnimation* pFloatAnim = null;
1717 IntegerAnimation* pIntegerAnim = null;
1719 pFloatAnim = dynamic_cast< FloatAnimation* >(&animationBase);
1720 pIntegerAnim = dynamic_cast< IntegerAnimation* >(&animationBase);
1721 SysTryReturn(NID_UI_ANIM, ((pFloatAnim) || (pIntegerAnim)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid.");
1725 FloatAnimation* pFloatValue = new (std::nothrow) FloatAnimation(*pFloatAnim);
1726 pAnimationBase = pFloatValue;
1730 IntegerAnimation* pIntegerValue = new (std::nothrow) IntegerAnimation(*pIntegerAnim);
1731 pAnimationBase = pIntegerValue;
1736 case ANIMATION_TARGET_ROTATION:
1738 RotateAnimation* pRotateAnimation = dynamic_cast< RotateAnimation* >(&animationBase);
1739 SysTryReturn(NID_UI_ANIM, ((pRotateAnimation)), null, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Animation is invalid.");
1741 RotateAnimation* pRotateValue = new (std::nothrow) RotateAnimation(*pRotateAnimation);
1742 pAnimationBase = pRotateValue;
1748 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid.");
1754 return pAnimationBase;
1758 _ControlAnimatorImpl::IsAnimatable(AnimationTargetType animTarget, Rectangle& bounds, AnimationBase* pAnimationBase, ControlAnimatorTriggerType animTrigger) const
1760 bool animatable = false;
1761 Rectangle endBounds(0, 0, 0, 0);
1767 if (pAnimationBase->IsHoldEndEnabled() == true)
1771 case ANIMATION_TARGET_SIZE:
1773 if (animTrigger == ANIMATION_TRIGGER_USER)
1775 DimensionAnimation* pDimAnim = null;
1776 RectangleAnimation* pRectAnim = null;
1778 if (pAnimationBase->GetType() == ANIMATION_TYPE_DIMENSION_ANIMATION)
1780 pDimAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase);
1781 if (pDimAnim != null)
1783 if (pAnimationBase->IsAutoReverseEnabled())
1785 endBounds.width = pDimAnim->GetStartValue().width;
1786 endBounds.height = pDimAnim->GetStartValue().height;
1790 endBounds.width = pDimAnim->GetEndValue().width;
1791 endBounds.height = pDimAnim->GetEndValue().height;
1795 else if (pAnimationBase->GetType() == ANIMATION_TYPE_RECTANGLE_ANIMATION)
1797 pRectAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
1798 if (pRectAnim != null)
1800 if (pAnimationBase->IsAutoReverseEnabled())
1802 endBounds.width = pRectAnim->GetStartValue().width;
1803 endBounds.height = pRectAnim->GetStartValue().height;
1807 endBounds.width = pRectAnim->GetEndValue().width;
1808 endBounds.height = pRectAnim->GetEndValue().height;
1818 if (!(__pControl->IsResizable()))
1824 //Scale Animation is allowed with any anchor (0,0) when HoldEnd=TRUE & Auto Reverse=FALSE
1827 DimensionAnimation* pDimAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase);
1828 RectangleAnimation* pRectAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
1830 (pDimAnim) ? (pDimAnim->GetAnchor(ancX, ancY)) : (pRectAnim->GetAnchor(ancX, ancY));
1832 if ((Float::Compare(ancX, 0.0)) || (Float::Compare(ancY, 0.0)))
1837 //CustomControl Changes
1838 CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(__pControl);
1842 Dimension endDimension(endBounds.width, endBounds.height);
1843 __pControlImpl->OnEvaluateSize(endDimension);
1847 Dimension controlMinSize = __pControl->GetMinimumSize();
1848 SysTryReturn(NID_UI_ANIM, ((endBounds.width >= controlMinSize.width) && (endBounds.height >= controlMinSize.height)),
1849 false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. end size = (%d, %d)", endBounds.width, endBounds.height);
1851 Dimension controlMaxSize = __pControl->GetMaximumSize();
1852 SysTryReturn(NID_UI_ANIM, ((endBounds.width <= controlMaxSize.width) && (endBounds.height <= controlMaxSize.height)),
1853 false, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. end size = (%d, %d)", endBounds.width, endBounds.height);
1860 case ANIMATION_TARGET_POSITION:
1862 if (animTrigger == ANIMATION_TRIGGER_USER)
1864 PointAnimation* pPointAnim = null;
1865 RectangleAnimation* pRectAnim = null;
1867 if (pAnimationBase->GetType() == ANIMATION_TYPE_POINT_ANIMATION)
1869 pPointAnim = dynamic_cast< PointAnimation* >(pAnimationBase);
1870 if (pPointAnim != null)
1872 if (pAnimationBase->IsAutoReverseEnabled())
1874 endBounds.x = pPointAnim->GetStartValue().x;
1875 endBounds.y = pPointAnim->GetStartValue().y;
1879 endBounds.x = pPointAnim->GetEndValue().x;
1880 endBounds.y = pPointAnim->GetEndValue().y;
1884 else if (pAnimationBase->GetType() == ANIMATION_TYPE_RECTANGLE_ANIMATION)
1886 pRectAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
1887 if (pRectAnim != null)
1889 if (pAnimationBase->IsAutoReverseEnabled())
1891 endBounds.x = pRectAnim->GetStartValue().x;
1892 endBounds.y = pRectAnim->GetStartValue().y;
1896 endBounds.x = pRectAnim->GetEndValue().x;
1897 endBounds.y = pRectAnim->GetEndValue().y;
1907 if (!(__pControl->IsMovable()))
1913 //CustomControl Changes
1914 CustomControlBase* pControlBase = dynamic_cast< CustomControlBase* >(__pControl);
1918 __pControlImpl->OnBoundsChanging(endBounds); //check this this API has been changed in 2.0
1920 //Comment. No limit on positive & negative "x" & "y" for the movable %Control's position property
1926 case ANIMATION_TARGET_ALPHA:
1928 float endVal = -1.0f;
1929 IntegerAnimation* pIntAnim = null;
1930 FloatAnimation* pFloatAnim = null;
1932 if (pAnimationBase->GetType() == ANIMATION_TYPE_FLOAT_ANIMATION)
1934 pFloatAnim = dynamic_cast< FloatAnimation* >(pAnimationBase);
1935 if (pFloatAnim != null)
1937 if (pAnimationBase->IsAutoReverseEnabled())
1939 endVal = pFloatAnim->GetStartValue();
1943 endVal = pFloatAnim->GetEndValue();
1947 else if (pAnimationBase->GetType() == ANIMATION_TYPE_INTEGER_ANIMATION)
1949 pIntAnim = dynamic_cast< IntegerAnimation* >(pAnimationBase);
1950 if (pIntAnim != null)
1952 if (pAnimationBase->IsAutoReverseEnabled())
1954 endVal = (static_cast< float >(pIntAnim->GetStartValue()));
1958 endVal = (static_cast< float >(pIntAnim->GetEndValue()));
1967 //removing the code of IsShowStateChangeable
1968 if ((!(Float::Compare(endVal, 1.0))) || (!(Float::Compare(endVal, 0.0))))
1974 SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. End value is invalid.");
1981 case ANIMATION_TARGET_ROTATION:
1983 if (animTrigger == ANIMATION_TRIGGER_USER)
1985 RotateAnimation* pRotAnim = null;
1986 if (pAnimationBase->GetType() == ANIMATION_TYPE_ROTATE_ANIMATION)
1988 float endVal = -1.0f;
1989 pRotAnim = dynamic_cast< RotateAnimation* >(pAnimationBase);
1990 if (pRotAnim != null)
1992 if (pAnimationBase->IsAutoReverseEnabled())
1994 endVal = pRotAnim->GetStartValue();
1998 endVal = pRotAnim->GetEndValue();
2001 int roundingVal = Tizen::Base::Utility::Math::Round((double) endVal);
2003 if ((!(Float::Compare(endVal, static_cast< float >(roundingVal)))) && (((static_cast< int >(endVal) % 360) == 0))) //check this : Todo
2009 SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. End value is invalid.");
2015 SysLogException(NID_UI_ANIM, E_INVALID_ARG, "Invalid argument(s) is used. End value is invalid.");
2024 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid.");
2030 else //IsHoldEndEnabled = false
2040 _ControlAnimatorImpl::IsAnimationSupported(void) const
2042 return _VisualElementAnimationImpl::IsAnimationSupported();
2046 _ControlAnimatorImpl::OnVisualElementAnimationStarted(const VisualElementAnimation& animation, const String& keyName, VisualElement& target)
2048 ActiveAnimation activeAnim;
2052 if (keyName.IsEmpty() == true)
2054 String* pUserData = (String*) (animation.GetUserData());
2055 if (pUserData != null)
2057 animName = *pUserData;
2065 index = GetActiveAnimationIndex(animName);
2069 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation name mismatch in the playlist.");
2073 if (__pActiveAnimationList->GetAt(index, activeAnim) != E_SUCCESS)
2075 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not present in the playlist.");
2079 __isAnimationTargetAnimating[activeAnim.animTarget] = true;
2084 if ((animName.IndexOf(TRANSACTION, startIndex, indexOf)) != E_SUCCESS)
2086 //Calling simple listeners registered in this control animator
2087 if (__pAnimStatusEventListener)
2089 IControlAnimatorEventListener* pCaEventListener = null;
2090 for (int count = (__pAnimStatusEventListener->GetCount() - 1); count >= 0; count--)
2092 __pAnimStatusEventListener->GetAt(count, pCaEventListener);
2093 if (pCaEventListener)
2095 pCaEventListener->OnControlAnimationStarted(*__pControlAnimator, *__pControl);
2100 //calling detailed event listerners registered in this control animator
2101 if (__pAnimDetailedEventListener)
2103 IControlAnimatorDetailedEventListener* pDetailedEventListener = null;
2105 for (int count = (__pAnimDetailedEventListener->GetCount() - 1); count >= 0; count--)
2107 __pAnimDetailedEventListener->GetAt(count, pDetailedEventListener);
2109 if (pDetailedEventListener)
2111 pDetailedEventListener->OnControlAnimationStarted(*__pControlAnimator, *__pControl, activeAnim.animType, activeAnim.animTarget, activeAnim.pAnimationBase);
2119 _ControlAnimatorImpl::OnVisualElementAnimationRepeated(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, long currentRepeatCount)
2121 ActiveAnimation activeAnim;
2125 if (keyName.IsEmpty() == true)
2127 String* pUserData = (String*) (animation.GetUserData());
2129 if (pUserData != null)
2131 animName = *pUserData;
2139 index = GetActiveAnimationIndex(animName);
2142 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation name mismatch in the playlist.");
2146 if (__pActiveAnimationList->GetAt(index, activeAnim) != E_SUCCESS)
2148 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not present in the playlist.");
2155 if ((animName.IndexOf(TRANSACTION, startIndex, indexOf)) != E_SUCCESS)
2157 if (__pAnimDetailedEventListener)
2159 IControlAnimatorDetailedEventListener* pDetailedEventListener = null;
2161 for (int count = (__pAnimDetailedEventListener->GetCount() - 1); count >= 0; count--)
2163 __pAnimDetailedEventListener->GetAt(count, pDetailedEventListener);
2165 if (pDetailedEventListener)
2167 pDetailedEventListener->OnControlAnimationRepeated(*__pControlAnimator, *__pControl, activeAnim.animType, activeAnim.animTarget, activeAnim.pAnimationBase, currentRepeatCount);
2175 _ControlAnimatorImpl::OnVisualElementAnimationFinished(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, bool completedNormally)
2179 if (keyName.IsEmpty() == true)
2181 String* pUserData = (String*) (animation.GetUserData());
2183 if (pUserData != null)
2185 animName = *pUserData;
2195 _VisualElementImpl* pPresentationImpl = _VisualElementImpl::GetInstance(*const_cast<VisualElement*>(__pVisualElement->AcquirePresentationInstance()));
2197 if (pPresentationImpl == null)
2199 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Screen is not updated with end values.");
2203 VisualElementValueAnimation* pValueAnimation = dynamic_cast< VisualElementValueAnimation* >(const_cast< VisualElementAnimation* >(&animation));
2204 VisualElementPropertyAnimation* pAnimation = dynamic_cast< VisualElementPropertyAnimation* >(const_cast< VisualElementAnimation* >(&animation));
2206 if (completedNormally == false || (pValueAnimation && pValueAnimation->IsEndValueApplied() == false))
2210 String propName = pAnimation->GetPropertyName();
2214 result r = E_SUCCESS;
2216 if ((propName.IndexOf(VeSubPropBoundsPosition, startIndex, indexOf)) == E_SUCCESS)
2218 r = pPresentationImpl->SetProperty(VePropBounds, __pVisualElement->GetBounds());
2220 else if ((propName.IndexOf(VePropBounds, startIndex, indexOf)) == E_SUCCESS)
2222 r = pPresentationImpl->SetProperty(VePropBounds, __pVisualElement->GetBounds());
2224 else if ((propName.IndexOf(VeSubPropTransformRotationZ, startIndex, indexOf)) == E_SUCCESS)
2226 r = pPresentationImpl->SetProperty(VePropTransform, __pVisualElement->GetTransformMatrix());
2228 else if ((propName.IndexOf(VePrivPropShowOpacity, startIndex, indexOf)) == E_SUCCESS)
2230 r = pPresentationImpl->SetProperty(VePropShowState, __pVisualElement->GetShowState());
2235 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Screen is not updated with end values.");
2238 else if (pValueAnimation)
2240 pPresentationImpl->SetProperty(VePropBounds, __pVisualElement->GetBounds());
2245 __pVisualElement->ReleasePresentationInstance();
2247 ActiveAnimation activeAnim;
2250 index = GetActiveAnimationIndex(animName);
2254 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation name mismatch in the playlist.");
2258 if (__pActiveAnimationList->GetAt(index, activeAnim) != E_SUCCESS)
2260 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Animation is not present in the playlist.");
2267 __isAnimationTargetAnimating[activeAnim.animTarget] = false;
2269 if ((animName.IndexOf(TRANSACTION, startIndex, indexOf)) != E_SUCCESS)
2271 if (__pAnimStatusEventListener)
2273 IControlAnimatorEventListener* pCaEventListener = null;
2275 for (int count = (__pAnimStatusEventListener->GetCount() - 1); count >= 0; count--)
2277 __pAnimStatusEventListener->GetAt(count, pCaEventListener);
2278 if (pCaEventListener)
2280 if (completedNormally)
2282 pCaEventListener->OnControlAnimationFinished(*__pControlAnimator, *__pControl);
2286 pCaEventListener->OnControlAnimationStopped(*__pControlAnimator, *__pControl);
2292 //Calling detailed event listeners
2293 if (__pAnimDetailedEventListener)
2295 IControlAnimatorDetailedEventListener* pDetailedEventListener = null;
2297 for (int count = (__pAnimDetailedEventListener->GetCount() - 1); count >= 0; count--)
2299 __pAnimDetailedEventListener->GetAt(count, pDetailedEventListener);
2301 if (pDetailedEventListener)
2303 if (completedNormally)
2305 pDetailedEventListener->OnControlAnimationFinished(*__pControlAnimator, *__pControl, activeAnim.animType, activeAnim.animTarget, activeAnim.pAnimationBase);
2309 pDetailedEventListener->OnControlAnimationStopped(*__pControlAnimator, *__pControl, activeAnim.animType, activeAnim.animTarget, activeAnim.pAnimationBase);
2316 RemoveAnimationAt(index);
2320 _ControlAnimatorImpl::StopAllAnimations(void)
2322 result r = E_SUCCESS;
2324 __pVisualElement->RemoveAllAnimations();
2330 _ControlAnimatorImpl::StopAnimation(ControlAnimatorTriggerType animTrigger)
2332 SysTryReturnResult(NID_UI_ANIM, (GetActiveAnimationListCount() > 0), E_SUCCESS, "No active animation.");
2334 result r = E_SUCCESS;
2336 for (int index = GetActiveAnimationListCount() - 1; index >= 0; index--)
2340 animName = GetActiveAnimationAt(index, animTrigger);
2341 if (!(animName.IsEmpty()))
2344 int indexOfGroup = 0;
2345 if ((animName.IndexOf(GROUP, startIndex, indexOfGroup)) == E_SUCCESS)
2348 r = animName.SubString(indexOfGroup, groupName);
2349 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Group name is not found.");
2351 r = __pVisualElement->RemoveAnimation(groupName);
2355 r = __pVisualElement->RemoveAnimation(animName);
2358 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Animation is either running or already removed.");
2366 _ControlAnimatorImpl::AddControlAnimatorEventListener(const IControlAnimatorEventListener& listener)
2368 if (__pAnimStatusEventListener == null)
2370 __pAnimStatusEventListener = new (std::nothrow) LinkedListT< IControlAnimatorEventListener* >();
2371 SysTryReturnResult(NID_UI_ANIM, (__pAnimStatusEventListener), E_OUT_OF_MEMORY, "Memory allocation failed.");
2374 IControlAnimatorEventListener* pStatusListener = const_cast< IControlAnimatorEventListener* >(&listener);
2376 if (__pAnimStatusEventListener->Contains(pStatusListener) == true)
2378 return E_OBJ_ALREADY_EXIST;
2381 return __pAnimStatusEventListener->Add(pStatusListener);
2385 _ControlAnimatorImpl::RemoveControlAnimatorEventListener(const IControlAnimatorEventListener& listener)
2387 result r = E_SYSTEM;
2389 if (__pAnimStatusEventListener)
2391 return __pAnimStatusEventListener->Remove((const_cast< IControlAnimatorEventListener* >(&listener)));
2398 _ControlAnimatorImpl::AddControlAnimatorDetailedEventListener(const IControlAnimatorDetailedEventListener& listener)
2400 if (__pAnimDetailedEventListener == null)
2402 __pAnimDetailedEventListener = new (std::nothrow) LinkedListT< IControlAnimatorDetailedEventListener* >();
2403 SysTryReturnResult(NID_UI_ANIM, (__pAnimDetailedEventListener), E_OUT_OF_MEMORY, "Memory allocation failed.");
2406 IControlAnimatorDetailedEventListener* pStatusListener = const_cast< IControlAnimatorDetailedEventListener* >(&listener);
2408 if (__pAnimDetailedEventListener->Contains(pStatusListener) == true)
2410 return E_OBJ_ALREADY_EXIST;
2413 return __pAnimDetailedEventListener->Add(pStatusListener);
2417 _ControlAnimatorImpl::RemoveControlAnimatorDetailedEventListener(const IControlAnimatorDetailedEventListener& listener)
2419 result r = E_SYSTEM;
2421 if (__pAnimDetailedEventListener)
2423 return __pAnimDetailedEventListener->Remove((const_cast< IControlAnimatorDetailedEventListener* >(&listener)));
2430 _ControlAnimatorImpl::GetActiveAnimationIndex(const String& animName) const
2432 result r = E_SUCCESS;
2434 for (int index = 0; index < __pActiveAnimationList->GetCount(); index++)
2436 ActiveAnimation activeAnim;
2438 r = __pActiveAnimationList->GetAt(index, activeAnim);
2439 SysTryReturn(NID_UI_ANIM, (r == E_SUCCESS), -1, r, "[%s] Failed to retrieve animation from the list.", GetErrorMessage(r));
2441 if (activeAnim.animName == animName)
2451 _ControlAnimatorImpl::SetPrevAnimationBoundsProperty(AnimationTargetType animTarget, AnimationBase& animationBase)
2453 result r = E_SUCCESS;
2455 if (animationBase.IsHoldEndEnabled() == true)
2459 case ANIMATION_TARGET_SIZE:
2461 DimensionAnimation* pDimAnim = null;
2462 RectangleAnimation* pRectAnim = null;
2463 pDimAnim = dynamic_cast< DimensionAnimation* >(const_cast< AnimationBase* >(&animationBase));
2464 pRectAnim = dynamic_cast< RectangleAnimation* >(const_cast< AnimationBase* >(&animationBase));
2465 SysTryReturnResult(NID_UI_ANIM, ((pDimAnim) || (pRectAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
2469 Dimension dimVal(0, 0);
2470 (animationBase.IsAutoReverseEnabled()) ? (dimVal = pDimAnim->GetStartValue()) : (dimVal = pDimAnim->GetEndValue());
2471 __prevAnimationBoundsHolder.width = dimVal.width;
2472 __prevAnimationBoundsHolder.height = dimVal.height;
2474 else //if (pRectAnim)
2476 Rectangle rectVal(0, 0, 0, 0);
2477 (animationBase.IsAutoReverseEnabled()) ? (rectVal = pRectAnim->GetStartValue()) : (rectVal = pRectAnim->GetEndValue());
2478 __prevAnimationBoundsHolder.width = rectVal.width;
2479 __prevAnimationBoundsHolder.height = rectVal.height;
2485 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid.");
2494 _ControlAnimatorImpl::SetAnimationTargetStatus(ControlAnimatorTriggerType triggerType)
2496 SysTryReturnResult(NID_UI_ANIM, (triggerType >= ANIMATION_TRIGGER_POSITION_CHANGE && triggerType <= ANIMATION_TRIGGER_SHOW_STATE_CHANGE), E_INVALID_ARG, "Invalid argument(s) is used. Animation trigger type is invalid.");
2498 result r = E_SUCCESS;
2499 ParallelAnimationGroup* pParallelAnimGrp = null;
2500 SequentialAnimationGroup* pSequentialAnimGrp = null;
2502 if (__propertyAnimationGroupType[triggerType - 1] == PROPERTY_ANIMATION_GROUP_TYPE_SEQUENTIAL)
2504 pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(__pPropertyAnimationGroupList[triggerType - 1]);
2505 if (pSequentialAnimGrp)
2507 for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++)
2509 AnimationTargetType _animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index);
2510 SysTryReturnResult(NID_UI_ANIM, ((_animTarget > ANIMATION_TARGET_NONE) && (_animTarget < ANIMATION_TARGET_MAX)),
2511 E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid.");
2512 __isAnimationTargetAnimating[_animTarget] = true;
2514 if (_animTarget == ANIMATION_TARGET_POSITION || _animTarget == ANIMATION_TARGET_SIZE || _animTarget == ANIMATION_TARGET_ALPHA)
2516 AnimationBase* pAnimationBase = null;
2518 pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index);
2521 if (_animTarget == ANIMATION_TARGET_ALPHA)
2523 SetControlShowState(_animTarget, *pAnimationBase);
2527 SetControlLogicalBounds(_animTarget, *pAnimationBase);
2530 delete pAnimationBase;
2536 else if (__propertyAnimationGroupType[triggerType - 1] == PROPERTY_ANIMATION_GROUP_TYPE_PARALLEL)
2538 pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(__pPropertyAnimationGroupList[triggerType - 1]);
2539 if (pParallelAnimGrp)
2541 for (int index = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); index < (static_cast< int >(ANIMATION_TARGET_MAX)); index++)
2543 AnimationTargetType _animTarget = static_cast< AnimationTargetType >(index);
2544 AnimationBase* pAnimBase = null;
2546 pAnimBase = pParallelAnimGrp->GetAnimationN(_animTarget);
2547 if (pAnimBase != null)
2549 SysTryReturnResult(NID_UI_ANIM, ((_animTarget > ANIMATION_TARGET_NONE) && (_animTarget < ANIMATION_TARGET_MAX)),
2550 E_INVALID_ARG, "Invalid argument(s) is used. animTarget is invalid.");
2551 __isAnimationTargetAnimating[_animTarget] = true;
2553 if (_animTarget == ANIMATION_TARGET_POSITION || _animTarget == ANIMATION_TARGET_SIZE)
2555 SetControlLogicalBounds(_animTarget, *pAnimBase);
2557 else if (_animTarget == ANIMATION_TARGET_ALPHA)
2559 SetControlShowState(_animTarget, *pAnimBase);
2567 //Set Target status playing in case of platform defined Implicit animations
2570 if (triggerType == ANIMATION_TRIGGER_POSITION_CHANGE)
2572 __isAnimationTargetAnimating[ANIMATION_TARGET_POSITION] = true;
2575 if (triggerType == ANIMATION_TRIGGER_SIZE_CHANGE)
2577 __isAnimationTargetAnimating[ANIMATION_TARGET_SIZE] = true;
2580 if (triggerType == ANIMATION_TRIGGER_SHOW_STATE_CHANGE)
2582 __isAnimationTargetAnimating[ANIMATION_TARGET_ALPHA] = true;
2590 _ControlAnimatorImpl::SetKeyFrameAnimation(AnimationTargetType animTarget, AnimationBase* pAnimationBase, const IVisualElementAnimationTimingFunction* pTimingFunction, VisualElementAnimation* pAnimation)
2593 result r = E_SUCCESS;
2595 VisualElementValueAnimation* pPropertyAnimation = dynamic_cast< VisualElementValueAnimation* >(pAnimation);
2596 SysTryReturnResult(NID_UI_ANIM, (pPropertyAnimation != null), E_INVALID_ARG, "Invalid argument(s) is used. VisualElementAnimation is null.");
2601 case ANIMATION_TARGET_SIZE:
2603 DimensionAnimation* pDimensionAnim = null;
2604 RectangleAnimation* pRectangleAnim = null;
2606 pDimensionAnim = dynamic_cast< DimensionAnimation* >(pAnimationBase);
2607 pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
2608 SysTryReturnResult(NID_UI_ANIM, ((pDimensionAnim) || (pRectangleAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
2610 Dimension controlSize;
2611 float anchorX = 0.0f;
2612 float anchorY = 0.0f;
2614 controlSize = __pControl->GetSize();
2618 Dimension dimValue(0, 0);
2620 pDimensionAnim->GetAnchor(anchorX, anchorY);
2622 for (int index = 0; index < pDimensionAnim->GetKeyFrameCount(); index++)
2624 pDimensionAnim->GetKeyFrameAt(index, keyTime, dimValue);
2626 if (keyTime < pDimensionAnim->GetDuration())
2628 FloatRectangle modelBounds = __pVisualElement->GetBounds();
2629 FloatRectangle presentationBounds = const_cast<VisualElement*>((__pVisualElement)->AcquirePresentationInstance())->GetBounds();
2630 __pVisualElement->ReleasePresentationInstance();
2632 float currentAnchorX = presentationBounds.width * anchorX;
2633 float currentAnchorY = presentationBounds.height * anchorY;
2634 float endAnchorX = dimValue.width * anchorX;
2635 float endAnchorY = dimValue.height * anchorY;
2637 float endX = modelBounds.x + (currentAnchorX - endAnchorX);
2638 float endY = modelBounds.y + (currentAnchorY - endAnchorY);
2640 Variant keyValue(FloatRectangle(endX, endY, static_cast< float >(dimValue.width), static_cast< float >(dimValue.height)));
2642 r = pPropertyAnimation->AddKeyFrame(keyTime / static_cast< float >(pDimensionAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction));
2643 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame.");
2647 else //if (pRectangleAnim)
2649 Rectangle dimValue(0, 0, 0, 0);
2651 pRectangleAnim->GetAnchor(anchorX, anchorY);
2653 for (int index = 0; index < pRectangleAnim->GetKeyFrameCount(); index++)
2655 pRectangleAnim->GetKeyFrameAt(index, keyTime, dimValue);
2657 if (keyTime < pRectangleAnim->GetDuration())
2659 FloatRectangle modelBounds = __pVisualElement->GetBounds();
2660 FloatRectangle presentationBounds = const_cast<VisualElement*>((__pVisualElement)->AcquirePresentationInstance())->GetBounds();
2661 __pVisualElement->ReleasePresentationInstance();
2663 float currentAnchorX = presentationBounds.width * anchorX;
2664 float currentAnchorY = presentationBounds.height * anchorY;
2665 float endAnchorX = dimValue.width * anchorX;
2666 float endAnchorY = dimValue.height * anchorY;
2668 float endX = modelBounds.x + (currentAnchorX - endAnchorX);
2669 float endY = modelBounds.y + (currentAnchorY - endAnchorY);
2671 Variant keyValue(FloatRectangle(endX, endY, static_cast< float >(dimValue.width), static_cast< float >(dimValue.height)));
2672 r = pPropertyAnimation->AddKeyFrame(keyTime / static_cast< float >(pRectangleAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction));
2673 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame.");
2680 case ANIMATION_TARGET_POSITION:
2682 PointAnimation* pPointAnim = null;
2683 RectangleAnimation* pRectangleAnim = null;
2685 pPointAnim = dynamic_cast< PointAnimation* >(pAnimationBase);
2686 pRectangleAnim = dynamic_cast< RectangleAnimation* >(pAnimationBase);
2687 SysTryReturnResult(NID_UI_ANIM, ((pPointAnim) || (pRectangleAnim)), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
2690 Rectangle clientBounds = __pControlImpl->GetParent()->GetClientBounds();
2691 FloatRectangle modelBounds = __pVisualElement->GetBounds();
2693 controlPos = __pControl->GetPosition();
2697 Point pointValue(0, 0);
2698 Point prevPointValue = controlPos;
2700 for (int index = 0; index < pPointAnim->GetKeyFrameCount(); index++)
2702 pPointAnim->GetKeyFrameAt(index, keyTime, pointValue);
2705 if (keyTime < pPointAnim->GetDuration())
2707 float absPointX = (static_cast< float >(clientBounds.x) + static_cast< float >(pointValue.x));
2708 float absPointY = (static_cast< float >(clientBounds.y) + static_cast< float >(pointValue.y));
2710 Variant keyValue(FloatPoint(absPointX, absPointY));
2712 r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pPointAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction));
2713 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame.");
2718 else //if (pRectangleAnim)
2720 Rectangle pointValue(0, 0, 0, 0);
2721 Rectangle prevPointValue = Rectangle(controlPos.x, controlPos.y, 0, 0);
2723 for (int index = 0; index < pRectangleAnim->GetKeyFrameCount(); index++)
2725 pRectangleAnim->GetKeyFrameAt(index, keyTime, pointValue);
2727 if (keyTime < pRectangleAnim->GetDuration())
2729 float absPointX = (static_cast< float >(clientBounds.x) + static_cast< float >(pointValue.x));
2730 float absPointY = (static_cast< float >(clientBounds.y) + static_cast< float >(pointValue.y));
2732 Variant keyValue(FloatPoint(absPointX, absPointY));
2734 r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pRectangleAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction));
2735 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame.");
2742 case ANIMATION_TARGET_ALPHA:
2744 IntegerAnimation* pIntegerAnim = null;
2745 FloatAnimation* pFloatAnim = null;
2747 pIntegerAnim = dynamic_cast< IntegerAnimation* >(pAnimationBase);
2748 pFloatAnim = dynamic_cast< FloatAnimation* >(pAnimationBase);
2749 SysTryReturnResult(NID_UI_ANIM, (pIntegerAnim || pFloatAnim), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
2753 int alphaIntValue = 0;
2755 for (int index = 0; index < pIntegerAnim->GetKeyFrameCount(); index++)
2757 pIntegerAnim->GetKeyFrameAt(index, keyTime, alphaIntValue);
2759 if (keyTime < pIntegerAnim->GetDuration())
2761 Variant keyValue(static_cast< float >(alphaIntValue));
2763 r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pIntegerAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction));
2764 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame.");
2769 else //if (pFloatAnim)
2771 float alphaFltValue = 0.0;
2773 for (int index = 0; index < pFloatAnim->GetKeyFrameCount(); index++)
2775 pFloatAnim->GetKeyFrameAt(index, keyTime, alphaFltValue);
2777 if (keyTime < pFloatAnim->GetDuration())
2779 Variant keyValue(static_cast< float >(alphaFltValue));
2781 r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pFloatAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction));
2782 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame.");
2789 case ANIMATION_TARGET_ROTATION:
2791 RotateAnimation* pRotateAnim = null;
2793 pRotateAnim = dynamic_cast< RotateAnimation* >(pAnimationBase);
2794 SysTryReturnResult(NID_UI_ANIM, (pRotateAnim), E_INVALID_ARG, "Invalid argument(s) is used. Animation is invalid.");
2796 float rotateFltValue = 0;
2798 for (int index = 0; index < pRotateAnim->GetKeyFrameCount(); index++)
2800 pRotateAnim->GetKeyFrameAt(index, keyTime, rotateFltValue);
2802 if (keyTime < pRotateAnim->GetDuration())
2804 Variant keyValue(rotateFltValue);
2806 r = pPropertyAnimation->AddKeyFrame(static_cast< float >(keyTime) / static_cast< float >(pRotateAnim->GetDuration()), keyValue, const_cast< IVisualElementAnimationTimingFunction* >(pTimingFunction));
2807 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to add key frame.");
2815 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. animTarget is invalid.");
2825 _ControlAnimatorImpl::SetGroupAnimation(AnimationGroup* pAnimGrp)
2827 result r = E_SUCCESS;
2828 ParallelAnimationGroup* pParallelAnimGrp = null;
2829 SequentialAnimationGroup* pSequentialAnimGrp = null;
2830 AnimationTargetType animTargetArray[ANIMATION_TARGET_MAX] =
2832 ANIMATION_TARGET_ROTATION,
2833 ANIMATION_TARGET_SIZE,
2834 ANIMATION_TARGET_POSITION,
2835 ANIMATION_TARGET_ALPHA
2837 bool setLogicalBnds = false;
2838 bool setShowStateInternal = false;
2841 long totalDelay = 0;
2842 long groupDuration = 0;
2843 VisualElementAnimationGroup* pAnimationGroup = null;
2844 String animIdentifier;
2845 int activeAnimationCount = GetActiveAnimationListCount();
2847 pParallelAnimGrp = dynamic_cast< ParallelAnimationGroup* >(pAnimGrp);
2848 pSequentialAnimGrp = dynamic_cast< SequentialAnimationGroup* >(pAnimGrp);
2849 SysTryReturnResult(NID_UI_ANIM, ((pParallelAnimGrp) || (pSequentialAnimGrp)), E_INVALID_ARG, "Invalid argument(s) is used. AnimationGroup argument is invalid.");
2852 pAnimationGroup = new (std::nothrow) VisualElementAnimationGroup();
2853 SysTryReturnResult(NID_UI_ANIM, (pAnimationGroup != null), E_OUT_OF_MEMORY, "Memory allocation failed.");
2855 animIdentifier.Append(__animId);
2856 animIdentifier.Append(GROUP);
2858 __groupName.Clear();
2859 __groupName = animIdentifier;
2861 if (pParallelAnimGrp)
2863 for (int target = (static_cast< int >(ANIMATION_TARGET_NONE) + 1); target < (static_cast< int >(ANIMATION_TARGET_MAX)); target++)
2865 AnimationTargetType animTarget = animTargetArray[target];
2866 AnimationBase* pAnimationBase = null;
2867 pAnimationBase = pParallelAnimGrp->GetAnimationN(animTarget);
2869 if (pAnimationBase != null)
2871 long duration = pAnimationBase->GetDuration();
2873 if (pAnimationBase->IsAutoReverseEnabled())
2875 duration = duration * 2;
2878 duration = (duration * pAnimationBase->GetRepeatCount() * pAnimationBase->GetScaleRatio()) + ((pAnimationBase->GetDelay() - pAnimationBase->GetOffset()) * pAnimationBase->GetScaleRatio());
2880 if (duration > groupDuration)
2882 groupDuration = duration;
2885 if (IsAnimationSupported() == false)
2887 r = SetControlProperty(animTarget, *pAnimationBase);
2888 delete pAnimationBase;
2890 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to store animation values.");
2894 if (pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_POSITION) ||
2895 pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_SIZE))
2897 __logicalBoundsHolder = __pControl->GetBounds();
2898 setLogicalBnds = true;
2900 else if (pParallelAnimGrp->IsAnimationAdded(ANIMATION_TARGET_ALPHA))
2902 __showStateHolder = __pControl->GetShowState();
2903 setShowStateInternal = true;
2906 r = SetAnimation(animTarget, *pAnimationBase, ANIMATION_TRIGGER_USER, pAnimationGroup);
2910 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start animation.");
2914 __isAnimationTargetAnimating[animTarget] = true;
2916 if (animTarget == ANIMATION_TARGET_POSITION || animTarget == ANIMATION_TARGET_SIZE)
2918 SetControlLogicalBounds(animTarget, *pAnimationBase);
2920 else if (animTarget == ANIMATION_TARGET_ALPHA)
2922 SetControlShowState(animTarget, *pAnimationBase);
2930 __prevAnimationBoundsHolder = __pControl->GetBounds();
2932 for (int index = 0; index < pSequentialAnimGrp->GetAnimationCount(); index++)
2934 AnimationTargetType animTarget = ANIMATION_TARGET_MAX;
2935 AnimationBase* pAnimationBase = null;
2936 pAnimationBase = pSequentialAnimGrp->GetAnimationAtN(index);
2937 animTarget = pSequentialAnimGrp->GetAnimationTargetTypeAt(index);
2939 if (pAnimationBase != null)
2941 if (IsAnimationSupported() == false)
2943 r = SetControlProperty(animTarget, *pAnimationBase);
2944 delete pAnimationBase;
2946 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to store animation values.");
2950 if ((pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == ANIMATION_TARGET_POSITION) ||
2951 (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == ANIMATION_TARGET_SIZE))
2953 __logicalBoundsHolder = __pControl->GetBounds();
2954 setLogicalBnds = true;
2957 if (pSequentialAnimGrp->GetAnimationTargetTypeAt(index) == ANIMATION_TARGET_ALPHA)
2959 __showStateHolder = __pControl->GetShowState();
2960 setShowStateInternal = true;
2963 if (animTarget == ANIMATION_TARGET_SIZE)
2965 r = SetPrevAnimationBoundsProperty(animTarget, *pAnimationBase);
2969 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to store previous animation bounds.");
2970 delete pAnimationBase;
2976 __sequentialGroupAnimation = true;
2977 //Add the animation to the group
2978 r = SetAnimation(animTarget, *pAnimationBase, ANIMATION_TRIGGER_USER, pAnimationGroup);
2979 __sequentialGroupAnimation = false;
2981 if (pAnimationBase->IsAutoReverseEnabled() == true)
2983 duration = 2 * pAnimationBase->GetDuration();
2987 duration = pAnimationBase->GetDuration();
2990 delay = pAnimationBase->GetDelay();
2991 totalDelay = delay + duration * pAnimationBase->GetRepeatCount();
2992 totalDelay = totalDelay - (pAnimationBase->GetOffset());
2993 __sequelDelay = totalDelay;
2994 groupDuration = groupDuration + __sequelDelay * pAnimationBase->GetScaleRatio();
2998 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start animation.");
3002 __isAnimationTargetAnimating[animTarget] = true;
3004 if (animTarget == ANIMATION_TARGET_POSITION || animTarget == ANIMATION_TARGET_SIZE)
3006 SetControlLogicalBounds(animTarget, *pAnimationBase);
3008 else if (animTarget == ANIMATION_TARGET_ALPHA)
3010 SetControlShowState(animTarget, *pAnimationBase);
3019 bool disable = false;
3020 bool propagation = false;
3022 result r = DisableImplicitAnimation(disable);
3023 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
3024 //if (pParallelAnimGrp == null)
3026 r = DisableVisualElementPropagation(propagation);
3027 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
3029 r = __pControl->SetBounds(__logicalBoundsHolder);
3033 DisableVisualElementPropagation(propagation);
3037 DisableImplicitAnimation(disable);
3040 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set bounds.");
3043 if (setShowStateInternal)
3045 bool disable = false;
3046 bool propagation = false;
3048 result r = DisableImplicitAnimation(disable);
3049 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable implicit animation.");
3051 r = DisableVisualElementPropagation(propagation);
3052 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to disable/enable visual element propagation.");
3054 r = __pControl->SetShowState(__showStateHolder);
3058 DisableVisualElementPropagation(propagation);
3062 DisableImplicitAnimation(disable);
3065 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, , E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to set show state.");
3069 __pControlImpl->SetBoundsAndUpdateLayout(__pControlImpl->GetBounds());
3071 pAnimationGroup->SetDuration(groupDuration);
3072 r = __pVisualElement->AddAnimation(animIdentifier, *pAnimationGroup);
3073 SysTryCatch(NID_UI_ANIM, r == E_SUCCESS, r = E_SYSTEM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to start group animation.");
3075 delete pAnimationGroup;
3080 delete pAnimationGroup;
3082 if (DestroyAnimation(activeAnimationCount) != E_SUCCESS)
3084 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to deallocate memory.");
3092 _ControlAnimatorImpl::DisableImplicitAnimation(bool& state)
3094 bool enable = __pVisualElement->IsImplicitAnimationEnabled();
3095 __pVisualElement->SetImplicitAnimationEnabled(state);
3102 _ControlAnimatorImpl::DisableVisualElementPropagation(bool& state)
3104 bool propagate = _VisualElementImpl::GetInstance(*__pVisualElement)->GetPropertyPropagationEnabled();
3105 result r = _VisualElementImpl::GetInstance(*__pVisualElement)->SetPropertyPropagationEnabled(state);
3112 _ControlAnimatorImpl::OnTickOccurred(const VisualElementAnimation& animation, const String& keyName, VisualElement& target, const Variant& currentValue)
3114 VisualElementValueAnimation* pAnimation = dynamic_cast< VisualElementValueAnimation* >(const_cast< VisualElementAnimation* >(&animation));
3115 VisualElement* pPresentation = const_cast< VisualElement* >(target.AcquirePresentationInstance());
3117 if (pPresentation && pAnimation)
3122 if (!pAnimation->IsEndValueApplied() && (__isAnimationTargetAnimating[ANIMATION_TARGET_POSITION]))
3124 diffX = pPresentation->GetBounds().x + currentValue.ToFloatRectangle().x - __presentationBounds.x;
3125 diffY = pPresentation->GetBounds().y + currentValue.ToFloatRectangle().y - __presentationBounds.y;
3129 diffX = pPresentation->GetBounds().x;
3130 diffY = pPresentation->GetBounds().y;
3133 Variant newBounds(FloatRectangle(diffX, diffY, currentValue.ToFloatRectangle().width, currentValue.ToFloatRectangle().height));
3134 _VisualElementImpl::GetInstance(*pPresentation)->SetProperty(VePropBounds, newBounds);
3138 SysLogException(NID_UI_ANIM, E_SYSTEM, "[E_SYSTEM] A system error has been occurred. Failed to get presentation instance of visual element.");
3141 target.ReleasePresentationInstance();
3143 }}} // Tizen::Ui::Animations