2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file HmProgressPanel.cpp
19 * @brief Keeps implementation of ProgressPanel Implementation
22 #include <FGraphics.h>
24 #include <FUiAnimations.h>
25 #include "HmApplicationUtils.h"
26 #include "HmProgressPanel.h"
29 using namespace Tizen::App;
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Media;
34 using namespace Tizen::Ui;
35 using namespace Tizen::Ui::Animations;
36 using namespace Tizen::Ui::Controls;
38 ProgressPanel::ProgressPanel(void)
39 : __pAnimationFrameList(null)
44 ProgressPanel::~ProgressPanel(void)
46 if (__pAnimationFrameList != null)
48 __pAnimationFrameList->RemoveAll(true);
49 delete __pAnimationFrameList;
54 ProgressPanel::Construct(const Tizen::Graphics::Rectangle& controlRectangle)
57 long duration = DURATION_FOR_EACH_IMAGE / MAX_BITMAP_COUNT;
58 r = Panel::Construct(controlRectangle);
59 TryCatch(r == E_SUCCESS, , "Panel::Construct failed with error = %s", GetErrorMessage(r));
60 __pAnimationFrameList = new (std::nothrow) ArrayList();
61 __pAnimationFrameList->Construct();
64 for (int bmpCount = 0; bmpCount < MAX_BITMAP_COUNT; bmpCount++)
66 Bitmap* pProgressBitmap = null;
67 String bitmapName(WAIT_CURSOR_IMAGE_BASE);
68 bitmapName.Append(bmpCount);
69 bitmapName.Append(BITMAP_EXTENSION);
71 pProgressBitmap = ApplicationUtils::GetResourceBitmapN(bitmapName);
73 if (pProgressBitmap != null)
75 AnimationFrame* pProgressAniFrame = new (std::nothrow) AnimationFrame(*pProgressBitmap, duration);
77 if (pProgressAniFrame != null)
79 r = __pAnimationFrameList->Add(pProgressAniFrame);
83 delete pProgressAniFrame;
84 pProgressAniFrame = null;
88 delete pProgressBitmap;
89 pProgressBitmap = null;
94 __pAnimation = new (std::nothrow) Animation();
95 r = __pAnimation->Construct(Rectangle((controlRectangle.width / 2 - WAIT_CURSUR_DIMESION / 2), (controlRectangle.height / 2 - WAIT_CURSUR_DIMESION / 2),
96 WAIT_CURSUR_DIMESION, WAIT_CURSUR_DIMESION), *__pAnimationFrameList);
97 TryCatch(r == E_SUCCESS, , "__pAnimation->Construct failed with error = %s", GetErrorMessage(r));
98 __pAnimation->SetRepeatCount(REPEAT_COUNT);
99 r = AddControl(__pAnimation);
100 TryCatch(r == E_SUCCESS, , "AddControl(__pAnimation) failed with error = %s", GetErrorMessage(r));
106 if (__pAnimation != null)
112 if (__pAnimationFrameList)
114 __pAnimationFrameList->RemoveAll(true);
115 delete __pAnimationFrameList;
116 __pAnimationFrameList = null;
123 ProgressPanel::StartAnimation(void)
126 result r = E_SUCCESS;
127 bool animatorFailed = false;
128 ControlAnimator* pAniControlAnimator = null;
130 TryReturn(__pAnimation != null, E_INVALID_STATE, "Animation is not yet constructed");
132 pAniControlAnimator = __pAnimation->GetControlAnimator();
134 if (pAniControlAnimator != null)
136 if (pAniControlAnimator->GetStatus() == ANIMATOR_STATUS_PLAYING)
138 r = pAniControlAnimator->StopAllAnimations();
143 r = pAniControlAnimator->SetShowState(true);
147 animatorFailed = true;
152 animatorFailed = true;
157 r = __pAnimation->SetShowState(true);
160 __pAnimation->Play();
171 ProgressPanel::StopAnimation(void)
174 result r = E_SUCCESS;
175 bool animatorFailed = false;
176 ControlAnimator* pAniControlAnimator = null;
178 TryReturn(__pAnimation != null, E_INVALID_STATE, "Animation is not yet constructed");
179 pAniControlAnimator = __pAnimation->GetControlAnimator();
181 if (pAniControlAnimator != null)
183 if (pAniControlAnimator->GetStatus() == ANIMATOR_STATUS_PLAYING)
185 r = pAniControlAnimator->StopAllAnimations();
190 r = pAniControlAnimator->SetShowState(false);
194 animatorFailed = true;
199 animatorFailed = true;
204 r = __pAnimation->SetShowState(false);
207 __pAnimation->Stop();