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_RectangleAnimationImpl.cpp
20 * @brief This file contains implementation of _RectangleAnimationImpl class
22 * This file contains implementation _RectanngleAnimationImpl class.
25 #include <FBaseSysLog.h>
26 #include <FBaseColHashMapT.h>
28 #include <FUiVariant.h>
30 #include "FUiAnim_VisualElementAnimationVariantInterpolator.h"
31 #include "FUiAnim_AnimationBaseImpl.h"
32 #include "FUiAnim_RectangleAnimationImpl.h"
35 using namespace Tizen::Base;
36 using namespace Tizen::Ui::Animations;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Graphics;
41 namespace Tizen { namespace Ui { namespace Animations
44 _RectangleAnimationImpl::~_RectangleAnimationImpl(void)
49 _RectangleAnimationImpl::_RectangleAnimationImpl(RectangleAnimation* pRectangle)
52 , startValue(Rectangle(0, 0, 0, 0))
53 , endValue(Rectangle(0, 0, 0, 0))
54 , __pRectangleAnimation(pRectangle)
60 _RectangleAnimationImpl::CopyRectangleAnimationValue(const RectangleAnimation& rectangleAnimation)
64 _AnimationBaseImpl* pAnimationBaseImpl = __pRectangleAnimation->_pAnimationBaseImpl;
66 // Deleting the contents of existing keyframe
67 r = pAnimationBaseImpl->RemoveAllKeyFrames();
68 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating.");
70 // Copying the contents
71 startValue = rectangleAnimation._pRectangleAnimationImpl->startValue;
72 endValue = rectangleAnimation._pRectangleAnimationImpl->endValue;
74 if (rectangleAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0)
79 IMapEnumeratorT< long, Object* >* pMapEnum = null;
80 MapEntryT< long, Object* > value;
81 Rectangle* pRectObj = null;
83 pMapEnum = rectangleAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN();
85 SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to get enumerator.");
88 while (pMapEnum->MoveNext() == E_SUCCESS)
90 r = pMapEnum->GetCurrent(value);
91 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
93 Rectangle* pRectValue = dynamic_cast< Rectangle* >(value.GetValue());
94 SysTryCatch(NID_UI_ANIM, (pRectValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. KeyFrame value is invalid.");
96 pRectObj = new (std::nothrow) Rectangle(*pRectValue);
97 SysTryCatch(NID_UI_ANIM, (pRectObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
99 r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pRectObj);
100 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
115 _RectangleAnimationImpl::GetAnimatedValue(float actualProgress, Tizen::Graphics::Rectangle& animatedValue) const
117 Variant startRect(startValue);
118 Variant endRect(endValue);
119 Variant value(Rectangle(0, 0, 0, 0));
121 _VisualElementAnimationVariantInterpolator variantInterpolator;
122 result r = variantInterpolator.Interpolate(actualProgress, startRect, endRect, value);
124 animatedValue = value.ToRectangle();
125 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, " A system error has been occurred. Failed to get the animated value.");
131 }}} // Tizen::Ui::Animations