uifw/ganes/src/HgScroller.cpp
branchRCL_3
changeset 59 978afdc0236f
parent 56 d48ab3b357f1
child 64 85902f042028
--- a/uifw/ganes/src/HgScroller.cpp	Wed Sep 01 12:16:19 2010 +0100
+++ b/uifw/ganes/src/HgScroller.cpp	Tue Sep 14 21:48:24 2010 +0300
@@ -15,7 +15,6 @@
 *
 */
 
-
 // INCLUDE FILES
 #include <ganes/HgScroller.h>
 
@@ -590,10 +589,16 @@
             iPointerDown = ETrue;
             HandleDownEventL( aEvent );
 
+            // Long tap is supported in marking mode only for an item that is marked.
+            const TBool validIndex = iSelectedIndex != KErrNotFound && 
+                    iSelectedIndex >= 0 && iSelectedIndex < iItems.Count();
+            const TBool selectionMode = iFlags & EHgScrollerSelectionMode;
+            const TBool longTapEnabled = validIndex && (!selectionMode ||
+                    (selectionMode && iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked));
+            
             if( iDetector 
-                    && iSelectedIndex != KErrNotFound 
+                    && longTapEnabled
                     && !HasHighlight()
-                    && !(iFlags & EHgScrollerSelectionMode)
                     && iActionMenu->InitMenuL() )
                 {
                 iDetector->PointerEventL( aEvent );
@@ -1272,6 +1277,19 @@
     {
     if(iItemCount)
         {
+        iHighlightTimer->Cancel();
+        iPointerDown = EFalse;
+        if(iDetector)
+            iDetector->CancelAnimationL();
+        iPanning = EFalse;
+    
+        iPhysics->StopPhysics();
+        iPhysics->ResetFriction();
+    
+        iFocusedIndex = KErrNotFound;
+        iSelectionToFocusedItem = EFalse;
+        iDrawUtils->EnableMarquee(false);    
+    
         iItems.ResetAndDestroy();
         iItemCount = 0;
         iSelectedIndex = KErrNotFound;
@@ -1282,6 +1300,9 @@
             }
     
         HandleItemCountChanged();
+    
+        iViewPosition = TPoint(iWidth/2, iHeight/2);    
+        HandleViewPositionChanged();        
         }
     }
 
@@ -1291,6 +1312,14 @@
 //
 EXPORT_C void CHgScroller::SetFlags(TInt aFlags)
     {
+    const TBool currentSelectionMode = iFlags & EHgScrollerSelectionMode;
+    const TBool newSelectionMode = aFlags & EHgScrollerSelectionMode;
+    if( currentSelectionMode != newSelectionMode )
+        {
+        // when selection mode changes we need to repaint
+        DrawDeferred();
+        }
+    
     iFlags |= aFlags;
     }
 
@@ -1599,12 +1628,18 @@
 //     
 void CHgScroller::SetSelectionMode( TSelectionMode aMode )
     {
+    if( aMode != iSelectionMode )
+        {
+        DrawDeferred();
+        }
+    
     iSelectionMode = aMode;
     if( iSelectionMode == ESelectionPossible
             || iSelectionMode == ENoSelection )
         {
         iCoeEnv->InputCapabilitiesChanged();
         }
+    
     }
 
 // ---------------------------------------------------------------------------
@@ -1747,7 +1782,14 @@
 void CHgScroller::HandleLongTapEventL( const TPoint& /*aPenEventLocation*/,
                         const TPoint& aPenEventScreenLocation)
     {
-    if( iActionMenu && !(iFlags & EHgScrollerSelectionMode) )
+    // Long tap is supported in marking mode only for an item that is marked.
+    const TBool validIndex = iSelectedIndex != KErrNotFound && 
+            iSelectedIndex >= 0 && iSelectedIndex < iItems.Count();
+    const TBool selectionMode = iFlags & EHgScrollerSelectionMode;
+    const TBool longTapEnabled = validIndex && (!selectionMode ||
+            (selectionMode && iItems[iSelectedIndex]->Flags() & CHgItem::EHgItemFlagMarked));
+    
+    if( iActionMenu && longTapEnabled )
         {
         iOldWinPos = DrawableWindow()->OrdinalPosition();
         iActionMenu->ShowMenuL(aPenEventScreenLocation);