From: joogab.yun Date: Tue, 23 Apr 2024 05:45:38 +0000 (+0900) Subject: [Tizen] Allows updating MinimumDistance and MinimumPanEvents of pan gestures. X-Git-Tag: accepted/tizen/8.0/unified/20240509.175855~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7d273449e1aab8eb1c670c351f14cb06cc465380;p=platform%2Fcore%2Fuifw%2Fdali-core.git [Tizen] Allows updating MinimumDistance and MinimumPanEvents of pan gestures. Change-Id: Ibe985928ae9e68f70fc4faf573284ce1ee956fb5 --- diff --git a/automated-tests/src/dali/utc-Dali-PanGestureRecognizer.cpp b/automated-tests/src/dali/utc-Dali-PanGestureRecognizer.cpp index 5f6e075..c6ee297 100644 --- a/automated-tests/src/dali/utc-Dali-PanGestureRecognizer.cpp +++ b/automated-tests/src/dali/utc-Dali-PanGestureRecognizer.cpp @@ -696,6 +696,62 @@ int UtcDaliPanGestureRecognizerNewParamsMinNum(void) END_TEST; } +int UtcDaliPanGestureRecognizerUpdateParamsMinNum(void) +{ + TestApplication application; + + Integration::SetPanGestureMinimumPanEvents(8); + + PanGestureDetector detector = PanGestureDetector::New(); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + SignalData data; + GestureReceivedFunctor functor(data); + detector.DetectedSignal().Connect(&application, functor); + + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655)); + + application.SendNotification(); + + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 90.0f), 756)); + application.SendNotification(); + data.Reset(); + + Integration::SetPanGestureMinimumPanEvents(10); + + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 100.0f), 756)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 110.0f), 857)); + + application.SendNotification(); + + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + END_TEST; +} + + int UtcDaliPanGestureRecognizerNewParamsMinDistance(void) { TestApplication application; @@ -732,3 +788,59 @@ int UtcDaliPanGestureRecognizerNewParamsMinDistance(void) END_TEST; } + +int UtcDaliPanGestureRecognizerUpdateParamsMinDistance(void) +{ + TestApplication application; + + Integration::SetPanGestureMinimumDistance(100); + + PanGestureDetector detector = PanGestureDetector::New(); + + Actor actor = Actor::New(); + actor.SetProperty(Actor::Property::SIZE, Vector2(100.0f, 100.0f)); + actor.SetProperty(Actor::Property::ANCHOR_POINT, AnchorPoint::TOP_LEFT); + application.GetScene().Add(actor); + + // Render and notify + application.SendNotification(); + application.Render(); + + detector.Attach(actor); + + SignalData data; + GestureReceivedFunctor functor(data); + detector.DetectedSignal().Connect(&application, functor); + + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655)); + + application.SendNotification(); + + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + application.ProcessEvent(GenerateSingleTouch(PointState::UP, Vector2(20.0f, 90.0f), 756)); + application.SendNotification(); + data.Reset(); + + Integration::SetPanGestureMinimumDistance(130); + + application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(20.0f, 20.0f), 150)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 40.0f), 251)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 60.0f), 352)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 70.0f), 453)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 80.0f), 554)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 90.0f), 655)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 100.0f),756)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 110.0f),857)); + application.ProcessEvent(GenerateSingleTouch(PointState::MOTION, Vector2(20.0f, 120.0f),858)); + + application.SendNotification(); + + DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); + + END_TEST; +} diff --git a/dali/internal/event/events/gesture-event-processor.cpp b/dali/internal/event/events/gesture-event-processor.cpp index 135097d..85abccc 100644 --- a/dali/internal/event/events/gesture-event-processor.cpp +++ b/dali/internal/event/events/gesture-event-processor.cpp @@ -329,11 +329,13 @@ void GestureEventProcessor::SetPanGestureMultitapSmoothingRange(int32_t value) void GestureEventProcessor::SetPanGestureMinimumDistance(int32_t value) { envOptionMinimumPanDistance = value; + mPanGestureProcessor.SetMinimumDistance(value); } void GestureEventProcessor::SetPanGestureMinimumPanEvents(int32_t value) { envOptionMinimumPanEvents = value; + mPanGestureProcessor.SetMinimumPanEvents(value); } void GestureEventProcessor::SetPinchGestureMinimumDistance(float value) 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 e1ff19e..a495995 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-processor.cpp @@ -495,6 +495,31 @@ void PanGestureProcessor::SetMultitapSmoothingRange(int value) mSceneObject->SetMultitapSmoothingRange(value); } +void PanGestureProcessor::SetMinimumDistance(int32_t value) +{ + if(mGestureRecognizer) + { + PanGestureRecognizer* panRecognizer = dynamic_cast(mGestureRecognizer.Get()); + if(panRecognizer) + { + panRecognizer->SetMinimumDistance(value); + } + } +} + +void PanGestureProcessor::SetMinimumPanEvents(int32_t value) +{ + if(mGestureRecognizer) + { + PanGestureRecognizer* panRecognizer = dynamic_cast(mGestureRecognizer.Get()); + if(panRecognizer) + { + panRecognizer->SetMinimumPanEvents(value); + } + } +} + + const SceneGraph::PanGesture& PanGestureProcessor::GetSceneObject() const { return *mSceneObject; diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-processor.h b/dali/internal/event/events/pan-gesture/pan-gesture-processor.h index bfeb623..c9f60c3 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-processor.h +++ b/dali/internal/event/events/pan-gesture/pan-gesture-processor.h @@ -221,6 +221,18 @@ public: // To be called by GestureEventProcessor */ void SetMultitapSmoothingRange(int value); + /** + * This method sets the minimum distance to start a pan + * @param[in] value The distance in pixels + */ + void SetMinimumDistance(int32_t value); + + /** + * Sets the minimum touch events required before a pan can be started + * @param[in] value The number of touch events + */ + void SetMinimumPanEvents(int32_t value); + public: // for PanGestureDetector /** * @return the pan gesture scene object diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp index 4e6ad9e..d5b40d0 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp +++ b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.cpp @@ -345,6 +345,27 @@ void PanGestureRecognizer::SendPan(GestureState state, const Integration::TouchE } } +void PanGestureRecognizer::SetMinimumDistance(int32_t minimumDistance) +{ + if(minimumDistance >= 0) + { + mMinimumDistanceSquared = minimumDistance * minimumDistance; + + // Usually, we do not want to apply the threshold straight away, but phased over the first few pans + // Set our distance to threshold adjustments ratio here. + float fMinimumDistance = static_cast(minimumDistance); + mThresholdTotalAdjustments = static_cast(fMinimumDistance * MINIMUM_MOTION_DISTANCE_TO_THRESHOLD_ADJUSTMENTS_RATIO); + } +} + +void PanGestureRecognizer::SetMinimumPanEvents(int32_t minimumPanEvents) +{ + if(minimumPanEvents >= 1) + { + mMinimumMotionEvents = minimumPanEvents - 1; // Down is the first event + } +} + } // namespace Internal } // namespace Dali diff --git a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h index 8bc3715..c1b1f30 100644 --- a/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h +++ b/dali/internal/event/events/pan-gesture/pan-gesture-recognizer.h @@ -63,6 +63,18 @@ public: public: /** + * This method sets the minimum distance to start a pan + * @param[in] minimumDistance The distance in pixels + */ + void SetMinimumDistance(int32_t minimumDistance); + + /** + * Sets the minimum touch events required before a pan can be started + * @param[in] minimumPanEvents The number of touch events + */ + void SetMinimumPanEvents(int32_t minimumPanEvents); + + /** * @copydoc Dali::Internal::GestureDetector::SendEvent(const Integration::TouchEvent&) */ void SendEvent(const Integration::TouchEvent& event) override;