From 3d321b256f0799b1683d9d23fabb8bfd612d3bd9 Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Tue, 26 Oct 2021 15:45:28 +0900 Subject: [PATCH] If the parent is intercepted, the child is informed that it is INTERRUPTED. Change-Id: I4ef25e7bad0883a9798f86add0b911de36078dea --- .../src/dali/utc-Dali-TouchProcessing.cpp | 15 ++++++++-- .../event/events/touch-event-processor.cpp | 33 ++++++++++++++++------ dali/internal/event/events/touch-event-processor.h | 12 ++++---- 3 files changed, 44 insertions(+), 16 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp index ac66e4d..eddbe46 100644 --- a/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-TouchProcessing.cpp @@ -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); diff --git a/dali/internal/event/events/touch-event-processor.cpp b/dali/internal/event/events/touch-event-processor.cpp index 4ac3034..2e173b5 100644 --- a/dali/internal/event/events/touch-event-processor.cpp +++ b/dali/internal/event/events/touch-event-processor.cpp @@ -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(&primaryHitActor.GetBaseObject()) : NULL, primaryHitActor ? primaryHitActor.GetProperty(Dali::Actor::Property::NAME).c_str() : ""); DALI_LOG_INFO(gLogFilter, Debug::Concise, "ConsumedActor: (%p) %s\n", consumedActor ? reinterpret_cast(&consumedActor.GetBaseObject()) : NULL, consumedActor ? consumedActor.GetProperty(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; } } diff --git a/dali/internal/event/events/touch-event-processor.h b/dali/internal/event/events/touch-event-processor.h index d803953..70a0fb9 100644 --- a/dali/internal/event/events/touch-event-processor.h +++ b/dali/internal/event/events/touch-event-processor.h @@ -21,6 +21,7 @@ // INTERNAL INCLUDES #include #include +#include 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 -- 2.7.4