|
1 /* |
|
2 * Copyright (c) 2008-2009 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: Implementation of background processing indicator |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <stringloader.h> |
|
19 #include <data_caging_path_literals.hrh> // KDC_APP_RESOURCE_DIR |
|
20 #include <glxtracer.h> |
|
21 #include <glxlog.h> // Glx logs |
|
22 #include <glxuistd.h> |
|
23 #include <glxuiutility.h> // UiUtility Singleton |
|
24 #include <glxicons.mbg> |
|
25 #include <glxtexturemanager.h> // Texturemanager |
|
26 #include <mglxmedialist.h> |
|
27 #include <glxthumbnailattributeinfo.h> |
|
28 #include <glxerrormanager.h> |
|
29 // Alf Headers |
|
30 #include <alf/alfutil.h> |
|
31 #include <alf/alfanchorlayout.h> |
|
32 #include <alf/alfcontrolgroup.h> |
|
33 #include <alf/alfimagevisual.h> |
|
34 #include "glxfullscreenbusyicon.h" |
|
35 |
|
36 const TInt KGlxFullScreenControlGrpId = 0x113; // This is the same control grp id used in FS view |
|
37 //define the opacity values |
|
38 const TReal KOpacityOpaque = 1.0; |
|
39 const TReal KOpacityTransparent = 0.0; |
|
40 const TInt KBusyIconFrameCount = 10; |
|
41 const TInt KMainVisSz = 60; |
|
42 const TInt KIconOffset = 10; |
|
43 const TTimeIntervalMicroSeconds32 KanInterval = 100000; |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // NewL |
|
47 // --------------------------------------------------------------------------- |
|
48 // |
|
49 CGlxFullScreenBusyIcon* CGlxFullScreenBusyIcon::NewL(MGlxMediaList& aMediaList, |
|
50 CGlxUiUtility& aUiUtility) |
|
51 { |
|
52 TRACER("CGlxFullScreenBusyIcon::NewL()"); |
|
53 CGlxFullScreenBusyIcon* self = new (ELeave) CGlxFullScreenBusyIcon( |
|
54 aMediaList, aUiUtility); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop(self); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // CGlxFullScreenBusyIcon constructor |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 CGlxFullScreenBusyIcon::CGlxFullScreenBusyIcon(MGlxMediaList& aMediaList, |
|
66 CGlxUiUtility& aUiUtility) : |
|
67 iMediaList(aMediaList), iUiUtility(aUiUtility), iBusyIconIndex(0) |
|
68 |
|
69 { |
|
70 //iBusyIconIndex(0), |
|
71 TRACER("CGlxFullScreenBusyIcon::CGlxFullScreenBusyIcon()"); |
|
72 // No Implementation |
|
73 } |
|
74 // --------------------------------------------------------------------------- |
|
75 // ~CGlxFullScreenBusyIcon Destructor |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 CGlxFullScreenBusyIcon::~CGlxFullScreenBusyIcon() |
|
79 { |
|
80 TRACER("CGlxFullScreenBusyIcon::~CGlxFullScreenBusyIcon()"); |
|
81 |
|
82 iMediaList.RemoveMediaListObserver(this); |
|
83 |
|
84 if (iPeriodic->IsActive()) |
|
85 { |
|
86 iPeriodic->Cancel(); |
|
87 } |
|
88 |
|
89 delete iPeriodic; |
|
90 |
|
91 if (iMainVisual) |
|
92 { |
|
93 iMainVisual->RemoveAndDestroyAllD(); |
|
94 iMainVisual = NULL; |
|
95 } |
|
96 } |
|
97 // --------------------------------------------------------------------------- |
|
98 // ConstructL |
|
99 // --------------------------------------------------------------------------- |
|
100 // |
|
101 void CGlxFullScreenBusyIcon::ConstructL() |
|
102 { |
|
103 TRACER("CGlxFullScreenBusyIcon::ConstructL"); |
|
104 TFileName resFile(KDC_APP_BITMAP_DIR); |
|
105 resFile.Append(KGlxIconsFilename); |
|
106 iPeriodic = CPeriodic::NewL(CActive::EPriorityStandard); |
|
107 iMediaList.AddMediaListObserverL(this); |
|
108 /* create the the alf visual,anchorlayout and add layout to visual*/ |
|
109 iEnv = iUiUtility.Env(); |
|
110 CAlfControl::ConstructL(*iEnv); |
|
111 iMainVisual = CAlfAnchorLayout::AddNewL(*this); |
|
112 |
|
113 //BackGround Border Image Visual |
|
114 iBackgroundBorderImageVisual = CAlfImageVisual::AddNewL(*this, iMainVisual); |
|
115 CAlfControlGroup* group = &iEnv->ControlGroup(KGlxFullScreenControlGrpId); |
|
116 group->AppendL(this); |
|
117 |
|
118 iMainVisual->SetFlag(EAlfVisualFlagManualLayout); |
|
119 |
|
120 // Update the pos and size of the visual |
|
121 UpdatePosition(); |
|
122 |
|
123 // Setting the Flag to get layout change notifications |
|
124 iMainVisual->SetFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
125 iMainVisual->SetSize(TAlfTimedPoint(KMainVisSz, KMainVisSz)); |
|
126 // Store the Current Screensize |
|
127 iScreenSize = GetScreenSize(); |
|
128 if (IsReadyL()) |
|
129 { |
|
130 ShowBusyIconL(EFalse); |
|
131 } |
|
132 else |
|
133 { |
|
134 ShowBusyIconL(ETrue); |
|
135 } |
|
136 } |
|
137 // --------------------------------------------------------------------------- |
|
138 // PeriodicCallbackL |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 TInt CGlxFullScreenBusyIcon::PeriodicCallbackL(TAny* aPtr) |
|
142 { |
|
143 TRACER("CGlxFullScreenBusyIcon::PeriodicCallbackL"); |
|
144 static_cast<CGlxFullScreenBusyIcon*> (aPtr)->CallPeriodicCallbackL(); |
|
145 return KErrNone; |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // Callback from periodic timer-- non static |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 inline void CGlxFullScreenBusyIcon::CallPeriodicCallbackL() |
|
153 { |
|
154 TRACER("CGlxFullScreenBusyIcon::CallPeriodicCallbackL"); |
|
155 // Get the icon file |
|
156 TFileName resFile(KDC_APP_BITMAP_DIR); |
|
157 resFile.Append(KGlxIconsFilename); |
|
158 CAlfTexture& backgroundTexture = |
|
159 iUiUtility.GlxTextureManager().CreateIconTextureL( |
|
160 EMbmGlxiconsQgn_graf_ring_wait_01 + iBusyIconIndex * 2, |
|
161 resFile); |
|
162 iBusyIconIndex++; |
|
163 //reset the svg frames |
|
164 if (iBusyIconIndex >= KBusyIconFrameCount) |
|
165 { |
|
166 iBusyIconIndex = 0; |
|
167 } |
|
168 iBackgroundBorderImageVisual->SetImage(TAlfImage(backgroundTexture)); |
|
169 ShowBusyIconL(ETrue); |
|
170 } |
|
171 // --------------------------------------------------------------------------- |
|
172 // ShowBusyIconL |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void CGlxFullScreenBusyIcon::ShowBusyIconL(TBool aShow) |
|
176 { |
|
177 TRACER("CGlxFullScreenBusyIcon::ShowBusyIconL()"); |
|
178 GLX_LOG_INFO1("CGlxFullScreenBusyIcon::ShowBusyIconL() value %d",aShow); |
|
179 if (aShow) |
|
180 { |
|
181 iMainVisual->SetOpacity(KOpacityOpaque); |
|
182 } |
|
183 else |
|
184 { |
|
185 iMainVisual->SetOpacity(KOpacityTransparent); |
|
186 } |
|
187 if (!aShow) |
|
188 { |
|
189 if (iPeriodic->IsActive()) |
|
190 { |
|
191 iPeriodic->Cancel(); |
|
192 } |
|
193 } |
|
194 if (!iPeriodic->IsActive() && aShow) |
|
195 { |
|
196 iPeriodic->Start(0, KanInterval, TCallBack(&PeriodicCallbackL, |
|
197 static_cast<TAny*> (this))); |
|
198 } |
|
199 } |
|
200 // --------------------------------------------------------------------------- |
|
201 // GetScreenSize |
|
202 // --------------------------------------------------------------------------- |
|
203 // |
|
204 TRect CGlxFullScreenBusyIcon::GetScreenSize() |
|
205 { |
|
206 TRACER("CGlxFullScreenBusyIcon::GetScreenSize()"); |
|
207 return AlfUtil::ScreenSize(); |
|
208 } |
|
209 // --------------------------------------------------------------------------- |
|
210 // UpdatePosition |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 void CGlxFullScreenBusyIcon::UpdatePosition() |
|
214 { |
|
215 TRACER("CGlxFullScreenBusyIcon::UpdatePosition()"); |
|
216 TRect rect = GetScreenSize(); |
|
217 TInt screenWidth = rect.Width(); |
|
218 // Switch off the Flag for layout update notification, else a change in size/pos |
|
219 // will call VisualLayoutUpdated multiple times. |
|
220 iMainVisual->ClearFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
221 //set the control size |
|
222 iMainVisual->SetSize(TSize(KMainVisSz, KMainVisSz)); |
|
223 iMainVisual->SetPos(TAlfRealPoint(screenWidth / 2 - KMainVisSz / 2, |
|
224 KIconOffset)); |
|
225 iMainVisual->SetFlag(EAlfVisualFlagLayoutUpdateNotification); |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // VisualLayoutUpdated |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 void CGlxFullScreenBusyIcon::VisualLayoutUpdated(CAlfVisual&/* aVisual*/) |
|
233 { |
|
234 TRACER("CGlxFullScreenBusyIcon::VisualLayoutUpdated()"); |
|
235 // Update the Screen positions only if the layout has changed. |
|
236 // For performace improvement |
|
237 TRect presentScreenSize = GetScreenSize(); |
|
238 if (iScreenSize.Width() != presentScreenSize.Width()) |
|
239 { |
|
240 UpdatePosition(); |
|
241 iScreenSize = presentScreenSize; |
|
242 } |
|
243 } |
|
244 // --------------------------------------------------------------------------- |
|
245 // IsReadyL |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 TBool CGlxFullScreenBusyIcon::IsReadyL() |
|
249 { |
|
250 TRACER("CGlxFullScreenBusyIcon::IsReadyL()"); |
|
251 if (iMediaList.Count() > 0) |
|
252 { |
|
253 TInt fsMediaIndex = iMediaList.FocusIndex(); |
|
254 TGlxMedia focusItem = iMediaList.Item(fsMediaIndex); |
|
255 TInt thumbnailError = GlxErrorManager::HasAttributeErrorL( |
|
256 focusItem.Properties(), KGlxMediaIdThumbnail); |
|
257 if (thumbnailError) |
|
258 { |
|
259 return ETrue; |
|
260 } |
|
261 |
|
262 TMPXAttribute tnAttribQuality(KGlxMediaIdThumbnail, |
|
263 GlxFullThumbnailAttributeId(ETrue, iScreenSize.Width(), |
|
264 iScreenSize.Height())); |
|
265 // This is because there is only one context maintained for FullScreen TN |
|
266 TMPXAttribute tnAttribQualityOtherOrientation(KGlxMediaIdThumbnail, |
|
267 GlxFullThumbnailAttributeId(ETrue, iScreenSize.Height(), |
|
268 iScreenSize.Width())); |
|
269 |
|
270 const CGlxThumbnailAttribute* qualityTn = focusItem.ThumbnailAttribute( |
|
271 tnAttribQuality); |
|
272 if (!qualityTn) |
|
273 { |
|
274 qualityTn = focusItem.ThumbnailAttribute( |
|
275 tnAttribQualityOtherOrientation); |
|
276 } |
|
277 if (qualityTn) |
|
278 { |
|
279 return ETrue; |
|
280 } |
|
281 |
|
282 return EFalse; |
|
283 } |
|
284 else |
|
285 { |
|
286 return ETrue; |
|
287 } |
|
288 } |
|
289 |
|
290 // --------------------------------------------------------------------------- |
|
291 // HandleAttributesAvailableL |
|
292 // --------------------------------------------------------------------------- |
|
293 // |
|
294 void CGlxFullScreenBusyIcon::HandleAttributesAvailableL(TInt aItemIndex, |
|
295 const RArray<TMPXAttribute>& /*aAttributes*/, MGlxMediaList* /*aList*/) |
|
296 { |
|
297 TRACER("CGlxFullScreenBusyIcon::HandleAttributesAvailableL()"); |
|
298 if (aItemIndex == iMediaList.FocusIndex()) |
|
299 { |
|
300 if (IsReadyL()) |
|
301 { |
|
302 ShowBusyIconL(EFalse); |
|
303 } |
|
304 } |
|
305 } |
|
306 |
|
307 // ---------------------------------------------------------------------------- |
|
308 // HandleFocusChangedL |
|
309 // ---------------------------------------------------------------------------- |
|
310 // |
|
311 void CGlxFullScreenBusyIcon::HandleFocusChangedL( |
|
312 NGlxListDefs::TFocusChangeType /*aType*/, TInt /*aNewIndex*/, |
|
313 TInt /*aOldIndex*/, MGlxMediaList* /*aList*/) |
|
314 { |
|
315 TRACER("CGlxFullScreenBusyIcon::HandleFocusChangedL()"); |
|
316 ShowBusyIconL(EFalse); |
|
317 iBusyIconIndex = 0;//reset the icon index to start from the beginning |
|
318 if (!IsReadyL()) |
|
319 { |
|
320 ShowBusyIconL(ETrue); |
|
321 } |
|
322 } |
|
323 // ---------------------------------------------------------------------------- |
|
324 // HandleError |
|
325 // ---------------------------------------------------------------------------- |
|
326 // |
|
327 void CGlxFullScreenBusyIcon::HandleError(TInt /*aError*/) |
|
328 { |
|
329 if (IsReadyL()) |
|
330 { |
|
331 ShowBusyIconL(EFalse); |
|
332 } |
|
333 } |