1 /* |
|
2 * Copyright (c) 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <ganes/HgVgMediaWall.h> |
|
21 #include <ganes/HgVgMediaWallObserverIface.h> |
|
22 #include <ganes/HgScroller.h> |
|
23 |
|
24 #include "HgVgDrawBuffer.h" |
|
25 #include "HgVgScrollBar.h" |
|
26 #include "HgVgHelper.h" |
|
27 #include "HgVgMediaWallRenderer.h" |
|
28 #include "HgVgSkinRenderer.h" |
|
29 #include "HgVgTimer.h" |
|
30 #include "HgVgLetterPopup.h" |
|
31 #include "HgVgButton.h" |
|
32 #include "HgVgLabel.h" |
|
33 #include "HgVgEGL.h" |
|
34 #include "HgVgSpring.h" |
|
35 #include "HgVgImageCreator.h" |
|
36 #include "HgPopupDrawer.h" |
|
37 |
|
38 #include <ganes/HgScrollBufferObserverIface.h> |
|
39 #include <ganes/HgSelectionObserverIface.h> |
|
40 #include <ganes/HgMarkingObserverIface.h> |
|
41 #include <ganes/HgVgItem.h> |
|
42 #include "HgScrollbar.h" |
|
43 #include "HgScrollBufferManager.h" |
|
44 #include "HgConstants.h" |
|
45 #include "HgVgConstants.h" |
|
46 #include <ganes.mbg> |
|
47 //#include <aknappui.h> |
|
48 #include <touchfeedback.h> |
|
49 #include <gulicon.h> |
|
50 #include <e32math.h> |
|
51 #include <gulcolor.h> |
|
52 #include <e32cmn.h> // Abs |
|
53 |
|
54 #include <alf/alfcompositionutility.h> |
|
55 |
|
56 #include <AknIconUtils.h> |
|
57 #include <avkon.mbg> |
|
58 #include <AknsDrawUtils.h> |
|
59 #include <AknUtils.h> |
|
60 #include <layoutmetadata.cdl.h> |
|
61 #include <AknLayout2ScalableDef.h> |
|
62 #include <aknlayoutscalable_apps.cdl.h> |
|
63 |
|
64 |
|
65 |
|
66 using namespace AknTouchGestureFw; |
|
67 using namespace HgVgConstants; |
|
68 |
|
69 const TInt KMediaWallFullScreenItemsOnScreen(5); |
|
70 const TReal KMediaWallFullScreenCameraZoomFactor(1.5); |
|
71 const TReal KMediaWallFullScreenCameraRotationFactor(KCameraRotationFactor * 2); |
|
72 const TReal KMediaWallFullScreenSpringVelocityToAnimationFactor(KSpringVelocityToAnimationFactor / 2); |
|
73 const TReal KMediaWallFullScreenZOffset(1); |
|
74 const TInt KMediaWallFullScreenRowCount(1); |
|
75 const TReal KMediaWallFullScreenSpringK(KSpringK); |
|
76 const TReal KMediaWallFullScreenSpringDamping(KSpringDamping); |
|
77 const TReal KMediaWallFullScreenSpringMaxVelocity(KMaxSpringVelocity); |
|
78 const TReal KMediaWallFullScreenItemsToMoveOnFullScreenDrag(5); |
|
79 |
|
80 const TInt KMediaWallTBoneItemsOnScreen(3); |
|
81 const TReal KMediaWallTBoneCameraZoomFactor(2); |
|
82 const TReal KMediaWallTBoneCameraRotationFactor(KCameraRotationFactor); |
|
83 const TReal KMediaWallTBoneSpringVelocityToAnimationFactor(KSpringVelocityToAnimationFactor); |
|
84 const TInt KMediaWallTBonePopupFontSize(100); |
|
85 const TInt KMediaWallTBoneLabelFontSize(18); |
|
86 const TReal KMediaWallTBoneZOffset(0.5); |
|
87 const TInt KMediaWallTBoneRowCount(1); |
|
88 const TReal KMediaWallTBoneSpringK(KSpringK); |
|
89 const TReal KMediaWallTBoneSpringDamping(KSpringDamping); |
|
90 const TReal KMediaWallTBoneSpringMaxVelocity(KMaxSpringVelocity); |
|
91 const TReal KMediaWallTBoneItemsToMoveOnFullScreenDrag(3); |
|
92 |
|
93 const TInt KMediaWallGridItemsOnScreen(3*10); |
|
94 const TReal KMediaWallGridCameraZoomFactor(0.2); |
|
95 const TReal KMediaWallGridCameraRotationFactor(KCameraRotationFactor); |
|
96 const TReal KMediaWallGridSpringVelocityToAnimationFactor(KSpringVelocityToAnimationFactor/3); |
|
97 const TInt KMediaWallGridPopupFontSize(30); |
|
98 const TReal KMediaWallGridZOffset(0.5); |
|
99 const TInt KMediaWallGridRowCount(3); |
|
100 const TReal KMediaWallGridSpringK(KSpringK); |
|
101 const TReal KMediaWallGridSpringDamping(KSpringDamping*2); |
|
102 const TReal KMediaWallGridSpringMaxVelocity(KMaxSpringVelocity/3); |
|
103 const TReal KMediaWallGridItemsToMoveOnFullScreenDrag(15); |
|
104 |
|
105 // ============================ MEMBER FUNCTIONS =============================== |
|
106 // ----------------------------------------------------------------------------- |
|
107 // CHgMediaWall::NewL() |
|
108 // Two-phased constructor. |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 EXPORT_C CHgVgMediaWall* CHgVgMediaWall::NewL( |
|
112 const TRect& aRect, |
|
113 TInt aItemCount, |
|
114 THgVgMediaWallStyle aStyle, |
|
115 TBool aScrollBarEnabled, |
|
116 MObjectProvider* aParent, |
|
117 CGulIcon* aDefaultIcon ) |
|
118 { |
|
119 CHgVgMediaWall* self = new ( ELeave ) CHgVgMediaWall( |
|
120 aItemCount, |
|
121 aDefaultIcon, aStyle, aScrollBarEnabled ); |
|
122 |
|
123 CleanupStack::PushL (self ); |
|
124 self->ConstructL( aRect, aParent ); |
|
125 CleanupStack::Pop (self ); |
|
126 return self; |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CHgVgMediaWall::ConstructL() |
|
131 // Symbian 2nd phase constructor can leave. |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CHgVgMediaWall::ConstructL (const TRect& aRect, MObjectProvider* aParent ) |
|
135 { |
|
136 iPopupText1.CreateL( KMaxPopupTextLength ); |
|
137 iPopupText2.CreateL( KMaxPopupTextLength ); |
|
138 |
|
139 iSpring = new (ELeave) THgVgSpring(KSpringK, KSpringDamping, |
|
140 KMaxSpringVelocity, KPositionSnap, KMinSpringVelocity); |
|
141 |
|
142 iSpring->Reset(0,0); |
|
143 |
|
144 iAnimationTimer = CHgVgTimer::NewL(); |
|
145 |
|
146 iKeyScrollingTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
147 |
|
148 SetEmptyTextL(KNullDesC); |
|
149 |
|
150 // Create a window for this application view |
|
151 CreateWindowL ( ); |
|
152 |
|
153 EnableDragEvents(); |
|
154 |
|
155 ClaimPointerGrab(); |
|
156 |
|
157 InitScreenL( aRect ); |
|
158 |
|
159 InitItemsL(); |
|
160 |
|
161 HandleViewPositionChanged(ETrue); |
|
162 |
|
163 iCoeEnv->AddForegroundObserverL( *this ); |
|
164 |
|
165 // setup Avkon gesture framework. |
|
166 iTouchFw = AknTouchGestureFw::CAknTouchGestureFw::NewL(*this, *this); |
|
167 iTouchFw->SetGestureInterestL(AknTouchGestureFw::EAknTouchGestureFwGroupDrag | |
|
168 AknTouchGestureFw::EAknTouchGestureFwGroupTap | |
|
169 AknTouchGestureFw::EAknTouchGestureFwGroupFlick); |
|
170 |
|
171 ActivateL ( ); |
|
172 |
|
173 SetMopParent( aParent ); |
|
174 |
|
175 // skin needs to be updated after parent is set. |
|
176 iSkinRenderer->UpdateSkinL(this, this); |
|
177 |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CHgVgMediaWall::InitScreenL() |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 EXPORT_C void CHgVgMediaWall::InitScreenL( const TRect& aRect ) |
|
185 { |
|
186 // Set the windows size |
|
187 SetRect ( aRect ); |
|
188 |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CHgVgMediaWall::RefreshScreen() |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 EXPORT_C void CHgVgMediaWall::RefreshScreen( TInt aIndex ) |
|
196 { |
|
197 |
|
198 if( !iIsForeground ) |
|
199 { |
|
200 return; |
|
201 } |
|
202 |
|
203 if( !iAnimationTimer->IsActive() ) |
|
204 { |
|
205 if( /*iMediaWallStyle == EHgVgMediaWallStyleGrid ||*/ |
|
206 (aIndex >= FirstIndexOnScreen() && aIndex <= FirstIndexOnScreen() + ItemsOnScreen()) ) |
|
207 { |
|
208 |
|
209 UpdateLabelsAndPopup(); |
|
210 if(iFlags & EHgVgMediaWallDrawToWindowGC) |
|
211 { |
|
212 DrawNow(); |
|
213 } |
|
214 else |
|
215 { |
|
216 DrawOpenVG(); |
|
217 } |
|
218 |
|
219 } |
|
220 } |
|
221 } |
|
222 |
|
223 // ----------------------------------------------------------------------------- |
|
224 // CHgVgMediaWall::FirstIndexOnScreen() |
|
225 // ----------------------------------------------------------------------------- |
|
226 // |
|
227 EXPORT_C TInt CHgVgMediaWall::FirstIndexOnScreen() |
|
228 { |
|
229 return iBufferPosition - iItemsOnScreen / 2; |
|
230 } |
|
231 |
|
232 // ----------------------------------------------------------------------------- |
|
233 // CHgVgMediaWall::RefreshScreen() |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 EXPORT_C TInt CHgVgMediaWall::ItemsOnScreen() |
|
237 { |
|
238 return iItemsOnScreen; |
|
239 } |
|
240 |
|
241 // ----------------------------------------------------------------------------- |
|
242 // CHgVgMediaWall::RefreshScreen() |
|
243 // ----------------------------------------------------------------------------- |
|
244 // |
|
245 EXPORT_C TInt CHgVgMediaWall::SelectedIndex() |
|
246 { |
|
247 return iSelectedIndex * iRowCount; |
|
248 } |
|
249 |
|
250 // ----------------------------------------------------------------------------- |
|
251 // CHgVgMediaWall::RefreshScreen() |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 EXPORT_C void CHgVgMediaWall::SetSelectedIndex( TInt aIndex ) |
|
255 { |
|
256 if( aIndex >= 0 && aIndex < iItems.Count() ) |
|
257 { |
|
258 iUpdateScrollBar = ETrue; |
|
259 iSpring->Reset(aIndex / iRowCount, iSpring->EndY()); |
|
260 HandleViewPositionChanged(ETrue); |
|
261 } |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // CHgVgMediaWall::EnableScrollBufferL() |
|
266 // ----------------------------------------------------------------------------- |
|
267 // |
|
268 EXPORT_C void CHgVgMediaWall::EnableScrollBufferL( |
|
269 MHgScrollBufferObserver& aObserver, |
|
270 TInt aBufferSize, |
|
271 TInt aBufferTreshold ) |
|
272 { |
|
273 |
|
274 delete iManager; |
|
275 iManager = NULL; |
|
276 |
|
277 iManager = CHgScrollBufferManager::NewL( |
|
278 aObserver, |
|
279 aBufferSize, |
|
280 aBufferTreshold, |
|
281 (TInt)iSpring->GetX() * iRowCount, |
|
282 iItemCount); |
|
283 |
|
284 iManager->SetBufferOwner( *this ); |
|
285 } |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // CHgVgMediaWall::SetSelectionObserver() |
|
289 // ----------------------------------------------------------------------------- |
|
290 // |
|
291 EXPORT_C void CHgVgMediaWall::SetSelectionObserver( MHgSelectionObserver& aObserver ) |
|
292 { |
|
293 iSelectionObserver = &aObserver; |
|
294 } |
|
295 |
|
296 // ----------------------------------------------------------------------------- |
|
297 // CHgVgMediaWall::CHgVgMediaWall() |
|
298 // C++ default constructor can NOT contain any code, that might leave. |
|
299 // ----------------------------------------------------------------------------- |
|
300 // |
|
301 CHgVgMediaWall::CHgVgMediaWall( |
|
302 TInt aItemCount, |
|
303 CGulIcon* aDefaultIcon, |
|
304 THgVgMediaWallStyle aStyle, |
|
305 TBool aEnableScrollBar) : |
|
306 iItemCount(aItemCount), |
|
307 iItemsOnScreen(KMaxCoversVisible), |
|
308 iDefaultIcon( aDefaultIcon ), |
|
309 iAnimationState(EHgVgMediaWallAnimationStateIdle), |
|
310 iScrollBarEnabled(aEnableScrollBar), |
|
311 iMediaWallStyle(aStyle), |
|
312 iOpeningAnimationType(CHgVgMediaWall::EHgVgOpeningAnimationFlipToFront), |
|
313 iIsForeground(ETrue), |
|
314 iUsingDefaultIcon(ETrue), |
|
315 iRowCount(1), |
|
316 iCameraRotationFactor(KCameraRotationFactor), |
|
317 iCameraZoomFactor(KCameraZoomFactor), |
|
318 iSpringVelocityToAnimationFactor(KSpringVelocityToAnimationFactor), |
|
319 iPrevGridItem(KErrNotFound), |
|
320 iSelGridItem(KErrNotFound) |
|
321 // other intialized to 0 or EFalse |
|
322 { |
|
323 } |
|
324 |
|
325 // ----------------------------------------------------------------------------- |
|
326 // CHgVgMediaWall::~CHgVgMediaWall() |
|
327 // Destructor. |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 EXPORT_C CHgVgMediaWall::~CHgVgMediaWall ( ) |
|
331 { |
|
332 |
|
333 if (iAnimationTimer->IsActive()) |
|
334 iAnimationTimer->Cancel(); |
|
335 |
|
336 iItems.ResetAndDestroy(); |
|
337 |
|
338 iCoeEnv->RemoveForegroundObserver( *this ); |
|
339 |
|
340 if(MTouchFeedback::Instance()) |
|
341 { |
|
342 MTouchFeedback::Instance()->RemoveFeedbackArea(this, 0); |
|
343 } |
|
344 |
|
345 delete iEmptyLabel; |
|
346 delete iTouchFw; |
|
347 delete iEmptyText; |
|
348 delete iSkinRenderer; |
|
349 delete iAlbumLabel; |
|
350 delete iArtistLabel; |
|
351 delete iRenderer; |
|
352 delete iScrollBar; |
|
353 delete iDefaultIcon; |
|
354 delete iManager; |
|
355 delete iKeyScrollingTimer; |
|
356 delete iAnimationTimer; |
|
357 delete iLetterPopup; |
|
358 //delete iCompositionSource; |
|
359 delete iEGL; |
|
360 delete iSpring; |
|
361 delete iSurfaceBitmap; |
|
362 |
|
363 iPopupText1.Close(); |
|
364 iPopupText2.Close(); |
|
365 |
|
366 } |
|
367 |
|
368 // ----------------------------------------------------------------------------- |
|
369 // CHgVgMediaWall::Style() |
|
370 // ----------------------------------------------------------------------------- |
|
371 // |
|
372 EXPORT_C CHgVgMediaWall::THgVgMediaWallStyle CHgVgMediaWall::Style() const |
|
373 { |
|
374 return iMediaWallStyle; |
|
375 } |
|
376 |
|
377 |
|
378 // ----------------------------------------------------------------------------- |
|
379 // CHgVgMediaWall::OpeningAnimationType() |
|
380 // ----------------------------------------------------------------------------- |
|
381 // |
|
382 EXPORT_C CHgVgMediaWall::THgVgOpeningAnimationType CHgVgMediaWall::OpeningAnimationType() const |
|
383 { |
|
384 return iOpeningAnimationType; |
|
385 } |
|
386 |
|
387 |
|
388 // ----------------------------------------------------------------------------- |
|
389 // CHgVgMediaWall::Draw() |
|
390 // Draws the display. |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 void CHgVgMediaWall::Draw ( const TRect& /*aRect*/ ) const |
|
394 { |
|
395 RDebug::Print(_L("CHgVgMediaWall::Draw begin")); |
|
396 |
|
397 CHgVgMediaWall* self = const_cast<CHgVgMediaWall*>(this); |
|
398 |
|
399 if (iIsForeground) |
|
400 { |
|
401 if( iFlags & EHgVgMediaWallDrawToWindowGC ) |
|
402 { |
|
403 CFbsBitmap* screenshot = NULL; |
|
404 screenshot = self->DrawToBitmap(); |
|
405 if (screenshot) |
|
406 { |
|
407 SystemGc().BitBlt( Rect().iTl,screenshot ); |
|
408 delete screenshot; |
|
409 } |
|
410 else |
|
411 { |
|
412 SystemGc().SetBrushColor(KRgbRed); |
|
413 SystemGc().Clear(); |
|
414 } |
|
415 } |
|
416 else |
|
417 { |
|
418 |
|
419 // draw with alpha to make a hole to composition layer |
|
420 SystemGc().SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha); |
|
421 SystemGc().SetBrushColor(TRgb(0,0,0,0)); |
|
422 SystemGc().Clear(); |
|
423 |
|
424 DrawOpenVG(); |
|
425 } |
|
426 } |
|
427 else |
|
428 { |
|
429 if (iSurfaceBitmap) |
|
430 { |
|
431 RDebug::Print(_L("CHgVgMediaWall::Draw blit screenshot")); |
|
432 |
|
433 SystemGc().BitBlt( Rect().iTl, iSurfaceBitmap ); |
|
434 } |
|
435 else |
|
436 { |
|
437 RDebug::Print(_L("CHgVgMediaWall::Draw clear red")); |
|
438 |
|
439 // we should not get here, ever |
|
440 // still, clear with red color for debug purposes |
|
441 SystemGc().SetBrushColor(KRgbRed); |
|
442 SystemGc().Clear(); |
|
443 } |
|
444 } |
|
445 |
|
446 RDebug::Print(_L("CHgVgMediaWall::Draw end")); |
|
447 |
|
448 } |
|
449 |
|
450 // ----------------------------------------------------------------------------- |
|
451 // CHgVgMediaWall::SizeChanged() |
|
452 // Called by framework when the view size is changed. |
|
453 // ----------------------------------------------------------------------------- |
|
454 // |
|
455 void CHgVgMediaWall::SizeChanged ( ) |
|
456 { |
|
457 |
|
458 iRect = Rect(); |
|
459 TRAPD(error, InitRenderingL(ETrue)); |
|
460 if( error != KErrNone ) |
|
461 { |
|
462 // if out of memory |
|
463 if (error == KErrNoMemory) |
|
464 { |
|
465 // free all resources |
|
466 FreeItemsImages(); |
|
467 // try again |
|
468 TRAPD(error, InitRenderingL(ETrue)); |
|
469 // if still fails, need to give up |
|
470 if (error != KErrNone) |
|
471 { |
|
472 User::Panic(_L("USER"), error); |
|
473 } |
|
474 // reload all images we can |
|
475 ReloadItemsImages(); |
|
476 } |
|
477 else |
|
478 { |
|
479 // some other error occured during initialization |
|
480 // TODO: should we try again? |
|
481 User::Panic(_L("USER"), error); |
|
482 } |
|
483 } |
|
484 |
|
485 if(MTouchFeedback::Instance()) |
|
486 { |
|
487 MTouchFeedback::Instance()->SetFeedbackArea(this, |
|
488 0, |
|
489 iRect, |
|
490 ETouchFeedbackBasic, |
|
491 ETouchEventStylusDown); |
|
492 } |
|
493 |
|
494 } |
|
495 |
|
496 // ----------------------------------------------------------------------------- |
|
497 // CHgVgMediaWall::ChangeStyleL() |
|
498 // ----------------------------------------------------------------------------- |
|
499 // |
|
500 EXPORT_C void CHgVgMediaWall::ChangeStyleL( THgVgMediaWallStyle aStyle, const TRect& aRect, TBool /*aReuseSurface*/ ) |
|
501 { |
|
502 |
|
503 // If animation is on, stop it before changing style. |
|
504 HandleTransitionAnimationStop(); |
|
505 |
|
506 iMediaWallStyle = aStyle; |
|
507 |
|
508 iAnimationState = EHgVgMediaWallAnimationStateIdle; |
|
509 |
|
510 // TODO: if (!aReUseSurface...) |
|
511 |
|
512 InitScreenL( aRect ); |
|
513 |
|
514 } |
|
515 |
|
516 // ----------------------------------------------------------------------------- |
|
517 // CHgVgMediaWall::HandleItemCountChaged() |
|
518 // ----------------------------------------------------------------------------- |
|
519 // |
|
520 void CHgVgMediaWall::HandleItemCountChanged() |
|
521 { |
|
522 |
|
523 TRAP_IGNORE( InitScrollBarL(ETrue); ) |
|
524 |
|
525 if( iSelectedIndex >= MaxViewPosition() ) |
|
526 { |
|
527 iSpring->Reset((TReal)(MaxViewPosition()-1), 0); |
|
528 HandleViewPositionChanged(); |
|
529 } |
|
530 |
|
531 } |
|
532 |
|
533 // ----------------------------------------------------------------------------- |
|
534 // CHgVgMediaWall::HandlePointerEventL() |
|
535 // ----------------------------------------------------------------------------- |
|
536 // |
|
537 void CHgVgMediaWall::HandlePointerEventL( const TPointerEvent& aEvent ) |
|
538 { |
|
539 |
|
540 if (iAnimationState != EHgVgMediaWallAnimationStateItemOpened) |
|
541 { |
|
542 |
|
543 // handle buttons |
|
544 iButtonsHit = HandleButtons(aEvent); |
|
545 |
|
546 if (iScrollBar && iScrollBar->HandlePointerEventL(aEvent)) |
|
547 { |
|
548 iScrollBarHit = ETrue; |
|
549 } |
|
550 |
|
551 if (aEvent.iType == TPointerEvent::EButton1Up) |
|
552 { |
|
553 iScrollBarHit = EFalse; |
|
554 } |
|
555 |
|
556 |
|
557 } |
|
558 |
|
559 |
|
560 } |
|
561 |
|
562 // ----------------------------------------------------------------------------- |
|
563 // CHgVgMediaWall::OfferKeyEventL() |
|
564 // ----------------------------------------------------------------------------- |
|
565 // |
|
566 TKeyResponse CHgVgMediaWall::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
567 { |
|
568 if (iIsForeground) |
|
569 { |
|
570 switch( aType ) |
|
571 { |
|
572 case EEventKeyDown: |
|
573 HandleKeyDown(); |
|
574 break; |
|
575 case EEventKey: |
|
576 return HandleKeyEvent( aKeyEvent ); |
|
577 case EEventKeyUp: |
|
578 HandleKeyUp(); |
|
579 break; |
|
580 default: |
|
581 break; |
|
582 } |
|
583 } |
|
584 |
|
585 // Let CCoeControl handle other cases. |
|
586 return CCoeControl::OfferKeyEventL( aKeyEvent, aType ); |
|
587 } |
|
588 |
|
589 // ----------------------------------------------------------------------------- |
|
590 // CHgVgMediaWall::SetItem() |
|
591 // ----------------------------------------------------------------------------- |
|
592 // |
|
593 EXPORT_C void CHgVgMediaWall::SetItem(CHgVgItem* aItem, TInt aIndex) |
|
594 { |
|
595 if( aItem && aIndex >= 0 && aIndex < iItems.Count() ) |
|
596 { |
|
597 delete iItems[aIndex]; |
|
598 iItems[aIndex] = aItem; |
|
599 } |
|
600 } |
|
601 |
|
602 // ----------------------------------------------------------------------------- |
|
603 // CHgVgMediaWall::AddItem() |
|
604 // ----------------------------------------------------------------------------- |
|
605 // |
|
606 EXPORT_C void CHgVgMediaWall::AddItem(CHgVgItem* aItem) |
|
607 { |
|
608 if( aItem ) |
|
609 { |
|
610 iItems.Append(aItem); |
|
611 iItemCount++; |
|
612 HandleItemCountChanged(); |
|
613 if( iManager ) |
|
614 { |
|
615 iManager->ItemCountChanged( iItemCount-1, EFalse, iItemCount ); |
|
616 } |
|
617 } |
|
618 } |
|
619 |
|
620 // ----------------------------------------------------------------------------- |
|
621 // CHgVgMediaWall::InsertItem() |
|
622 // ----------------------------------------------------------------------------- |
|
623 // |
|
624 EXPORT_C void CHgVgMediaWall::InsertItem(CHgVgItem* aItem, TInt aIndex) |
|
625 { |
|
626 if( aItem && aIndex >= 0 ) |
|
627 { |
|
628 if(aIndex < iItems.Count()) |
|
629 { |
|
630 iItems.Insert(aItem, aIndex); |
|
631 } |
|
632 else |
|
633 { |
|
634 iItems.Append(aItem); |
|
635 } |
|
636 |
|
637 iItemCount++; |
|
638 HandleItemCountChanged(); |
|
639 |
|
640 if( iManager ) |
|
641 { |
|
642 iManager->ItemCountChanged( aIndex, EFalse, iItemCount ); |
|
643 } |
|
644 } |
|
645 } |
|
646 |
|
647 // ----------------------------------------------------------------------------- |
|
648 // CHgVgMediaWall::RemoveItem() |
|
649 // ----------------------------------------------------------------------------- |
|
650 // |
|
651 EXPORT_C void CHgVgMediaWall::RemoveItem(TInt aIndex) |
|
652 { |
|
653 if( aIndex >= 0 && aIndex < iItems.Count() ) |
|
654 { |
|
655 delete iItems[aIndex]; |
|
656 iItems[aIndex] = NULL; |
|
657 iItems.Remove(aIndex); |
|
658 iItemCount--; |
|
659 |
|
660 HandleItemCountChanged(); |
|
661 |
|
662 if( iManager ) |
|
663 { |
|
664 iManager->ItemCountChanged( aIndex, ETrue, iItemCount ); |
|
665 } |
|
666 } |
|
667 } |
|
668 |
|
669 // ----------------------------------------------------------------------------- |
|
670 // CHgVgMediaWall::ResizeL() |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 EXPORT_C void CHgVgMediaWall::ResizeL( TInt aItemCount ) |
|
674 { |
|
675 // Add More |
|
676 if( iItems.Count() < aItemCount ) |
|
677 { |
|
678 while( iItems.Count() < aItemCount ) |
|
679 { |
|
680 iItems.AppendL( CHgVgItem::NewL() ); |
|
681 } |
|
682 } |
|
683 // remove from the end |
|
684 else if( iItems.Count() > aItemCount ) |
|
685 { |
|
686 while( iItems.Count() > aItemCount ) |
|
687 { |
|
688 delete iItems[iItems.Count() - 1]; |
|
689 iItems.Remove( iItems.Count() - 1 ); |
|
690 } |
|
691 } |
|
692 else |
|
693 { |
|
694 return; // no change needed |
|
695 } |
|
696 |
|
697 iItemCount = aItemCount; |
|
698 |
|
699 if( iManager ) |
|
700 { |
|
701 iManager->ResetBuffer( iSelectedIndex, iItemCount ); |
|
702 } |
|
703 |
|
704 HandleItemCountChanged(); |
|
705 } |
|
706 |
|
707 // ----------------------------------------------------------------------------- |
|
708 // CHgVgMediaWall::ItemL() |
|
709 // ----------------------------------------------------------------------------- |
|
710 // |
|
711 EXPORT_C CHgVgItem& CHgVgMediaWall::ItemL(TInt aIndex) |
|
712 { |
|
713 if( aIndex < 0 || aIndex >= iItems.Count() ) |
|
714 { |
|
715 User::Leave( KErrArgument ); |
|
716 } |
|
717 |
|
718 return *iItems[aIndex]; |
|
719 } |
|
720 |
|
721 // ----------------------------------------------------------------------------- |
|
722 // CHgVgMediaWall::HandleViewPositionChanged() |
|
723 // ----------------------------------------------------------------------------- |
|
724 // |
|
725 void CHgVgMediaWall::HandleViewPositionChanged(TBool aDontUpdateObserver) |
|
726 { |
|
727 // save previous index |
|
728 TInt prevIndex = iSelectedIndex; |
|
729 |
|
730 // calculate new selected index |
|
731 TReal frac; |
|
732 Math::Frac(frac, iSpring->GetX()); |
|
733 iSelectedIndex = (frac > 0.5f) ? iSpring->GetX() + 1 : iSpring->GetX(); |
|
734 |
|
735 // limit index to items |
|
736 if (iSelectedIndex < 0) |
|
737 iSelectedIndex = 0; |
|
738 else if (iSelectedIndex >= MaxViewPosition()) |
|
739 iSelectedIndex = MaxViewPosition() - 1; |
|
740 |
|
741 // if index has changed |
|
742 if (iSelectedIndex != prevIndex) |
|
743 { |
|
744 // update titles |
|
745 UpdateLabelsAndPopup(); |
|
746 |
|
747 // update scrollbar if needed |
|
748 if (iUpdateScrollBar && iScrollBar) |
|
749 iScrollBar->SetViewPosition(TPoint((TInt)iSelectedIndex, 0)); |
|
750 |
|
751 } |
|
752 |
|
753 // inform observer if needed |
|
754 if (iMediaWallStyle != EHgVgMediaWallStyleGrid && |
|
755 (iItems.Count() > 0 && iSelectionObserver && !aDontUpdateObserver && !iPointerDown)) |
|
756 { |
|
757 TRAP_IGNORE(iSelectionObserver->HandleSelectL(iSelectedIndex, this);) |
|
758 } |
|
759 |
|
760 // update scroll buffer manager position |
|
761 TInt newCol = (TInt)iSpring->GetX() * iRowCount; |
|
762 if( newCol != iBufferPosition ) |
|
763 { |
|
764 iBufferPosition = newCol; |
|
765 if( iManager ) |
|
766 { |
|
767 iManager->SetPosition((TInt)iBufferPosition); |
|
768 } |
|
769 } |
|
770 } |
|
771 |
|
772 // ----------------------------------------------------------------------------- |
|
773 // CHgVgMediaWall::HandleKeyDown() |
|
774 // ----------------------------------------------------------------------------- |
|
775 // |
|
776 void CHgVgMediaWall::HandleKeyDown() |
|
777 { |
|
778 iKeyRepeats = 0; |
|
779 iKeyScrollingState = ENoKeyScrolling; |
|
780 iPointerDown = EFalse; |
|
781 } |
|
782 |
|
783 // ----------------------------------------------------------------------------- |
|
784 // CHgVgMediaWall::HandleKeyEvent() |
|
785 // ----------------------------------------------------------------------------- |
|
786 // |
|
787 TKeyResponse CHgVgMediaWall::HandleKeyEvent(const TKeyEvent& aKeyEvent) |
|
788 { |
|
789 iKeyRepeats++; |
|
790 |
|
791 TKeyScrollingState possibleKeyScrollingState = ENoKeyScrolling; |
|
792 |
|
793 TBool handled = EFalse; |
|
794 |
|
795 // handle input |
|
796 switch( aKeyEvent.iCode ) |
|
797 { |
|
798 case EKeyUpArrow: |
|
799 { |
|
800 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
801 { |
|
802 |
|
803 TInt posY = (TInt)iSpring->EndY(); |
|
804 TInt posX = (TInt)iSpring->EndX(); |
|
805 |
|
806 posY--; |
|
807 if (posY < 0) |
|
808 { |
|
809 if (posX > 0) |
|
810 { |
|
811 posX--; |
|
812 posY = iRowCount - 1; |
|
813 } |
|
814 else |
|
815 { |
|
816 posY = 0; |
|
817 } |
|
818 } |
|
819 |
|
820 BeginSelection(posX * iRowCount + posY); |
|
821 |
|
822 possibleKeyScrollingState = EKeyScrollingUp; |
|
823 handled = ETrue; |
|
824 } |
|
825 |
|
826 } break; |
|
827 case EKeyDownArrow: |
|
828 { |
|
829 |
|
830 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
831 { |
|
832 |
|
833 TInt posY = (TInt)iSpring->EndY(); |
|
834 TInt posX = (TInt)iSpring->EndX(); |
|
835 |
|
836 posY++; |
|
837 if (posY >= iRowCount) |
|
838 { |
|
839 if (posX < MaxViewPosition()) |
|
840 { |
|
841 posY = 0; |
|
842 posX++; |
|
843 } |
|
844 else |
|
845 { |
|
846 posY = iRowCount - 1; |
|
847 } |
|
848 } |
|
849 |
|
850 BeginSelection(posX * iRowCount + posY); |
|
851 |
|
852 possibleKeyScrollingState = EKeyScrollingDown; |
|
853 handled = ETrue; |
|
854 |
|
855 } |
|
856 |
|
857 } break; |
|
858 case EKeyLeftArrow: |
|
859 { |
|
860 TInt posY = (TInt)iSpring->EndY(); |
|
861 TInt posX = (TInt)iSpring->EndX(); |
|
862 |
|
863 if (AknLayoutUtils::LayoutMirrored()) |
|
864 { |
|
865 posX++; |
|
866 } |
|
867 else |
|
868 { |
|
869 posX--; |
|
870 } |
|
871 |
|
872 BeginSelection(posX * iRowCount + posY); |
|
873 |
|
874 possibleKeyScrollingState = EKeyScrollingLeft; |
|
875 handled = ETrue; |
|
876 } break; |
|
877 case EKeyRightArrow: |
|
878 { |
|
879 TInt posY = (TInt)iSpring->EndY(); |
|
880 TInt posX = (TInt)iSpring->EndX(); |
|
881 |
|
882 if (!AknLayoutUtils::LayoutMirrored()) |
|
883 { |
|
884 posX++; |
|
885 } |
|
886 else |
|
887 { |
|
888 posX--; |
|
889 } |
|
890 |
|
891 BeginSelection(posX * iRowCount + posY); |
|
892 |
|
893 possibleKeyScrollingState = EKeyScrollingRight; |
|
894 handled = ETrue; |
|
895 } break; |
|
896 case EKeyEnter: |
|
897 { |
|
898 if( iSelectedIndex != KErrNotFound && iSelectionObserver ) |
|
899 { |
|
900 TRAP_IGNORE( StartOpeningAnimationL(ETrue ); ) |
|
901 return EKeyWasConsumed; |
|
902 } |
|
903 return EKeyWasNotConsumed; |
|
904 } |
|
905 default: |
|
906 break; |
|
907 } |
|
908 |
|
909 // start key scrolling timer if enough key repeats hit |
|
910 // and we are not yet scrolling |
|
911 if( possibleKeyScrollingState != ENoKeyScrolling && iKeyRepeats > KPhysLaunchKeyCount ) |
|
912 { |
|
913 if( !iKeyScrollingTimer->IsActive() ) |
|
914 { |
|
915 iKeyScrollingState = possibleKeyScrollingState; |
|
916 iKeyScrollingTimer->Start( |
|
917 TTimeIntervalMicroSeconds32( 0 ), |
|
918 TTimeIntervalMicroSeconds32( KMediaWallKeyScrollingUpdateInterval ), |
|
919 TCallBack( KeyScrollingTimerCallback, this ) ); |
|
920 } |
|
921 } |
|
922 |
|
923 return handled ? EKeyWasConsumed : EKeyWasNotConsumed; |
|
924 } |
|
925 |
|
926 // ----------------------------------------------------------------------------- |
|
927 // CHgVgMediaWall::HandleKeyUp() |
|
928 // ----------------------------------------------------------------------------- |
|
929 // |
|
930 void CHgVgMediaWall::HandleKeyUp() |
|
931 { |
|
932 StopKeyScrolling(); |
|
933 } |
|
934 |
|
935 // ----------------------------------------------------------------------------- |
|
936 // CHgVgMediaWall::StopKeyScrolling() |
|
937 // ----------------------------------------------------------------------------- |
|
938 // |
|
939 void CHgVgMediaWall::StopKeyScrolling() |
|
940 { |
|
941 if (iKeyScrollingTimer->IsActive()) |
|
942 iKeyScrollingTimer->Cancel(); |
|
943 |
|
944 iKeyScrollingState = ENoKeyScrolling; |
|
945 } |
|
946 |
|
947 // ----------------------------------------------------------------------------- |
|
948 // CHgVgMediaWall::DoKeyScrolling() |
|
949 // ----------------------------------------------------------------------------- |
|
950 // |
|
951 void CHgVgMediaWall::DoKeyScrolling() |
|
952 { |
|
953 TKeyEvent keyEvent; |
|
954 if (iKeyScrollingState == EKeyScrollingRight) |
|
955 { |
|
956 keyEvent.iCode = EKeyRightArrow; |
|
957 HandleKeyEvent(keyEvent); |
|
958 } |
|
959 else if (iKeyScrollingState == EKeyScrollingLeft) |
|
960 { |
|
961 keyEvent.iCode = EKeyLeftArrow; |
|
962 HandleKeyEvent(keyEvent); |
|
963 } |
|
964 else if (iKeyScrollingState == EKeyScrollingUp) |
|
965 { |
|
966 keyEvent.iCode = EKeyUpArrow; |
|
967 HandleKeyEvent(keyEvent); |
|
968 } |
|
969 else if (iKeyScrollingState == EKeyScrollingDown) |
|
970 { |
|
971 keyEvent.iCode = EKeyDownArrow; |
|
972 HandleKeyEvent(keyEvent); |
|
973 } |
|
974 } |
|
975 |
|
976 // --------------------------------------------------------------------------- |
|
977 // CHgVgMediaWall::KeyScrollingTimerCallback() |
|
978 // --------------------------------------------------------------------------- |
|
979 // |
|
980 TInt CHgVgMediaWall::KeyScrollingTimerCallback( TAny* aPtr ) |
|
981 { |
|
982 CHgVgMediaWall* self = |
|
983 static_cast<CHgVgMediaWall*>( aPtr ); |
|
984 |
|
985 TInt err = KErrNotFound; |
|
986 |
|
987 if ( self ) |
|
988 { |
|
989 self->DoKeyScrolling(); |
|
990 err = KErrNone; |
|
991 } |
|
992 |
|
993 return err; |
|
994 } |
|
995 |
|
996 // ----------------------------------------------------------------------------- |
|
997 // CHgVgMediaWall::Release() |
|
998 // From MHgBufferOwner |
|
999 // ----------------------------------------------------------------------------- |
|
1000 // |
|
1001 void CHgVgMediaWall::Release(TInt aReleaseStart, TInt aReleaseEnd) |
|
1002 { |
|
1003 for(; aReleaseStart <= aReleaseEnd; ++aReleaseStart) |
|
1004 { |
|
1005 if( aReleaseStart >= 0 && aReleaseStart < iItems.Count()) |
|
1006 { |
|
1007 iItems[aReleaseStart]->SetIcon(NULL, iItems[aReleaseStart]->Flags()); |
|
1008 } |
|
1009 } |
|
1010 } |
|
1011 |
|
1012 // ----------------------------------------------------------------------------- |
|
1013 // CHgVgMediaWall::Reset() |
|
1014 // ----------------------------------------------------------------------------- |
|
1015 // |
|
1016 EXPORT_C void CHgVgMediaWall::Reset() |
|
1017 { |
|
1018 iItems.ResetAndDestroy(); |
|
1019 iItemCount = 0; |
|
1020 HandleItemCountChanged(); |
|
1021 } |
|
1022 |
|
1023 // ----------------------------------------------------------------------------- |
|
1024 // CHgVgMediaWall::SetEmptyTextL() |
|
1025 // ----------------------------------------------------------------------------- |
|
1026 // |
|
1027 EXPORT_C void CHgVgMediaWall::SetEmptyTextL( const TDesC& aEmptyText ) |
|
1028 { |
|
1029 delete iEmptyText; |
|
1030 iEmptyText = 0; |
|
1031 iEmptyText = aEmptyText.AllocL(); |
|
1032 } |
|
1033 |
|
1034 // ----------------------------------------------------------------------------- |
|
1035 // CHgVgMediaWall::ItemCount() |
|
1036 // ----------------------------------------------------------------------------- |
|
1037 // |
|
1038 EXPORT_C TInt CHgVgMediaWall::ItemCount() const |
|
1039 { |
|
1040 return iItems.Count(); |
|
1041 } |
|
1042 |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 // CHgVgMediaWall::SetDefaultIconL() |
|
1045 // ----------------------------------------------------------------------------- |
|
1046 // |
|
1047 EXPORT_C void CHgVgMediaWall::SetDefaultIconL( CGulIcon* aDefaultIcon ) |
|
1048 { |
|
1049 |
|
1050 if (iDefaultIcon) |
|
1051 { |
|
1052 delete iDefaultIcon; |
|
1053 } |
|
1054 |
|
1055 iDefaultIcon = aDefaultIcon; |
|
1056 |
|
1057 iUsingDefaultIcon = EFalse; |
|
1058 |
|
1059 InitDefaultIconL(); |
|
1060 |
|
1061 } |
|
1062 |
|
1063 // ----------------------------------------------------------------------------- |
|
1064 // CHgVgMediaWall::DisableScrollBuffer() |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // |
|
1067 EXPORT_C void CHgVgMediaWall::DisableScrollBuffer() |
|
1068 { |
|
1069 delete iManager; |
|
1070 iManager = NULL; |
|
1071 } |
|
1072 |
|
1073 |
|
1074 // ----------------------------------------------------------------------------- |
|
1075 // CHgVgMediaWall::SetObserver() |
|
1076 // ----------------------------------------------------------------------------- |
|
1077 // |
|
1078 EXPORT_C void CHgVgMediaWall::SetObserver(MHgVgMediaWallObserver* aObserver) |
|
1079 { |
|
1080 iMediaWallObserver = aObserver; |
|
1081 } |
|
1082 |
|
1083 |
|
1084 // ----------------------------------------------------------------------------- |
|
1085 // CHgVgMediaWall::SetSelectionAnimationType() |
|
1086 // ----------------------------------------------------------------------------- |
|
1087 // |
|
1088 EXPORT_C void CHgVgMediaWall::SetOpeningAnimationType(THgVgOpeningAnimationType aType) |
|
1089 { |
|
1090 iOpeningAnimationType = aType; |
|
1091 } |
|
1092 |
|
1093 // --------------------------------------------------------------------------- |
|
1094 // CHgVgMediaWall::StartOpeningAnimation() |
|
1095 // --------------------------------------------------------------------------- |
|
1096 // |
|
1097 EXPORT_C void CHgVgMediaWall::StartOpeningAnimationL(TBool aOpening) |
|
1098 { |
|
1099 // stop possible animation |
|
1100 HandleTransitionAnimationStop(); |
|
1101 |
|
1102 if (iOpeningAnimationType == EHgVgOpeningAnimationNone) |
|
1103 { |
|
1104 if (iSelectionObserver) |
|
1105 { |
|
1106 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
1107 { |
|
1108 iSelectionObserver->HandleOpenL(iPickedGridItem, this); |
|
1109 } |
|
1110 else |
|
1111 { |
|
1112 iSelectionObserver->HandleOpenL((TInt)iSpring->EndX(), this); |
|
1113 } |
|
1114 } |
|
1115 } |
|
1116 else |
|
1117 { |
|
1118 iAnimationState = aOpening ? EHgVgMediaWallAnimationStateOpening : EHgVgMediaWallAnimationStateClosing; |
|
1119 |
|
1120 StartAnimationTimer(); |
|
1121 } |
|
1122 } |
|
1123 |
|
1124 // --------------------------------------------------------------------------- |
|
1125 // CHgVgMediaWall::DrawToWindow() |
|
1126 // --------------------------------------------------------------------------- |
|
1127 // |
|
1128 CFbsBitmap* CHgVgMediaWall::DrawToBitmap() |
|
1129 { |
|
1130 |
|
1131 if (!DrawAll()) |
|
1132 return NULL; |
|
1133 |
|
1134 return iEGL->GetSurfaceToBitmap(iRect); |
|
1135 |
|
1136 } |
|
1137 |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // CHgVgMediaWall::InitDefaultIconL() |
|
1140 // ----------------------------------------------------------------------------- |
|
1141 // |
|
1142 void CHgVgMediaWall::InitDefaultIconL() |
|
1143 { |
|
1144 // if no icon is set, load ganes default icon |
|
1145 if (!iDefaultIcon && iUsingDefaultIcon) |
|
1146 { |
|
1147 |
|
1148 iDefaultIcon = CreateIconL(EMbmGanesQgn_prop_checkbox_on, |
|
1149 EMbmGanesQgn_prop_checkbox_on_mask, |
|
1150 iRenderer->ImageSize()); |
|
1151 |
|
1152 } |
|
1153 |
|
1154 if (iDefaultIcon && iRenderer) |
|
1155 { |
|
1156 iRenderer->SetDefaultIconL(*iDefaultIcon); |
|
1157 } |
|
1158 |
|
1159 } |
|
1160 |
|
1161 // --------------------------------------------------------------------------- |
|
1162 // CHgVgMediaWall::FocusChanged() |
|
1163 // From CCoeControl |
|
1164 // --------------------------------------------------------------------------- |
|
1165 // |
|
1166 void CHgVgMediaWall::FocusChanged(TDrawNow /*aDrawNow*/) |
|
1167 { |
|
1168 } |
|
1169 |
|
1170 // --------------------------------------------------------------------------- |
|
1171 // CHgVgMediaWall::HandleResourceChange() |
|
1172 // --------------------------------------------------------------------------- |
|
1173 // |
|
1174 void CHgVgMediaWall::HandleResourceChange( TInt aType ) |
|
1175 { |
|
1176 if ( aType == KAknsMessageSkinChange ) |
|
1177 { |
|
1178 TRAP_IGNORE ( |
|
1179 InitButtonsL(); |
|
1180 InitScrollBarL(ETrue); |
|
1181 if (iRenderer) |
|
1182 iRenderer->HandleSkinChange(); |
|
1183 // if the default icon is not set by client, |
|
1184 // we need to reload our new default icon from skin. |
|
1185 if (iUsingDefaultIcon) |
|
1186 { |
|
1187 delete iDefaultIcon; |
|
1188 iDefaultIcon = NULL; |
|
1189 InitDefaultIconL(); |
|
1190 } |
|
1191 if (iSkinRenderer) |
|
1192 iSkinRenderer->UpdateSkinL(this, this); |
|
1193 ) |
|
1194 } |
|
1195 } |
|
1196 |
|
1197 |
|
1198 // --------------------------------------------------------------------------- |
|
1199 // CHgVgMediaWall::InitItemsL() |
|
1200 // --------------------------------------------------------------------------- |
|
1201 // |
|
1202 void CHgVgMediaWall::InitItemsL() |
|
1203 { |
|
1204 for(TInt i = 0; i < iItemCount; ++i) |
|
1205 { |
|
1206 iItems.Append( CHgVgItem::NewL() ); |
|
1207 } |
|
1208 } |
|
1209 |
|
1210 // --------------------------------------------------------------------------- |
|
1211 // CHgVgMediaWall::HandleGainingForeground() |
|
1212 // --------------------------------------------------------------------------- |
|
1213 // |
|
1214 void CHgVgMediaWall::HandleGainingForeground() |
|
1215 { |
|
1216 |
|
1217 // draw previous screenshot |
|
1218 DrawNow(); |
|
1219 |
|
1220 // delete it |
|
1221 delete iSurfaceBitmap; |
|
1222 iSurfaceBitmap = NULL; |
|
1223 |
|
1224 iIsForeground = ETrue; |
|
1225 |
|
1226 // init egl and openvg again |
|
1227 TRAP_IGNORE( InitRenderingL(EFalse); ) |
|
1228 |
|
1229 // reload images to ive |
|
1230 ReloadItemsImages(); |
|
1231 |
|
1232 // draw using openvg |
|
1233 DrawNow(); |
|
1234 |
|
1235 } |
|
1236 |
|
1237 // --------------------------------------------------------------------------- |
|
1238 // CHgVgMediaWall::HandleLosingForeground() |
|
1239 // --------------------------------------------------------------------------- |
|
1240 // |
|
1241 void CHgVgMediaWall::HandleLosingForeground() |
|
1242 { |
|
1243 |
|
1244 // make sure we are not animating |
|
1245 HandleTransitionAnimationStop(); |
|
1246 |
|
1247 if (iAnimationTimer->IsActive()) |
|
1248 { |
|
1249 if (iAnimationState == EHgVgMediaWallAnimationStateClosing) |
|
1250 iAnimationState = EHgVgMediaWallAnimationStateIdle; |
|
1251 else if (iAnimationState == EHgVgMediaWallAnimationStateOpening) |
|
1252 iAnimationState = EHgVgMediaWallAnimationStateItemOpened; |
|
1253 else |
|
1254 iAnimationState = EHgVgMediaWallAnimationStateIdle; |
|
1255 |
|
1256 iAnimationTimer->Cancel(); |
|
1257 } |
|
1258 |
|
1259 iIsForeground = EFalse; |
|
1260 |
|
1261 // take a screenshot |
|
1262 delete iSurfaceBitmap; |
|
1263 iSurfaceBitmap = NULL; |
|
1264 iSurfaceBitmap = DrawToBitmap(); |
|
1265 |
|
1266 // draw screenshot using window gc, this is needed |
|
1267 // for nga effects to work |
|
1268 DrawNow(); |
|
1269 |
|
1270 // free textures |
|
1271 FreeItemsImages(); |
|
1272 // free other resources |
|
1273 DestroyRendering(); |
|
1274 |
|
1275 iCoeEnv->WsSession().Flush(); |
|
1276 |
|
1277 } |
|
1278 |
|
1279 // --------------------------------------------------------------------------- |
|
1280 // CHgVgMediaWall::DrawOpenVG() |
|
1281 // --------------------------------------------------------------------------- |
|
1282 // |
|
1283 void CHgVgMediaWall::DrawOpenVG() const |
|
1284 { |
|
1285 |
|
1286 if( iFlags & EHgVgMediaWallDrawToWindowGC || !iIsForeground ) |
|
1287 { |
|
1288 // Window GC drawing mode is on or we are on backround. |
|
1289 return; |
|
1290 } |
|
1291 |
|
1292 CHgVgMediaWall* self = const_cast<CHgVgMediaWall*>(this); |
|
1293 |
|
1294 if (!self->DrawAll()) |
|
1295 return; |
|
1296 |
|
1297 iEGL->SwapBuffers(); |
|
1298 |
|
1299 } |
|
1300 |
|
1301 // --------------------------------------------------------------------------- |
|
1302 // CHgVgMediaWall::DoAnimation() |
|
1303 // --------------------------------------------------------------------------- |
|
1304 // |
|
1305 void CHgVgMediaWall::DoAnimation() |
|
1306 { |
|
1307 switch (iAnimationState) |
|
1308 { |
|
1309 case EHgVgMediaWallAnimationStateTransition: |
|
1310 case EHgVgMediaWallAnimationStateFastTransition: |
|
1311 { |
|
1312 DoTransitionAnimation(); |
|
1313 } break; |
|
1314 case EHgVgMediaWallAnimationStateOpening: |
|
1315 case EHgVgMediaWallAnimationStateClosing: |
|
1316 case EHgVgMediaWallAnimationStateIdle: |
|
1317 case EHgVgMediaWallAnimationStateItemOpened: |
|
1318 { |
|
1319 DoSelectionAnimation(); |
|
1320 } break; |
|
1321 } |
|
1322 |
|
1323 DrawOpenVG(); |
|
1324 } |
|
1325 |
|
1326 // --------------------------------------------------------------------------- |
|
1327 // CHgVgMediaWall::DoSelectionAnimation() |
|
1328 // --------------------------------------------------------------------------- |
|
1329 // |
|
1330 void CHgVgMediaWall::DoSelectionAnimation() |
|
1331 { |
|
1332 TTime now; |
|
1333 now.HomeTime(); |
|
1334 TInt diff = now.MicroSecondsFrom(iAnimationStartTime).Int64(); |
|
1335 |
|
1336 // limit to max duration |
|
1337 if (diff > KSelectionAnimationDuration) |
|
1338 diff = KSelectionAnimationDuration; |
|
1339 |
|
1340 // calculate animation alpha |
|
1341 TReal alpha = (TReal)diff / (TReal)KSelectionAnimationDuration; |
|
1342 |
|
1343 switch (iAnimationState) |
|
1344 { |
|
1345 case EHgVgMediaWallAnimationStateClosing: |
|
1346 { |
|
1347 iAnimationAlpha = 1.0f - alpha; |
|
1348 if (diff == KSelectionAnimationDuration) |
|
1349 iAnimationState = EHgVgMediaWallAnimationStateIdle; |
|
1350 } break; |
|
1351 case EHgVgMediaWallAnimationStateOpening: |
|
1352 { |
|
1353 iAnimationAlpha = alpha; |
|
1354 if (diff == KSelectionAnimationDuration) |
|
1355 iAnimationState = EHgVgMediaWallAnimationStateItemOpened; |
|
1356 } break; |
|
1357 case EHgVgMediaWallAnimationStateItemOpened: |
|
1358 { |
|
1359 iAnimationTimer->Cancel(); |
|
1360 if (iSelectionObserver) |
|
1361 { |
|
1362 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
1363 { |
|
1364 TRAP_IGNORE( iSelectionObserver->HandleOpenL(iPickedGridItem, this); ) |
|
1365 } |
|
1366 else |
|
1367 { |
|
1368 TRAP_IGNORE( iSelectionObserver->HandleOpenL(iSelectedIndex, this); ) |
|
1369 } |
|
1370 } |
|
1371 } break; |
|
1372 case EHgVgMediaWallAnimationStateIdle: |
|
1373 { |
|
1374 iAnimationTimer->Cancel(); |
|
1375 } break; |
|
1376 } |
|
1377 } |
|
1378 |
|
1379 |
|
1380 // --------------------------------------------------------------------------- |
|
1381 // CHgVgMediaWall::DoTransitionAnimation() |
|
1382 // --------------------------------------------------------------------------- |
|
1383 // |
|
1384 void CHgVgMediaWall::DoTransitionAnimation() |
|
1385 { |
|
1386 TTime now; |
|
1387 now.HomeTime(); |
|
1388 TReal deltaTime = (TReal)now.MicroSecondsFrom(iPrevTime).Int64() / (TReal)KOneSecondInMicroSeconds; |
|
1389 iPrevTime = now; |
|
1390 |
|
1391 if (iSpring->IntegratePhysics(deltaTime, !iPointerDown)) |
|
1392 { |
|
1393 // snap |
|
1394 HandleTransitionAnimationStop(); |
|
1395 } |
|
1396 else |
|
1397 { |
|
1398 // update view position dependant stuff |
|
1399 HandleViewPositionChanged(ETrue); |
|
1400 } |
|
1401 |
|
1402 } |
|
1403 |
|
1404 void CHgVgMediaWall::HandleTransitionAnimationStop() |
|
1405 { |
|
1406 if (iAnimationTimer->IsActive() && (iAnimationState == EHgVgMediaWallAnimationStateTransition || |
|
1407 iAnimationState == EHgVgMediaWallAnimationStateFastTransition)) |
|
1408 { |
|
1409 // stop to this location |
|
1410 iSpring->Reset(); |
|
1411 iAnimationState = EHgVgMediaWallAnimationStateIdle; |
|
1412 |
|
1413 // cancel animation |
|
1414 iAnimationTimer->Cancel(); |
|
1415 |
|
1416 // handle view position change |
|
1417 HandleViewPositionChanged(); |
|
1418 } |
|
1419 } |
|
1420 |
|
1421 |
|
1422 // --------------------------------------------------------------------------- |
|
1423 // CHgVgMediaWall::AnimationTimerCallback() |
|
1424 // Timer callback for selection animation. |
|
1425 // --------------------------------------------------------------------------- |
|
1426 // |
|
1427 TInt CHgVgMediaWall::AnimationTimerCallback( TAny* aPtr ) |
|
1428 { |
|
1429 CHgVgMediaWall* scroller = static_cast<CHgVgMediaWall*>(aPtr); |
|
1430 |
|
1431 TInt err = KErrNotFound; |
|
1432 |
|
1433 if( scroller ) |
|
1434 { |
|
1435 scroller->DoAnimation(); |
|
1436 err = KErrNone; |
|
1437 } |
|
1438 |
|
1439 return err; |
|
1440 } |
|
1441 |
|
1442 // --------------------------------------------------------------------------- |
|
1443 // CHgVgMediaWall::ScrollBarViewPositionChanged() |
|
1444 // Called by scroll bar when its position has changed. |
|
1445 // --------------------------------------------------------------------------- |
|
1446 // |
|
1447 void CHgVgMediaWall::ScrollBarPositionChanged( const TPoint& aNewPosition ) |
|
1448 { |
|
1449 iScrollBarHit = ETrue; |
|
1450 if (iSpring->GetX() != aNewPosition.iX) |
|
1451 { |
|
1452 StartAnimationToPosition(aNewPosition.iX, EFalse); |
|
1453 } |
|
1454 } |
|
1455 |
|
1456 |
|
1457 // --------------------------------------------------------------------------- |
|
1458 // CHgVgMediaWall::HandleNaviStripChar() |
|
1459 // --------------------------------------------------------------------------- |
|
1460 // |
|
1461 void CHgVgMediaWall::HandleNaviStripChar( const TChar& /*aChar*/ ) |
|
1462 { |
|
1463 // do nothing |
|
1464 } |
|
1465 |
|
1466 // --------------------------------------------------------------------------- |
|
1467 // CHgVgMediaWall::UpdateTitles() |
|
1468 // Updates album and artist titles. |
|
1469 // --------------------------------------------------------------------------- |
|
1470 // |
|
1471 void CHgVgMediaWall::UpdateLabelsAndPopup() |
|
1472 { |
|
1473 if (iItems.Count() == 0) |
|
1474 return; |
|
1475 |
|
1476 CHgVgItem* item = NULL; |
|
1477 |
|
1478 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
1479 { |
|
1480 TInt pos = (iSpring->GetX() * (TReal)KGridRowCount); |
|
1481 if (pos >= 0 && pos < iItems.Count() && iItems.Count() == iItemCount) |
|
1482 { |
|
1483 item = iItems[pos]; |
|
1484 } |
|
1485 } |
|
1486 else |
|
1487 { |
|
1488 if (iSelectedIndex >= 0 && iSelectedIndex < iItems.Count()) |
|
1489 item = iItems[iSelectedIndex]; |
|
1490 } |
|
1491 |
|
1492 // set album and artist titles from item |
|
1493 if( item ) |
|
1494 { |
|
1495 if (iArtistLabel && iAlbumLabel) |
|
1496 { |
|
1497 TRAP_IGNORE( |
|
1498 iArtistLabel->SetTextL(item->Title()); |
|
1499 iAlbumLabel->SetTextL(item->Text()); ) |
|
1500 } |
|
1501 |
|
1502 if (iLetterPopup) |
|
1503 { |
|
1504 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
1505 { |
|
1506 if (item != iTempItem) |
|
1507 { |
|
1508 iTempItem = item; |
|
1509 |
|
1510 TRAP_IGNORE( |
|
1511 item->Time().FormatL( iPopupText1, KGanesMonthString ); |
|
1512 item->Time().FormatL( iPopupText2, KGanesYearString ); |
|
1513 ) |
|
1514 |
|
1515 // To display year correctly in arabic. |
|
1516 AknTextUtils::LanguageSpecificNumberConversion( iPopupText2 ); |
|
1517 |
|
1518 iLetterPopup->SetTexts(iPopupText1, iPopupText2); |
|
1519 } |
|
1520 } |
|
1521 else |
|
1522 { |
|
1523 TRAP_IGNORE( iLetterPopup->SetTextL(item->Title().Left(1)); ) |
|
1524 } |
|
1525 } |
|
1526 } |
|
1527 } |
|
1528 |
|
1529 // --------------------------------------------------------------------------- |
|
1530 // CHgVgMediaWall::DrawTitles() |
|
1531 // Draws album and artist titles. |
|
1532 // --------------------------------------------------------------------------- |
|
1533 // |
|
1534 void CHgVgMediaWall::DrawTitles(TReal aAlpha) |
|
1535 { |
|
1536 TReal alpha = aAlpha; |
|
1537 if( iAnimationState == EHgVgMediaWallAnimationStateOpening || |
|
1538 iAnimationState == EHgVgMediaWallAnimationStateClosing) |
|
1539 { |
|
1540 alpha = 1.0f - iAnimationAlpha; |
|
1541 } |
|
1542 else if (iAnimationState == EHgVgMediaWallAnimationStateItemOpened) |
|
1543 { |
|
1544 alpha = 0.0f; |
|
1545 } |
|
1546 |
|
1547 if( iAlbumLabel && iArtistLabel ) |
|
1548 { |
|
1549 iArtistLabel->Draw(iRect, alpha); |
|
1550 iAlbumLabel->Draw(iRect, alpha); |
|
1551 } |
|
1552 } |
|
1553 |
|
1554 // --------------------------------------------------------------------------- |
|
1555 // CHgVgMediaWall::InitScrollBarL() |
|
1556 // Inits scroll bar |
|
1557 // --------------------------------------------------------------------------- |
|
1558 // |
|
1559 void CHgVgMediaWall::InitScrollBarL(TBool /*aResize*/) |
|
1560 { |
|
1561 delete iScrollBar; |
|
1562 iScrollBar = NULL; |
|
1563 |
|
1564 if (iMediaWallStyle != CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen && |
|
1565 iMediaWallStyle != CHgVgMediaWall::EHgVgMediaWallStyleGrid) |
|
1566 return; |
|
1567 |
|
1568 iScrollBar = CHgVgScrollBar::NewL(*this, iRect, |
|
1569 TSize(MaxViewPosition(), 1), TSize(1, 1), |
|
1570 ETrue, CHgScroller::EHgScrollerScrollBar); |
|
1571 |
|
1572 iScrollBar->SetViewPosition( TPoint(iSelectedIndex, 0) ); |
|
1573 } |
|
1574 |
|
1575 // --------------------------------------------------------------------------- |
|
1576 // CHgVgMediaWall::InitRenderingL() |
|
1577 // Inits all rendering. |
|
1578 // --------------------------------------------------------------------------- |
|
1579 // |
|
1580 void CHgVgMediaWall::InitRenderingL(TBool aRecreateSurface) |
|
1581 { |
|
1582 if (!iEGL) |
|
1583 { |
|
1584 iEGL = CHgVgEGL::NewL(Window()); |
|
1585 CHgVgImageCreator::InstanceL()->Initialize(iEGL); |
|
1586 } |
|
1587 else |
|
1588 { |
|
1589 if (aRecreateSurface) |
|
1590 iEGL->InitWindowSurfaceL(Window()); |
|
1591 } |
|
1592 |
|
1593 delete iRenderer; iRenderer = NULL; |
|
1594 delete iArtistLabel; iArtistLabel = NULL; |
|
1595 delete iAlbumLabel; iAlbumLabel = NULL; |
|
1596 delete iLetterPopup; iLetterPopup = NULL; |
|
1597 delete iSkinRenderer; iSkinRenderer = NULL; |
|
1598 iSkinRenderer = CHgVgSkinRenderer::NewL(iRect); |
|
1599 iSkinRenderer->UpdateSkinL(this, this); |
|
1600 |
|
1601 delete iEmptyLabel; iEmptyLabel = NULL; |
|
1602 iEmptyLabel = CHgVgLabel::NewL( |
|
1603 /*TRect(TPoint(iRect.Center().iX - 100, iRect.Center().iY - 50), |
|
1604 TSize(200, 100))*/iRect, &ScreenFont( TCoeFont( KMediaWallGridPopupFontSize, TCoeFont::EPlain )), |
|
1605 *iEmptyText); |
|
1606 |
|
1607 switch (iMediaWallStyle) |
|
1608 { |
|
1609 case EHgVgMediaWallStyleCoverflowFullScreen: |
|
1610 { |
|
1611 InitMediaWallFullScreenLandscapeL(); |
|
1612 } break; |
|
1613 case EHgVgMediaWallStyleCoverflowTBonePortrait: |
|
1614 { |
|
1615 InitMediaWallTBonePortraitL(); |
|
1616 } break; |
|
1617 case EHgVgMediaWallStyleGrid: |
|
1618 { |
|
1619 InitMediaWallGridLandscapeL(); |
|
1620 } break; |
|
1621 default: |
|
1622 { |
|
1623 User::Leave(KErrNotSupported); |
|
1624 } break; |
|
1625 } |
|
1626 |
|
1627 // load default icon |
|
1628 InitDefaultIconL(); |
|
1629 |
|
1630 // invalidate selected index so |
|
1631 // that HandleViewPositionChanged does |
|
1632 // all updates needed. |
|
1633 iSelectedIndex = KErrNotFound; |
|
1634 HandleViewPositionChanged(ETrue); |
|
1635 } |
|
1636 |
|
1637 |
|
1638 // --------------------------------------------------------------------------- |
|
1639 // CHgVgMediaWall::InitButtonsL() |
|
1640 // --------------------------------------------------------------------------- |
|
1641 // |
|
1642 void CHgVgMediaWall::InitButtonsL() |
|
1643 { |
|
1644 |
|
1645 CGulIcon* icon = CreateIconL(EMbmGanesQgn_indi_button_exit_fs, |
|
1646 EMbmGanesQgn_indi_button_exit_fs_mask, TSize(41,41)); |
|
1647 |
|
1648 CleanupStack::PushL(icon); |
|
1649 |
|
1650 delete iHideSKButton; iHideSKButton = NULL; |
|
1651 |
|
1652 TAknLayoutRect rect; |
|
1653 rect.LayoutRect(iRect, AknLayoutScalable_Apps::main_cf0_pane_g1(0)); |
|
1654 |
|
1655 iHideSKButton = CHgVgButton::NewL(rect.Rect().Size(), rect.Rect().iTl, *icon); |
|
1656 |
|
1657 CleanupStack::PopAndDestroy(icon); |
|
1658 |
|
1659 } |
|
1660 |
|
1661 |
|
1662 // --------------------------------------------------------------------------- |
|
1663 // CHgVgMediaWall::CreateIconL() |
|
1664 // --------------------------------------------------------------------------- |
|
1665 // |
|
1666 CGulIcon* CHgVgMediaWall::CreateIconL(TInt aId1, TInt aId2, const TSize& aSize) |
|
1667 { |
|
1668 CFbsBitmap* bitmap = NULL; |
|
1669 CFbsBitmap* mask = NULL; |
|
1670 |
|
1671 AknIconUtils::CreateIconL( |
|
1672 bitmap, |
|
1673 mask, |
|
1674 KGanesMif, |
|
1675 aId1, |
|
1676 aId2 ); |
|
1677 |
|
1678 CGulIcon* icon = CGulIcon::NewL(bitmap, mask); |
|
1679 |
|
1680 AknIconUtils::SetSize(icon->Bitmap(), |
|
1681 aSize); |
|
1682 AknIconUtils::SetSize(icon->Mask(), |
|
1683 aSize); |
|
1684 |
|
1685 return icon; |
|
1686 } |
|
1687 |
|
1688 // --------------------------------------------------------------------------- |
|
1689 // CHgVgMediaWall::FreeItemImages() |
|
1690 // Frees all loaded images. |
|
1691 // --------------------------------------------------------------------------- |
|
1692 // |
|
1693 void CHgVgMediaWall::FreeItemsImages() |
|
1694 { |
|
1695 for (TInt i = 0; i < iItems.Count(); i++) |
|
1696 { |
|
1697 iItems[i]->FreeOpenVgImage(); |
|
1698 } |
|
1699 } |
|
1700 |
|
1701 // --------------------------------------------------------------------------- |
|
1702 // CHgVgMediaWall::ReloadItemsImages() |
|
1703 // --------------------------------------------------------------------------- |
|
1704 // |
|
1705 void CHgVgMediaWall::ReloadItemsImages() |
|
1706 { |
|
1707 for (TInt i = 0; i < iItems.Count(); i++) |
|
1708 { |
|
1709 iItems[i]->ReloadOpenVgImage(); |
|
1710 } |
|
1711 } |
|
1712 |
|
1713 |
|
1714 // --------------------------------------------------------------------------- |
|
1715 // CHgVgMediaWall::HandleTouchGestureL() |
|
1716 // --------------------------------------------------------------------------- |
|
1717 // |
|
1718 void CHgVgMediaWall::HandleTouchGestureL( MAknTouchGestureFwEvent& aEvent ) |
|
1719 { |
|
1720 |
|
1721 if (iScrollBarHit || iButtonsHit || iAnimationState == EHgVgMediaWallAnimationStateOpening || |
|
1722 iAnimationState == EHgVgMediaWallAnimationStateClosing) |
|
1723 return; |
|
1724 |
|
1725 if (iAnimationState == EHgVgMediaWallAnimationStateItemOpened) |
|
1726 { |
|
1727 StartOpeningAnimationL(EFalse); |
|
1728 } |
|
1729 else |
|
1730 { |
|
1731 |
|
1732 switch (aEvent.Group()) |
|
1733 { |
|
1734 case EAknTouchGestureFwGroupTap: |
|
1735 { |
|
1736 MAknTouchGestureFwTapEvent* tapEvent = AknTouchGestureFwEventTap(aEvent); |
|
1737 if (tapEvent && aEvent.Type() == EAknTouchGestureFwTap) |
|
1738 { |
|
1739 HandleTapEventL(tapEvent->Position()); |
|
1740 } |
|
1741 } break; |
|
1742 case EAknTouchGestureFwGroupFlick: |
|
1743 { |
|
1744 MAknTouchGestureFwFlickEvent* flickEvent = AknTouchGestureFwEventFlick(aEvent); |
|
1745 if ((flickEvent && aEvent.Type() == EAknTouchGestureFwFlickLeft) || |
|
1746 (flickEvent && aEvent.Type() == EAknTouchGestureFwFlickRight)) |
|
1747 { |
|
1748 EndSelection(); |
|
1749 HandleFlick(flickEvent->Speed()); |
|
1750 } |
|
1751 } break; |
|
1752 case EAknTouchGestureFwGroupDrag: |
|
1753 { |
|
1754 MAknTouchGestureFwDragEvent* dragEvent = AknTouchGestureFwEventDrag(aEvent); |
|
1755 if (dragEvent && aEvent.Type() == EAknTouchGestureFwDrag) |
|
1756 { |
|
1757 EndSelection(); |
|
1758 HandleDragging(*dragEvent); |
|
1759 } |
|
1760 } break; |
|
1761 } |
|
1762 |
|
1763 } |
|
1764 |
|
1765 } |
|
1766 |
|
1767 // --------------------------------------------------------------------------- |
|
1768 // CHgVgMediaWall::HandleTapEvent() |
|
1769 // --------------------------------------------------------------------------- |
|
1770 // |
|
1771 void CHgVgMediaWall::HandleTapEventL(const TPoint& aPosition) |
|
1772 { |
|
1773 if (iRenderer) |
|
1774 { |
|
1775 TInt index = iRenderer->GetItemIndex(aPosition); |
|
1776 if (index != KErrNotFound) |
|
1777 { |
|
1778 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
1779 { |
|
1780 iPickedGridItem = index; |
|
1781 DoStartOpeningAnimationL(); |
|
1782 } |
|
1783 else |
|
1784 { |
|
1785 if (index == iSelectedIndex && index == (TInt)iSpring->EndX()) |
|
1786 { |
|
1787 DoStartOpeningAnimationL(); |
|
1788 } |
|
1789 else |
|
1790 { |
|
1791 StartAnimationToPosition(index, ETrue); |
|
1792 } |
|
1793 } |
|
1794 } |
|
1795 } |
|
1796 } |
|
1797 |
|
1798 // --------------------------------------------------------------------------- |
|
1799 // CHgVgMediaWall::HandleFlick() |
|
1800 // --------------------------------------------------------------------------- |
|
1801 // |
|
1802 void CHgVgMediaWall::HandleFlick(const TPoint& aSpeed) |
|
1803 { |
|
1804 |
|
1805 // mirror for mirrored layouts |
|
1806 TInt speed = aSpeed.iX; |
|
1807 if (AknLayoutUtils::LayoutMirrored()) |
|
1808 speed = -speed; |
|
1809 |
|
1810 TReal fspeed = GetAsPercentageOfScreenWidth((TReal)speed); |
|
1811 |
|
1812 if (Abs(fspeed) < KMinFlickSpeed) // Discard small and slow flicks |
|
1813 return; |
|
1814 |
|
1815 TInt steps = -GetStepsFromSpeed(speed); |
|
1816 |
|
1817 iSpring->SetVelocity(iSpring->VelX() - fspeed, iSpring->VelY()); |
|
1818 |
|
1819 if (Abs(steps) > 0) |
|
1820 { |
|
1821 TReal x = iSpring->EndX() + steps; |
|
1822 x = Min(x, (TReal)(MaxViewPosition() - 1)); |
|
1823 x = Max(x, 0); |
|
1824 if (x != iSpring->EndX()) |
|
1825 { |
|
1826 StartAnimationToPosition(x, ETrue); |
|
1827 } |
|
1828 } |
|
1829 } |
|
1830 |
|
1831 // --------------------------------------------------------------------------- |
|
1832 // CHgVgMediaWall::GetStepsFromSpeed() |
|
1833 // --------------------------------------------------------------------------- |
|
1834 // |
|
1835 TInt CHgVgMediaWall::GetStepsFromSpeed(TInt aSpeed) const |
|
1836 { |
|
1837 TInt steps = aSpeed > 0 ? 1 : -1; |
|
1838 TReal speed = GetAsPercentageOfScreenWidth(aSpeed); |
|
1839 TReal absSpeed = Abs(speed); |
|
1840 if (absSpeed > 1.0f) |
|
1841 { |
|
1842 steps = (TInt)(speed / KSwipeSpeedFactor); |
|
1843 } |
|
1844 return steps; |
|
1845 } |
|
1846 |
|
1847 |
|
1848 // --------------------------------------------------------------------------- |
|
1849 // CHgVgMediaWall::HandleDragging() |
|
1850 // --------------------------------------------------------------------------- |
|
1851 // |
|
1852 void CHgVgMediaWall::HandleDragging(const AknTouchGestureFw::MAknTouchGestureFwDragEvent& aEvent) |
|
1853 { |
|
1854 |
|
1855 switch (aEvent.State()) |
|
1856 { |
|
1857 case AknTouchGestureFw::EAknTouchGestureFwStart: |
|
1858 { |
|
1859 HandleDragStart(aEvent); |
|
1860 } break; |
|
1861 case AknTouchGestureFw::EAknTouchGestureFwStop: |
|
1862 { |
|
1863 HandleDragStop(aEvent); |
|
1864 } break; |
|
1865 case AknTouchGestureFw::EAknTouchGestureFwOn: |
|
1866 { |
|
1867 HandleDragOn(aEvent); |
|
1868 } break; |
|
1869 } |
|
1870 } |
|
1871 |
|
1872 // --------------------------------------------------------------------------- |
|
1873 // CHgVgMediaWall::HandleDragging() |
|
1874 // --------------------------------------------------------------------------- |
|
1875 // |
|
1876 void CHgVgMediaWall::StartAnimationTimer() |
|
1877 { |
|
1878 |
|
1879 // animation may start event when |
|
1880 // timer was previously active. |
|
1881 iAnimationStartTime.HomeTime(); |
|
1882 |
|
1883 if (!iAnimationTimer->IsActive()) |
|
1884 { |
|
1885 iPrevTime.HomeTime(); |
|
1886 iAnimationTimer->Start( |
|
1887 TTimeIntervalMicroSeconds32( 0 ), |
|
1888 TTimeIntervalMicroSeconds32( KViewScrollingUpdateInterval ), |
|
1889 TCallBack( AnimationTimerCallback, this ) ); |
|
1890 } |
|
1891 } |
|
1892 |
|
1893 // --------------------------------------------------------------------------- |
|
1894 // CHgVgMediaWall::GetAsPercentageOfScreenWidth() |
|
1895 // --------------------------------------------------------------------------- |
|
1896 // |
|
1897 TReal CHgVgMediaWall::GetAsPercentageOfScreenWidth(TInt aPixels) const |
|
1898 { |
|
1899 return (TReal)aPixels / (TReal)iRect.Width(); |
|
1900 } |
|
1901 |
|
1902 // --------------------------------------------------------------------------- |
|
1903 // CHgVgMediaWall::GetAsPercentageOfScreenHeight() |
|
1904 // --------------------------------------------------------------------------- |
|
1905 // |
|
1906 TReal CHgVgMediaWall::GetAsPercentageOfScreenHeight(TInt aPixels) const |
|
1907 { |
|
1908 return (TReal)aPixels / (TReal)iRect.Height(); |
|
1909 } |
|
1910 |
|
1911 // --------------------------------------------------------------------------- |
|
1912 // CHgVgMediaWall::DrawScene() |
|
1913 // --------------------------------------------------------------------------- |
|
1914 // |
|
1915 void CHgVgMediaWall::DrawScene() |
|
1916 { |
|
1917 |
|
1918 TReal t = iSpring->VelX() / iSpringVelocityToAnimationFactor; |
|
1919 if (Abs(t) > 1.0f) |
|
1920 t = t / Abs(t); |
|
1921 |
|
1922 if (AknLayoutUtils::LayoutMirrored()) |
|
1923 t = -t; |
|
1924 |
|
1925 iRenderer->SetCameraRotation(-t * iCameraRotationFactor); |
|
1926 |
|
1927 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
1928 { |
|
1929 TReal cameraY = (TReal)(iRowCount - 1) - iSpring->GetInterpolatedY(); |
|
1930 iRenderer->SetCameraPosition(0, 0,//cameraY * iRenderer->GetWorldSpaceRowHeight(), |
|
1931 -Abs(t)*iCameraZoomFactor); |
|
1932 iRenderer->DrawGrid(iRowCount, iItems, |
|
1933 iSpring->GetInterpolatedX(), iSpring->GetInterpolatedY(), |
|
1934 iSelGridItem, iPrevGridItem, iAnimationAlpha, iAnimationState, |
|
1935 iPickedGridItem, iOpeningAnimationType); |
|
1936 } |
|
1937 else |
|
1938 { |
|
1939 iRenderer->Draw(iItems, iSelectedIndex, iSpring->EndX(), |
|
1940 iSpring->GetInterpolatedX(), iAnimationAlpha, iAnimationState, |
|
1941 iOpeningAnimationType, iMediaWallStyle); |
|
1942 } |
|
1943 } |
|
1944 |
|
1945 // --------------------------------------------------------------------------- |
|
1946 // CHgVgMediaWall::HandleDragStart() |
|
1947 // --------------------------------------------------------------------------- |
|
1948 // |
|
1949 void CHgVgMediaWall::HandleDragStart(const AknTouchGestureFw::MAknTouchGestureFwDragEvent& /*aEvent*/) |
|
1950 { |
|
1951 |
|
1952 // cancel ongoing animation. |
|
1953 if (iAnimationTimer->IsActive()) |
|
1954 { |
|
1955 iAnimationTimer->Cancel(); |
|
1956 if (iMediaWallStyle != EHgVgMediaWallStyleGrid) |
|
1957 { |
|
1958 iSpring->SetEnd(iSelectedIndex, iSpring->EndY()); |
|
1959 } |
|
1960 } |
|
1961 |
|
1962 iPointerDown = ETrue; |
|
1963 iViewPositionAtDragStart = iSpring->GetX(); |
|
1964 } |
|
1965 |
|
1966 // --------------------------------------------------------------------------- |
|
1967 // CHgVgMediaWall::HandleDragOn() |
|
1968 // --------------------------------------------------------------------------- |
|
1969 // |
|
1970 void CHgVgMediaWall::HandleDragOn(const AknTouchGestureFw::MAknTouchGestureFwDragEvent& aEvent) |
|
1971 { |
|
1972 |
|
1973 // calculate delta of dragging |
|
1974 TInt delta = aEvent.StartPosition().iX - aEvent.CurrentPosition().iX; |
|
1975 TReal fDelta = GetAsPercentageOfScreenWidth(delta); |
|
1976 |
|
1977 // flip for mirrored layout |
|
1978 if (AknLayoutUtils::LayoutMirrored()) |
|
1979 { |
|
1980 fDelta = -fDelta; |
|
1981 } |
|
1982 |
|
1983 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
1984 { |
|
1985 // for grid we set new position to dragpos and start animation |
|
1986 // to get camera rotation effect for dragging also. |
|
1987 TReal newPosition = iViewPositionAtDragStart + fDelta * iItemsToMoveOnFullScreenDrag; |
|
1988 StartAnimationToPosition(newPosition, ETrue); |
|
1989 } |
|
1990 else |
|
1991 { |
|
1992 // for normal mediawall we move view position according to drag |
|
1993 TReal x = iViewPositionAtDragStart + fDelta * iItemsToMoveOnFullScreenDrag; |
|
1994 iUpdateScrollBar = ETrue; |
|
1995 iSpring->SetXY(x, 0); |
|
1996 iSpring->SetEnd(x, 0); |
|
1997 HandleViewPositionChanged(ETrue); |
|
1998 // draw view at new view position |
|
1999 DrawOpenVG(); |
|
2000 } |
|
2001 } |
|
2002 |
|
2003 // --------------------------------------------------------------------------- |
|
2004 // CHgVgMediaWall::HandleDragStop() |
|
2005 // --------------------------------------------------------------------------- |
|
2006 // |
|
2007 void CHgVgMediaWall::HandleDragStop(const AknTouchGestureFw::MAknTouchGestureFwDragEvent& /*aEvent*/) |
|
2008 { |
|
2009 iPointerDown = EFalse; |
|
2010 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
2011 { |
|
2012 // if we dragged grids position outside bounds, |
|
2013 // we need to animate it back. |
|
2014 TReal x = iSpring->EndX(); |
|
2015 x = Min(x, (TReal)(MaxViewPosition() - 1)); |
|
2016 x = Max(x, 0); |
|
2017 if (x != iSpring->EndX()) |
|
2018 { |
|
2019 StartAnimationToPosition(x, ETrue); |
|
2020 } |
|
2021 } |
|
2022 else |
|
2023 { |
|
2024 // animate back to current selected index, because |
|
2025 // we dont want to be between items in mediawall |
|
2026 StartAnimationToPosition(iSelectedIndex, ETrue); |
|
2027 } |
|
2028 } |
|
2029 |
|
2030 // --------------------------------------------------------------------------- |
|
2031 // CHgVgMediaWall::DrawLetterStripAndTitles() |
|
2032 // --------------------------------------------------------------------------- |
|
2033 // |
|
2034 void CHgVgMediaWall::DrawLetterStripAndTitles() |
|
2035 { |
|
2036 if (iItems.Count() == 0) |
|
2037 { |
|
2038 DrawTitles(1.0f); |
|
2039 } |
|
2040 else |
|
2041 { |
|
2042 |
|
2043 // get distance to next target item |
|
2044 TReal dist = Abs(iSpring->GetX() - iSpring->EndX()); |
|
2045 |
|
2046 if (iMediaWallStyle == EHgVgMediaWallStyleCoverflowTBonePortrait) |
|
2047 { |
|
2048 // we bring letter popup when we are far enough from next item |
|
2049 if (iLetterPopup && (dist > 2.0f && iSpring->GetX() >= 0 && iSpring->GetX() < iItems.Count())) |
|
2050 { |
|
2051 iLetterPopup->Draw(iRect, KMaxLetterPopupOpacity * Max(1.0f, (dist - 2.0f) / 2.0f)); |
|
2052 } |
|
2053 else |
|
2054 { |
|
2055 DrawTitles(1.0f - dist/2.0f); |
|
2056 } |
|
2057 } |
|
2058 else if (iMediaWallStyle == EHgVgMediaWallStyleCoverflowFullScreen || |
|
2059 iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
2060 { |
|
2061 // when scrollbar is being dragged we draw letter popup |
|
2062 if (iLetterPopup && (iScrollBarHit || (iKeyScrollingState != ENoKeyScrolling && dist >= 2.0f))) |
|
2063 { |
|
2064 iLetterPopup->Draw(iRect, KMaxLetterPopupOpacity); |
|
2065 } |
|
2066 |
|
2067 // when close to target item, we draw titles |
|
2068 if (dist <= 2.0f) |
|
2069 { |
|
2070 DrawTitles(1.0f - dist / 2.0f); |
|
2071 } |
|
2072 } |
|
2073 } |
|
2074 } |
|
2075 |
|
2076 // --------------------------------------------------------------------------- |
|
2077 // CHgVgMediaWall::DrawButtonsAndScrollbar() |
|
2078 // --------------------------------------------------------------------------- |
|
2079 // |
|
2080 void CHgVgMediaWall::DrawButtonsAndScrollbar() |
|
2081 { |
|
2082 if (iScrollBar || iHideSKButton) |
|
2083 { |
|
2084 TReal alpha = 1.0f; |
|
2085 if (iAnimationState == EHgVgMediaWallAnimationStateOpening || iAnimationState == EHgVgMediaWallAnimationStateClosing) |
|
2086 alpha = 1.0f - iAnimationAlpha; |
|
2087 else if (iAnimationState == EHgVgMediaWallAnimationStateItemOpened) |
|
2088 alpha = 0.0f; |
|
2089 if (iScrollBar) |
|
2090 iScrollBar->Draw(iRect, alpha); |
|
2091 if (iHideSKButton) |
|
2092 iHideSKButton->Draw(iRect, alpha); |
|
2093 } |
|
2094 } |
|
2095 |
|
2096 // --------------------------------------------------------------------------- |
|
2097 // CHgVgMediaWall::HandleButtons() |
|
2098 // --------------------------------------------------------------------------- |
|
2099 // |
|
2100 TBool CHgVgMediaWall::HandleButtons(const TPointerEvent& aEvent) |
|
2101 { |
|
2102 // handle hitting buttons |
|
2103 TBool ret = EFalse; |
|
2104 if (iHideSKButton) |
|
2105 { |
|
2106 // if buttons is hit, hide scrollbar and button |
|
2107 if (iHideSKButton->HandlePointerEvent(aEvent)) |
|
2108 { |
|
2109 |
|
2110 if (iScrollBar) |
|
2111 iScrollBar->SetEnabled(EFalse); |
|
2112 |
|
2113 iHideSKButton->SetEnabled(EFalse); |
|
2114 |
|
2115 ret = ETrue; |
|
2116 |
|
2117 DrawOpenVG(); |
|
2118 |
|
2119 if (iMediaWallObserver) |
|
2120 iMediaWallObserver->HandleMediaWallEvent((TInt)EHgVgMediaWallEventRequestShowSoftkeys, this); |
|
2121 |
|
2122 } |
|
2123 // if screen is hit when button is not visible, show button and scrollbar |
|
2124 else if (!iHideSKButton->IsEnabled() && aEvent.iType == TPointerEvent::EButton1Down) |
|
2125 { |
|
2126 |
|
2127 if (iScrollBar) |
|
2128 iScrollBar->SetEnabled(ETrue); |
|
2129 |
|
2130 iHideSKButton->SetEnabled(ETrue); |
|
2131 |
|
2132 DrawOpenVG(); |
|
2133 |
|
2134 if (iMediaWallObserver) |
|
2135 iMediaWallObserver->HandleMediaWallEvent((TInt)EHgVgMediaWallEventRequestHideSoftkeys, this); |
|
2136 |
|
2137 } |
|
2138 } |
|
2139 |
|
2140 return ret; |
|
2141 } |
|
2142 |
|
2143 // --------------------------------------------------------------------------- |
|
2144 // CHgVgMediaWall::MaxViewPosition() |
|
2145 // --------------------------------------------------------------------------- |
|
2146 // |
|
2147 TInt CHgVgMediaWall::MaxViewPosition() const |
|
2148 { |
|
2149 return iItemCount / iRowCount; |
|
2150 } |
|
2151 |
|
2152 // --------------------------------------------------------------------------- |
|
2153 // CHgVgMediaWall::BeginSelection() |
|
2154 // --------------------------------------------------------------------------- |
|
2155 // |
|
2156 TBool CHgVgMediaWall::BeginSelection(TInt aIndex) |
|
2157 { |
|
2158 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
2159 { |
|
2160 if (iSelectionObserver) |
|
2161 { |
|
2162 TRAP_IGNORE( iSelectionObserver->HandleSelectL(aIndex, this); ) |
|
2163 } |
|
2164 iPrevGridItem = iSelGridItem; |
|
2165 iSelGridItem = aIndex; |
|
2166 iSelectionMode = ETrue; |
|
2167 TInt x = aIndex / iRowCount; |
|
2168 TInt y = aIndex % iRowCount; |
|
2169 StartAnimationToPosition(x, y, ETrue); |
|
2170 } |
|
2171 return ETrue; |
|
2172 } |
|
2173 |
|
2174 // --------------------------------------------------------------------------- |
|
2175 // CHgVgMediaWall::EndSelection() |
|
2176 // --------------------------------------------------------------------------- |
|
2177 // |
|
2178 void CHgVgMediaWall::EndSelection() |
|
2179 { |
|
2180 if (iSelectionMode) |
|
2181 { |
|
2182 iSelGridItem = KErrNotFound; |
|
2183 iPrevGridItem = KErrNotFound; |
|
2184 iSelectionMode = EFalse; |
|
2185 StartAnimationToPosition(iSpring->EndX(), iRowCount - 1, ETrue); |
|
2186 } |
|
2187 } |
|
2188 |
|
2189 // --------------------------------------------------------------------------- |
|
2190 // CHgVgMediaWall::DoStartOpeningAnimationL() |
|
2191 // --------------------------------------------------------------------------- |
|
2192 // |
|
2193 void CHgVgMediaWall::DoStartOpeningAnimationL() |
|
2194 { |
|
2195 TBool opening = ETrue; |
|
2196 |
|
2197 if (iAnimationState == EHgVgMediaWallAnimationStateItemOpened) |
|
2198 opening = EFalse; |
|
2199 |
|
2200 StartOpeningAnimationL(opening); |
|
2201 } |
|
2202 |
|
2203 // --------------------------------------------------------------------------- |
|
2204 // CHgVgMediaWall::StartAnimationToPosition() |
|
2205 // --------------------------------------------------------------------------- |
|
2206 // |
|
2207 void CHgVgMediaWall::StartAnimationToPosition(TReal aX, TBool aUpdateScrollBar) |
|
2208 { |
|
2209 StartAnimationToPosition(aX, iSpring->EndY(), aUpdateScrollBar); |
|
2210 } |
|
2211 |
|
2212 // --------------------------------------------------------------------------- |
|
2213 // CHgVgMediaWall::StartAnimationToPosition() |
|
2214 // --------------------------------------------------------------------------- |
|
2215 // |
|
2216 void CHgVgMediaWall::StartAnimationToPosition(TReal aX, TReal aY, TBool aUpdateScrollBar) |
|
2217 { |
|
2218 iSpring->SetEnd(aX, aY); |
|
2219 iUpdateScrollBar = aUpdateScrollBar; |
|
2220 iAnimationState = EHgVgMediaWallAnimationStateTransition; |
|
2221 StartAnimationTimer(); |
|
2222 } |
|
2223 |
|
2224 // ----------------------------------------------------------------------------- |
|
2225 // CHgVgMediaWall::SetFlags() |
|
2226 // ----------------------------------------------------------------------------- |
|
2227 // |
|
2228 EXPORT_C void CHgVgMediaWall::SetFlags(TInt aFlags) |
|
2229 { |
|
2230 iFlags |= aFlags; |
|
2231 } |
|
2232 |
|
2233 // ----------------------------------------------------------------------------- |
|
2234 // CHgVgMediaWall::ClearFlags() |
|
2235 // ----------------------------------------------------------------------------- |
|
2236 // |
|
2237 EXPORT_C void CHgVgMediaWall::ClearFlags(TInt aFlags) |
|
2238 { |
|
2239 iFlags &= ~aFlags; |
|
2240 } |
|
2241 |
|
2242 // ----------------------------------------------------------------------------- |
|
2243 // CHgVgMediaWall::Flags() |
|
2244 // ----------------------------------------------------------------------------- |
|
2245 // |
|
2246 EXPORT_C TInt CHgVgMediaWall::Flags() |
|
2247 { |
|
2248 return iFlags; |
|
2249 } |
|
2250 |
|
2251 // ----------------------------------------------------------------------------- |
|
2252 // CHgVgMediaWall::SetItemToOpenedState() |
|
2253 // ----------------------------------------------------------------------------- |
|
2254 // |
|
2255 EXPORT_C void CHgVgMediaWall::SetItemToOpenedState(TInt aIndex) |
|
2256 { |
|
2257 if (aIndex >= 0 && aIndex < iItemCount) |
|
2258 { |
|
2259 HandleTransitionAnimationStop(); |
|
2260 SetSelectedIndex(aIndex); |
|
2261 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
|
2262 { |
|
2263 iPickedGridItem = aIndex; |
|
2264 } |
|
2265 iAnimationAlpha = 1.0f; |
|
2266 iAnimationState = EHgVgMediaWallAnimationStateItemOpened; |
|
2267 } |
|
2268 } |
|
2269 |
|
2270 // ----------------------------------------------------------------------------- |
|
2271 // CHgVgMediaWall::SetFlippedRect() |
|
2272 // ----------------------------------------------------------------------------- |
|
2273 // |
|
2274 EXPORT_C void CHgVgMediaWall::SetOpenedItemRect(const TRect& aRect) |
|
2275 { |
|
2276 if (iRenderer) |
|
2277 { |
|
2278 iRenderer->SetFlippedRect(aRect); |
|
2279 } |
|
2280 } |
|
2281 |
|
2282 // ----------------------------------------------------------------------------- |
|
2283 // CHgVgMediaWall::DeleteComponents() |
|
2284 // ----------------------------------------------------------------------------- |
|
2285 // |
|
2286 void CHgVgMediaWall::DestroyRendering() |
|
2287 { |
|
2288 delete iScrollBar; iScrollBar = NULL; |
|
2289 delete iRenderer; iRenderer = NULL; |
|
2290 delete iArtistLabel; iArtistLabel = NULL; |
|
2291 delete iAlbumLabel; iAlbumLabel = NULL; |
|
2292 delete iLetterPopup; iLetterPopup = NULL; |
|
2293 delete iSkinRenderer; iSkinRenderer = NULL; |
|
2294 delete iEGL; iEGL = NULL; |
|
2295 } |
|
2296 |
|
2297 // ----------------------------------------------------------------------------- |
|
2298 // CHgVgMediaWall::DrawAll() |
|
2299 // ----------------------------------------------------------------------------- |
|
2300 // |
|
2301 TBool CHgVgMediaWall::DrawAll() |
|
2302 { |
|
2303 if ( !iEGL || !iEGL->ReadyToRender() || !iRenderer ) |
|
2304 { |
|
2305 return EFalse; |
|
2306 } |
|
2307 |
|
2308 if (iSkinRenderer) |
|
2309 iSkinRenderer->Draw(); |
|
2310 |
|
2311 DrawScene(); |
|
2312 |
|
2313 DrawButtonsAndScrollbar(); |
|
2314 |
|
2315 if (iItems.Count() == 0) |
|
2316 { |
|
2317 if (iEmptyLabel) |
|
2318 { |
|
2319 iEmptyLabel->DrawEmptyText(iRect, *iEmptyText); |
|
2320 } |
|
2321 } |
|
2322 else |
|
2323 { |
|
2324 DrawLetterStripAndTitles(); |
|
2325 } |
|
2326 |
|
2327 return ETrue; |
|
2328 } |
|
2329 |
|
2330 // ----------------------------------------------------------------------------- |
|
2331 // CHgVgMediaWall::CreateMediaWallFullScreenLandscapeL() |
|
2332 // ----------------------------------------------------------------------------- |
|
2333 // |
|
2334 void CHgVgMediaWall::InitMediaWallFullScreenLandscapeL() |
|
2335 { |
|
2336 |
|
2337 // set some factors to mediawall fullscreen mode specific values |
|
2338 iCameraZoomFactor = KMediaWallFullScreenCameraZoomFactor; |
|
2339 iCameraRotationFactor = KMediaWallFullScreenCameraRotationFactor; |
|
2340 iItemsOnScreen = KMediaWallFullScreenItemsOnScreen; |
|
2341 iSpringVelocityToAnimationFactor = KMediaWallFullScreenSpringVelocityToAnimationFactor; |
|
2342 iItemsToMoveOnFullScreenDrag = KMediaWallFullScreenItemsToMoveOnFullScreenDrag; |
|
2343 iRowCount = KMediaWallFullScreenRowCount; |
|
2344 |
|
2345 // get front rectange from layout |
|
2346 TAknLayoutRect frontRect; |
|
2347 frontRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g1(0) ); |
|
2348 |
|
2349 // set items at the back a bit further in the fullscreen mode. |
|
2350 iRenderer = CHgVgMediaWallRenderer::NewL(KMaxCoversVisible, iRect, frontRect.Rect(), |
|
2351 KMediaWallFullScreenZOffset); |
|
2352 |
|
2353 // set some default flipped rect for opening animation |
|
2354 iRenderer->SetFlippedRect(TRect(TPoint(iRect.Center().iX - iRect.Height() / 2, |
|
2355 iRect.Center().iY - iRect.Height() / 2), |
|
2356 TSize(iRect.Height(), iRect.Height()))); |
|
2357 |
|
2358 // in full screen, enable blurring on flip/zoom |
|
2359 iRenderer->EnableBlurOnFlip(ETrue, KDefaultBlurDeviation, |
|
2360 KDefaultBlurDeviation); |
|
2361 |
|
2362 InitLabelsL(1); |
|
2363 |
|
2364 InitPopupL(0); |
|
2365 |
|
2366 InitButtonsL(); |
|
2367 |
|
2368 InitScrollBarL(EFalse); |
|
2369 |
|
2370 iSpring->SetConstants( |
|
2371 KMediaWallFullScreenSpringK, |
|
2372 KMediaWallFullScreenSpringDamping, |
|
2373 KMediaWallFullScreenSpringMaxVelocity, |
|
2374 KPositionSnap, KMinSpringVelocity); |
|
2375 |
|
2376 } |
|
2377 |
|
2378 // ----------------------------------------------------------------------------- |
|
2379 // CHgVgMediaWall::CreateMediaWallTBonePortraitL() |
|
2380 // ----------------------------------------------------------------------------- |
|
2381 // |
|
2382 void CHgVgMediaWall::InitMediaWallTBonePortraitL() |
|
2383 { |
|
2384 |
|
2385 // set some factors to mediawall fullscreen mode specific values |
|
2386 iCameraZoomFactor = KMediaWallTBoneCameraZoomFactor; |
|
2387 iCameraRotationFactor = KMediaWallTBoneCameraRotationFactor; |
|
2388 iItemsOnScreen = KMediaWallTBoneItemsOnScreen; |
|
2389 iSpringVelocityToAnimationFactor = KMediaWallTBoneSpringVelocityToAnimationFactor; |
|
2390 iItemsToMoveOnFullScreenDrag = KMediaWallTBoneItemsToMoveOnFullScreenDrag; |
|
2391 iRowCount = KMediaWallTBoneRowCount; |
|
2392 iOpeningAnimationType = EHgVgOpeningAnimationZoomToFront; |
|
2393 |
|
2394 // get front rectange from layout |
|
2395 TAknLayoutRect frontRect; |
|
2396 frontRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g1(1) ); |
|
2397 |
|
2398 iRenderer = CHgVgMediaWallRenderer::NewL(KMaxCoversVisible, iRect, frontRect.Rect(), |
|
2399 KMediaWallTBoneZOffset); |
|
2400 |
|
2401 iRenderer->SetFlippedRect(TRect(TPoint(iRect.Center().iX - iRect.Height() / 2, |
|
2402 iRect.Center().iY - iRect.Height() / 2), |
|
2403 TSize(iRect.Height(), iRect.Height()))); |
|
2404 |
|
2405 InitLabelsL(0); |
|
2406 |
|
2407 InitPopupL(0); |
|
2408 |
|
2409 iSpring->SetConstants( |
|
2410 KMediaWallTBoneSpringK, |
|
2411 KMediaWallTBoneSpringDamping, |
|
2412 KMediaWallTBoneSpringMaxVelocity, |
|
2413 KPositionSnap, KMinSpringVelocity); |
|
2414 |
|
2415 } |
|
2416 |
|
2417 void CHgVgMediaWall::InitMediaWallGridLandscapeL() |
|
2418 { |
|
2419 |
|
2420 TRect frontRect; |
|
2421 TSize size(120,90); |
|
2422 |
|
2423 // TODO: set this from layout data |
|
2424 frontRect = TRect(TPoint(iRect.Center().iX - size.iWidth/2, iRect.Center().iY - 45 + 90), |
|
2425 size); |
|
2426 |
|
2427 iCameraZoomFactor = KMediaWallGridCameraZoomFactor; |
|
2428 iCameraRotationFactor = KMediaWallGridCameraRotationFactor; |
|
2429 iItemsOnScreen = KMediaWallGridItemsOnScreen; |
|
2430 iSpringVelocityToAnimationFactor = KMediaWallGridSpringVelocityToAnimationFactor; |
|
2431 iItemsToMoveOnFullScreenDrag = KMediaWallGridItemsToMoveOnFullScreenDrag; |
|
2432 iRowCount = KMediaWallGridRowCount; |
|
2433 iOpeningAnimationType = EHgVgOpeningAnimationZoomIn; |
|
2434 |
|
2435 iRenderer = CHgVgMediaWallRenderer::NewL((KMaxCoversVisible+1) * KMediaWallGridRowCount, |
|
2436 iRect, frontRect, KMediaWallGridZOffset); |
|
2437 |
|
2438 iRenderer->SetFlippedRect(iRect); |
|
2439 |
|
2440 InitButtonsL(); |
|
2441 |
|
2442 InitScrollBarL(EFalse); |
|
2443 |
|
2444 //iRenderer->EnableFlipXY(ETrue); |
|
2445 |
|
2446 // TODO: set this from layout data |
|
2447 TSize lsize(300, 70); |
|
2448 iLetterPopup = CHgVgPopup::NewL(TRect(TPoint(iRect.Center().iX - lsize.iWidth / 2, |
|
2449 iRect.Center().iY - lsize.iHeight / 2), lsize), |
|
2450 &ScreenFont( TCoeFont( KMediaWallGridPopupFontSize, TCoeFont::EPlain ))); |
|
2451 |
|
2452 iSpring->SetConstants( |
|
2453 KMediaWallGridSpringK, |
|
2454 KMediaWallGridSpringDamping, |
|
2455 KMediaWallGridSpringMaxVelocity, |
|
2456 KPositionSnap, |
|
2457 KMinSpringVelocity); |
|
2458 } |
|
2459 |
|
2460 |
|
2461 void CHgVgMediaWall::InitLabelsL(TInt aLayoutVariant) |
|
2462 { |
|
2463 TAknTextComponentLayout l0 = AknLayoutScalable_Apps::main_cf0_pane_t1(aLayoutVariant); |
|
2464 TAknTextComponentLayout l1 = AknLayoutScalable_Apps::main_cf0_pane_t2(aLayoutVariant); |
|
2465 |
|
2466 TAknLayoutText t0; |
|
2467 TAknLayoutText t1; |
|
2468 |
|
2469 t0.LayoutText(iRect, l0); |
|
2470 t1.LayoutText(iRect, l1); |
|
2471 |
|
2472 iAlbumLabel = CHgVgLabel::NewL(t0.TextRect(), |
|
2473 &ScreenFont( TCoeFont( KMediaWallTBoneLabelFontSize, TCoeFont::EBold )) ); |
|
2474 |
|
2475 iArtistLabel = CHgVgLabel::NewL(t1.TextRect(), |
|
2476 &ScreenFont( TCoeFont( KMediaWallTBoneLabelFontSize, TCoeFont::EBold )) ); |
|
2477 |
|
2478 iAlbumLabel->SetLayout(l0, iRect); |
|
2479 iArtistLabel->SetLayout(l1, iRect); |
|
2480 } |
|
2481 |
|
2482 void CHgVgMediaWall::InitPopupL(TInt aLayoutVariant) |
|
2483 { |
|
2484 TAknLayoutRect popupRect; |
|
2485 popupRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g2(aLayoutVariant) ); |
|
2486 iLetterPopup = CHgVgPopup::NewL(popupRect.Rect(), |
|
2487 &ScreenFont( TCoeFont( KMediaWallTBonePopupFontSize, TCoeFont::EPlain ))); |
|
2488 |
|
2489 iLetterPopup->SetLayouts(AknLayoutScalable_Apps::cf0_flow_pane_g2(aLayoutVariant), |
|
2490 AknLayoutScalable_Apps::cf0_flow_pane_t1(aLayoutVariant), iRect); |
|
2491 } |
|
2492 |
|
2493 |
|
2494 |
|
2495 // End of File |
|