menufw/menufwui/mmwidgets/src/mmgrid.cpp
branchRCL_3
changeset 88 3321d3e205b6
parent 83 5456b4e8b3a8
child 102 ba63c83f4716
--- a/menufw/menufwui/mmwidgets/src/mmgrid.cpp	Wed Sep 01 12:32:46 2010 +0100
+++ b/menufw/menufwui/mmwidgets/src/mmgrid.cpp	Tue Sep 14 20:58:58 2010 +0300
@@ -12,7 +12,7 @@
 * Contributors:
 *
 * Description:
-*  Version     : %version: MM_106 % << Don't touch! Updated by Synergy at check-out.
+*  Version     : %version: MM_108 % << Don't touch! Updated by Synergy at check-out.
 *
 */
 
@@ -51,7 +51,6 @@
 //
 CMmGrid::~CMmGrid()
     {
-    delete iRedrawTimer;
     }
 
 // -----------------------------------------------------------------------------
@@ -216,35 +215,18 @@
 void CMmGrid::HandleScrollEventL( CEikScrollBar* aScrollBar,
         TEikScrollEvent aEventType )
     {
-    if ( aEventType == EEikScrollThumbDragVert && !iScrollbarThumbIsBeingDragged )
+    if ( aEventType == EEikScrollThumbDragVert )
         {
-        iScrollbarThumbIsBeingDragged = ETrue;
         static_cast<CMmListBoxItemDrawer*>(
                 View()->ItemDrawer() )->EnableCachedDataUse( ETrue );
-        iRedrawTimer->Start( KScrollingRedrawInterval, KScrollingRedrawInterval,
-                TCallBack( &CMmGrid::RedrawTimerCallback, static_cast<TAny*>( this ) ) );
         }
     else if ( aEventType == EEikScrollThumbReleaseVert )
         {
-        iScrollbarThumbIsBeingDragged = EFalse;
         static_cast<CMmListBoxItemDrawer*>(
                 View()->ItemDrawer() )->EnableCachedDataUse( EFalse );
-        // The view will be redrawn with cache disabled when ProcessScrollEventL
-        // calls the base class's HandleScrollEventL method -- no need to
-        // explicitly redraw the view.
-        iRedrawTimer->Cancel();
         }
-
-    if ( !iScrollbarThumbIsBeingDragged )
-        {
         ProcessScrollEventL( aScrollBar, aEventType );
         }
-    else
-        {
-        __ASSERT_DEBUG( aEventType == EEikScrollThumbDragVert, User::Invariant() );
-        ++iSkippedScrollbarEventsCount;
-        }
-    }
 
 // -----------------------------------------------------------------------------
 // Clearing ELeftDownInViewRect flag before invoking the base class
@@ -379,12 +361,12 @@
 //
 void CMmGrid::ScrollWithoutRedraw( TInt distanceInPixels )
     {
-    CAknGridView* view = static_cast<CAknGridView*>( iView );
+    CAknGridView* view = static_cast<CAknGridView*> ( iView );
     const TInt rowHeight = ItemHeight();
     const TInt numOfCols = view->NumberOfColsInView();
     const TInt itemCount = iModel->NumberOfItems();
     TInt totalNumberOfRows = itemCount / numOfCols;
-    if ( itemCount % numOfCols )
+    if( itemCount % numOfCols )
         {
         ++totalNumberOfRows;
         }
@@ -396,8 +378,8 @@
     desiredViewPosition += distanceInPixels;
 
     const TInt viewPositionMin = 0;
-    const TInt viewPositionMax =
-    Max( 0, ( totalNumberOfRows * rowHeight ) - view->ViewRect().Height() );
+    const TInt viewPositionMax = Max( 0, ( totalNumberOfRows * rowHeight )
+            - view->ViewRect().Height() );
 
     desiredViewPosition = Min( desiredViewPosition, viewPositionMax );
     desiredViewPosition = Max( desiredViewPosition, viewPositionMin );
@@ -416,47 +398,45 @@
 //
 TInt CMmGrid::ScrollIfNeeded( const TPointerEvent& aPointerEvent )
     {
-    CAknGridView* view = static_cast<CAknGridView*>( View() );
     TInt nextScrollDelay = 0;
 
     TBool readyForScrolling = iMmDrawer->GetAnimator()->IsReadyForNewAnimation()
-    && iMmDrawer->GetFloatingItemCount() != 0;
+            && iMmDrawer->GetFloatingItemCount() != 0;
 
-  if ( IsPointerInTopScrollingThreshold( aPointerEvent ) )
-    {
-    // scroll up by one row
-    TInt newCurrentItemIndex = CurrentItemIndex() - view->NumberOfColsInView();
-        if ( newCurrentItemIndex < 0 )
-            {
-            newCurrentItemIndex = CurrentItemIndex();
-            }
-
-       nextScrollDelay = MmEffects::KEditModeScrollingDelayFactor *
-       Max( 1, aPointerEvent.iPosition.iY - Rect().iTl.iY );
+    if( IsPointerInTopScrollingThreshold( aPointerEvent ) )
+        {
+        // scroll up
+        TInt startPos = MmGrid::KFocusScrollingThreshold * TReal(
+                View()->ItemSize().iHeight );
+        TInt diff = Max( 1, Min( aPointerEvent.iPosition.iY
+                - Rect().iTl.iY, startPos ) );
+        nextScrollDelay = ( (TReal) diff / (TReal) startPos )
+                * ( MmGrid::KEditModeScrollingGridMaxDelay
+                        - MmGrid::KEditModeScrollingGridMinDelay )
+                + MmGrid::KEditModeScrollingGridMinDelay;
 
-    if ( readyForScrolling )
-      {
-      ScrollWithoutRedraw( -iItemHeight );
-      View()->SetCurrentItemIndex( newCurrentItemIndex );
-      }
-    }
-  else if ( IsPointerInBottomScrollingThreshold( aPointerEvent) )
-    {
-    TInt newCurrentItemIndex = CurrentItemIndex() + view->NumberOfColsInView();
-    if ( newCurrentItemIndex > iModel->NumberOfItems() - 1 )
-      {
-      newCurrentItemIndex = CurrentItemIndex();
-      }
+        if( readyForScrolling )
+            {
+            ScrollWithoutRedraw( -MmGrid::KScrollingStep );
+            }
+        }
+    else if( IsPointerInBottomScrollingThreshold( aPointerEvent ) )
+        {
+        // scroll down
+        TInt startPos = MmGrid::KFocusScrollingThreshold * TReal(
+                View()->ItemSize().iHeight );
+        TInt diff = Max( 1, Min( Rect().iBr.iY
+                - aPointerEvent.iPosition.iY, startPos ) );
+        nextScrollDelay = ( (TReal) diff / (TReal) startPos )
+                * ( MmGrid::KEditModeScrollingGridMaxDelay
+                        - MmGrid::KEditModeScrollingGridMinDelay )
+                + MmGrid::KEditModeScrollingGridMinDelay;
 
-    nextScrollDelay = MmEffects::KEditModeScrollingDelayFactor *
-      Max( 1, Rect().iBr.iY - aPointerEvent.iPosition.iY );
-
-    if ( readyForScrolling )
-      {
-      ScrollWithoutRedraw( iItemHeight );
-      View()->SetCurrentItemIndex( newCurrentItemIndex );
-      }
-    }
+        if( readyForScrolling )
+            {
+            ScrollWithoutRedraw( MmGrid::KScrollingStep );
+            }
+        }
 
     return nextScrollDelay;
     }
@@ -601,7 +581,6 @@
         }
 
     DoSetupLayoutL();
-    iRedrawTimer = CPeriodic::NewL( EPriorityRealTime );
     }
 
 // -----------------------------------------------------------------------------
@@ -961,33 +940,6 @@
 //
 // -----------------------------------------------------------------------------
 //
-void CMmGrid::HandleRedrawTimerEventL()
-    {
-    if ( iSkippedScrollbarEventsCount )
-        {
-        ProcessScrollEventL( ScrollBarFrame()->VerticalScrollBar(),
-                EEikScrollThumbDragVert );
-        }
-    iSkippedScrollbarEventsCount = 0;
-    }
-
-// -----------------------------------------------------------------------------
-//
-// -----------------------------------------------------------------------------
-//
-TInt CMmGrid::RedrawTimerCallback( TAny* aPtr )
-    {
-    CMmGrid* self = static_cast<CMmGrid*>( aPtr );
-    TRAP_IGNORE( self->HandleRedrawTimerEventL() );
-    // Do not bother returning a meaningful error code, CPeriodic will ignore it
-    // anyway.
-    return 0;
-    }
-
-// -----------------------------------------------------------------------------
-//
-// -----------------------------------------------------------------------------
-//
 void CMmGrid::SetVerticalItemOffset(TInt aOffset)
   {
   static_cast<CMmGridView*> (View())->SetItemOffsetInPixels(aOffset);