(ScrollView) Check for an interrupted event and finish transform 94/24194/1
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Fri, 27 Jun 2014 12:29:45 +0000 (21:29 +0900)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 17:47:55 +0000 (18:47 +0100)
[problem]     Scroll-view can get stuck if it doesn't receive an up event after it receives a down
[cause]       It is no longer the hit-actor (or a parent of the hit-actor).
[solution]    Together with the core change (Emit Up to down consumer) -> comes as interrupted
              React to interrupted event now in a similar manner to up event

Change-Id: I3c44276e3f8168fb2d9e9016e11f6ce497b40761
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp

index 48f0b9f..20392a7 100644 (file)
@@ -2187,7 +2187,8 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event)
     return false;
   }
 
-  if( event.GetPoint(0).state == TouchPoint::Down )
+  const TouchPoint::State pointState = event.GetPoint(0).state;
+  if( pointState == TouchPoint::Down )
   {
     DALI_LOG_SCROLL_STATE("[0x%X] Down", this);
 
@@ -2202,9 +2203,10 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event)
       StartTouchDownTimer();
     }
   }
-  else if( event.GetPoint(0).state == TouchPoint::Up )
+  else if( ( pointState == TouchPoint::Up ) ||
+           ( ( pointState == TouchPoint::Interrupted ) && ( event.GetPoint(0).hitActor == Self() ) ) )
   {
-    DALI_LOG_SCROLL_STATE("[0x%X] Up", this);
+    DALI_LOG_SCROLL_STATE("[0x%X] %s", this, ( ( pointState == TouchPoint::Up ) ? "Up" : "Interrupted" ) );
 
     StopTouchDownTimer();
 
@@ -2213,8 +2215,8 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event)
     // otherwise our scroll could be stopped (interrupted) half way through an animation.
     if(mGestureStackDepth==0 && mTouchDownTimeoutReached)
     {
-      unsigned timeDelta( event.time - mTouchDownTime );
-      if ( timeDelta >= MINIMUM_TIME_BETWEEN_DOWN_AND_UP_FOR_RESET )
+      if( ( event.GetPoint(0).state == TouchPoint::Interrupted ) ||
+          ( ( event.time - mTouchDownTime ) >= MINIMUM_TIME_BETWEEN_DOWN_AND_UP_FOR_RESET ) )
       {
         // Reset the velocity only if down was received a while ago
         mLastVelocity = Vector2( 0.0f, 0.0f );