Revert "[Tizen] Revert "Use touch consumed return to set whether we process a gesture...
authorJoogab Yun <joogab.yun@samsung.com>
Wed, 19 Aug 2020 05:17:31 +0000 (14:17 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Wed, 19 Aug 2020 05:17:31 +0000 (14:17 +0900)
This reverts commit 180a454b481807369761b740f6fe6d473aebfbd3.

dali/internal/event/events/event-processor.cpp
dali/internal/event/events/pinch-gesture/pinch-gesture-recognizer.cpp
dali/internal/event/events/rotation-gesture/rotation-gesture-recognizer.cpp
dali/internal/event/events/touch-event-processor.cpp
dali/internal/event/events/touch-event-processor.h
dali/public-api/actors/actor.h

index 06250ba..fed209a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -152,8 +152,18 @@ void EventProcessor::ProcessEvents()
     {
       case Event::Touch:
       {
-        mTouchEventProcessor.ProcessTouchEvent( static_cast<const Integration::TouchEvent&>(*event) );
-        mGestureEventProcessor.ProcessTouchEvent(mScene, static_cast<const Integration::TouchEvent&>(*event));
+        Integration::TouchEvent& touchEvent = static_cast<Integration::TouchEvent&>(*event);
+        const bool consumed = mTouchEventProcessor.ProcessTouchEvent( touchEvent );
+
+        // If touch is consumed, then gestures should be cancelled
+        // Do this by sending an interrupted event to the GestureEventProcessor
+        if( consumed )
+        {
+          Integration::Point& point = touchEvent.GetPoint(0);
+          point.SetState( PointState::INTERRUPTED );
+        }
+
+        mGestureEventProcessor.ProcessTouchEvent(mScene, touchEvent);
         break;
       }
 
index 0c41120..de2bd4f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -118,7 +118,7 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
         const Integration::Point& currentPoint1 = event.points[0];
         const Integration::Point& currentPoint2 = event.points[1];
 
-        if (currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP)
+        if (currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP || currentPoint1.GetState() == PointState::INTERRUPTED)
         {
           // One of our touch points has an Up event so change our state back to Clear.
           mState = Clear;
@@ -171,7 +171,15 @@ void PinchGestureRecognizer::SendEvent(const Integration::TouchEvent& event)
 
     case Started:
     {
-      if (pointCount != 2)
+      if(event.points[0].GetState() == PointState::INTERRUPTED)
+      {
+        // System interruption occurred, pinch should be cancelled
+        mTouchEvents.clear();
+        SendPinch(Gesture::Cancelled, event);
+        mState = Clear;
+        mTouchEvents.clear();
+      }
+      else if (pointCount != 2)
       {
         // Send pinch finished event
         SendPinch(Gesture::Finished, event);
index 7863886..6de3490 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -97,7 +97,7 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event
         const Integration::Point& currentPoint1 = event.points[0];
         const Integration::Point& currentPoint2 = event.points[1];
 
-        if( currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP )
+        if( currentPoint1.GetState() == PointState::UP || currentPoint2.GetState() == PointState::UP || currentPoint1.GetState() == PointState::INTERRUPTED )
         {
           // One of our touch points has an Up event so change our state back to Clear.
           mState = Clear;
@@ -139,7 +139,15 @@ void RotationGestureRecognizer::SendEvent( const Integration::TouchEvent& event
 
     case Started:
     {
-      if( pointCount != 2 )
+      if(event.points[0].GetState() == PointState::INTERRUPTED)
+      {
+        // System interruption occurred, rotation should be cancelled
+        mTouchEvents.clear();
+        SendRotation(Gesture::Cancelled, event);
+        mState = Clear;
+        mTouchEvents.clear();
+      }
+      else if( pointCount != 2 )
       {
         // Send rotation finished event
         SendRotation( Gesture::Finished, event );
index d09f59b..e1c8730 100644 (file)
@@ -202,7 +202,7 @@ TouchEventProcessor::~TouchEventProcessor()
   DALI_LOG_TRACE_METHOD( gLogFilter );
 }
 
-void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& event )
+bool TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& event )
 {
   DALI_LOG_TRACE_METHOD( gLogFilter );
   DALI_ASSERT_ALWAYS( !event.points.empty() && "Empty TouchEvent sent from Integration\n" );
@@ -264,7 +264,7 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
     touchEventImpl->AddPoint( currentPoint );
 
     mScene.EmitTouchedSignal( touchEventHandle );
-    return; // No need for hit testing
+    return false; // No need for hit testing & already an interrupted event so just return false
   }
 
   // 2) Hit Testing.
@@ -309,11 +309,14 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
 
   // 3) Recursively deliver events to the actor and its parents, until the event is consumed or the stage is reached.
 
+  bool consumed = false;
+
   // Emit the touch signal
   Dali::Actor consumedActor;
   if ( currentRenderTask )
   {
     consumedActor = EmitTouchSignals( touchEventImpl->GetPoint( 0 ).GetHitActor(), touchEventHandle );
+    consumed = consumedActor ? true : false;
   }
 
   Integration::Point& primaryPoint = touchEventImpl->GetPoint( 0 );
@@ -363,6 +366,8 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
         }
       }
 
+      consumed |= leaveEventConsumer ? true : false;
+
       // Check if the motion event has been consumed by another actor's listener.  In this case, the previously
       // consumed actor's listeners may need to be informed (through a leave event).
       // Further checks here to ensure we do not signal the same actor twice for the same event.
@@ -474,6 +479,8 @@ void TouchEventProcessor::ProcessTouchEvent( const Integration::TouchEvent& even
       }
     }
   }
+
+  return consumed;
 }
 
 void TouchEventProcessor::OnObservedActorDisconnected( Actor* actor )
index 9306e6f..c2e4bc7 100644 (file)
@@ -67,8 +67,9 @@ public:
   /**
    * This function is called by the event processor whenever a touch event occurs.
    * @param[in] event The touch event that has occurred.
+   * @return true if consumed
    */
-  void ProcessTouchEvent( const Integration::TouchEvent& event );
+  bool ProcessTouchEvent( const Integration::TouchEvent& event );
 
 private:
 
index 18d1c3d..21ead2d 100644 (file)
@@ -215,10 +215,6 @@ typedef Rect<float> Padding;      ///< Padding definition @SINCE_1_0.0
  *   - If the consumed actor on hover-start is not the same as the consumed actor on hover-finished, then
  *     hover signals are also emitted from the hover-started actor with an "Interrupted" state.
  *
- * <h3>Key Events:</h3>
- *
- * Key events are received by an actor once set to grab key events, only one actor can be set as focused.
- *
  * @nosubgrouping
  *
  * Signals
@@ -1173,6 +1169,7 @@ public: // Signals
    * @endcode
    * The return value of True, indicates that the touch event has been consumed.
    * Otherwise the signal will be emitted on the next sensitive parent of the actor.
+   * A true return will also cancel any ongoing gestures.
    * @SINCE_1_1.37
    * @return The signal to connect to
    * @pre The Actor has been initialized.