uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 29 a8834a2e9a96
parent 25 941195f2d488
child 38 c52421ed5f07
--- a/uifw/ganes/src/HgScroller.cpp	Tue May 25 12:58:19 2010 +0300
+++ b/uifw/ganes/src/HgScroller.cpp	Wed Jun 09 09:58:37 2010 +0300
@@ -372,7 +372,7 @@
     iCurrentRow(-1),
     iSelectedIndex(KErrNotFound),
     iScrollBarType( EHgScrollerScrollBar ),
-    iFirstTime(ETrue),
+    iResetViewPosition(ETrue),
     iOldWinPos(KErrNotFound)
     {
     // No implementation required
@@ -423,15 +423,21 @@
     // The world is set to be at least the size of the view.
     TSize worldSize = TotalSize();
     
-    if( !iLandscapeScrolling && (worldSize.iHeight < iHeight) )
+    if( !iLandscapeScrolling && (worldSize.iHeight <= iHeight) )
+        {
         worldSize.iHeight = iHeight;
+        iResetViewPosition = ETrue;
+        }
     
-    if( iLandscapeScrolling && (worldSize.iWidth < iWidth) )
+    if( iLandscapeScrolling && (worldSize.iWidth <= iWidth) )
+        {
         worldSize.iWidth = iWidth;
+        iResetViewPosition = ETrue;
+        }
 
     iPhysics->InitPhysicsL( worldSize, 
-            TSize(iWidth, iHeight), 
-            iLandscapeScrolling);
+                            TSize(iWidth, iHeight), 
+                            iLandscapeScrolling);
     }
 
 // -----------------------------------------------------------------------------
@@ -516,10 +522,10 @@
         iPopupDrawer->Init( Rect(), iPopupFont );
         }
     
-    if(iFirstTime)
+    if(iResetViewPosition)
         {
         iViewPosition = TPoint(iWidth/2, iHeight/2);
-        iFirstTime = EFalse;
+        iResetViewPosition = EFalse;
         }
     
     HandleViewPositionChanged();
@@ -607,7 +613,6 @@
                 iDetector->PointerEventL( aEvent );
             
             HandleUpEventL( aEvent );
-            iPointerDown = EFalse;
             }
         }
     }
@@ -777,15 +782,17 @@
         if(iLandscapeScrolling && AknLayoutUtils::LayoutMirrored())
             drag = -drag;
         iPhysics->StartPhysics(drag, iStartTime);
+        iPointerDown = EFalse;
         }
     else
         {
-        HandleSelectionL();
         MTouchFeedback* feedback = MTouchFeedback::Instance();
         if ( feedback && iSelectedIndex != KErrNotFound )
             {
             feedback->InstantFeedback( this, ETouchFeedbackList, ETouchFeedbackVibra, aEvent );
             }
+
+        HandleSelectionL();
         }
     }
 
@@ -804,6 +811,8 @@
             // this is not usually the case since interval is 50ms but just to be sure.
             SetHighlightL();
             }
+
+        iPointerDown = EFalse;
         
         // selection needs to be valid.
         if( iSelectedIndex >= 0 && iSelectedIndex < iItems.Count() )
@@ -831,6 +840,10 @@
                 }
             }
         }
+    else
+        {
+        iPointerDown = EFalse;
+        }
     }
 
 // -----------------------------------------------------------------------------
@@ -1180,21 +1193,21 @@
             {
             if( iSelectedIndex != KErrNotFound && HasHighlight() )
                 {
+                iShowHighlight = EFalse;
+                iDrawUtils->EnableMarquee(HasHighlight());
                 if( iSelectionObserver )
                     TRAP_IGNORE( iSelectionObserver->HandleOpenL( iSelectedIndex ); )
-                iShowHighlight = EFalse;
-                iDrawUtils->EnableMarquee(HasHighlight());
                 return EKeyWasConsumed;
                 }
             else if( iItemCount )
                 {
                 iSelectedIndex = iCurrentRow;
-                if( iSelectionObserver )
-                    TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
                 FitSelectionToView();
                 iShowHighlight = ETrue;
                 iDrawUtils->EnableMarquee(HasHighlight());
                 DrawDeferred();
+                if( iSelectionObserver )
+                    TRAP_IGNORE( iSelectionObserver->HandleSelectL( iSelectedIndex ); )
                 return EKeyWasConsumed;
                 }
             return EKeyWasNotConsumed;