uifw/ganes/src/HgVgMediaWallRenderer.cpp
changeset 14 3320e4e6e8bb
parent 0 2f259fa3e83a
equal deleted inserted replaced
0:2f259fa3e83a 14:3320e4e6e8bb
   475         TInt aSelectedIndex, TReal aNextIndex,
   475         TInt aSelectedIndex, TReal aNextIndex,
   476         TReal aViewPosition,
   476         TReal aViewPosition,
   477         TReal aAnimationAlpha,
   477         TReal aAnimationAlpha,
   478         CHgVgMediaWall::THgVgAnimationState aState, 
   478         CHgVgMediaWall::THgVgAnimationState aState, 
   479         CHgVgMediaWall::THgVgOpeningAnimationType aSelectionAnimationType, 
   479         CHgVgMediaWall::THgVgOpeningAnimationType aSelectionAnimationType, 
   480         CHgVgMediaWall::THgVgMediaWallStyle /*aStyle*/,
   480         CHgVgMediaWall::THgVgMediaWallStyle /*aStyle*/)
   481         TReal aStartIndex)
       
   482     { 
   481     { 
   483     
   482     
   484     TInt itemsOnScreen = 0;
   483     TInt itemsOnScreen = 0;
   485     itemsOnScreen = SetupQuads(aItems,
   484     itemsOnScreen = SetupQuads(aItems,
   486             aSelectedIndex, aNextIndex,
   485             aSelectedIndex, aNextIndex,
   487             aViewPosition,
   486             aViewPosition,
   488             aAnimationAlpha,
   487             aAnimationAlpha,
   489             aState, aSelectionAnimationType, aStartIndex);
   488             aState, aSelectionAnimationType);
   490     
   489     
   491     TransformAndDraw(itemsOnScreen, aSelectionAnimationType);
   490     TransformAndDraw(itemsOnScreen, aSelectionAnimationType);
   492     }
   491     }
   493 
   492 
   494 
   493 
   520     }
   519     }
   521 
   520 
   522 
   521 
   523 TReal CHgVgMediaWallRenderer::GetWorldSpaceRowHeight() const
   522 TReal CHgVgMediaWallRenderer::GetWorldSpaceRowHeight() const
   524     {
   523     {
   525     // TODO: replace these macig numbers
       
   526     return (120.0 / 90.0 * 0.25 + 0.02);
   524     return (120.0 / 90.0 * 0.25 + 0.02);
   527     }
   525     }
   528 
   526 
   529 
   527 
   530 // ---------------------------------------------------------------------------
   528 // ---------------------------------------------------------------------------
   531 // CHgVgCoverflowRenderer::CreateGround()
   529 // CHgVgCoverflowRenderer::CreateGround()
   532 // ---------------------------------------------------------------------------
   530 // ---------------------------------------------------------------------------
   533 //     
   531 //     
   534 void CHgVgMediaWallRenderer::CreateGround()
   532 void CHgVgMediaWallRenderer::CreateGround()
   535 {
   533 {
   536     // Create path and paint for drawing ground plane
       
   537     
       
   538     iGroundPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, KGroundScale, KGroundBias, 
   534     iGroundPath = vgCreatePath(VG_PATH_FORMAT_STANDARD, VG_PATH_DATATYPE_F, KGroundScale, KGroundBias, 
   539             KGroundVerticesHint, KGroundSegmentsHint, (unsigned int)VG_PATH_CAPABILITY_ALL);
   535             KGroundVerticesHint, KGroundSegmentsHint, (unsigned int)VG_PATH_CAPABILITY_ALL);
   540     
   536     
   541     vguRect(iGroundPath, 0, 0, 1, 1);
   537     vguRect(iGroundPath, 0, 0, 1, 1);
   542         
   538         
   755 TInt CHgVgMediaWallRenderer::SetupQuads(RPointerArray<CHgVgItem>& aItems,
   751 TInt CHgVgMediaWallRenderer::SetupQuads(RPointerArray<CHgVgItem>& aItems,
   756         TInt aSelectedIndex, TReal aNextIndex,
   752         TInt aSelectedIndex, TReal aNextIndex,
   757         VGfloat aViewPosition,
   753         VGfloat aViewPosition,
   758         VGfloat aAnimationAlpha,
   754         VGfloat aAnimationAlpha,
   759         CHgVgMediaWall::THgVgAnimationState aState, 
   755         CHgVgMediaWall::THgVgAnimationState aState, 
   760         CHgVgMediaWall::THgVgOpeningAnimationType aOpeningAnimationType, 
   756         CHgVgMediaWall::THgVgOpeningAnimationType aOpeningAnimationType)
   761         TReal aStartIndex)
       
   762     {
   757     {
   763     
   758     
   764     
   759     
   765     if (aItems.Count() <= 0)
   760     if (aItems.Count() <= 0)
   766         return 0;
   761         return 0;
   779     TReal src = aViewPosition;
   774     TReal src = aViewPosition;
   780     TReal frac;
   775     TReal frac;
   781     Math::Frac(frac, src);
   776     Math::Frac(frac, src);
   782     VGfloat fDiff = frac;
   777     VGfloat fDiff = frac;
   783             
   778             
       
   779     VGfloat zFar = iZFar;
   784     VGfloat leftIndex = (VGfloat)(iSelectedItemIndex - 1);
   780     VGfloat leftIndex = (VGfloat)(iSelectedItemIndex - 1);
       
   781     VGfloat rightIndex = (VGfloat)(iSelectedItemIndex + 1);
       
   782     VGfloat centerIndex = (VGfloat)iSelectedItemIndex;
   785     VGfloat leftX = iLeftStackEndX;
   783     VGfloat leftX = iLeftStackEndX;
       
   784     VGfloat rightX = iRightStackStartX;
   786     VGfloat step = iSpaceBetween;
   785     VGfloat step = iSpaceBetween;
   787 
   786     VGfloat centerX = 0;
   788     // support mirrored layouts (right-to-left reading)
   787     
   789     if (AknLayoutUtils::LayoutMirrored())
   788     if (AknLayoutUtils::LayoutMirrored())
   790         {
   789         {
   791         leftX = -iLeftStackEndX;
   790         rightX = iLeftStackEndX;
       
   791         leftX = iRightStackStartX;
   792         step = -step;
   792         step = -step;
   793         }
   793         }
   794     
   794         
   795     TInt i = 0;
   795     TInt i = 0;
   796     TInt itemsOnScreen = 0;
   796     TInt itemsOnScreen = 0;
   797     TInt currentRow = (TInt)aViewPosition - KSelectedItemIndex;
   797     TInt currentRow = (TInt)aViewPosition - KSelectedItemIndex;
   798         
   798     
       
   799     TReal dist = Min(Max(0, Abs(aNextIndex - aViewPosition) - 1.0f), 1.0f);
       
   800     VGfloat zNear = HgVgHelper::Lerp(iZNear, iZFar, dist);
       
   801     
   799     while (itemsOnScreen < iQuads.Count())
   802     while (itemsOnScreen < iQuads.Count())
   800         {
   803         {
   801         TInt itemIndex = currentRow + i;
   804         TInt itemIndex = currentRow + i;
   802 
   805         
   803         // not really an item
       
   804         if (itemIndex < 0)
   806         if (itemIndex < 0)
   805             {
   807             {
   806             i++;
   808             i++;
   807             continue;
   809             continue;
   808             }
   810             }
   809         
   811         
   810         // got past all items
       
   811         if (itemIndex  >= aItems.Count())
   812         if (itemIndex  >= aItems.Count())
   812             {
   813             {
   813             break;
   814             break;
   814             }
   815             }
   815 
   816 
   816         // setup quads to represent coverflow
       
   817         TQuad* q = iQuads[itemsOnScreen];        
   817         TQuad* q = iQuads[itemsOnScreen];        
   818 
   818 
   819         q->iY = 0;
   819         q->iY = 0;
   820         q->iZ = iZFar;
   820         q->iZ = zFar;
   821         q->iAngle = 0;
   821         q->iAngle = 0;
   822 
       
   823         q->iFlipped = EFalse;
   822         q->iFlipped = EFalse;
   824 
   823             
   825         VGfloat fi = (VGfloat)i - fDiff;
   824         VGfloat fi = (VGfloat)i - fDiff;
   826         
   825         
   827         q->iX = leftX - step * (leftIndex - fi);
   826         if (fi < leftIndex)
   828         
   827             {
   829         
   828             q->iX = leftX - step * (leftIndex - fi);
   830         if (aStartIndex != aNextIndex)
   829             }
   831             {
   830         else if (fi >= leftIndex && fi < centerIndex)
   832             // if start and next index are not same, we can just interpolate
   831             {
   833             // items at these indices.
   832             q->iX = HgVgHelper::Lerp(leftX, centerX, fi - leftIndex);
   834             if (itemIndex == (TInt)aStartIndex ||
   833             q->iZ = HgVgHelper::Lerp(zFar, zNear, fi - leftIndex);                                            
   835                     itemIndex == (TInt)aNextIndex)
   834             }
   836                 {
   835         else if (fi >= centerIndex && fi < rightIndex)
   837                 q->iZ = HgVgHelper::Lerp((VGfloat)iZNear, (VGfloat)iZFar, Abs(q->iX / leftX));
   836             {
   838                 q->iZ = Min(q->iZ, (VGfloat)iZFar);            
   837             q->iX = HgVgHelper::Lerp(centerX, rightX, fi - centerIndex);
   839                 }
   838             q->iZ = HgVgHelper::Lerp(zNear, zFar, fi - centerIndex);            
   840             }
   839             }
   841         else
   840         else if (fi >= rightIndex)
   842             {
   841             {
   843             // in this case we are just dragging and startindex and left index are
   842             q->iX = rightX + step * (fi - rightIndex);
   844             // same so we need to interpolate z for all items coming/leaving center 
   843             }
   845             // of the screen.
   844         
   846             q->iZ = HgVgHelper::Lerp((VGfloat)iZNear, (VGfloat)iZFar, Abs(q->iX / leftX));
       
   847             q->iZ = Min(q->iZ, (VGfloat)iZFar);                    
       
   848             }
       
   849         
       
   850         // calculate alpha so that items further are more transparent.
       
   851         q->iAlpha = HgVgHelper::Lerp(1, 0, Max(0.0, (Abs(q->iX)-2.0) / (TReal)(iQuads.Count()/2-2)));         
   845         q->iAlpha = HgVgHelper::Lerp(1, 0, Max(0.0, (Abs(q->iX)-2.0) / (TReal)(iQuads.Count()/2-2)));         
   852                     
   846             
       
   847         
   853         q->iItemIndex = itemIndex;
   848         q->iItemIndex = itemIndex;
   854         
   849         
   855         // setup image to quad from item
       
   856         if  (aItems[itemIndex]->VgImage() == VG_INVALID_HANDLE)
   850         if  (aItems[itemIndex]->VgImage() == VG_INVALID_HANDLE)
   857             {
   851             {
   858             q->iNoImage = ETrue;
   852             q->iNoImage = ETrue;
   859             }
   853             }
   860         else
   854         else
   861             {
   855             {
   862             q->iNoImage = EFalse;
   856             q->iNoImage = EFalse;
   863             q->iImage = aItems[itemIndex]->VgImage();
   857             q->iImage = aItems[itemIndex]->VgImage();
   864             }
   858             }
   865 
   859 
   866         // apply opening animation to item if needed
       
   867         if (isSelectionToFocusedItem && (itemIndex == aSelectedIndex))
   860         if (isSelectionToFocusedItem && (itemIndex == aSelectedIndex))
   868             {
   861             {
   869             q->iAlpha = 1;
   862             q->iAlpha = 1;
   870             q->iFlipped = ETrue;
   863             q->iFlipped = ETrue;
   871             iBlurAlpha = selectionAnimationAlpha;
   864             iBlurAlpha = selectionAnimationAlpha;
   872             ApplyOpeningAnimation(q, selectionAnimationAlpha, q->iZ, 
   865             ApplyOpeningAnimation(q, selectionAnimationAlpha, zNear, 
   873                     CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen, 
   866                     CHgVgMediaWall::EHgVgMediaWallStyleCoverflowFullScreen, 
   874                     aOpeningAnimationType);
   867                     aOpeningAnimationType);
   875             }
   868             }
   876 
   869 
   877         i++;
   870         i++;