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_PointAnimationImpl.cpp
20 * @brief This file contains implementation of _PointAnimationImpl class
22 * This file contains implementation _PointAnimationImpl class.
25 #include <FBaseSysLog.h>
26 #include <FBaseColHashMapT.h>
28 #include <FUiAnimVisualElementAnimation.h>
29 #include <FUiAnimVisualElement.h>
30 #include <FUiAnimVisualElementPropertyAnimation.h>
31 #include <FUiAnimBezierTimingFunction.h>
33 #include "FUiAnim_AnimationBaseImpl.h"
34 #include "FUiAnim_PointAnimationImpl.h"
35 #include "FUiAnim_VisualElementAnimationVariantInterpolator.h"
38 using namespace Tizen::Base;
39 using namespace Tizen::Ui::Animations;
40 using namespace Tizen::Base::Collection;
41 using namespace Tizen::Graphics;
44 namespace Tizen { namespace Ui { namespace Animations
47 _PointAnimationImpl::~_PointAnimationImpl(void)
51 _PointAnimationImpl::_PointAnimationImpl(PointAnimation* pPoint)
52 : startValue(Point(0, 0))
53 , endValue(Point(0, 0))
54 , __pPointAnimation(pPoint)
59 _PointAnimationImpl::CopyPointAnimationValue(const PointAnimation& pointAnimation)
63 _AnimationBaseImpl* pAnimationBaseImpl = __pPointAnimation->_pAnimationBaseImpl;
65 // Deleting the contents of existing keyframe
66 r = pAnimationBaseImpl->RemoveAllKeyFrames();
67 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), r, "Propagating.");
69 // Copying the contents
70 startValue = pointAnimation._pPointAnimationImpl->startValue;
71 endValue = pointAnimation._pPointAnimationImpl->endValue;
73 if (pointAnimation._pAnimationBaseImpl->keyFrameList.GetCount() == 0)
78 IMapEnumeratorT< long, Object* >* pMapEnum = null;
79 MapEntryT< long, Object* > value;
80 Point* pPointObj = null;
82 pMapEnum = pointAnimation._pAnimationBaseImpl->keyFrameList.GetMapEnumeratorN();
84 SysTryReturnResult(NID_UI_ANIM, (pMapEnum), r, "Failed to get enumerator.");
86 while (pMapEnum->MoveNext() == E_SUCCESS)
88 r = pMapEnum->GetCurrent(value);
89 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
91 Point* pPointValue = dynamic_cast< Point* >(value.GetValue());
92 SysTryCatch(NID_UI_ANIM, (pPointValue), r = E_INVALID_ARG, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument(s) is used. KeyFrame value is invalid.");
94 pPointObj = new (std::nothrow) Point(*pPointValue);
95 SysTryCatch(NID_UI_ANIM, (pPointObj), r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
97 r = pAnimationBaseImpl->keyFrameList.Add(value.GetKey(), pPointObj);
98 SysTryCatch(NID_UI_ANIM, (r == E_SUCCESS), , r, "[%s] Propagating.", GetErrorMessage(r));
113 _PointAnimationImpl::GetAnimatedValue(float actualProgress, Tizen::Graphics::Point& animatedValue) const
115 Variant startPoint(startValue);
116 Variant endPoint(endValue);
117 Variant value(Point(0,0));
119 _VisualElementAnimationVariantInterpolator variantInterpolator;
120 result r = variantInterpolator.Interpolate(actualProgress, startPoint, endPoint, value);
122 animatedValue = value.ToPoint();
123 SysTryReturnResult(NID_UI_ANIM, (r == E_SUCCESS), E_SYSTEM, "A system error has been occurred. Failed to get the animated value.");
127 }}} //Tizen::Ui::Animations