If the parent is intercepted, the child is informed that it is INTERRUPTED. 49/265649/3
authorjoogab.yun <joogab.yun@samsung.com>
Tue, 26 Oct 2021 06:45:28 +0000 (15:45 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Thu, 28 Oct 2021 05:02:10 +0000 (14:02 +0900)
Change-Id: I4ef25e7bad0883a9798f86add0b911de36078dea

automated-tests/src/dali/utc-Dali-TouchProcessing.cpp
dali/internal/event/events/touch-event-processor.cpp
dali/internal/event/events/touch-event-processor.h

index ac66e4d..eddbe46 100644 (file)
@@ -2114,6 +2114,15 @@ int UtcDaliTouchEventIntercept(void)
   SignalData        parentData;
   TouchEventFunctor parentFunctor(parentData, false /* Do not consume */);
   parent.TouchedSignal().Connect(&application, parentFunctor);
+
+  // Emit a down signal
+  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
+
+  data.Reset();
+  parentData.Reset();
+
   // Connect to parent's intercept touched signal
   SignalData        interceptData;
   TouchEventFunctor interceptFunctor(interceptData, true /* Do intercept */);
@@ -2121,8 +2130,10 @@ int UtcDaliTouchEventIntercept(void)
 
   // Emit a down signal
   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
-  // The actor touched signal is not called because the touch is intercepted in the parent.
-  DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+
+  // The actor gets interrupted. Because touch is intercepted by parent.
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  DALI_TEST_EQUALS(PointState::INTERRUPTED, data.receivedTouch.points[0].state, TEST_LOCATION);
   DALI_TEST_EQUALS(true, interceptData.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(PointState::DOWN, interceptData.receivedTouch.points[0].state, TEST_LOCATION);
   DALI_TEST_CHECK(actor == interceptData.receivedTouch.points[0].hitActor);
index 4ac3034..2e173b5 100644 (file)
@@ -218,7 +218,8 @@ TouchEventProcessor::TouchEventProcessor(Scene& scene)
   mLastConsumedActor(),
   mCapturingTouchActor(),
   mTouchDownConsumedActor(),
-  mLastRenderTask()
+  mLastRenderTask(),
+  mLastPrimaryPointState(PointState::FINISHED)
 {
   DALI_LOG_TRACE_METHOD(gLogFilter);
 }
@@ -281,6 +282,7 @@ bool TouchEventProcessor::ProcessTouchEvent(const Integration::TouchEvent& event
     mCapturingTouchActor.SetActor(nullptr);
     mTouchDownConsumedActor.SetActor(nullptr);
     mLastRenderTask.Reset();
+    mLastPrimaryPointState = PointState::FINISHED;
 
     currentPoint.SetHitActor(Dali::Actor());
 
@@ -334,25 +336,35 @@ bool TouchEventProcessor::ProcessTouchEvent(const Integration::TouchEvent& event
 
   // Emit the touch signal
   Dali::Actor consumedActor;
+
+  Integration::Point& primaryPoint      = touchEventImpl->GetPoint(0);
+  Dali::Actor         primaryHitActor   = primaryPoint.GetHitActor();
+  PointState::Type    primaryPointState = primaryPoint.GetState();
+
   if(currentRenderTask)
   {
     // Emit the intercept touch signal
-    Dali::Actor interceptedActor = EmitInterceptTouchSignals(touchEventImpl->GetPoint(0).GetHitActor(), touchEventHandle);
+    Dali::Actor interceptedActor = EmitInterceptTouchSignals(primaryHitActor, touchEventHandle);
     if(interceptedActor)
     {
+      // If the child is being touched, INTERRUPTED is sent.
+      if(mLastPrimaryHitActor.GetActor() &&
+         mLastPrimaryHitActor.GetActor() != interceptedActor &&
+         mLastRenderTask &&
+         mLastPrimaryPointState != PointState::FINISHED)
+      {
+        EmitTouchSignals(mLastPrimaryHitActor.GetActor(), *mLastRenderTask.Get(), touchEventImpl, PointState::INTERRUPTED);
+      }
+
       consumedActor = EmitTouchSignals(interceptedActor, touchEventHandle);
     }
     else
     {
-      consumedActor = EmitTouchSignals(touchEventImpl->GetPoint(0).GetHitActor(), touchEventHandle);
+      consumedActor = EmitTouchSignals(primaryHitActor, touchEventHandle);
     }
     consumed = consumedActor ? true : false;
   }
 
-  Integration::Point& primaryPoint      = touchEventImpl->GetPoint(0);
-  Dali::Actor         primaryHitActor   = primaryPoint.GetHitActor();
-  PointState::Type    primaryPointState = primaryPoint.GetState();
-
   DALI_LOG_INFO(gLogFilter, Debug::Concise, "PrimaryHitActor:     (%p) %s\n", primaryHitActor ? reinterpret_cast<void*>(&primaryHitActor.GetBaseObject()) : NULL, primaryHitActor ? primaryHitActor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : "");
   DALI_LOG_INFO(gLogFilter, Debug::Concise, "ConsumedActor:       (%p) %s\n", consumedActor ? reinterpret_cast<void*>(&consumedActor.GetBaseObject()) : NULL, consumedActor ? consumedActor.GetProperty<std::string>(Dali::Actor::Property::NAME).c_str() : "");
 
@@ -428,13 +440,13 @@ bool TouchEventProcessor::ProcessTouchEvent(const Integration::TouchEvent& event
 
   // 5) If our primary point is an Up event, then the primary point (in multi-touch) will change next
   //    time so set our last primary actor to NULL.  Do the same to the last consumed actor as well.
-
   if(primaryPointState == PointState::UP)
   {
     mLastPrimaryHitActor.SetActor(nullptr);
     mLastConsumedActor.SetActor(nullptr);
     mCapturingTouchActor.SetActor(nullptr);
     mLastRenderTask.Reset();
+    mLastPrimaryPointState = PointState::FINISHED;
   }
   else
   {
@@ -453,7 +465,8 @@ bool TouchEventProcessor::ProcessTouchEvent(const Integration::TouchEvent& event
         mLastConsumedActor.SetActor(nullptr);
       }
 
-      mLastRenderTask = currentRenderTask;
+      mLastRenderTask        = currentRenderTask;
+      mLastPrimaryPointState = primaryPointState;
     }
     else
     {
@@ -461,6 +474,7 @@ bool TouchEventProcessor::ProcessTouchEvent(const Integration::TouchEvent& event
       mLastConsumedActor.SetActor(nullptr);
       mCapturingTouchActor.SetActor(nullptr);
       mLastRenderTask.Reset();
+      mLastPrimaryPointState = PointState::FINISHED;
     }
   }
 
@@ -538,6 +552,7 @@ void TouchEventProcessor::OnObservedActorDisconnected(Actor* actor)
 
     mLastConsumedActor.SetActor(nullptr);
     mLastRenderTask.Reset();
+    mLastPrimaryPointState = PointState::FINISHED;
   }
 }
 
index d803953..70a0fb9 100644 (file)
@@ -21,6 +21,7 @@
 // INTERNAL INCLUDES
 #include <dali/internal/event/events/actor-observer.h>
 #include <dali/internal/event/render-tasks/render-task-impl.h>
+#include <dali/public-api/events/point-state.h>
 
 namespace Dali
 {
@@ -85,11 +86,12 @@ private:
    */
   void OnObservedActorDisconnected(Actor* actor);
 
-  ActorObserver mLastPrimaryHitActor;    ///< Stores the last primary point hit actor
-  ActorObserver mLastConsumedActor;      ///< Stores the last consumed actor
-  ActorObserver mCapturingTouchActor;    ///< Stored the actor that captures touch
-  ActorObserver mTouchDownConsumedActor; ///< Stores the touch-down consumed actor
-  RenderTaskPtr mLastRenderTask;         ///< The RenderTask used for the last hit actor
+  ActorObserver    mLastPrimaryHitActor;    ///< Stores the last primary point hit actor
+  ActorObserver    mLastConsumedActor;      ///< Stores the last consumed actor
+  ActorObserver    mCapturingTouchActor;    ///< Stored the actor that captures touch
+  ActorObserver    mTouchDownConsumedActor; ///< Stores the touch-down consumed actor
+  RenderTaskPtr    mLastRenderTask;         ///< The RenderTask used for the last hit actor
+  PointState::Type mLastPrimaryPointState;  ///< Stores the last primary point state
 };
 
 } // namespace Internal