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_DimensionAnimationImpl.cpp
20 * @brief This file contains implementation of _DimensionAnimationImpl class
22 * This file contains implementation _DimensionAnimationImpl 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_DimensionAnimationImpl.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 _DimensionAnimationImpl::~_DimensionAnimationImpl(void)
48 _DimensionAnimationImpl::_DimensionAnimationImpl(DimensionAnimation* pDimensionAnimation)
51 , startValue(Dimension(0, 0))
52 , endValue(Dimension(0, 0))
53 , __pDimensionAnimation(pDimensionAnimation)
58 _DimensionAnimationImpl::CopyDimensionAnimationValue(const DimensionAnimation& dimensionAnimation)
62 _AnimationBaseImpl* pAnimationBaseImpl = __pDimensionAnimation->_pAnimationBaseImpl;
64 // Deleting the contents of existing keyframe
65 r = pAnimationBaseImpl->RemoveAllKeyFrames();
66 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating.");
68 // Copying the contents
69 startValue = dimensionAnimation._pDimensionAnimationImpl->startValue;
70 endValue = dimensionAnimation._pDimensionAnimationImpl->endValue;
72 if (dimensionAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0)
77 IMapEnumeratorT< long, Object* >* pMapEnum = null;
78 MapEntryT< long, Object* > value;
79 Dimension* pDimensionObj = null;
81 pMapEnum = dimensionAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN();
83 SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to GetMapEnumeratorN()");
85 while (pMapEnum->MoveNext() == E_SUCCESS)
87 r = pMapEnum->GetCurrent(value);
88 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
90 Dimension* pDimValue = dynamic_cast< Dimension* >(value.GetValue());
91 SysTryCatch(NID_UI_ANIM, (pDimValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. KeyFrame value is invalid.");
93 pDimensionObj = new (std::nothrow) Dimension(*pDimValue);
94 SysTryCatch(NID_UI_ANIM, (pDimensionObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
96 r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pDimensionObj);
97 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
105 delete pDimensionObj;
112 _DimensionAnimationImpl::GetAnimatedValue(float actualProgress, Tizen::Graphics::Dimension& animatedValue) const
114 Variant startDimension(startValue);
115 Variant endDimension(endValue);
116 Variant value(Dimension(0, 0));
118 _VisualElementAnimationVariantInterpolator variantInterpolator;
119 result r = variantInterpolator.Interpolate(actualProgress, startDimension, endDimension, value);
121 animatedValue = value.ToDimension();
122 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get the animated value.");
128 }}} // Tizen::Ui::Animations