uifw/EikStd/coctlsrc/aknedwinphysicshandler.cpp
branchRCL_3
changeset 55 aecbbf00d063
parent 38 c52421ed5f07
child 56 d48ab3b357f1
--- a/uifw/EikStd/coctlsrc/aknedwinphysicshandler.cpp	Thu Aug 19 10:11:06 2010 +0300
+++ b/uifw/EikStd/coctlsrc/aknedwinphysicshandler.cpp	Tue Aug 31 15:28:30 2010 +0300
@@ -52,39 +52,12 @@
     }
 
 // ---------------------------------------------------------------------------
-// CAknEdwinPhysicsHandler::NewL
-// ---------------------------------------------------------------------------
-//
-CAknEdwinPhysicsHandler* CAknEdwinPhysicsHandler::NewL( CEikEdwin& aEdwin, CAknPhysics* aPhysics )
-    {
-    CAknEdwinPhysicsHandler* self = CAknEdwinPhysicsHandler::NewLC( aEdwin, aPhysics );
-    CleanupStack::Pop( self );
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
-// CAknEdwinPhysicsHandler::NewLC
-// ---------------------------------------------------------------------------
-//
-CAknEdwinPhysicsHandler* CAknEdwinPhysicsHandler::NewLC( CEikEdwin& aEdwin, CAknPhysics* aPhysics )
-    {
-    CAknEdwinPhysicsHandler* self = new ( ELeave ) CAknEdwinPhysicsHandler(
-            aEdwin, aPhysics );
-    CleanupStack::PushL( self );
-    self->ConstructL();
-    return self;
-    }
-
-// ---------------------------------------------------------------------------
 // CAknEdwinPhysicsHandler::~CAknEdwinPhysicsHandler
 // ---------------------------------------------------------------------------
 //
 CAknEdwinPhysicsHandler::~CAknEdwinPhysicsHandler()
     {
-    if (iOwnsPhysics)
-        {
-        delete iPhysics;
-        }
+    delete iPhysics;
     }
 
 // ---------------------------------------------------------------------------
@@ -94,78 +67,66 @@
 void CAknEdwinPhysicsHandler::HandlePointerEvent(
     const TPointerEvent& aPointerEvent )
     {   
-    if (iOwnsPhysics)
+    if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
+        iViewRect.Contains( aPointerEvent.iPosition ) &&
+        iEventUnblockingAllowed )
         {
-        if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
-            iViewRect.Contains( aPointerEvent.iPosition ) &&
-            iEventUnblockingAllowed )
-            {
-            BlockEvents( EFalse );
-            iPreviousYCoordinate = - KMaxWorldSize;
-            }
-        if ( iEventsBlocked )
-            {
-            return;
-            }
+        BlockEvents( EFalse );
+        iPreviousYCoordinate = - KMaxWorldSize;
+        }
+    if ( iEventsBlocked )
+        {
+	    return;
+        }
+
+    // Dragging/flicking logic    
     
-        // Dragging/flicking logic    
-        
-        if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
-            iViewRect.Contains( aPointerEvent.iPosition ) )
-            {
-            // Pointer down inside view rect, set flag to allow dragging 
-            // and initialize values
-            iFlags.Set( EFlagDraggingAllowed );
-            iStartPosition = aPointerEvent.iPosition;
-            StopPhysics();
-    
-            iStartTime.HomeTime();
-            iDragThresholdExceeded = EFalse;
-            iFlags.Clear( EFlagBouncingUp );
-            iFlags.Clear( EFlagBouncingDown );
-            return;
-            }
-        if ( iFlags.IsClear( EFlagDraggingAllowed ) )
+    if ( aPointerEvent.iType == TPointerEvent::EButton1Down &&
+        iViewRect.Contains( aPointerEvent.iPosition ) )
+        {
+        // Pointer down inside view rect, set flag to allow dragging 
+        // and initialize values
+        iFlags.Set( EFlagDraggingAllowed );
+        iPrevPosition = aPointerEvent.iPosition;
+        iStartPosition = aPointerEvent.iPosition;
+        StopPhysics();
+
+        iStartTime.HomeTime();
+        iDragThresholdExceeded = EFalse;
+        iFlags.Clear( EFlagBouncingUp );
+        iFlags.Clear( EFlagBouncingDown );
+        return;
+        }
+    if ( iFlags.IsClear( EFlagDraggingAllowed ) )
+        {
+        return;
+        }
+
+    if ( aPointerEvent.iType == TPointerEvent::EDrag )
+        {
+        if ( !iDragThresholdExceeded )
             {
-            return;
-            }
-    
-        if ( aPointerEvent.iType == TPointerEvent::EDrag )
-            {
-            if ( !iDragThresholdExceeded )
-                {
-                TInt drag( iStartPosition.iY - aPointerEvent.iPosition.iY );
-                if ( Abs( drag ) > DragThreshold() )
-                    {
-                    iDragThresholdExceeded = ETrue;
-                    }
-                }
-            else
+            TInt drag( iStartPosition.iY - aPointerEvent.iPosition.iY );
+            if ( Abs( drag ) > DragThreshold() )
                 {
-                if ( !iEdwin.ContentFitsToViewRect() )
-                    {
-                    TInt deltaY( iPrevPosition.iY - aPointerEvent.iPosition.iY );
-                    TPoint deltaPoint( 0, deltaY );
-                    iPhysics->RegisterPanningPosition( deltaPoint );
-                    }
-                }
-            iPrevPosition = aPointerEvent.iPosition;
-            }
-        else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
-            {
-            if ( iFlags.IsClear( EFlagDraggingAllowed ) )
-                {
-                return;
-                }
-            
-            iFlags.Clear( EFlagDraggingAllowed );
-
-            if ( !iEdwin.ContentFitsToViewRect() )
-                {
-                TPoint drag( 0, iStartPosition.iY - aPointerEvent.iPosition.iY );
-                iPhysics->StartPhysics( drag, iStartTime );
+                iDragThresholdExceeded = ETrue;
                 }
             }
+
+        if ( iDragThresholdExceeded )
+            {
+            TInt deltaY( iPrevPosition.iY - aPointerEvent.iPosition.iY );
+            iPrevPosition = aPointerEvent.iPosition;
+
+            TPoint deltaPoint( 0, deltaY );
+            iPhysics->RegisterPanningPosition( deltaPoint );
+            }
+        }
+    else if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
+        {
+        iFlags.Clear( EFlagDraggingAllowed );
+        TPoint drag( 0, iStartPosition.iY - aPointerEvent.iPosition.iY );
+        iPhysics->StartPhysics( drag, iStartTime );
         }
     }
 
@@ -184,26 +145,11 @@
 //   
 void CAknEdwinPhysicsHandler::InitPhysicsL()
     {
-    if (iOwnsPhysics)
-        {
-        TSize totalSize( iViewRect.Width(), iViewRect.Height()
-                + KMaxWorldSize );
-        TSize viewSize( iViewRect.Width(), iViewRect.Height() );
-        
-        CTextLayout* layout = iEdwin.TextLayout();
-        
-        if ( layout )
-            {
-            TInt pixelsAbove = layout->PixelsAboveBand();
-            if ( pixelsAbove > 0 )
-                {
-                MoveScrollIndex( -pixelsAbove );
-                }
-            } 
-        
-        iPhysics->InitPhysicsL( totalSize, viewSize, EFalse );
-        }
-	}
+    TSize totalSize( iViewRect.Width(), iViewRect.Height() + KMaxWorldSize );
+    TSize viewSize( iViewRect.Width(), iViewRect.Height() );
+
+    iPhysics->InitPhysicsL( totalSize, viewSize, EFalse );
+    }
 
 // ---------------------------------------------------------------------------
 // CAknEdwinPhysicsHandler::MoveScrollIndex
@@ -218,11 +164,7 @@
         {
         return;
         }
-    if ( !IsBouncing() )
-        {
-        iFlags.Clear( EFlagBouncingDown ); 
-        iFlags.Clear( EFlagBouncingUp ); 
-        }
+
     iWorldIndex += aPixelsToMove;
     ScrollView( EFalse );
     }
@@ -283,17 +225,8 @@
         {
         BlockEvents( ETrue );
         }
-    
-    // Check also world indexes here because those might still equal although
-    // y coordinates differ due to crossing world boundaries.
-    if ( iPreviousWorldIndex != iWorldIndex )
-        {
-        // Disable background drawing while panning or flicking. Instead,
-        // background is drawn in one frame.
-        iEdwin.DrawViewBackground( ETrue );
-        ScrollView( ETrue );
-        iEdwin.DrawViewBackground( EFalse );
-        }
+    // Scroll view based on values from aknphysics
+    ScrollView( ETrue );
     }
 
 // ---------------------------------------------------------------------------
@@ -367,13 +300,11 @@
 // CAknEdwinPhysicsHandler::CAknEdwinPhysicsHandler
 // ---------------------------------------------------------------------------
 //
-CAknEdwinPhysicsHandler::CAknEdwinPhysicsHandler( CEikEdwin& aEdwin,
-    CAknPhysics* aPhysics ) :
+CAknEdwinPhysicsHandler::CAknEdwinPhysicsHandler( CEikEdwin& aEdwin ) :
     iWorldIndex( 0 ),
     iPreviousWorldIndex( 0 ),
-    iPhysics( aPhysics ),
-    iEdwin( aEdwin ),
-    iOwnsPhysics( aPhysics == NULL )
+    iPhysics( NULL ),
+    iEdwin( aEdwin )
     {
     }
 
@@ -383,10 +314,7 @@
 //
 void CAknEdwinPhysicsHandler::ConstructL()
     {
-    if (iOwnsPhysics)
-        {
-        iPhysics = CAknPhysics::NewL( *this, &iEdwin );    
-        }
+    iPhysics = CAknPhysics::NewL( *this, &iEdwin );    
     }
 
 // ---------------------------------------------------------------------------
@@ -421,7 +349,7 @@
 
                 if ( restOfPixels != 0)
                     {
-                    ScrollStep( restOfPixels, ETrue );
+                    ScrollStep( pixelsToScroll, ETrue );
                     }
                 }
             else
@@ -462,7 +390,6 @@
                 
                 iPhysics->SuspendPhysics();
                 InitBounce( aPixelsToScroll > 0 );
-                ScrollRestOfPixels( restOfPixels );
                 iPhysics->ResumePhysics();
                 }
             else
@@ -720,13 +647,3 @@
         }
     return EFalse;
     }
-
-// ---------------------------------------------------------------------------
-// CAknEdwinPhysicsHandler::DisableDragging
-// ---------------------------------------------------------------------------
-//
-void CAknEdwinPhysicsHandler::DisableDragging()
-    {
-    iFlags.Clear( EFlagDraggingAllowed );
-    }
-