1 /* |
|
2 * Copyright (c) 2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "musuinavimediaanimator.h" |
|
21 #include "musuidefinitions.h" |
|
22 #include "muslogger.h" // debug logging |
|
23 #include <musuiicons.mbg> |
|
24 //#include <musui.mbg> |
|
25 //#include <musui_temp_icons.mbg> |
|
26 #include <musui.rsg> |
|
27 #include "musresourcefinderutil.h" |
|
28 |
|
29 #include <data_caging_path_literals.hrh> // KDC_APP_BITMAP_DIR |
|
30 #include <AknsUtils.h> |
|
31 #include <aknnavi.h> // CAknNavigationControlContainer |
|
32 #include <eikspane.h> // CEikStatusPaneBase |
|
33 #include <StringLoader.h> |
|
34 #include <applayout.cdl.h> // scalable UI |
|
35 #include <AknIconUtils.h> // SetSize for the icons |
|
36 #include <AknIconArray.h> |
|
37 #include <gulicon.h> |
|
38 #include <applayout.cdl.h> |
|
39 #include <e32std.h> |
|
40 #include <e32base.h> |
|
41 |
|
42 using namespace AppLayout; |
|
43 |
|
44 |
|
45 // CONSTANTS |
|
46 const TInt KMusUiAnimatorTimer = 50000; // Default 50 ms, 20 fps |
|
47 |
|
48 const TInt KIconArraySize = 15; |
|
49 |
|
50 _LIT( KMyBitmapRomFile, "Z:\\resource\\apps\\musuiicons.mif" ); |
|
51 _LIT( KMyBitmapRamFile, "C:\\resource\\apps\\musuiicons.mif" ); |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CMusUiNaviMediaAnimator* CMusUiNaviMediaAnimator::NewL( |
|
59 MMusUiNaviMediaAnimatorObserver& aObserver, TSize aImageSize ) |
|
60 { |
|
61 CMusUiNaviMediaAnimator* self = |
|
62 new( ELeave ) CMusUiNaviMediaAnimator( aObserver, aImageSize ); |
|
63 CleanupStack::PushL( self ); |
|
64 self->ConstructL(); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CMusUiNaviMediaAnimator::~CMusUiNaviMediaAnimator() |
|
75 { |
|
76 MUS_LOG( "mus: [MUSUI ] -> CMusUiNaviMediaAnimator::~CMusUiNaviMediaAnimator" ); |
|
77 |
|
78 if ( iAnimationTimer->IsActive() ) |
|
79 { |
|
80 iAnimationTimer->Cancel(); |
|
81 } |
|
82 delete iAnimationTimer; |
|
83 delete iBitmapArray; |
|
84 |
|
85 MUS_LOG( "mus: [MUSUI ] <- CMusUiNaviMediaAnimator::~CMusUiNaviMediaAnimator" ); |
|
86 } |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CMusUiNaviMediaAnimator::CMusUiNaviMediaAnimator( |
|
94 MMusUiNaviMediaAnimatorObserver& aObserver, TSize aImageSize ) |
|
95 : iObserver( aObserver ) |
|
96 { |
|
97 iSize = aImageSize; |
|
98 MUS_LOG1( "mus: [MUSUI ] -> \ |
|
99 CMusUiNaviMediaAnimator::CMusUiNaviMediaAnimator(): iSize.iWidth %d", |
|
100 iSize.iWidth ) |
|
101 MUS_LOG1( "mus: [MUSUI ] -> \ |
|
102 CMusUiNaviMediaAnimator::CMusUiNaviMediaAnimator(): iSize.iHeight %d", |
|
103 iSize.iHeight ) |
|
104 iBitmapArray = NULL; |
|
105 iInterval = KMusUiAnimatorTimer; |
|
106 iIndex = 0; |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 /* iAnimationTimer->Start( iInterval, |
|
112 iInterval, |
|
113 TCallBack( AnimationInterval, this ) ); |
|
114 */ |
|
115 } |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 // |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void CMusUiNaviMediaAnimator::ConstructL() |
|
124 { |
|
125 MUS_LOG( "mus: [MUSUI ] -> CMusUiNaviMediaAnimator::ConstructL" ); |
|
126 |
|
127 if( MusResourceFinderUtil::IsExistL( KMyBitmapRomFile ) ) |
|
128 { |
|
129 iResourceRam = EFalse; |
|
130 } |
|
131 else if( MusResourceFinderUtil::IsExistL( KMyBitmapRamFile ) ) |
|
132 { |
|
133 iResourceRam = ETrue; |
|
134 } |
|
135 else |
|
136 { |
|
137 MUS_LOG( "mus: [MUSUI ] Icon File Not Found " ); |
|
138 User::Leave(KErrNotFound); |
|
139 } |
|
140 |
|
141 |
|
142 LoadImagesL(); |
|
143 |
|
144 iAnimationTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
145 |
|
146 iAnimationTimer->Start( iInterval, |
|
147 iInterval, |
|
148 TCallBack( AnimationInterval, this ) ); |
|
149 |
|
150 |
|
151 MUS_LOG( "mus: [MUSUI ] <- CMusUiNaviMediaAnimator::ConstructL" ); |
|
152 } |
|
153 |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 // |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 void CMusUiNaviMediaAnimator::SetInterval( const TInt aAnimationInterval ) |
|
161 { |
|
162 iInterval = aAnimationInterval; |
|
163 |
|
164 |
|
165 if ( iAnimationTimer->IsActive() ) |
|
166 { |
|
167 iAnimationTimer->Cancel(); |
|
168 } |
|
169 |
|
170 iAnimationTimer->Start( iInterval, |
|
171 iInterval, |
|
172 TCallBack( AnimationInterval, this ) ); |
|
173 } |
|
174 |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // Callback for disable level indicator. |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 TInt CMusUiNaviMediaAnimator::AnimationInterval( TAny* aThis ) |
|
181 { |
|
182 MUS_LOG( "mus: [MUSUI ] -> CMusUiNaviMediaAnimator::AnimationInterval()" ); |
|
183 CMusUiNaviMediaAnimator* animator = |
|
184 static_cast< CMusUiNaviMediaAnimator* > ( aThis ); |
|
185 |
|
186 |
|
187 if ( animator->iBitmapArray ) |
|
188 { |
|
189 animator->iObserver.SetIcon( animator->iBitmapArray->At( animator->iIndex ) ); |
|
190 if( animator->iIndex < ( animator->iBitmapArray->Count() - 1 ) ) |
|
191 { |
|
192 animator->iIndex++; |
|
193 } |
|
194 else |
|
195 { |
|
196 animator->iIndex = 0; |
|
197 } |
|
198 } |
|
199 |
|
200 MUS_LOG( "mus: [MUSUI ] <- CMusUiNaviMediaAnimator::AnimationInterval()" ); |
|
201 return KErrNone; |
|
202 } |
|
203 |
|
204 |
|
205 // ----------------------------------------------------------------------------- |
|
206 // Layouts the text depending on current icon situation. |
|
207 // ----------------------------------------------------------------------------- |
|
208 // |
|
209 void CMusUiNaviMediaAnimator::LoadImagesL() |
|
210 { |
|
211 MUS_LOG( "mus: [MUSUI ] -> CMusUiNaviMediaAnimator::DoLayoutText" ); |
|
212 |
|
213 delete iBitmapArray; |
|
214 iBitmapArray = NULL; |
|
215 iBitmapArray = new ( ELeave ) CAknIconArray( KIconArraySize ); |
|
216 |
|
217 TParse parse; |
|
218 if( iResourceRam ) |
|
219 { |
|
220 parse.Set( KMyBitmapRamFile, &KDC_APP_RESOURCE_DIR, NULL ); |
|
221 } |
|
222 else |
|
223 { |
|
224 parse.Set( KMyBitmapRomFile, &KDC_APP_RESOURCE_DIR, NULL ); |
|
225 } |
|
226 |
|
227 |
|
228 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
229 |
|
230 TAknsItemID item; |
|
231 item.Set( 0xFFCC, 0xC ); // It's a kind a magic |
|
232 |
|
233 ConstructImageL( skin, |
|
234 item, |
|
235 EMbmMusuiiconsQgn_indi_video_wait1, |
|
236 EMbmMusuiiconsQgn_indi_video_wait1_mask, |
|
237 parse ); |
|
238 |
|
239 ConstructImageL( skin, |
|
240 item, |
|
241 EMbmMusuiiconsQgn_indi_video_wait2, |
|
242 EMbmMusuiiconsQgn_indi_video_wait2_mask, |
|
243 parse ); |
|
244 |
|
245 ConstructImageL( skin, |
|
246 item, |
|
247 EMbmMusuiiconsQgn_indi_video_wait3, |
|
248 EMbmMusuiiconsQgn_indi_video_wait3_mask, |
|
249 parse ); |
|
250 |
|
251 ConstructImageL( skin, |
|
252 item, |
|
253 EMbmMusuiiconsQgn_indi_video_wait4, |
|
254 EMbmMusuiiconsQgn_indi_video_wait4_mask, |
|
255 parse ); |
|
256 |
|
257 ConstructImageL( skin, |
|
258 item, |
|
259 EMbmMusuiiconsQgn_indi_video_wait5, |
|
260 EMbmMusuiiconsQgn_indi_video_wait5_mask, |
|
261 parse ); |
|
262 |
|
263 ConstructImageL( skin, |
|
264 item, |
|
265 EMbmMusuiiconsQgn_indi_video_wait6, |
|
266 EMbmMusuiiconsQgn_indi_video_wait6_mask, |
|
267 parse ); |
|
268 |
|
269 ConstructImageL( skin, |
|
270 item, |
|
271 EMbmMusuiiconsQgn_indi_video_wait7, |
|
272 EMbmMusuiiconsQgn_indi_video_wait7_mask, |
|
273 parse ); |
|
274 |
|
275 ConstructImageL( skin, |
|
276 item, |
|
277 EMbmMusuiiconsQgn_indi_video_wait8, |
|
278 EMbmMusuiiconsQgn_indi_video_wait8_mask, |
|
279 parse ); |
|
280 |
|
281 |
|
282 |
|
283 MUS_LOG( "mus: [MUSUI ] <- CMusUiNaviMediaAnimator::DoLayoutText" ); |
|
284 } |
|
285 |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 void CMusUiNaviMediaAnimator::ConstructImageL( MAknsSkinInstance* aSkin, |
|
292 const TAknsItemID& aId, |
|
293 TInt aBitmapId, |
|
294 TInt aMaskId, |
|
295 TParse parse ) |
|
296 |
|
297 { |
|
298 MUS_LOG( "mus: [MUSUI ] -> CMusUiNaviMediaAnimator::ConstructImageL()" ); |
|
299 |
|
300 CFbsBitmap* bitmap = NULL; |
|
301 CFbsBitmap* mask = NULL; |
|
302 |
|
303 |
|
304 AknsUtils::CreateIconL(aSkin, |
|
305 aId, |
|
306 bitmap, |
|
307 mask, |
|
308 parse.FullName(), |
|
309 aBitmapId, |
|
310 aMaskId); |
|
311 |
|
312 AknIconUtils::SetSize( bitmap, iSize ); |
|
313 AknIconUtils::SetSize( mask, iSize ); |
|
314 |
|
315 MUS_LOG1( "mus: [MUSUI ] -> CMusUiNaviMediaAnimator::ConstructImageL(): iSize.iWidth %d", |
|
316 iSize.iWidth ) |
|
317 MUS_LOG1( "mus: [MUSUI ] -> CMusUiNaviMediaAnimator::ConstructImageL(): iSize.iHeight %d", |
|
318 iSize.iHeight ) |
|
319 |
|
320 CGulIcon* icon = CGulIcon::NewL(); |
|
321 icon->SetBitmap( bitmap ); |
|
322 icon->SetMask( mask ); |
|
323 |
|
324 CleanupStack::PushL( icon ); |
|
325 iBitmapArray->AppendL( icon ); |
|
326 CleanupStack::Pop( icon ); |
|
327 |
|
328 //aImage->SetPicture(bitmap, mask); // Owership transferred to CEikImage |
|
329 |
|
330 MUS_LOG( "mus: [MUSUI ] <- CMusUiNaviMediaAnimator::ConstructImageL()" ); |
|
331 |
|
332 } |
|
333 |
|