From b0516efeefaff68139bee29a7317eccd3729adbb Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Thu, 4 Apr 2024 10:54:25 +0900 Subject: [PATCH] 1. Fixes a bug where events do not occur when longPressGestures overlap. This is when using gestures with FeedTouch. 2. Remove unnecessary conditional statements. Change-Id: If8a4e876cb0b6031e744b6f0b8a3beef6d28517d --- .../long-press-gesture-processor.cpp | 20 +++++++++----------- .../events/pan-gesture/pan-gesture-processor.cpp | 11 ++++------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp b/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp index 81cead4..19b772d 100644 --- a/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp +++ b/dali/internal/event/events/long-press-gesture/long-press-gesture-processor.cpp @@ -148,17 +148,18 @@ void LongPressGestureProcessor::Process(Scene& scene, const LongPressGestureEven case GestureState::STARTED: { - Actor* currentGesturedActor = GetCurrentGesturedActor(); - if(currentGesturedActor) + if(GetCurrentGesturedActor()) { HitTestAlgorithm::Results hitTestResults; - if(GetFeededActor()) + Actor* feededActor = GetFeededActor(); + if(feededActor) { - hitTestResults.actor = Dali::Actor(GetFeededActor()); + SetActor(feededActor); + hitTestResults.actor = Dali::Actor(feededActor); hitTestResults.renderTask = GetFeededRenderTask(); Vector2 actorCoords; - currentGesturedActor->ScreenToLocal(*hitTestResults.renderTask.Get(), actorCoords.x, actorCoords.y, longPressEvent.point.x, longPressEvent.point.y); + feededActor->ScreenToLocal(*hitTestResults.renderTask.Get(), actorCoords.x, actorCoords.y, longPressEvent.point.x, longPressEvent.point.y); hitTestResults.actorCoordinates = actorCoords; } else @@ -166,14 +167,14 @@ void LongPressGestureProcessor::Process(Scene& scene, const LongPressGestureEven HitTest(scene, longPressEvent.point, hitTestResults); } - if(hitTestResults.actor && (currentGesturedActor == &GetImplementation(hitTestResults.actor))) + if(hitTestResults.actor && (GetCurrentGesturedActor() == &GetImplementation(hitTestResults.actor))) { // Record the current render-task for Screen->Actor coordinate conversions mCurrentRenderTask = hitTestResults.renderTask; // Set mCurrentLongPressEvent to use inside overridden methods called from ProcessAndEmit() mCurrentLongPressEvent = &longPressEvent; - if(GetFeededActor()) + if(feededActor) { ProcessAndEmitActor(hitTestResults, GetFeededGestureDetector()); } @@ -207,10 +208,7 @@ void LongPressGestureProcessor::Process(Scene& scene, const LongPressGestureEven // Ensure actor is still attached to the emitters, if it is not then remove the emitter. GestureDetectorContainer::iterator endIter = std::remove_if(mCurrentEmitters.begin(), mCurrentEmitters.end(), IsNotAttachedFunctor(currentGesturedActor)); mCurrentEmitters.erase(endIter, mCurrentEmitters.end()); - if(GetFeededGestureDetector()) - { - mCurrentEmitters.push_back(GetFeededGestureDetector()); - } + if(!mCurrentEmitters.empty()) { Vector2 actorCoords; diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp index 8267a2b..e1ff19e 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp @@ -276,13 +276,10 @@ void PanGestureProcessor::Process(Scene& scene, const PanGestureEvent& panEvent) { GestureDetectorContainer outsideTouchesRangeEmitters; - if(!(GetFeededActor() && GetFeededGestureDetector())) - { - // Removes emitters that no longer have the actor attached - // Also remove emitters whose touches are outside the range of the current pan event and add them to outsideTouchesRangeEmitters - GestureDetectorContainer::iterator endIter = std::remove_if(mCurrentPanEmitters.begin(), mCurrentPanEmitters.end(), IsNotAttachedAndOutsideTouchesRangeFunctor(currentGesturedActor, panEvent.numberOfTouches, outsideTouchesRangeEmitters)); - mCurrentPanEmitters.erase(endIter, mCurrentPanEmitters.end()); - } + // Removes emitters that no longer have the actor attached + // Also remove emitters whose touches are outside the range of the current pan event and add them to outsideTouchesRangeEmitters + GestureDetectorContainer::iterator endIter = std::remove_if(mCurrentPanEmitters.begin(), mCurrentPanEmitters.end(), IsNotAttachedAndOutsideTouchesRangeFunctor(currentGesturedActor, panEvent.numberOfTouches, outsideTouchesRangeEmitters)); + mCurrentPanEmitters.erase(endIter, mCurrentPanEmitters.end()); Vector2 actorCoords; if(!outsideTouchesRangeEmitters.empty() || !mCurrentPanEmitters.empty()) -- 2.7.4