(HitTest) Check clipped actor if it is really touchable before using as hit-actor submit/tizen_6.0/20210311.224848
authorAdeel Kazmi <adeel.kazmi@samsung.com>
Mon, 1 Feb 2021 19:55:58 +0000 (19:55 +0000)
committerJoogab Yun <joogab.yun@samsung.com>
Fri, 5 Feb 2021 03:39:58 +0000 (12:39 +0900)
Change-Id: I073f6ddab910acb7aaf850d1f1c93fd6d15e1ebe

automated-tests/src/dali/utc-Dali-HoverProcessing.cpp
automated-tests/src/dali/utc-Dali-TouchProcessing.cpp
dali/internal/event/events/hit-test-algorithm-impl.cpp

index 7f1784d..70393de 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 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.
@@ -1261,9 +1261,9 @@ int UtcDaliHoverClippingActor(void)
   HoverEventFunctor functor(data);
   actor.HoveredSignal().Connect(&application, functor);
 
-  // Emit an event within clipped area - no hit.
+  // Emit an event within clipped area - we should have a hit.
   application.ProcessEvent(GenerateSingleHover(PointState::STARTED, Vector2(10.0f, 10.0f)));
-  DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   data.Reset();
 
   // Emit an event outside the clipped area but within the actor area, we should have a hit.
index 275aa2a..d82eacb 100755 (executable)
@@ -1501,22 +1501,40 @@ int UtcDaliTouchEventClippedActor(void)
   TouchEventFunctor functor(data);
   actor.TouchedSignal().Connect(&application, functor);
 
-  // Emit an event within clipped area - no hit.
+  // Emit an event within clipped area - we should have a hit.
   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(10.0f, 10.0f)));
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  data.Reset();
+
+  // Emit an event within clipped child area - we should still have a hit.
+  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
+  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  data.Reset();
+
+  // Now connect to the clippingChild's touch signal
+  SignalData        clippingChildData;
+  TouchEventFunctor clippingChildFunctor(clippingChildData);
+  clippingChild.TouchedSignal().Connect(&application, clippingChildFunctor);
+
+  // Emit an event within clipped child area - no hit on actor, but hit on clipped child.
+  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
+  DALI_TEST_EQUALS(true, clippingChildData.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
   data.Reset();
+  clippingChildData.Reset();
 
   // Emit an event outside the clipped area but within the actor area, we should have a hit.
   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(60.0f, 60.0f)));
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   data.Reset();
+  clippingChildData.Reset();
 
-  clippingChild.TouchedSignal().Connect(&application, functor);
-
-  // Emit an event inside part of the child which is within the clipped area, we should have a hit.
+  // Emit an event inside part of the child which is within the clipped area, we should have a hit on the clipped child but not the actor.
   application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(30.0f, 30.0f)));
-  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
+  DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
+  DALI_TEST_EQUALS(true, clippingChildData.functorCalled, TEST_LOCATION);
   data.Reset();
+  clippingChildData.Reset();
 
   END_TEST;
 }
index 25d6a42..d47f35d 100644 (file)
@@ -301,6 +301,14 @@ HitActor HitTestWithinLayer( Actor& actor,
                                                  clippingBitPlaneMask,
                                                  rayTest ) );
 
+        // Make sure the set hit actor is actually hittable. This is usually required when we have some
+        // clipping as we need to hit-test all actors as we descend the tree regardless of whether they
+        // are hittable or not.
+        if(currentHit.actor && !hitCheck.IsActorHittable(currentHit.actor))
+        {
+          continue;
+        }
+
         bool updateChildHit = false;
         if( currentHit.distance >= 0.0f )
         {