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_IntegerAnimationImpl.cpp
20 * @brief This file contains implementation of _IntegerAnimationImpl class
22 * This file contains implementation _IntegerAnimationImpl class.
25 #include <FBaseColHashMapT.h>
26 #include <FUiVariant.h>
27 #include <FBaseSysLog.h>
29 #include "FUiAnim_VisualElementAnimationVariantInterpolator.h"
30 #include "FUiAnim_AnimationBaseImpl.h"
31 #include "FUiAnim_IntegerAnimationImpl.h"
34 using namespace Tizen::Base;
35 using namespace Tizen::Ui::Animations;
36 using namespace Tizen::Base::Collection;
39 namespace Tizen { namespace Ui { namespace Animations
42 _IntegerAnimationImpl::~_IntegerAnimationImpl(void)
46 _IntegerAnimationImpl::_IntegerAnimationImpl(IntegerAnimation* pInt)
47 : startValue(Integer(0))
48 , endValue(Integer(0))
49 , __pIntegerAnimation(pInt)
54 _IntegerAnimationImpl::CopyIntegerAnimationValue(const IntegerAnimation& integerAnimation)
58 _AnimationBaseImpl* pAnimationBaseImpl = __pIntegerAnimation->_pAnimationBaseImpl;
60 // Deleting the contents of existing keyframe
61 r = pAnimationBaseImpl->RemoveAllKeyFrames();
62 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating.");
64 // Copying the contents
65 startValue = integerAnimation._pIntegerAnimationImpl->startValue;
66 endValue = integerAnimation._pIntegerAnimationImpl->endValue;
68 if (integerAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0)
73 IMapEnumeratorT< long, Object* >* pMapEnum = null;
74 MapEntryT< long, Object* > value;
75 Integer* pIntegerObj = null;
77 pMapEnum = integerAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN();
79 SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to get enumerator.");
81 while (pMapEnum->MoveNext() == E_SUCCESS)
83 r = pMapEnum->GetCurrent(value);
84 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
86 Integer* pIntValue = dynamic_cast< Integer* >(value.GetValue());
87 SysTryCatch(NID_UI_ANIM, (pIntValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. KeyFrame value is invalid.");
89 pIntegerObj = new (std::nothrow) Integer(*pIntValue);
90 SysTryCatch(NID_UI_ANIM, (pIntegerObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
92 r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pIntegerObj);
93 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
108 _IntegerAnimationImpl::GetAnimatedValue(float actualProgress, int& animatedValue) const
110 Variant startIntValue(startValue.ToInt());
111 Variant endIntValue(endValue.ToInt());
114 _VisualElementAnimationVariantInterpolator variantInterpolator;
115 result r = variantInterpolator.Interpolate(actualProgress, startIntValue, endIntValue, value);
117 animatedValue = value.ToInt();
118 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get the animated value.");
124 }}} // Tizen::Ui::Animations