diff -r aabf2c525e0f -r 9f56a4e1b8ab uifw/ganes/src/HgVgMediaWall.cpp --- a/uifw/ganes/src/HgVgMediaWall.cpp Fri Mar 12 15:43:43 2010 +0200 +++ b/uifw/ganes/src/HgVgMediaWall.cpp Mon Mar 15 12:41:34 2010 +0200 @@ -123,7 +123,7 @@ InitScreenL( aRect ); InitItemsL(); - + HandleViewPositionChanged(ETrue); iCoeEnv->AddForegroundObserverL( *this ); @@ -135,9 +135,13 @@ AknTouchGestureFw::EAknTouchGestureFwGroupFlick); ActivateL ( ); - +#ifdef MEDIAWALL_ORIENTATION_FIX + iCoeEnv->WsSession().Flush(); +#endif + SetMopParent( aParent ); SetFlags( EHgVgMediaWallDrawToWindowGC | EHgVgMediaWallUninitialized ); + } // ----------------------------------------------------------------------------- @@ -145,10 +149,19 @@ // ----------------------------------------------------------------------------- // EXPORT_C void CHgVgMediaWall::InitScreenL( const TRect& aRect ) - { + { + // Set the windows size SetRect ( aRect ); - + +#ifdef MEDIAWALL_ORIENTATION_FIX + TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels(); + if (aRect == TRect(TPoint(0,0), screenSize) && iMediaWallStyle == EHgVgMediaWallStyleCoverflowFullScreen) + { + Window().FixNativeOrientation(); + } +#endif + } // ----------------------------------------------------------------------------- @@ -162,8 +175,6 @@ { return; } - - //RDebug::Print(_L("\t\tMediaWall FirstIndexOnScreen=%d"), FirstIndexOnScreen()); if( !iAnimationTimer->IsActive() ) { @@ -353,14 +364,10 @@ // void CHgVgMediaWall::Draw ( const TRect& /*aRect*/ ) const { - //RDebug::Print(_L("CHgVgMediaWall::Draw begin")); if(iFlags & EHgVgMediaWallUninitialized) { - MAknsSkinInstance* skin = AknsUtils::SkinInstance(); - MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); - AknsDrawUtils::DrawBackground( skin, cc, this, SystemGc(), TPoint(0,0), - Rect(), KAknsDrawParamDefault ); + FillSystemGcWithSkin( ); return; } @@ -379,8 +386,7 @@ } else { - SystemGc().SetBrushColor(KRgbRed); - SystemGc().Clear(); + FillSystemGcWithSkin( ); } } else @@ -398,23 +404,22 @@ { if (iSurfaceBitmap) { - //RDebug::Print(_L("CHgVgMediaWall::Draw blit screenshot")); - SystemGc().BitBlt( Rect().iTl, iSurfaceBitmap ); } else { - //RDebug::Print(_L("CHgVgMediaWall::Draw clear red")); - - // we should not get here, ever - // still, clear with red color for debug purposes - SystemGc().SetBrushColor(KRgbRed); - SystemGc().Clear(); + FillSystemGcWithSkin( ); } } + + } - //RDebug::Print(_L("CHgVgMediaWall::Draw end")); - +void CHgVgMediaWall::FillSystemGcWithSkin( ) const + { + MAknsSkinInstance* skin = AknsUtils::SkinInstance(); + MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); + AknsDrawUtils::DrawBackground( skin, cc, this, SystemGc(), TPoint(0,0), + Rect(), KAknsDrawParamDefault ); } // ----------------------------------------------------------------------------- @@ -1087,9 +1092,13 @@ if (!DrawAll()) return NULL; - - return iEGL->GetSurfaceToBitmap(iRect); - + +#ifdef MEDIAWALL_ORIENTATION_FIX + return iEGL->GetSurfaceToBitmap(iRect, iMediaWallStyle == EHgVgMediaWallStyleCoverflowFullScreen); +#else + return iEGL->GetSurfaceToBitmap(iRect, EFalse); +#endif + } // ----------------------------------------------------------------------------- @@ -1201,6 +1210,7 @@ // void CHgVgMediaWall::HandleGainingForeground() { + if(iIsForeground) return; // don't react to gaining foreground without losing it // draw previous screenshot DrawNow(); @@ -1228,6 +1238,7 @@ // void CHgVgMediaWall::HandleLosingForeground() { + if(!iIsForeground) return; // don't react to losing foreground without gaining it // make sure we are not animating HandleTransitionAnimationStop(); @@ -1277,8 +1288,6 @@ CHgVgMediaWall* self = const_cast(this); - //RDebug::Print(_L("\t\tMediaWall FirstIndexOnScreen=%d"), self->FirstIndexOnScreen()); - if (!self->DrawAll()) return; @@ -1385,6 +1394,17 @@ { // update view position dependant stuff HandleViewPositionChanged(ETrue); + + // inform observer when needed + if (!iObserverNotified) + { + if (Abs(iSpring->GetX() - iSpring->EndX()) < KHalfItemWidth) + { + iObserverNotified = ETrue; + TRAP_IGNORE( + iSelectionObserver->HandleSelectL((int)iSpring->EndX(), this); ) + } + } } } @@ -1402,7 +1422,7 @@ iAnimationTimer->Cancel(); // handle view position change - HandleViewPositionChanged(); + HandleViewPositionChanged(EFalse); } } @@ -1557,7 +1577,8 @@ TSize(MaxViewPosition(), 1), TSize(1, 1), ETrue, CHgScroller::EHgScrollerScrollBar); - iScrollBar->SetViewPosition( TPoint(iSelectedIndex, 0) ); + iScrollBar->SetViewPosition( TPoint(iSelectedIndex, 0) ); + } // --------------------------------------------------------------------------- @@ -1578,6 +1599,7 @@ iEGL->InitWindowSurfaceL(Window()); } + delete iRenderer; iRenderer = NULL; delete iArtistLabel; iArtistLabel = NULL; delete iAlbumLabel; iAlbumLabel = NULL; @@ -1640,7 +1662,7 @@ iHideSKButton = CHgVgButton::NewL(rect.Rect().Size(), rect.Rect().iTl, *icon); CleanupStack::PopAndDestroy(icon); - + } @@ -1900,13 +1922,20 @@ void CHgVgMediaWall::DrawScene() { - TReal t = iSpring->VelX() / iSpringVelocityToAnimationFactor; - if (Abs(t) > 1.0f) - t = t / Abs(t); - + TReal springVel = iSpring->VelX(); + if (iPointerDown) + springVel = iSpringDragVel; + + TReal t = springVel / iSpringVelocityToAnimationFactor; + if (t > 1.0f) + t = 1.0f; + else if (t < -1.0f) + t = -1.0f; + if (AknLayoutUtils::LayoutMirrored()) t = -t; + iRenderer->SetCameraRotation(-t * iCameraRotationFactor); if (iMediaWallStyle == EHgVgMediaWallStyleGrid) @@ -1921,9 +1950,10 @@ } else { + iRenderer->Draw(iItems, /*iSelectedIndex*/iSpring->GetX(), iSpring->EndX(), iSpring->GetInterpolatedX(), iAnimationAlpha, iAnimationState, - iOpeningAnimationType, iMediaWallStyle, iSpring->StartX()); + iOpeningAnimationType, iMediaWallStyle, iSpring->StartX(), springVel); } } @@ -1941,10 +1971,17 @@ if (iMediaWallStyle != EHgVgMediaWallStyleGrid) { iSpring->SetEnd(iSelectedIndex, iSpring->EndY()); - } + } + + iSpringVelAtDragStart = iSpringDragVel = iSpring->VelX(); } + else + { + iSpringVelAtDragStart = iSpringDragVel = 0; + } iPointerDown = ETrue; + iDragFrames = 0; iViewPositionAtDragStart = iSpring->GetX(); } @@ -1978,6 +2015,14 @@ TReal x = iViewPositionAtDragStart + fDelta * iItemsToMoveOnFullScreenDrag; iUpdateScrollBar = ETrue; iSpring->Reset(x, 0); + + // interpolate velocity during frame count to zero + TReal t = (TReal)iDragFrames/(TReal)KFramesToZeroVelocity; + if (t > 1.0f) t = 1.0f; + iSpringDragVel = iSpringVelAtDragStart * (1.0f - t); + + iDragFrames++; + HandleViewPositionChanged(ETrue); // draw view at new view position DrawOpenVG(); @@ -2200,6 +2245,7 @@ iSpring->SetEnd(aX, aY); iUpdateScrollBar = aUpdateScrollBar; iAnimationState = EHgVgMediaWallAnimationStateTransition; + iObserverNotified = EFalse; StartAnimationTimer(); } @@ -2358,6 +2404,17 @@ KMediaWallFullScreenSpringMaxVelocity, KPositionSnap, KMinSpringVelocity); +#ifdef MEDIAWALL_ORIENTATION_FIX + iRenderer->EnableLandscapeMode(ETrue); + iAlbumLabel->EnableLandscapeRendering(ETrue); + iArtistLabel->EnableLandscapeRendering(ETrue); + iEmptyLabel->EnableLandscapeRendering(ETrue); + iSkinRenderer->EnableLanscapeRendering(ETrue); + iScrollBar->EnableLandscapeRendering(ETrue); + iHideSKButton->EnableLandscapeRendering(ETrue); + iLetterPopup->EnableLandscapeRendering(ETrue); +#endif + } // ----------------------------------------------------------------------------- @@ -2458,7 +2515,9 @@ iArtistLabel = CHgVgLabel::NewL( t1.TextRect() ); iAlbumLabel->SetLayout(l0, iRect); - iArtistLabel->SetLayout(l1, iRect); + iArtistLabel->SetLayout(l1, iRect); + + } void CHgVgMediaWall::InitPopupL(TInt aLayoutVariant) @@ -2469,7 +2528,8 @@ &ScreenFont( TCoeFont( KMediaWallTBonePopupFontSize, TCoeFont::EPlain ))); iLetterPopup->SetLayouts(AknLayoutScalable_Apps::cf0_flow_pane_g2(aLayoutVariant), - AknLayoutScalable_Apps::cf0_flow_pane_t1(aLayoutVariant), iRect); + AknLayoutScalable_Apps::cf0_flow_pane_t1(aLayoutVariant), iRect); + } // ----------------------------------------------------------------------------- @@ -2494,4 +2554,5 @@ } + // End of File