taskswitcher/taskswitcherui/taskswitcherapp/src/tsfastswapgrid.cpp
branchRCL_3
changeset 9 f966699dea19
parent 5 c743ef5928ba
child 16 9674c1a575e9
equal deleted inserted replaced
5:c743ef5928ba 9:f966699dea19
    28   * CTsFastSwapGrid
    28   * CTsFastSwapGrid
    29   * ================================================================================
    29   * ================================================================================
    30   */
    30   */
    31 
    31 
    32 const TInt KCloseIconRedrawTime = 300000; // 0.3 second
    32 const TInt KCloseIconRedrawTime = 300000; // 0.3 second
       
    33 const TInt KFeedbackTime = 0;
    33 
    34 
    34 // -----------------------------------------------------------------------------
    35 // -----------------------------------------------------------------------------
    35 // CTsFastSwapGrid::CTsFastSwapGrid
    36 // CTsFastSwapGrid::CTsFastSwapGrid
    36 // -----------------------------------------------------------------------------
    37 // -----------------------------------------------------------------------------
    37 //
    38 //
    51 CTsFastSwapGrid::~CTsFastSwapGrid()
    52 CTsFastSwapGrid::~CTsFastSwapGrid()
    52     {
    53     {
    53     iCloseItems.Close();
    54     iCloseItems.Close();
    54     delete iBgContext;
    55     delete iBgContext;
    55     delete iCloseIconRedrawTimer;
    56     delete iCloseIconRedrawTimer;
       
    57     delete iFeedbackTimer;
    56     iFullyVisibleItems.Close();
    58     iFullyVisibleItems.Close();
    57     iPartialVisibleItems.Close();
    59     iPartialVisibleItems.Close();
    58     }
    60     }
    59 
    61 
    60 // -----------------------------------------------------------------------------
    62 // -----------------------------------------------------------------------------
    71                KAknsIIDQsnFrPopup,
    73                KAknsIIDQsnFrPopup,
    72                TRect(),
    74                TRect(),
    73                TRect(),
    75                TRect(),
    74                ETrue );
    76                ETrue );
    75     iBgContext->SetCenter( KAknsIIDQsnFrPopupCenter );
    77     iBgContext->SetCenter( KAknsIIDQsnFrPopupCenter );
    76     iVisibleViewRect = TRect( 0, 0, 0, 0 );
       
    77     iCloseIconRedrawTimer = new (ELeave) CTsFastSwapTimer( *this );
    78     iCloseIconRedrawTimer = new (ELeave) CTsFastSwapTimer( *this );
    78     iCloseIconRedrawTimer->ConstructL();
    79     iCloseIconRedrawTimer->ConstructL();
       
    80     iFeedbackTimer = new (ELeave) CTsFastSwapTimer( *this );
       
    81     iFeedbackTimer->ConstructL();
    79     }
    82     }
    80 
    83 
    81 // -----------------------------------------------------------------------------
    84 // -----------------------------------------------------------------------------
    82 // CTsFastSwapGrid::HandlePointerEventL
    85 // CTsFastSwapGrid::HandlePointerEventL
    83 // -----------------------------------------------------------------------------
    86 // -----------------------------------------------------------------------------
   203 // CTsFastSwapGrid::HandleResourceChange
   206 // CTsFastSwapGrid::HandleResourceChange
   204 // -----------------------------------------------------------------------------
   207 // -----------------------------------------------------------------------------
   205 //
   208 //
   206 void CTsFastSwapGrid::HandleResourceChange( TInt aType )
   209 void CTsFastSwapGrid::HandleResourceChange( TInt aType )
   207     {
   210     {
   208     if ( aType != KEikDynamicLayoutVariantSwitch )
   211     if ( aType != KEikDynamicLayoutVariantSwitch &&
       
   212          Model()->ItemTextArray()->MdcaCount() )
   209         {
   213         {
   210         CAknGrid::HandleResourceChange( aType );
   214         CAknGrid::HandleResourceChange( aType );
   211         }
   215         }
   212     }
   216     }
   213 
   217 
   243     TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
   247     TInt variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0;
   244     fastSwapAreaPane.LayoutRect( availableRect,
   248     fastSwapAreaPane.LayoutRect( availableRect,
   245             AknLayoutScalable_Apps::tport_appsw_pane( variety ) );
   249             AknLayoutScalable_Apps::tport_appsw_pane( variety ) );
   246     const TInt leftOffset = fastSwapAreaPane.Rect().iTl.iX;
   250     const TInt leftOffset = fastSwapAreaPane.Rect().iTl.iX;
   247     const TInt rightOffset = availableRect.Width() - fastSwapAreaPane.Rect().iBr.iX;
   251     const TInt rightOffset = availableRect.Width() - fastSwapAreaPane.Rect().iBr.iX;
       
   252     SetVisibleViewRect(fastSwapAreaPane.Rect());
   248     
   253     
   249     CFormattedCellGridData* data = CFormattedCellGridData::NewL();
   254     CFormattedCellGridData* data = CFormattedCellGridData::NewL();
   250     CleanupStack::PushL( data );
   255     CleanupStack::PushL( data );
   251     CTsGridItemDrawer* itemDrawer =
   256     CTsGridItemDrawer* itemDrawer =
   252         new ( ELeave ) CTsGridItemDrawer( this, data );
   257         new ( ELeave ) CTsGridItemDrawer( this, data );
   264 //
   269 //
   265 void CTsFastSwapGrid::TimerCompletedL( CTsFastSwapTimer* aSource )
   270 void CTsFastSwapGrid::TimerCompletedL( CTsFastSwapTimer* aSource )
   266     {
   271     {
   267     if ( aSource == iCloseIconRedrawTimer )
   272     if ( aSource == iCloseIconRedrawTimer )
   268         {
   273         {
   269         iFastSwapGridObserver->HandleCloseEventL( iCloseIconHitIdx );
   274         TInt itemToClose = iCloseIconHitIdx;
   270         ResetCloseHit();
   275         ResetCloseHit();
       
   276         iFastSwapGridObserver->HandleCloseEventL( itemToClose );
       
   277         }
       
   278     else if ( aSource == iFeedbackTimer )
       
   279         {
       
   280         MTouchFeedback* feedback = MTouchFeedback::Instance();
       
   281         if (feedback)
       
   282             {
       
   283             feedback->InstantFeedback(ETouchFeedbackSensitive);
       
   284             }
   271         }
   285         }
   272     }
   286     }
   273 
   287 
   274 // -----------------------------------------------------------------------------
   288 // -----------------------------------------------------------------------------
   275 // CTsFastSwapGrid::SetCloseItemsL
   289 // CTsFastSwapGrid::SetCloseItemsL
   498     if( !iTactileFeedbackSupport )
   512     if( !iTactileFeedbackSupport )
   499         {
   513         {
   500         return;
   514         return;
   501         }
   515         }
   502     
   516     
   503     MTouchFeedback* feedback = MTouchFeedback::Instance();
   517     iFeedbackTimer->Cancel();
   504     if (feedback)
   518     iFeedbackTimer->After(KFeedbackTime);
   505         {
       
   506         feedback->InstantFeedback(ETouchFeedbackSensitive);
       
   507         }
       
   508     }
   519     }
   509 
   520 
   510 // -----------------------------------------------------------------------------
   521 // -----------------------------------------------------------------------------
   511 // CTsFastSwapGrid::SetTactileFeedbackSupport
   522 // CTsFastSwapGrid::SetTactileFeedbackSupport
   512 // -----------------------------------------------------------------------------
   523 // -----------------------------------------------------------------------------
   663     iRightOffset = aRightOffset;
   674     iRightOffset = aRightOffset;
   664     }
   675     }
   665 
   676 
   666 
   677 
   667 // -----------------------------------------------------------------------------
   678 // -----------------------------------------------------------------------------
   668 // CTsTeleportGridItemDrawer::SetRedrawBackground
   679 // CTsGridItemDrawer::SetRedrawBackground
   669 // -----------------------------------------------------------------------------
   680 // -----------------------------------------------------------------------------
   670 //
   681 //
   671 void CTsGridItemDrawer::SetRedrawBackground( TBool aEnable )
   682 void CTsGridItemDrawer::SetRedrawBackground( TBool aEnable )
   672     {
   683     {
   673     iRedrawBackground = aEnable;
   684     iRedrawBackground = aEnable;
   768 //
   779 //
   769 TBool CTsGridItemDrawer::IsItemRectVisible( const TRect& aItemRect ) const
   780 TBool CTsGridItemDrawer::IsItemRectVisible( const TRect& aItemRect ) const
   770     {
   781     {
   771     TBool retVal( EFalse );
   782     TBool retVal( EFalse );
   772     TRect viewRect = iGrid->VisibleViewRect();
   783     TRect viewRect = iGrid->VisibleViewRect();
   773     if ( // left edge of item rectangle on screen
   784     if ( viewRect.Intersects( aItemRect ) )
   774          ( aItemRect.iTl.iX >= viewRect.iTl.iX && aItemRect.iTl.iX <= viewRect.iBr.iX ) ||
       
   775          // right edge of item rectangle on screen
       
   776          ( aItemRect.iBr.iX >= viewRect.iTl.iX && aItemRect.iBr.iX <= viewRect.iBr.iX )
       
   777         )
       
   778         {
   785         {
   779         retVal = ETrue;
   786         retVal = ETrue;
   780         }
   787         }
   781     return retVal;
   788     return retVal;
   782     }
   789     }