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.
18 * @file FUiCtrlAnimation.cpp
19 * @brief This is the implementation file for Animation class.
22 #include <FUiCtrlAnimation.h>
23 #include <FBaseSysLog.h>
24 #include "FUiCtrl_AnimationImpl.h"
26 using namespace Tizen::Graphics;
27 using namespace Tizen::Base::Collection;
29 namespace Tizen { namespace Ui { namespace Controls
32 Animation::Animation(void)
36 Animation::~Animation(void)
41 Animation::Construct(const Rectangle& rectangle, const IList& animationFrames)
45 _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
47 SysAssertf((pAnimationImpl == null), "Already constructed! Calling Construct() twice or more on a same instance is not allowed for this class.");
49 pAnimationImpl = _AnimationImpl::CreateAnimationImplN(this);
51 SysTryReturn(NID_UI_CTRL, pAnimationImpl != null, r, r, "[%s] Propagating.", GetErrorMessage(r));
53 _pControlImpl = pAnimationImpl;
55 r = Control::SetBounds(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
56 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
58 r = pAnimationImpl->SetAnimationFrames(animationFrames);
59 SysTryCatch(NID_UI_CTRL, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
61 pAnimationImpl->SetImageCount(animationFrames.GetCount());
66 delete pAnimationImpl;
67 pAnimationImpl = null;
75 Animation::AddAnimationEventListener(IAnimationEventListener& listener)
77 _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
78 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
80 result r = pAnimationImpl->AddAnimationEventListener(listener);
81 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
83 SetLastResult(E_SUCCESS);
88 Animation::RemoveAnimationEventListener(IAnimationEventListener& listener)
90 _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
91 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
93 result r = pAnimationImpl->RemoveAnimationEventListener(listener);
94 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
96 SetLastResult(E_SUCCESS);
101 Animation::SetRepeatCount(int count)
103 _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
104 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
106 result r = pAnimationImpl->SetRepeatCount(count);
107 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
109 SetLastResult(E_SUCCESS);
114 Animation::GetRepeatCount(void) const
116 const _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
117 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
119 return pAnimationImpl->GetRepeatCount();
123 Animation::GetCurrentRepeatedCount(void) const
125 const _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
126 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
128 return pAnimationImpl->GetCurrentRepeatedCount();
132 Animation::GetImageCount(void) const
134 const _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
135 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
137 return pAnimationImpl->GetImageCount();
141 Animation::Play(void)
143 _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
144 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
146 result r = pAnimationImpl->Play();
147 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
149 SetLastResult(E_SUCCESS);
154 Animation::Stop(void)
156 _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
157 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
159 result r = pAnimationImpl->Stop();
160 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
162 SetLastResult(E_SUCCESS);
167 Animation::Pause(void)
169 _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
170 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
172 result r = pAnimationImpl->Pause();
173 SysTryReturnVoidResult(NID_UI_CTRL, r == E_SUCCESS, r, "[%s] Propagating.", GetErrorMessage(r));
175 SetLastResult(E_SUCCESS);
180 Animation::GetStatus(void) const
182 const _AnimationImpl* pAnimationImpl = _AnimationImpl::GetInstance(*this);
183 SysAssertf(pAnimationImpl != null, "Not yet constructed. Construct() should be called before use.");
185 return pAnimationImpl->GetStatus();
188 }}} // Tizen::Ui::Controls