121 IgnoreEventsUntilNextPointerUp(); |
121 IgnoreEventsUntilNextPointerUp(); |
122 |
122 |
123 InitScreenL( aRect ); |
123 InitScreenL( aRect ); |
124 |
124 |
125 InitItemsL(); |
125 InitItemsL(); |
126 |
126 |
127 HandleViewPositionChanged(ETrue); |
127 HandleViewPositionChanged(ETrue); |
128 |
128 |
129 iCoeEnv->AddForegroundObserverL( *this ); |
129 iCoeEnv->AddForegroundObserverL( *this ); |
130 |
130 |
131 // setup Avkon gesture framework. |
131 // setup Avkon gesture framework. |
133 iTouchFw->SetGestureInterestL(AknTouchGestureFw::EAknTouchGestureFwGroupDrag | |
133 iTouchFw->SetGestureInterestL(AknTouchGestureFw::EAknTouchGestureFwGroupDrag | |
134 AknTouchGestureFw::EAknTouchGestureFwGroupTap | |
134 AknTouchGestureFw::EAknTouchGestureFwGroupTap | |
135 AknTouchGestureFw::EAknTouchGestureFwGroupFlick); |
135 AknTouchGestureFw::EAknTouchGestureFwGroupFlick); |
136 |
136 |
137 ActivateL ( ); |
137 ActivateL ( ); |
138 |
138 #ifdef MEDIAWALL_ORIENTATION_FIX |
|
139 iCoeEnv->WsSession().Flush(); |
|
140 #endif |
|
141 |
139 SetMopParent( aParent ); |
142 SetMopParent( aParent ); |
140 SetFlags( EHgVgMediaWallDrawToWindowGC | EHgVgMediaWallUninitialized ); |
143 SetFlags( EHgVgMediaWallDrawToWindowGC | EHgVgMediaWallUninitialized ); |
|
144 |
141 } |
145 } |
142 |
146 |
143 // ----------------------------------------------------------------------------- |
147 // ----------------------------------------------------------------------------- |
144 // CHgVgMediaWall::InitScreenL() |
148 // CHgVgMediaWall::InitScreenL() |
145 // ----------------------------------------------------------------------------- |
149 // ----------------------------------------------------------------------------- |
146 // |
150 // |
147 EXPORT_C void CHgVgMediaWall::InitScreenL( const TRect& aRect ) |
151 EXPORT_C void CHgVgMediaWall::InitScreenL( const TRect& aRect ) |
148 { |
152 { |
|
153 |
149 // Set the windows size |
154 // Set the windows size |
150 SetRect ( aRect ); |
155 SetRect ( aRect ); |
151 |
156 |
|
157 #ifdef MEDIAWALL_ORIENTATION_FIX |
|
158 TSize screenSize = iCoeEnv->ScreenDevice()->SizeInPixels(); |
|
159 if (aRect == TRect(TPoint(0,0), screenSize) && iMediaWallStyle == EHgVgMediaWallStyleCoverflowFullScreen) |
|
160 { |
|
161 Window().FixNativeOrientation(); |
|
162 } |
|
163 #endif |
|
164 |
152 } |
165 } |
153 |
166 |
154 // ----------------------------------------------------------------------------- |
167 // ----------------------------------------------------------------------------- |
155 // CHgVgMediaWall::RefreshScreen() |
168 // CHgVgMediaWall::RefreshScreen() |
156 // ----------------------------------------------------------------------------- |
169 // ----------------------------------------------------------------------------- |
351 // Draws the display. |
362 // Draws the display. |
352 // ----------------------------------------------------------------------------- |
363 // ----------------------------------------------------------------------------- |
353 // |
364 // |
354 void CHgVgMediaWall::Draw ( const TRect& /*aRect*/ ) const |
365 void CHgVgMediaWall::Draw ( const TRect& /*aRect*/ ) const |
355 { |
366 { |
356 //RDebug::Print(_L("CHgVgMediaWall::Draw begin")); |
|
357 |
367 |
358 if(iFlags & EHgVgMediaWallUninitialized) |
368 if(iFlags & EHgVgMediaWallUninitialized) |
359 { |
369 { |
360 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
370 FillSystemGcWithSkin( ); |
361 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
362 AknsDrawUtils::DrawBackground( skin, cc, this, SystemGc(), TPoint(0,0), |
|
363 Rect(), KAknsDrawParamDefault ); |
|
364 return; |
371 return; |
365 } |
372 } |
366 |
373 |
367 CHgVgMediaWall* self = const_cast<CHgVgMediaWall*>(this); |
374 CHgVgMediaWall* self = const_cast<CHgVgMediaWall*>(this); |
368 |
375 |
396 } |
402 } |
397 else |
403 else |
398 { |
404 { |
399 if (iSurfaceBitmap) |
405 if (iSurfaceBitmap) |
400 { |
406 { |
401 //RDebug::Print(_L("CHgVgMediaWall::Draw blit screenshot")); |
|
402 |
|
403 SystemGc().BitBlt( Rect().iTl, iSurfaceBitmap ); |
407 SystemGc().BitBlt( Rect().iTl, iSurfaceBitmap ); |
404 } |
408 } |
405 else |
409 else |
406 { |
410 { |
407 //RDebug::Print(_L("CHgVgMediaWall::Draw clear red")); |
411 FillSystemGcWithSkin( ); |
408 |
412 } |
409 // we should not get here, ever |
413 } |
410 // still, clear with red color for debug purposes |
414 |
411 SystemGc().SetBrushColor(KRgbRed); |
415 } |
412 SystemGc().Clear(); |
416 |
413 } |
417 void CHgVgMediaWall::FillSystemGcWithSkin( ) const |
414 } |
418 { |
415 |
419 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
416 //RDebug::Print(_L("CHgVgMediaWall::Draw end")); |
420 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
417 |
421 AknsDrawUtils::DrawBackground( skin, cc, this, SystemGc(), TPoint(0,0), |
|
422 Rect(), KAknsDrawParamDefault ); |
418 } |
423 } |
419 |
424 |
420 // ----------------------------------------------------------------------------- |
425 // ----------------------------------------------------------------------------- |
421 // CHgVgMediaWall::SizeChanged() |
426 // CHgVgMediaWall::SizeChanged() |
422 // Called by framework when the view size is changed. |
427 // Called by framework when the view size is changed. |
1085 CFbsBitmap* CHgVgMediaWall::DrawToBitmap() |
1090 CFbsBitmap* CHgVgMediaWall::DrawToBitmap() |
1086 { |
1091 { |
1087 |
1092 |
1088 if (!DrawAll()) |
1093 if (!DrawAll()) |
1089 return NULL; |
1094 return NULL; |
1090 |
1095 |
1091 return iEGL->GetSurfaceToBitmap(iRect); |
1096 #ifdef MEDIAWALL_ORIENTATION_FIX |
1092 |
1097 return iEGL->GetSurfaceToBitmap(iRect, iMediaWallStyle == EHgVgMediaWallStyleCoverflowFullScreen); |
|
1098 #else |
|
1099 return iEGL->GetSurfaceToBitmap(iRect, EFalse); |
|
1100 #endif |
|
1101 |
1093 } |
1102 } |
1094 |
1103 |
1095 // ----------------------------------------------------------------------------- |
1104 // ----------------------------------------------------------------------------- |
1096 // CHgVgMediaWall::InitDefaultIconL() |
1105 // CHgVgMediaWall::InitDefaultIconL() |
1097 // ----------------------------------------------------------------------------- |
1106 // ----------------------------------------------------------------------------- |
1199 // CHgVgMediaWall::HandleGainingForeground() |
1208 // CHgVgMediaWall::HandleGainingForeground() |
1200 // --------------------------------------------------------------------------- |
1209 // --------------------------------------------------------------------------- |
1201 // |
1210 // |
1202 void CHgVgMediaWall::HandleGainingForeground() |
1211 void CHgVgMediaWall::HandleGainingForeground() |
1203 { |
1212 { |
|
1213 if(iIsForeground) return; // don't react to gaining foreground without losing it |
1204 |
1214 |
1205 // draw previous screenshot |
1215 // draw previous screenshot |
1206 DrawNow(); |
1216 DrawNow(); |
1207 |
1217 |
1208 // delete it |
1218 // delete it |
1226 // CHgVgMediaWall::HandleLosingForeground() |
1236 // CHgVgMediaWall::HandleLosingForeground() |
1227 // --------------------------------------------------------------------------- |
1237 // --------------------------------------------------------------------------- |
1228 // |
1238 // |
1229 void CHgVgMediaWall::HandleLosingForeground() |
1239 void CHgVgMediaWall::HandleLosingForeground() |
1230 { |
1240 { |
|
1241 if(!iIsForeground) return; // don't react to losing foreground without gaining it |
1231 |
1242 |
1232 // make sure we are not animating |
1243 // make sure we are not animating |
1233 HandleTransitionAnimationStop(); |
1244 HandleTransitionAnimationStop(); |
1234 |
1245 |
1235 if (iAnimationTimer->IsActive()) |
1246 if (iAnimationTimer->IsActive()) |
1383 } |
1392 } |
1384 else |
1393 else |
1385 { |
1394 { |
1386 // update view position dependant stuff |
1395 // update view position dependant stuff |
1387 HandleViewPositionChanged(ETrue); |
1396 HandleViewPositionChanged(ETrue); |
|
1397 |
|
1398 // inform observer when needed |
|
1399 if (!iObserverNotified) |
|
1400 { |
|
1401 if (Abs(iSpring->GetX() - iSpring->EndX()) < KHalfItemWidth) |
|
1402 { |
|
1403 iObserverNotified = ETrue; |
|
1404 TRAP_IGNORE( |
|
1405 iSelectionObserver->HandleSelectL((int)iSpring->EndX(), this); ) |
|
1406 } |
|
1407 } |
1388 } |
1408 } |
1389 |
1409 |
1390 } |
1410 } |
1391 |
1411 |
1392 void CHgVgMediaWall::HandleTransitionAnimationStop() |
1412 void CHgVgMediaWall::HandleTransitionAnimationStop() |
1555 |
1575 |
1556 iScrollBar = CHgVgScrollBar::NewL(*this, iRect, |
1576 iScrollBar = CHgVgScrollBar::NewL(*this, iRect, |
1557 TSize(MaxViewPosition(), 1), TSize(1, 1), |
1577 TSize(MaxViewPosition(), 1), TSize(1, 1), |
1558 ETrue, CHgScroller::EHgScrollerScrollBar); |
1578 ETrue, CHgScroller::EHgScrollerScrollBar); |
1559 |
1579 |
1560 iScrollBar->SetViewPosition( TPoint(iSelectedIndex, 0) ); |
1580 iScrollBar->SetViewPosition( TPoint(iSelectedIndex, 0) ); |
|
1581 |
1561 } |
1582 } |
1562 |
1583 |
1563 // --------------------------------------------------------------------------- |
1584 // --------------------------------------------------------------------------- |
1564 // CHgVgMediaWall::InitRenderingL() |
1585 // CHgVgMediaWall::InitRenderingL() |
1565 // Inits all rendering. |
1586 // Inits all rendering. |
1575 else |
1596 else |
1576 { |
1597 { |
1577 if (aRecreateSurface) |
1598 if (aRecreateSurface) |
1578 iEGL->InitWindowSurfaceL(Window()); |
1599 iEGL->InitWindowSurfaceL(Window()); |
1579 } |
1600 } |
|
1601 |
1580 |
1602 |
1581 delete iRenderer; iRenderer = NULL; |
1603 delete iRenderer; iRenderer = NULL; |
1582 delete iArtistLabel; iArtistLabel = NULL; |
1604 delete iArtistLabel; iArtistLabel = NULL; |
1583 delete iAlbumLabel; iAlbumLabel = NULL; |
1605 delete iAlbumLabel; iAlbumLabel = NULL; |
1584 delete iLetterPopup; iLetterPopup = NULL; |
1606 delete iLetterPopup; iLetterPopup = NULL; |
1638 rect.LayoutRect(iRect, AknLayoutScalable_Apps::main_cf0_pane_g1(0)); |
1660 rect.LayoutRect(iRect, AknLayoutScalable_Apps::main_cf0_pane_g1(0)); |
1639 |
1661 |
1640 iHideSKButton = CHgVgButton::NewL(rect.Rect().Size(), rect.Rect().iTl, *icon); |
1662 iHideSKButton = CHgVgButton::NewL(rect.Rect().Size(), rect.Rect().iTl, *icon); |
1641 |
1663 |
1642 CleanupStack::PopAndDestroy(icon); |
1664 CleanupStack::PopAndDestroy(icon); |
1643 |
1665 |
1644 } |
1666 } |
1645 |
1667 |
1646 |
1668 |
1647 // --------------------------------------------------------------------------- |
1669 // --------------------------------------------------------------------------- |
1648 // CHgVgMediaWall::CreateIconL() |
1670 // CHgVgMediaWall::CreateIconL() |
1898 // --------------------------------------------------------------------------- |
1920 // --------------------------------------------------------------------------- |
1899 // |
1921 // |
1900 void CHgVgMediaWall::DrawScene() |
1922 void CHgVgMediaWall::DrawScene() |
1901 { |
1923 { |
1902 |
1924 |
1903 TReal t = iSpring->VelX() / iSpringVelocityToAnimationFactor; |
1925 TReal springVel = iSpring->VelX(); |
1904 if (Abs(t) > 1.0f) |
1926 if (iPointerDown) |
1905 t = t / Abs(t); |
1927 springVel = iSpringDragVel; |
1906 |
1928 |
|
1929 TReal t = springVel / iSpringVelocityToAnimationFactor; |
|
1930 if (t > 1.0f) |
|
1931 t = 1.0f; |
|
1932 else if (t < -1.0f) |
|
1933 t = -1.0f; |
|
1934 |
1907 if (AknLayoutUtils::LayoutMirrored()) |
1935 if (AknLayoutUtils::LayoutMirrored()) |
1908 t = -t; |
1936 t = -t; |
|
1937 |
1909 |
1938 |
1910 iRenderer->SetCameraRotation(-t * iCameraRotationFactor); |
1939 iRenderer->SetCameraRotation(-t * iCameraRotationFactor); |
1911 |
1940 |
1912 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
1941 if (iMediaWallStyle == EHgVgMediaWallStyleGrid) |
1913 { |
1942 { |
1919 iSelGridItem, iPrevGridItem, iAnimationAlpha, iAnimationState, |
1948 iSelGridItem, iPrevGridItem, iAnimationAlpha, iAnimationState, |
1920 iPickedGridItem, iOpeningAnimationType); |
1949 iPickedGridItem, iOpeningAnimationType); |
1921 } |
1950 } |
1922 else |
1951 else |
1923 { |
1952 { |
|
1953 |
1924 iRenderer->Draw(iItems, /*iSelectedIndex*/iSpring->GetX(), iSpring->EndX(), |
1954 iRenderer->Draw(iItems, /*iSelectedIndex*/iSpring->GetX(), iSpring->EndX(), |
1925 iSpring->GetInterpolatedX(), iAnimationAlpha, iAnimationState, |
1955 iSpring->GetInterpolatedX(), iAnimationAlpha, iAnimationState, |
1926 iOpeningAnimationType, iMediaWallStyle, iSpring->StartX()); |
1956 iOpeningAnimationType, iMediaWallStyle, iSpring->StartX(), springVel); |
1927 } |
1957 } |
1928 } |
1958 } |
1929 |
1959 |
1930 // --------------------------------------------------------------------------- |
1960 // --------------------------------------------------------------------------- |
1931 // CHgVgMediaWall::HandleDragStart() |
1961 // CHgVgMediaWall::HandleDragStart() |
1939 { |
1969 { |
1940 iAnimationTimer->Cancel(); |
1970 iAnimationTimer->Cancel(); |
1941 if (iMediaWallStyle != EHgVgMediaWallStyleGrid) |
1971 if (iMediaWallStyle != EHgVgMediaWallStyleGrid) |
1942 { |
1972 { |
1943 iSpring->SetEnd(iSelectedIndex, iSpring->EndY()); |
1973 iSpring->SetEnd(iSelectedIndex, iSpring->EndY()); |
1944 } |
1974 } |
1945 } |
1975 |
|
1976 iSpringVelAtDragStart = iSpringDragVel = iSpring->VelX(); |
|
1977 } |
|
1978 else |
|
1979 { |
|
1980 iSpringVelAtDragStart = iSpringDragVel = 0; |
|
1981 } |
1946 |
1982 |
1947 iPointerDown = ETrue; |
1983 iPointerDown = ETrue; |
|
1984 iDragFrames = 0; |
1948 iViewPositionAtDragStart = iSpring->GetX(); |
1985 iViewPositionAtDragStart = iSpring->GetX(); |
1949 } |
1986 } |
1950 |
1987 |
1951 // --------------------------------------------------------------------------- |
1988 // --------------------------------------------------------------------------- |
1952 // CHgVgMediaWall::HandleDragOn() |
1989 // CHgVgMediaWall::HandleDragOn() |
1976 { |
2013 { |
1977 // for normal mediawall we move view position according to drag |
2014 // for normal mediawall we move view position according to drag |
1978 TReal x = iViewPositionAtDragStart + fDelta * iItemsToMoveOnFullScreenDrag; |
2015 TReal x = iViewPositionAtDragStart + fDelta * iItemsToMoveOnFullScreenDrag; |
1979 iUpdateScrollBar = ETrue; |
2016 iUpdateScrollBar = ETrue; |
1980 iSpring->Reset(x, 0); |
2017 iSpring->Reset(x, 0); |
|
2018 |
|
2019 // interpolate velocity during frame count to zero |
|
2020 TReal t = (TReal)iDragFrames/(TReal)KFramesToZeroVelocity; |
|
2021 if (t > 1.0f) t = 1.0f; |
|
2022 iSpringDragVel = iSpringVelAtDragStart * (1.0f - t); |
|
2023 |
|
2024 iDragFrames++; |
|
2025 |
1981 HandleViewPositionChanged(ETrue); |
2026 HandleViewPositionChanged(ETrue); |
1982 // draw view at new view position |
2027 // draw view at new view position |
1983 DrawOpenVG(); |
2028 DrawOpenVG(); |
1984 } |
2029 } |
1985 } |
2030 } |
2198 void CHgVgMediaWall::StartAnimationToPosition(TReal aX, TReal aY, TBool aUpdateScrollBar) |
2243 void CHgVgMediaWall::StartAnimationToPosition(TReal aX, TReal aY, TBool aUpdateScrollBar) |
2199 { |
2244 { |
2200 iSpring->SetEnd(aX, aY); |
2245 iSpring->SetEnd(aX, aY); |
2201 iUpdateScrollBar = aUpdateScrollBar; |
2246 iUpdateScrollBar = aUpdateScrollBar; |
2202 iAnimationState = EHgVgMediaWallAnimationStateTransition; |
2247 iAnimationState = EHgVgMediaWallAnimationStateTransition; |
|
2248 iObserverNotified = EFalse; |
2203 StartAnimationTimer(); |
2249 StartAnimationTimer(); |
2204 } |
2250 } |
2205 |
2251 |
2206 // ----------------------------------------------------------------------------- |
2252 // ----------------------------------------------------------------------------- |
2207 // CHgVgMediaWall::SetFlags() |
2253 // CHgVgMediaWall::SetFlags() |
2356 KMediaWallFullScreenSpringK, |
2402 KMediaWallFullScreenSpringK, |
2357 KMediaWallFullScreenSpringDamping, |
2403 KMediaWallFullScreenSpringDamping, |
2358 KMediaWallFullScreenSpringMaxVelocity, |
2404 KMediaWallFullScreenSpringMaxVelocity, |
2359 KPositionSnap, KMinSpringVelocity); |
2405 KPositionSnap, KMinSpringVelocity); |
2360 |
2406 |
|
2407 #ifdef MEDIAWALL_ORIENTATION_FIX |
|
2408 iRenderer->EnableLandscapeMode(ETrue); |
|
2409 iAlbumLabel->EnableLandscapeRendering(ETrue); |
|
2410 iArtistLabel->EnableLandscapeRendering(ETrue); |
|
2411 iEmptyLabel->EnableLandscapeRendering(ETrue); |
|
2412 iSkinRenderer->EnableLanscapeRendering(ETrue); |
|
2413 iScrollBar->EnableLandscapeRendering(ETrue); |
|
2414 iHideSKButton->EnableLandscapeRendering(ETrue); |
|
2415 iLetterPopup->EnableLandscapeRendering(ETrue); |
|
2416 #endif |
|
2417 |
2361 } |
2418 } |
2362 |
2419 |
2363 // ----------------------------------------------------------------------------- |
2420 // ----------------------------------------------------------------------------- |
2364 // CHgVgMediaWall::CreateMediaWallTBonePortraitL() |
2421 // CHgVgMediaWall::CreateMediaWallTBonePortraitL() |
2365 // ----------------------------------------------------------------------------- |
2422 // ----------------------------------------------------------------------------- |
2456 iAlbumLabel = CHgVgLabel::NewL( t0.TextRect() ); |
2513 iAlbumLabel = CHgVgLabel::NewL( t0.TextRect() ); |
2457 |
2514 |
2458 iArtistLabel = CHgVgLabel::NewL( t1.TextRect() ); |
2515 iArtistLabel = CHgVgLabel::NewL( t1.TextRect() ); |
2459 |
2516 |
2460 iAlbumLabel->SetLayout(l0, iRect); |
2517 iAlbumLabel->SetLayout(l0, iRect); |
2461 iArtistLabel->SetLayout(l1, iRect); |
2518 iArtistLabel->SetLayout(l1, iRect); |
|
2519 |
|
2520 |
2462 } |
2521 } |
2463 |
2522 |
2464 void CHgVgMediaWall::InitPopupL(TInt aLayoutVariant) |
2523 void CHgVgMediaWall::InitPopupL(TInt aLayoutVariant) |
2465 { |
2524 { |
2466 TAknLayoutRect popupRect; |
2525 TAknLayoutRect popupRect; |
2467 popupRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g2(aLayoutVariant) ); |
2526 popupRect.LayoutRect( iRect, AknLayoutScalable_Apps::cf0_flow_pane_g2(aLayoutVariant) ); |
2468 iLetterPopup = CHgVgPopup::NewL(popupRect.Rect(), |
2527 iLetterPopup = CHgVgPopup::NewL(popupRect.Rect(), |
2469 &ScreenFont( TCoeFont( KMediaWallTBonePopupFontSize, TCoeFont::EPlain ))); |
2528 &ScreenFont( TCoeFont( KMediaWallTBonePopupFontSize, TCoeFont::EPlain ))); |
2470 |
2529 |
2471 iLetterPopup->SetLayouts(AknLayoutScalable_Apps::cf0_flow_pane_g2(aLayoutVariant), |
2530 iLetterPopup->SetLayouts(AknLayoutScalable_Apps::cf0_flow_pane_g2(aLayoutVariant), |
2472 AknLayoutScalable_Apps::cf0_flow_pane_t1(aLayoutVariant), iRect); |
2531 AknLayoutScalable_Apps::cf0_flow_pane_t1(aLayoutVariant), iRect); |
|
2532 |
2473 } |
2533 } |
2474 |
2534 |
2475 // ----------------------------------------------------------------------------- |
2535 // ----------------------------------------------------------------------------- |
2476 // CHgVgMediaWall::DelayedInit() |
2536 // CHgVgMediaWall::DelayedInit() |
2477 // ----------------------------------------------------------------------------- |
2537 // ----------------------------------------------------------------------------- |