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