Fixed issue 45122
[apps/osp/Gallery.git] / src / GlProgressAnimation.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file                GlProgressAnimation.cpp
19  * @brief               This is the implementation file for GlProgressAnimation class.
20  */
21
22 #include <FApp.h>
23 #include "GlProgressAnimation.h"
24 #include "GlTypes.h"
25
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Media;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Controls;
33
34 ProgressAnimation::ProgressAnimation(void)
35         : __pAnimation(null)
36         , __pAnimationFrameList(null)
37 {
38 }
39
40 ProgressAnimation::~ProgressAnimation(void)
41 {
42         if (__pAnimationFrameList != null)
43         {
44                 delete __pAnimationFrameList;
45         }
46 }
47
48 result
49 ProgressAnimation::Construct(Tizen::Graphics::Rectangle rect)
50 {
51         Panel::Construct(rect);
52
53         AppResource *pAppResource = Application::GetInstance()->GetAppResource();
54         if (pAppResource != null)
55         {
56                 Bitmap *pBitmap0 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS1);
57                 Bitmap *pBitmap1 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS2);
58                 Bitmap *pBitmap2 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS3);
59                 Bitmap *pBitmap3 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS4);
60                 Bitmap *pBitmap4 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS5);
61                 Bitmap *pBitmap5 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS6);
62                 Bitmap *pBitmap6 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS7);
63                 Bitmap *pBitmap7 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS8);
64                 Bitmap *pBitmap8 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS9);
65                 Bitmap *pBitmap9 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS10);
66                 Bitmap *pBitmap10 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS11);
67                 Bitmap *pBitmap11 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS12);
68                 Bitmap *pBitmap12 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS13);
69                 Bitmap *pBitmap13 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS14);
70                 Bitmap *pBitmap14 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS15);
71                 Bitmap *pBitmap15 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS16);
72                 Bitmap *pBitmap16 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS17);
73                 Bitmap *pBitmap17 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS18);
74                 Bitmap *pBitmap18 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS19);
75                 Bitmap *pBitmap19 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS20);
76                 Bitmap *pBitmap20 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS21);
77                 Bitmap *pBitmap21 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS22);
78                 Bitmap *pBitmap22 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS23);
79                 Bitmap *pBitmap23 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS24);
80                 Bitmap *pBitmap24 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS25);
81                 Bitmap *pBitmap25 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS26);
82                 Bitmap *pBitmap26 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS27);
83                 Bitmap *pBitmap27 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS28);
84                 Bitmap *pBitmap28 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS29);
85                 Bitmap *pBitmap29 = pAppResource->GetBitmapN(IDB_ALBUM_RENAME_PROGRESS30);
86
87                 // Create AnimationFrames
88                 long duration = DURATION / PROGRESS_COUNT;
89                 AnimationFrame *pAniFrame1 = new (std::nothrow) AnimationFrame(*pBitmap0, duration);
90                 AnimationFrame *pAniFrame2 = new (std::nothrow) AnimationFrame(*pBitmap1, duration);
91                 AnimationFrame *pAniFrame3 = new (std::nothrow) AnimationFrame(*pBitmap2, duration);
92                 AnimationFrame *pAniFrame4 = new (std::nothrow) AnimationFrame(*pBitmap3, duration);
93                 AnimationFrame *pAniFrame5 = new (std::nothrow) AnimationFrame(*pBitmap4, duration);
94                 AnimationFrame *pAniFrame6 = new (std::nothrow) AnimationFrame(*pBitmap5, duration);
95                 AnimationFrame *pAniFrame7 = new (std::nothrow) AnimationFrame(*pBitmap6, duration);
96                 AnimationFrame *pAniFrame8 = new (std::nothrow) AnimationFrame(*pBitmap7, duration);
97                 AnimationFrame *pAniFrame9 = new (std::nothrow) AnimationFrame(*pBitmap8, duration);
98                 AnimationFrame *pAniFrame10 = new (std::nothrow) AnimationFrame(*pBitmap9, duration);
99                 AnimationFrame *pAniFrame11 = new (std::nothrow) AnimationFrame(*pBitmap10, duration);
100                 AnimationFrame *pAniFrame12 = new (std::nothrow) AnimationFrame(*pBitmap11, duration);
101                 AnimationFrame *pAniFrame13 = new (std::nothrow) AnimationFrame(*pBitmap12, duration);
102                 AnimationFrame *pAniFrame14 = new (std::nothrow) AnimationFrame(*pBitmap13, duration);
103                 AnimationFrame *pAniFrame15 = new (std::nothrow) AnimationFrame(*pBitmap14, duration);
104                 AnimationFrame *pAniFrame16 = new (std::nothrow) AnimationFrame(*pBitmap15, duration);
105                 AnimationFrame *pAniFrame17 = new (std::nothrow) AnimationFrame(*pBitmap16, duration);
106                 AnimationFrame *pAniFrame18 = new (std::nothrow) AnimationFrame(*pBitmap17, duration);
107                 AnimationFrame *pAniFrame19 = new (std::nothrow) AnimationFrame(*pBitmap18, duration);
108                 AnimationFrame *pAniFrame20 = new (std::nothrow) AnimationFrame(*pBitmap19, duration);
109                 AnimationFrame *pAniFrame21 = new (std::nothrow) AnimationFrame(*pBitmap20, duration);
110                 AnimationFrame *pAniFrame22 = new (std::nothrow) AnimationFrame(*pBitmap21, duration);
111                 AnimationFrame *pAniFrame23 = new (std::nothrow) AnimationFrame(*pBitmap22, duration);
112                 AnimationFrame *pAniFrame24 = new (std::nothrow) AnimationFrame(*pBitmap23, duration);
113                 AnimationFrame *pAniFrame25 = new (std::nothrow) AnimationFrame(*pBitmap24, duration);
114                 AnimationFrame *pAniFrame26 = new (std::nothrow) AnimationFrame(*pBitmap25, duration);
115                 AnimationFrame *pAniFrame27 = new (std::nothrow) AnimationFrame(*pBitmap26, duration);
116                 AnimationFrame *pAniFrame28 = new (std::nothrow) AnimationFrame(*pBitmap27, duration);
117                 AnimationFrame *pAniFrame29 = new (std::nothrow) AnimationFrame(*pBitmap28, duration);
118                 AnimationFrame *pAniFrame30 = new (std::nothrow) AnimationFrame(*pBitmap29, duration);
119
120                 // Create AnimationList
121                 __pAnimationFrameList = new (std::nothrow) ArrayList(SingleObjectDeleter);
122                 __pAnimationFrameList->Construct();
123                 __pAnimationFrameList->Add(*pAniFrame1);
124                 __pAnimationFrameList->Add(*pAniFrame2);
125                 __pAnimationFrameList->Add(*pAniFrame3);
126                 __pAnimationFrameList->Add(*pAniFrame4);
127                 __pAnimationFrameList->Add(*pAniFrame5);
128                 __pAnimationFrameList->Add(*pAniFrame6);
129                 __pAnimationFrameList->Add(*pAniFrame7);
130                 __pAnimationFrameList->Add(*pAniFrame8);
131                 __pAnimationFrameList->Add(*pAniFrame9);
132                 __pAnimationFrameList->Add(*pAniFrame10);
133                 __pAnimationFrameList->Add(*pAniFrame11);
134                 __pAnimationFrameList->Add(*pAniFrame12);
135                 __pAnimationFrameList->Add(*pAniFrame13);
136                 __pAnimationFrameList->Add(*pAniFrame14);
137                 __pAnimationFrameList->Add(*pAniFrame15);
138                 __pAnimationFrameList->Add(*pAniFrame16);
139                 __pAnimationFrameList->Add(*pAniFrame17);
140                 __pAnimationFrameList->Add(*pAniFrame18);
141                 __pAnimationFrameList->Add(*pAniFrame19);
142                 __pAnimationFrameList->Add(*pAniFrame20);
143                 __pAnimationFrameList->Add(*pAniFrame21);
144                 __pAnimationFrameList->Add(*pAniFrame22);
145                 __pAnimationFrameList->Add(*pAniFrame23);
146                 __pAnimationFrameList->Add(*pAniFrame24);
147                 __pAnimationFrameList->Add(*pAniFrame25);
148                 __pAnimationFrameList->Add(*pAniFrame26);
149                 __pAnimationFrameList->Add(*pAniFrame27);
150                 __pAnimationFrameList->Add(*pAniFrame28);
151                 __pAnimationFrameList->Add(*pAniFrame29);
152                 __pAnimationFrameList->Add(*pAniFrame30);
153
154                 // Deallocate a Bitmap.
155                 delete pBitmap0;
156                 delete pBitmap1;
157                 delete pBitmap2;
158                 delete pBitmap3;
159                 delete pBitmap4;
160                 delete pBitmap5;
161                 delete pBitmap6;
162                 delete pBitmap7;
163                 delete pBitmap8;
164                 delete pBitmap9;
165                 delete pBitmap10;
166                 delete pBitmap11;
167                 delete pBitmap12;
168                 delete pBitmap13;
169                 delete pBitmap14;
170                 delete pBitmap15;
171                 delete pBitmap16;
172                 delete pBitmap17;
173                 delete pBitmap18;
174                 delete pBitmap19;
175                 delete pBitmap20;
176                 delete pBitmap21;
177                 delete pBitmap22;
178                 delete pBitmap23;
179                 delete pBitmap24;
180                 delete pBitmap25;
181                 delete pBitmap26;
182                 delete pBitmap27;
183                 delete pBitmap28;
184                 delete pBitmap29;
185
186                 // Create Animation
187                 __pAnimation = new (std::nothrow) Animation();
188                 __pAnimation->Construct(Rectangle((rect.width / 2 - 60 / 2), (rect.height / 2 + 30), 60, 60), *__pAnimationFrameList);
189                 __pAnimation->SetRepeatCount(10000);
190                 AddControl(__pAnimation);
191         }
192
193         return E_SUCCESS;
194 }
195
196 void
197 ProgressAnimation::AnimationStart(void)
198 {
199         __pAnimation->SetShowState(true);
200         __pAnimation->Play();
201 }
202
203 void
204 ProgressAnimation::AnimationStop(void)
205 {
206         __pAnimation->Stop();
207         __pAnimation->SetShowState(false);
208 }
209
210 void
211 ProgressAnimation::ChangeOrientation(Tizen::Graphics::Rectangle rect)
212 {
213         Panel::SetBounds(rect);
214         __pAnimation->SetBounds((rect.width / 2 - 60 / 2), (rect.height / 2 + 30), 60, 60);
215         __pAnimation->Invalidate(true);
216 }