From b13394993ab3a6847b64bd037cfedf4a82edfbd0 Mon Sep 17 00:00:00 2001 From: "joogab.yun" Date: Mon, 27 Mar 2023 18:56:08 +0900 Subject: [PATCH] [Tizen] The hover event now starts in the STARTED state when a new actor is encountered. When hover event is registered, only motion comes. You can't know that the hover has started on that actor. So, when the hover starts on the new actor, set it to STARTED state. Change-Id: If25595536bce2279529847056ed962c515632165 --- .../src/dali/utc-Dali-HoverProcessing.cpp | 12 ++++++------ .../event/events/hover-event-processor.cpp | 22 +++++++++++++++++----- dali/public-api/actors/actor.h | 3 ++- dali/public-api/events/hover-event.h | 5 ++++- 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp index 6c07092..f28d202 100644 --- a/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp +++ b/automated-tests/src/dali/utc-Dali-HoverProcessing.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -571,10 +571,10 @@ int UtcDaliHoverLeave(void) DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION); data.Reset(); - // Another motion event inside actor, signalled with motion + // Another motion event inside actor, signalled with start. This is because a new hover event was started on that actor. application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(10.0f, 10.0f))); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(PointState::MOTION, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); data.Reset(); // We do not want to listen to leave events anymore @@ -646,12 +646,12 @@ int UtcDaliHoverLeaveParentConsumer(void) data.Reset(); rootData.Reset(); - // Another motion event inside actor, signalled with motion + // Another motion event inside actor, signalled with start. This is because a new hover event was started on that actor. application.ProcessEvent(GenerateSingleHover(PointState::MOTION, Vector2(10.0f, 10.0f))); DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION); DALI_TEST_EQUALS(true, rootData.functorCalled, TEST_LOCATION); - DALI_TEST_EQUALS(PointState::MOTION, data.hoverEvent.GetState(0), TEST_LOCATION); - DALI_TEST_EQUALS(PointState::MOTION, rootData.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, data.hoverEvent.GetState(0), TEST_LOCATION); + DALI_TEST_EQUALS(PointState::STARTED, rootData.hoverEvent.GetState(0), TEST_LOCATION); DALI_TEST_CHECK(actor == data.hoverEvent.GetHitActor(0)); DALI_TEST_CHECK(actor == rootData.hoverEvent.GetHitActor(0)); data.Reset(); diff --git a/dali/internal/event/events/hover-event-processor.cpp b/dali/internal/event/events/hover-event-processor.cpp index 114255e..0f61ab5 100644 --- a/dali/internal/event/events/hover-event-processor.cpp +++ b/dali/internal/event/events/hover-event-processor.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -271,7 +271,19 @@ void HoverEventProcessor::ProcessHoverEvent(const Integration::HoverEvent& event Dali::Actor consumedActor; if(currentRenderTask) { - consumedActor = EmitHoverSignals(hoverEvent->GetHitActor(0), hoverEventHandle); + Dali::Actor hitActor = hoverEvent->GetHitActor(0); + // If the actor is hit first, the hover is started. + if(hitActor && + mLastPrimaryHitActor.GetActor() != hitActor && + state == PointState::MOTION) + { + Actor* hitActorImpl = &GetImplementation(hitActor); + if(hitActorImpl->GetLeaveRequired()) + { + hoverEvent->GetPoint(0).SetState(PointState::STARTED); + } + } + consumedActor = EmitHoverSignals(hitActor, hoverEventHandle); } Integration::Point primaryPoint = hoverEvent->GetPoint(0); @@ -293,7 +305,7 @@ void HoverEventProcessor::ProcessHoverEvent(const Integration::HoverEvent& event Actor* lastPrimaryHitActor(mLastPrimaryHitActor.GetActor()); Actor* lastConsumedActor(mLastConsumedActor.GetActor()); - if((primaryPointState == PointState::MOTION) || (primaryPointState == PointState::FINISHED) || (primaryPointState == PointState::STATIONARY)) + if((primaryPointState == PointState::STARTED) || (primaryPointState == PointState::MOTION) || (primaryPointState == PointState::FINISHED) || (primaryPointState == PointState::STATIONARY)) { if(mLastRenderTask) { @@ -312,7 +324,7 @@ void HoverEventProcessor::ProcessHoverEvent(const Integration::HoverEvent& event leaveEventConsumer = EmitHoverSignals(mLastPrimaryHitActor.GetActor(), lastRenderTaskImpl, hoverEvent, PointState::LEAVE); } } - else + else if(primaryPointState != PointState::STARTED) { // At this point mLastPrimaryHitActor was touchable and sensitive in the previous touch event process but is not in the current one. // An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls) @@ -338,7 +350,7 @@ void HoverEventProcessor::ProcessHoverEvent(const Integration::HoverEvent& event EmitHoverSignals(lastConsumedActor, lastRenderTaskImpl, hoverEvent, PointState::LEAVE); } } - else + else if(primaryPointState != PointState::STARTED) { // At this point mLastConsumedActor was touchable and sensitive in the previous touch event process but is not in the current one. // An interrupted event is send to allow some actors to go back to their original state (i.e. Button controls) diff --git a/dali/public-api/actors/actor.h b/dali/public-api/actors/actor.h index 0252ce5..843d82f 100644 --- a/dali/public-api/actors/actor.h +++ b/dali/public-api/actors/actor.h @@ -2,7 +2,7 @@ #define DALI_ACTOR_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -515,6 +515,7 @@ public: /** * @brief The flag whether an actor should receive a notification when touch or hover motion events leave. + * In the case of the hover event, when the hover event enters the actor, it will receive started state. * @details Name "leaveRequired", type Property::BOOLEAN * @SINCE_1_0.0 */ diff --git a/dali/public-api/events/hover-event.h b/dali/public-api/events/hover-event.h index 26593b5..2ad55df 100644 --- a/dali/public-api/events/hover-event.h +++ b/dali/public-api/events/hover-event.h @@ -2,7 +2,7 @@ #define DALI_HOVER_EVENT_H /* - * Copyright (c) 2020 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -141,6 +141,9 @@ public: * @param[in] point The point required * @return The state of the point specified * @note If point is greater than GetPointCount() then this method will return PointState::FINISHED. + * If you set Actor::Property::LEAVE_REQUIRED to true, when the hover event enters the actor, it will receive STARTED state. + * an actor that received a hover PointState::MOTION event will receive PointState::INTERRUPTED event when Actor::Property::SENSITIVE is changed to false. + * However, an actor that received a hover PointState::STARTED event will not receive any event when Actor::Property::SENSITIVE is changed to false. * @see State */ PointState::Type GetState(std::size_t point) const; -- 2.7.4