Fix for flick gesture in Screen Reader mode
authorPaul Wisbey <p.wisbey@samsung.com>
Thu, 22 May 2014 17:45:52 +0000 (18:45 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Thu, 29 May 2014 14:09:30 +0000 (15:09 +0100)
[problem]      Flick gestures do not work with 2 fingers
[cause]        Incorrect velocity calculation
[solution]     Use correct 'previous position' in Gesture::Finished event

base/dali-toolkit/internal/focus-manager/focus-manager-impl.cpp
base/dali-toolkit/internal/focus-manager/focus-manager-impl.h

index a52d48022aec0c5803c8f03f0b5f40938312912f..2ca17e50604f9565685e6b526def6dd60f74ca0b 100644 (file)
@@ -877,13 +877,21 @@ bool FocusManager::HandlePanGesture(const Integration::PanGestureEvent& panEvent
     }
   }
 
+  // Gesture::Finished (Up) events are delivered with previous (Motion) event position
+  // Use the real previous position; otherwise we may incorrectly get a ZERO velocity
+  if ( Gesture::Finished != panEvent.state )
+  {
+    // Store the previous position for next Gesture::Finished iteration.
+    mPreviousPosition = panEvent.previousPosition;
+  }
+
   Actor rootActor = Stage::GetCurrent().GetRootLayer();
 
   Dali::PanGesture pan(panEvent.state);
   pan.time = panEvent.time;
   pan.numberOfTouches = panEvent.numberOfTouches;
   pan.screenPosition = panEvent.currentPosition;
-  pan.screenDisplacement = panEvent.previousPosition - panEvent.currentPosition;
+  pan.screenDisplacement = mPreviousPosition - panEvent.currentPosition;
   pan.screenVelocity.x = pan.screenDisplacement.x / panEvent.timeDelta;
   pan.screenVelocity.y = pan.screenDisplacement.y / panEvent.timeDelta;
 
@@ -898,7 +906,7 @@ bool FocusManager::HandlePanGesture(const Integration::PanGestureEvent& panEvent
       pan.position = localCurrent;
 
       Vector2 localPrevious;
-      control.ScreenToLocal( localPrevious.x, localPrevious.y, panEvent.previousPosition.x, panEvent.previousPosition.y );
+      control.ScreenToLocal( localPrevious.x, localPrevious.y, mPreviousPosition.x, mPreviousPosition.y );
 
       pan.displacement = localCurrent - localPrevious;
       pan.velocity.x = pan.displacement.x / panEvent.timeDelta;
index de2cd39c2a83e46f2771de801b395d2410effe37..c69557c2e81fda6dd14e9eece19471cdeeca6a2f 100644 (file)
@@ -386,6 +386,8 @@ private:
 
   Actor mFocusIndicatorActor; ///< The focus indicator actor shared by all the focusable actors for highlight
 
+  Vector2 mPreviousPosition; ///< The previous pan position; useful for calculating velocity for Gesture::Finished events
+
   unsigned int mRecursiveFocusMoveCounter; ///< The counter to count the number of recursive focus movement attempted before the focus movement is successful.
 
   bool mIsAccessibilityTtsEnabled; ///< Whether accessibility feature(screen-reader) turned on/off