uifw/ganes/src/HgVgMediaWall.cpp
branchRCL_3
changeset 18 0aa5fbdfbc30
parent 16 71dd06cfe933
child 23 3d340a0166ff
equal deleted inserted replaced
16:71dd06cfe933 18:0aa5fbdfbc30
    64 
    64 
    65 
    65 
    66 using namespace AknTouchGestureFw;
    66 using namespace AknTouchGestureFw;
    67 using namespace HgVgConstants;
    67 using namespace HgVgConstants;
    68 
    68 
    69 #ifdef SYMBIAN_GRAPHICS_FIXNATIVEORIENTATION
    69 #ifndef __WINSCW__
    70     #define MEDIAWALL_ORIENTATION_FIX
    70     #ifdef SYMBIAN_GRAPHICS_FIXNATIVEORIENTATION
       
    71         #define MEDIAWALL_ORIENTATION_FIX
       
    72     #endif
    71 #endif
    73 #endif
    72 
    74 
    73 // ============================ MEMBER FUNCTIONS ===============================
    75 // ============================ MEMBER FUNCTIONS ===============================
    74 // -----------------------------------------------------------------------------
    76 // -----------------------------------------------------------------------------
    75 // CHgMediaWall::NewL()
    77 // CHgMediaWall::NewL()
   431 //
   433 //
   432 void CHgVgMediaWall::SizeChanged ( )
   434 void CHgVgMediaWall::SizeChanged ( )
   433     {
   435     {
   434     iRect = Rect();
   436     iRect = Rect();
   435     
   437     
       
   438     SetConstantsForStyle();
       
   439     
   436     if(iDelayedInit && !iDelayedInit->IsActive())
   440     if(iDelayedInit && !iDelayedInit->IsActive())
   437         iDelayedInit->Start(0, 1000000, TCallBack(DelayedInit, this));
   441         iDelayedInit->Start(0, 1000000, TCallBack(DelayedInit, this));
   438 
   442 
   439     if(MTouchFeedback::Instance())
   443     if(MTouchFeedback::Instance())
   440         {
   444         {
  1227     // init egl and openvg again
  1231     // init egl and openvg again
  1228     TRAP_IGNORE( InitRenderingL(EFalse); )
  1232     TRAP_IGNORE( InitRenderingL(EFalse); )
  1229     
  1233     
  1230     // reload images to ive
  1234     // reload images to ive
  1231     ReloadItemsImages();
  1235     ReloadItemsImages();
  1232         
  1236 
       
  1237     ClearFlags(EHgVgMediaWallUninitialized);
       
  1238 
  1233     // draw using openvg
  1239     // draw using openvg
  1234     DrawNow();
  1240     DrawNow();
  1235     
  1241     
  1236     }    
  1242     }    
  1237 
  1243 
  1243     {
  1249     {
  1244     if(!iIsForeground) return; // don't react to losing foreground without gaining it
  1250     if(!iIsForeground) return; // don't react to losing foreground without gaining it
  1245     
  1251     
  1246     // make sure we are not animating
  1252     // make sure we are not animating
  1247     HandleTransitionAnimationStop();
  1253     HandleTransitionAnimationStop();
       
  1254     
       
  1255     // cancel the initialization
       
  1256     if(iDelayedInit)
       
  1257         iDelayedInit->Cancel();
  1248     
  1258     
  1249     if (iAnimationTimer->IsActive())
  1259     if (iAnimationTimer->IsActive())
  1250         {
  1260         {
  1251         if (iAnimationState == EHgVgMediaWallAnimationStateOpening)
  1261         if (iAnimationState == EHgVgMediaWallAnimationStateOpening)
  1252             iAnimationState = EHgVgMediaWallAnimationStateItemOpened;
  1262             iAnimationState = EHgVgMediaWallAnimationStateItemOpened;
  1588             TSize(MaxViewPosition(), 1), TSize(1, 1), 
  1598             TSize(MaxViewPosition(), 1), TSize(1, 1), 
  1589             ETrue, CHgScroller::EHgScrollerScrollBar);
  1599             ETrue, CHgScroller::EHgScrollerScrollBar);
  1590     
  1600     
  1591     iScrollBar->SetViewPosition( TPoint(iSelectedIndex, 0) );
  1601     iScrollBar->SetViewPosition( TPoint(iSelectedIndex, 0) );
  1592     
  1602     
       
  1603 #ifdef MEDIAWALL_ORIENTATION_FIX
       
  1604     iScrollBar->EnableLandscapeRendering( iMediaWallStyle == CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen );
       
  1605 #endif
       
  1606     
  1593     }
  1607     }
  1594 
  1608 
  1595 // ---------------------------------------------------------------------------
  1609 // ---------------------------------------------------------------------------
  1596 // CHgVgMediaWall::InitRenderingL()
  1610 // CHgVgMediaWall::InitRenderingL()
  1597 // Inits all rendering.
  1611 // Inits all rendering.
  1644         default: 
  1658         default: 
  1645             {
  1659             {
  1646             User::Leave(KErrNotSupported);
  1660             User::Leave(KErrNotSupported);
  1647             } break;
  1661             } break;
  1648         }
  1662         }
  1649         
  1663     
       
  1664     if( iOpenedItemRect != TRect() )
       
  1665         {
       
  1666         iRenderer->SetFlippedRect( iOpenedItemRect );
       
  1667         }
       
  1668     else
       
  1669         {
       
  1670         // set some default flipped rect for opening animation
       
  1671         if(iMediaWallStyle == EHgVgMediaWallStyleGrid)
       
  1672             {
       
  1673             iRenderer->SetFlippedRect(iRect);
       
  1674             }
       
  1675         else
       
  1676             {
       
  1677             iRenderer->SetFlippedRect(TRect(TPoint(iRect.Center().iX - iRect.Height() / 2,
       
  1678                     iRect.Center().iY - iRect.Height() / 2),
       
  1679                     TSize(iRect.Height(), iRect.Height())));
       
  1680             }
       
  1681         }
       
  1682 
  1650     // load default icon
  1683     // load default icon
  1651     InitDefaultIconL();
  1684     InitDefaultIconL();
  1652 
  1685 
  1653     // invalidate selected index so
  1686     // invalidate selected index so
  1654     // that HandleViewPositionChanged does
  1687     // that HandleViewPositionChanged does
  2315 // CHgVgMediaWall::SetFlippedRect()
  2348 // CHgVgMediaWall::SetFlippedRect()
  2316 // -----------------------------------------------------------------------------
  2349 // -----------------------------------------------------------------------------
  2317 //
  2350 //
  2318 EXPORT_C void CHgVgMediaWall::SetOpenedItemRect(const TRect& aRect)
  2351 EXPORT_C void CHgVgMediaWall::SetOpenedItemRect(const TRect& aRect)
  2319     {
  2352     {
       
  2353     iOpenedItemRect = aRect;
  2320     if (iRenderer)
  2354     if (iRenderer)
  2321         {
  2355         {
  2322         iRenderer->SetFlippedRect(aRect);
  2356         iRenderer->SetFlippedRect(iOpenedItemRect);
  2323         }
  2357         }
  2324     }
  2358     }
  2325 
  2359 
  2326 // -----------------------------------------------------------------------------
  2360 // -----------------------------------------------------------------------------
  2327 // CHgVgMediaWall::DeleteComponents()
  2361 // CHgVgMediaWall::DeleteComponents()
  2379 // CHgVgMediaWall::CreateMediaWallFullScreenLandscapeL()
  2413 // CHgVgMediaWall::CreateMediaWallFullScreenLandscapeL()
  2380 // -----------------------------------------------------------------------------
  2414 // -----------------------------------------------------------------------------
  2381 //
  2415 //
  2382 void CHgVgMediaWall::InitMediaWallFullScreenLandscapeL()
  2416 void CHgVgMediaWall::InitMediaWallFullScreenLandscapeL()
  2383     {
  2417     {
  2384                 
       
  2385     // set some factors to mediawall fullscreen mode specific values
       
  2386     iCameraZoomFactor = KMediaWallFullScreenCameraZoomFactor;
       
  2387     iCameraRotationFactor = KMediaWallFullScreenCameraRotationFactor;            
       
  2388     iItemsOnScreen = KMediaWallFullScreenItemsOnScreen;
       
  2389     iSpringVelocityToAnimationFactor = KMediaWallFullScreenSpringVelocityToAnimationFactor;
       
  2390     iItemsToMoveOnFullScreenDrag = KMediaWallFullScreenItemsToMoveOnFullScreenDrag;
       
  2391     iRowCount = KMediaWallFullScreenRowCount;
       
  2392     
       
  2393     // get front rectange from layout
  2418     // get front rectange from layout
  2394     TAknLayoutRect frontRect;
  2419     TAknLayoutRect frontRect;
  2395     frontRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g1(0) );
  2420     frontRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g1(0) );
  2396 
  2421 
  2397     // set items at the back a bit further in the fullscreen mode.
  2422     // set items at the back a bit further in the fullscreen mode.
  2398     iRenderer = CHgVgMediaWallRenderer::NewL(KMaxCoversVisible, iRect, frontRect.Rect(), 
  2423     iRenderer = CHgVgMediaWallRenderer::NewL(KMaxCoversVisible, iRect, frontRect.Rect(), 
  2399             KMediaWallFullScreenZOffset);
  2424             KMediaWallFullScreenZOffset);
  2400 
       
  2401     // set some default flipped rect for opening animation
       
  2402     iRenderer->SetFlippedRect(TRect(TPoint(iRect.Center().iX - iRect.Height() / 2,
       
  2403             iRect.Center().iY - iRect.Height() / 2),
       
  2404             TSize(iRect.Height(), iRect.Height())));
       
  2405 
  2425 
  2406     // in full screen, enable blurring on flip/zoom
  2426     // in full screen, enable blurring on flip/zoom
  2407     iRenderer->EnableBlurOnFlip(ETrue, KDefaultBlurDeviation, 
  2427     iRenderer->EnableBlurOnFlip(ETrue, KDefaultBlurDeviation, 
  2408             KDefaultBlurDeviation);
  2428             KDefaultBlurDeviation);
  2409      
  2429      
  2412     InitPopupL(0);
  2432     InitPopupL(0);
  2413     
  2433     
  2414     InitButtonsL();
  2434     InitButtonsL();
  2415     
  2435     
  2416     InitScrollBarL(EFalse);
  2436     InitScrollBarL(EFalse);
  2417 
       
  2418     iSpring->SetConstants(
       
  2419             KMediaWallFullScreenSpringK, 
       
  2420             KMediaWallFullScreenSpringDamping, 
       
  2421             KMediaWallFullScreenSpringMaxVelocity, 
       
  2422             KPositionSnap, KMinSpringVelocity);    
       
  2423 
  2437 
  2424 #ifdef MEDIAWALL_ORIENTATION_FIX    
  2438 #ifdef MEDIAWALL_ORIENTATION_FIX    
  2425     iRenderer->EnableLandscapeMode(ETrue);
  2439     iRenderer->EnableLandscapeMode(ETrue);
  2426     iAlbumLabel->EnableLandscapeRendering(ETrue);
  2440     iAlbumLabel->EnableLandscapeRendering(ETrue);
  2427     iArtistLabel->EnableLandscapeRendering(ETrue);
  2441     iArtistLabel->EnableLandscapeRendering(ETrue);
  2438 // CHgVgMediaWall::CreateMediaWallTBonePortraitL()
  2452 // CHgVgMediaWall::CreateMediaWallTBonePortraitL()
  2439 // -----------------------------------------------------------------------------
  2453 // -----------------------------------------------------------------------------
  2440 //
  2454 //
  2441 void CHgVgMediaWall::InitMediaWallTBonePortraitL()
  2455 void CHgVgMediaWall::InitMediaWallTBonePortraitL()
  2442     {
  2456     {
  2443     
       
  2444     // set some factors to mediawall fullscreen mode specific values
       
  2445     iCameraZoomFactor = KMediaWallTBoneCameraZoomFactor;
       
  2446     iCameraRotationFactor = KMediaWallTBoneCameraRotationFactor;            
       
  2447     iItemsOnScreen = KMediaWallTBoneItemsOnScreen;
       
  2448     iSpringVelocityToAnimationFactor = KMediaWallTBoneSpringVelocityToAnimationFactor;
       
  2449     iItemsToMoveOnFullScreenDrag = KMediaWallTBoneItemsToMoveOnFullScreenDrag;
       
  2450     iRowCount = KMediaWallTBoneRowCount;
       
  2451     
       
  2452     // get front rectange from layout
  2457     // get front rectange from layout
  2453     TAknLayoutRect frontRect;
  2458     TAknLayoutRect frontRect;
  2454     frontRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g1(0) );
  2459     frontRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g1(0) );
  2455 
  2460 
  2456     iRenderer = CHgVgMediaWallRenderer::NewL(KMaxCoversVisible, iRect, frontRect.Rect(), 
  2461     iRenderer = CHgVgMediaWallRenderer::NewL(KMaxCoversVisible, iRect, frontRect.Rect(), 
  2457             KMediaWallTBoneZOffset);
  2462             KMediaWallTBoneZOffset);
  2458                 
  2463                 
  2459     iRenderer->SetFlippedRect(TRect(TPoint(iRect.Center().iX - iRect.Height() / 2,
       
  2460             iRect.Center().iY - iRect.Height() / 2),
       
  2461             TSize(iRect.Height(), iRect.Height())));
       
  2462     
       
  2463     InitLabelsL(0);
  2464     InitLabelsL(0);
  2464     
  2465     
  2465     InitPopupL(0);
  2466     InitPopupL(0);
  2466     
  2467     
  2467     iSpring->SetConstants(
       
  2468             KMediaWallTBoneSpringK, 
       
  2469             KMediaWallTBoneSpringDamping, 
       
  2470             KMediaWallTBoneSpringMaxVelocity, 
       
  2471             KPositionSnap, KMinSpringVelocity);
       
  2472         
       
  2473     }
  2468     }
  2474 
  2469 
  2475 void CHgVgMediaWall::InitMediaWallGridLandscapeL()
  2470 void CHgVgMediaWall::InitMediaWallGridLandscapeL()
  2476     {
  2471     {
  2477 
  2472 
  2480     
  2475     
  2481     // TODO: set this from layout data
  2476     // TODO: set this from layout data
  2482     frontRect = TRect(TPoint(iRect.Center().iX - size.iWidth/2, iRect.Center().iY - 45 + 90), 
  2477     frontRect = TRect(TPoint(iRect.Center().iX - size.iWidth/2, iRect.Center().iY - 45 + 90), 
  2483             size);
  2478             size);
  2484                 
  2479                 
  2485     iCameraZoomFactor = KMediaWallGridCameraZoomFactor;
       
  2486     iCameraRotationFactor = KMediaWallGridCameraRotationFactor;            
       
  2487     iItemsOnScreen = KMediaWallGridItemsOnScreen;
       
  2488     iSpringVelocityToAnimationFactor = KMediaWallGridSpringVelocityToAnimationFactor;
       
  2489     iItemsToMoveOnFullScreenDrag = KMediaWallGridItemsToMoveOnFullScreenDrag;
       
  2490     iRowCount = KMediaWallGridRowCount;
       
  2491     iOpeningAnimationType = EHgVgOpeningAnimationZoomIn;
       
  2492     
       
  2493     iRenderer = CHgVgMediaWallRenderer::NewL((KMaxCoversVisible+1) * KMediaWallGridRowCount, 
  2480     iRenderer = CHgVgMediaWallRenderer::NewL((KMaxCoversVisible+1) * KMediaWallGridRowCount, 
  2494             iRect, frontRect, KMediaWallGridZOffset);
  2481             iRect, frontRect, KMediaWallGridZOffset);
  2495     
  2482     
  2496     iRenderer->SetFlippedRect(iRect);
       
  2497                                         
       
  2498     InitButtonsL();
  2483     InitButtonsL();
  2499     
  2484     
  2500     InitScrollBarL(EFalse);
  2485     InitScrollBarL(EFalse);
  2501     
  2486     
  2502     //iRenderer->EnableFlipXY(ETrue);
  2487     //iRenderer->EnableFlipXY(ETrue);
  2505     TSize lsize(300, 70);
  2490     TSize lsize(300, 70);
  2506     iLetterPopup = CHgVgPopup::NewL(TRect(TPoint(iRect.Center().iX - lsize.iWidth / 2, 
  2491     iLetterPopup = CHgVgPopup::NewL(TRect(TPoint(iRect.Center().iX - lsize.iWidth / 2, 
  2507             iRect.Center().iY - lsize.iHeight / 2), lsize), 
  2492             iRect.Center().iY - lsize.iHeight / 2), lsize), 
  2508             &ScreenFont( TCoeFont( KMediaWallGridPopupFontSize, TCoeFont::EPlain )));
  2493             &ScreenFont( TCoeFont( KMediaWallGridPopupFontSize, TCoeFont::EPlain )));
  2509     
  2494     
  2510     iSpring->SetConstants(
       
  2511             KMediaWallGridSpringK, 
       
  2512             KMediaWallGridSpringDamping, 
       
  2513             KMediaWallGridSpringMaxVelocity, 
       
  2514             KPositionSnap, 
       
  2515             KMinSpringVelocity);
       
  2516     }
  2495     }
  2517 
  2496 
  2518 
  2497 
  2519 void CHgVgMediaWall::InitLabelsL(TInt aLayoutVariant)
  2498 void CHgVgMediaWall::InitLabelsL(TInt aLayoutVariant)
  2520     {
  2499     {
  2568             }
  2547             }
  2569         }
  2548         }
  2570     return KErrNone;
  2549     return KErrNone;
  2571     }
  2550     }
  2572 
  2551 
       
  2552 // -----------------------------------------------------------------------------
       
  2553 // CHgVgMediaWall::SetConstantsForStyle()
       
  2554 // -----------------------------------------------------------------------------
       
  2555 //
       
  2556 void CHgVgMediaWall::SetConstantsForStyle()
       
  2557     {
       
  2558     switch (iMediaWallStyle)
       
  2559         {
       
  2560         case EHgVgMediaWallStyleCoverflowFullScreen:
       
  2561             {
       
  2562             // set some factors to mediawall fullscreen mode specific values
       
  2563             iCameraZoomFactor = KMediaWallFullScreenCameraZoomFactor;
       
  2564             iCameraRotationFactor = KMediaWallFullScreenCameraRotationFactor;            
       
  2565             iItemsOnScreen = KMediaWallFullScreenItemsOnScreen;
       
  2566             iSpringVelocityToAnimationFactor = KMediaWallFullScreenSpringVelocityToAnimationFactor;
       
  2567             iItemsToMoveOnFullScreenDrag = KMediaWallFullScreenItemsToMoveOnFullScreenDrag;
       
  2568             iRowCount = KMediaWallFullScreenRowCount;
       
  2569 
       
  2570             iSpring->SetConstants(
       
  2571                     KMediaWallFullScreenSpringK, 
       
  2572                     KMediaWallFullScreenSpringDamping, 
       
  2573                     KMediaWallFullScreenSpringMaxVelocity, 
       
  2574                     KPositionSnap, KMinSpringVelocity);    
       
  2575 
       
  2576             } break;
       
  2577         
       
  2578         case EHgVgMediaWallStyleCoverflowTBonePortrait:
       
  2579             {
       
  2580             // set some factors to mediawall tbone mode specific values
       
  2581             iCameraZoomFactor = KMediaWallTBoneCameraZoomFactor;
       
  2582             iCameraRotationFactor = KMediaWallTBoneCameraRotationFactor;            
       
  2583             iItemsOnScreen = KMediaWallTBoneItemsOnScreen;
       
  2584             iSpringVelocityToAnimationFactor = KMediaWallTBoneSpringVelocityToAnimationFactor;
       
  2585             iItemsToMoveOnFullScreenDrag = KMediaWallTBoneItemsToMoveOnFullScreenDrag;
       
  2586             iRowCount = KMediaWallTBoneRowCount;
       
  2587 
       
  2588             iSpring->SetConstants(
       
  2589                     KMediaWallTBoneSpringK, 
       
  2590                     KMediaWallTBoneSpringDamping, 
       
  2591                     KMediaWallTBoneSpringMaxVelocity, 
       
  2592                     KPositionSnap, KMinSpringVelocity);
       
  2593                 
       
  2594             } break;
       
  2595         
       
  2596         case EHgVgMediaWallStyleGrid:
       
  2597             {
       
  2598             // set some factors to mediawall grid mode specific values
       
  2599             iCameraZoomFactor = KMediaWallGridCameraZoomFactor;
       
  2600             iCameraRotationFactor = KMediaWallGridCameraRotationFactor;            
       
  2601             iItemsOnScreen = KMediaWallGridItemsOnScreen;
       
  2602             iSpringVelocityToAnimationFactor = KMediaWallGridSpringVelocityToAnimationFactor;
       
  2603             iItemsToMoveOnFullScreenDrag = KMediaWallGridItemsToMoveOnFullScreenDrag;
       
  2604             iRowCount = KMediaWallGridRowCount;
       
  2605             iOpeningAnimationType = EHgVgOpeningAnimationZoomIn;
       
  2606 
       
  2607             iSpring->SetConstants(
       
  2608                     KMediaWallGridSpringK, 
       
  2609                     KMediaWallGridSpringDamping, 
       
  2610                     KMediaWallGridSpringMaxVelocity, 
       
  2611                     KPositionSnap, 
       
  2612                     KMinSpringVelocity);
       
  2613             
       
  2614             } break;
       
  2615         default: 
       
  2616             {
       
  2617             } break;
       
  2618         }
       
  2619     }
  2573 
  2620 
  2574 
  2621 
  2575 // End of File
  2622 // End of File