(Pinch) Remove gradient limitations, distance moved = pinch 47/24147/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 7 Jul 2014 17:54:17 +0000 (18:54 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 16:07:50 +0000 (17:07 +0100)
[problem]      Hard to do pinch sometimes when fingers moving opposite gradients (but apart)
[cause]        Checking the gradient of motion of the two fingers matches (within a certain threshold).
[solution]     Just emit a pinch if there is enough distance.

Change-Id: I4e5a119843a19ae35348cf1794ec28c416fef897
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
adaptors/tizen/internal/common/events/pinch-gesture-detector.cpp

index e2e92ea..5c9c34f 100644 (file)
@@ -44,9 +44,6 @@ namespace
 const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED = 4;
 const unsigned int MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START = 4;
 
-const float MAXIMUM_GRADIENT_CHANGE_ALLOWED = 2.0f;
-const float MAXIMUM_X_DIFF_CALCULATION_FOR_UNDEFINED_GRADIENT = 100.0f;
-
 inline float GetDistance(const TouchPoint& point1, const TouchPoint& point2)
 {
   Vector2 vector(point1.screen - point2.screen);
@@ -139,46 +136,20 @@ void PinchGestureDetector::SendEvent(const Integration::TouchEvent& event)
             // Check if distance has changed enough
             if (fabsf(distanceChanged) > mMinimumDistanceDelta)
             {
-              // Ensure the gradient between the two points is similar
-              float firstGradient = GetGradient(firstPoint1, firstPoint2);
-              float currentGradient = GetGradient(currentPoint1, currentPoint2);
+              // Remove the first few events from the vector otherwise values are exaggerated
+              mTouchEvents.erase(mTouchEvents.begin(), mTouchEvents.end() - MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START);
 
-              float gradientDelta = firstGradient - currentGradient;
+              if ( !mTouchEvents.empty() )
+              {
+                mStartingDistance = GetDistance(mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1]);
 
-              // Need to deal with undefined gradient so ensure X difference between points is sufficiently large
-              float point1XDiff = firstPoint1.screen.x - currentPoint1.screen.x;
-              float point2XDiff = firstPoint2.screen.x - currentPoint2.screen.x;
+                // Send pinch started
+                SendPinch(Gesture::Started, event);
 
-              if (fabsf(gradientDelta) <= MAXIMUM_GRADIENT_CHANGE_ALLOWED ||
-                  (fabsf(point1XDiff) <= MAXIMUM_X_DIFF_CALCULATION_FOR_UNDEFINED_GRADIENT &&
-                   fabsf(point2XDiff) <= MAXIMUM_X_DIFF_CALCULATION_FOR_UNDEFINED_GRADIENT))
-              {
-                if ((point1XDiff >= 0.0f && point2XDiff <= 0.0f) ||
-                    (point1XDiff <= 0.0f && point2XDiff >= 0.0f))
-                {
-                  float point1YDiff = firstPoint1.screen.y - currentPoint1.screen.y;
-                  float point2YDiff = firstPoint2.screen.y - currentPoint2.screen.y;
-
-                  if ((point1YDiff >= 0.0f && point2YDiff <= 0.0f) ||
-                      (point1YDiff <= 0.0f && point2YDiff >= 0.0f))
-                  {
-                    // Remove the first few events from the vector otherwise values are exaggerated
-                    mTouchEvents.erase(mTouchEvents.begin(), mTouchEvents.end() - MINIMUM_TOUCH_EVENTS_REQUIRED_AFTER_START);
-
-                    if ( !mTouchEvents.empty() )
-                    {
-                      mStartingDistance = GetDistance(mTouchEvents.begin()->points[0], mTouchEvents.begin()->points[1]);
-
-                      // Send pinch started
-                      SendPinch(Gesture::Started, event);
-
-                      mState = Started;
-                    }
-
-                    mTouchEvents.clear();
-                  }
-                }
+                mState = Started;
               }
+
+              mTouchEvents.clear();
             }
 
             if (mState == Possible)