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_FloatAnimationImpl.cpp
20 * @brief This file contains implementation of _FloatAnimationImpl class
22 * This file contains implementation _FloatAnimationImpl class.
25 #include <FBaseSysLog.h>
26 #include <FBaseColHashMapT.h>
28 #include <FUiVariant.h>
31 #include "FUiAnim_VisualElementAnimationVariantInterpolator.h"
32 #include "FUiAnim_AnimationBaseImpl.h"
33 #include "FUiAnim_FloatAnimationImpl.h"
36 using namespace Tizen::Base;
37 using namespace Tizen::Ui::Animations;
38 using namespace Tizen::Base::Collection;
41 namespace Tizen { namespace Ui { namespace Animations
44 _FloatAnimationImpl::~_FloatAnimationImpl(void)
48 _FloatAnimationImpl::_FloatAnimationImpl(FloatAnimation* pFloat)
49 : startValue(Float(0.0f))
50 , endValue(Float(0.0f))
51 , __pFloatAnimation(pFloat)
56 _FloatAnimationImpl::CopyFloatAnimationValue(const FloatAnimation& floatAnimation)
60 _AnimationBaseImpl* pAnimationBaseImpl = __pFloatAnimation->_pAnimationBaseImpl;
62 // Deleting the contents of existing keyframe
63 r = pAnimationBaseImpl->RemoveAllKeyFrames();
64 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating.");
66 // Copying the contents
67 startValue = floatAnimation._pFloatAnimationImpl->startValue;
68 endValue = floatAnimation._pFloatAnimationImpl->endValue;
70 if (floatAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0)
75 IMapEnumeratorT< long, Object* >* pMapEnum = null;
76 MapEntryT< long, Object* > value;
77 Float* pFloatObj = null;
79 pMapEnum = floatAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN();
81 SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to get the enumerator.");
83 while (pMapEnum->MoveNext() == E_SUCCESS)
85 r = pMapEnum->GetCurrent(value);
86 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
88 Float* pFloatValue = dynamic_cast< Float* >(value.GetValue());
89 SysTryCatch(NID_UI_ANIM, (pFloatValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. Key frame is invalid.");
91 pFloatObj = new (std::nothrow) Float(*pFloatValue);
92 SysTryCatch(NID_UI_ANIM, (pFloatObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
94 r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pFloatObj);
95 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
110 _FloatAnimationImpl::GetAnimatedValue(float actualProgress, float& animatedValue) const
112 Variant startFloatValue(startValue.ToFloat());
113 Variant endFloatValue(endValue.ToFloat());
116 _VisualElementAnimationVariantInterpolator variantInterpolator;
117 result r = variantInterpolator.Interpolate(actualProgress, startFloatValue, endFloatValue, value);
119 animatedValue = value.ToFloat();
120 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get the animated value.");
126 }}} // Tizen::Ui::Animations