[Tizen] The hover event now starts in the STARTED state when a new actor is encountered. 20/290720/1 accepted/tizen/7.0/unified/20230403.235554 accepted/tizen/7.0/unified/20230404.033728
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 27 Mar 2023 09:56:08 +0000 (18:56 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Fri, 31 Mar 2023 07:39:29 +0000 (16:39 +0900)
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

automated-tests/src/dali/utc-Dali-HoverProcessing.cpp
dali/internal/event/events/hover-event-processor.cpp
dali/public-api/actors/actor.h
dali/public-api/events/hover-event.h

index 6c07092..f28d202 100644 (file)
@@ -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();
index 114255e..0f61ab5 100644 (file)
@@ -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)
index 0252ce5..843d82f 100644 (file)
@@ -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
        */
index 26593b5..2ad55df 100644 (file)
@@ -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;