Revert "Change TOUCH_AREA to TOUCH_AREA_OFFSET" 84/257084/1
authorJoogab Yun <joogab.yun@samsung.com>
Mon, 19 Apr 2021 08:23:23 +0000 (17:23 +0900)
committerJoogab Yun <joogab.yun@samsung.com>
Mon, 19 Apr 2021 08:23:29 +0000 (17:23 +0900)
Change-Id: Ib036e525002837901293a1b190f4005c62b490f0

automated-tests/src/dali/utc-Dali-Actor.cpp
automated-tests/src/dali/utc-Dali-TouchProcessing.cpp
dali/devel-api/actors/actor-devel.h
dali/internal/event/actors/actor-impl.cpp
dali/internal/event/actors/actor-impl.h
dali/internal/event/actors/actor-property-handler.cpp
dali/internal/event/events/ray-test.cpp

index 940902e..02324d3 100644 (file)
@@ -8577,20 +8577,20 @@ int UtcDaliActorCaptureAllTouchAfterStartPropertyN(void)
   END_TEST;
 }
 
-int UtcDaliActorTouchAreaOffsetPropertyP(void)
+int UtcDaliActorTouchAreaPropertyP(void)
 {
   TestApplication application;
 
-  Actor     actor           = Actor::New();
-  Rect<int> touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
-  DALI_TEST_EQUALS(Rect<int>(0, 0, 0, 0), touchAreaOffset, TEST_LOCATION);
-  actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(10, 20, 30, 40));
-  touchAreaOffset = actor.GetProperty(DevelActor::Property::TOUCH_AREA_OFFSET).Get<Rect<int>>();
-  DALI_TEST_EQUALS(Rect<int>(10, 20, 30, 40), touchAreaOffset, TEST_LOCATION);
+  Actor   actor     = Actor::New();
+  Vector2 touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
+  DALI_TEST_EQUALS(touchArea, Vector2::ZERO, TEST_LOCATION);
+  actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(10.f, 10.f));
+  touchArea = actor.GetProperty(DevelActor::Property::TOUCH_AREA).Get<Vector2>();
+  DALI_TEST_EQUALS(touchArea, Vector2(10.f, 10.f), TEST_LOCATION);
   END_TEST;
 }
 
-int UtcDaliActorTouchAreaOffsetPropertyN(void)
+int UtcDaliActorTouchAreaPropertyN(void)
 {
   TestApplication application;
 
@@ -8599,12 +8599,12 @@ int UtcDaliActorTouchAreaOffsetPropertyN(void)
   // Make sure setting invalid types does not cause a crash
   try
   {
-    actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, 1.0f);
-    actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector2::ONE);
-    actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector3::ONE);
-    actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Vector4::ONE);
-    actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Map());
-    actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Property::Array());
+    actor.SetProperty(DevelActor::Property::TOUCH_AREA, 1.0f);
+    actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2::ONE);
+    actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector3::ONE);
+    actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector4::ONE);
+    actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Map());
+    actor.SetProperty(DevelActor::Property::TOUCH_AREA, Property::Array());
     tet_result(TET_PASS);
   }
   catch(...)
index ac66e4d..5f2d395 100644 (file)
@@ -2137,7 +2137,7 @@ int UtcDaliTouchEventIntercept(void)
   END_TEST;
 }
 
-int UtcDaliTouchAreaOffset(void)
+int UtcDaliTouchArea(void)
 {
   TestApplication application;
 
@@ -2163,7 +2163,7 @@ int UtcDaliTouchAreaOffset(void)
   data.Reset();
 
   // set a bigger touch area
-  actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(-70, 70, 70, -70)); // left, right, bottom, top
+  actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(200.0f, 200.0f));
 
   // Render and notify
   application.SendNotification();
@@ -2177,36 +2177,21 @@ int UtcDaliTouchAreaOffset(void)
   DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
   data.Reset();
 
-  // set a offset touch area
-  actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(50, 100, -50, 0)); // left, right, bottom, top
-
-  // Render and notify
-  application.SendNotification();
-  application.Render();
-
-  // Emit a down signal
-  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(190.0f, 25.0f)));
-  // The actor touched signal is called because the touch area is inside touchArea.
-  DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
-  DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
-  DALI_TEST_CHECK(actor == data.receivedTouch.points[0].hitActor);
-  data.Reset();
-
   // set a smaller touch area
-  actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(50, 0, 0, 50));
+  actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(50.0f, 50.0f));
 
   // Render and notify
   application.SendNotification();
   application.Render();
 
   // Emit a down signal
-  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(40.0f, 40.0f)));
+  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(80.0f, 80.0f)));
   // The actor touched signal is not called because the touch area is outside touchArea.
   DALI_TEST_EQUALS(false, data.functorCalled, TEST_LOCATION);
   data.Reset();
 
   // Emit a down signal
-  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(90.0f, 90.0f)));
+  application.ProcessEvent(GenerateSingleTouch(PointState::DOWN, Vector2(30.0f, 30.0f)));
   // The actor touched signal is called because the touch area is inside touchArea.
   DALI_TEST_EQUALS(true, data.functorCalled, TEST_LOCATION);
   DALI_TEST_EQUALS(PointState::DOWN, data.receivedTouch.points[0].state, TEST_LOCATION);
index 3df66b4..5821af0 100755 (executable)
@@ -2,7 +2,7 @@
 #define DALI_ACTOR_DEVEL_H
 
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -120,36 +120,18 @@ enum Type
   CAPTURE_ALL_TOUCH_AFTER_START,
 
   /**
-    * @brief If you set the TOUCH_AREA_OFFSET on an actor, when you touch the actor, the touch area is expand from the size of actor.
-    * @details Name "touchAreaOffset", type Property::Rect<int> (left, right, bottom, top)
+    * @brief If you set the TOUCH_AREA on an actor, when you touch the actor, the touch area is used rather than the size of the actor
+    * @details Name "touchArea", type Property::Vector2
+    * @note Default is Vector2::ZERO.
     * @note for example
     *  Actor actor = Actor::New();
-    *  actor.SetProperty(Actor::Property::SIZE, Vector2(20.0f, 20.0f));
-    *  actor.SetProperty(DevelActor::Property::TOUCH_AREA_OFFSET, Rect<int>(-10, 20, 30, -40));
+    *  actor.SetProperty(Actor::Property::SIZE, Vector2(10.0f, 10.0f));
+    *  actor.SetProperty(DevelActor::Property::TOUCH_AREA, Vector2(200.0f, 200.0f));
     *  actor.TouchedSignal().Connect(OnTouchCallback);
     *
-    * +---------------------+
-    * |         ^           |
-    * |         |           |
-    * |         | -40       |
-    * |         |           |
-    * |         |           |
-    * |    +----+----+      |
-    * |    |         |      |
-    * | -10|         | 20   |
-    * |<---+         +----->|
-    * |    |         |      |
-    * |    |         |      |
-    * |    +----+----+      |
-    * |         |           |
-    * |         | 30        |
-    * |         |           |
-    * |         v           |
-    * +---------------------+
-
-    *  The actual touched size is actor.width + touchAreaOffset.right - touchAreaOffset.left and actor.height + touchAreaOffset.bottom - touchAreaOffset.top
+    *  If you want to reset the touch area to an area different with the size of the actor, you can set this TOUCH_AREA property.
     */
-  TOUCH_AREA_OFFSET,
+  TOUCH_AREA,
 
   /**
    * @brief Determines which blend equation will be used to render renderers of this actor.
index 776c3f3..408c273 100644 (file)
@@ -146,7 +146,7 @@ DALI_PROPERTY("keyboardFocusable", BOOLEAN, true, false, false, Dali::Actor::Pro
 DALI_PROPERTY("siblingOrder", INTEGER, true, false, false, Dali::DevelActor::Property::SIBLING_ORDER)
 DALI_PROPERTY("updateSizeHint", VECTOR2, true, false, false, Dali::DevelActor::Property::UPDATE_SIZE_HINT)
 DALI_PROPERTY("captureAllTouchAfterStart", BOOLEAN, true, false, false, Dali::DevelActor::Property::CAPTURE_ALL_TOUCH_AFTER_START)
-DALI_PROPERTY("touchAreaOffset", RECTANGLE, true, false, false, Dali::DevelActor::Property::TOUCH_AREA_OFFSET)
+DALI_PROPERTY("touchArea", VECTOR2, true, false, false, Dali::DevelActor::Property::TOUCH_AREA)
 DALI_PROPERTY("blendEquation", INTEGER, true, false, false, Dali::DevelActor::Property::BLEND_EQUATION)
 DALI_PROPERTY_TABLE_END(DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties)
 
@@ -1321,7 +1321,7 @@ Actor::Actor(DerivedType derivedType, const SceneGraph::Node& node)
   mTargetPosition(Vector3::ZERO),
   mTargetScale(Vector3::ONE),
   mAnimatedSize(Vector3::ZERO),
-  mTouchAreaOffset(0, 0, 0, 0),
+  mTouchArea(Vector2::ZERO),
   mName(),
   mSortedDepth(0u),
   mDepth(0u),
index eb0ee82..106af0d 100644 (file)
@@ -1363,21 +1363,21 @@ public:
   }
 
   /**
-   * Sets the touch area offset of an actor.
-   * @param [in] offset The new offset of area (left, right, bottom, top).
+   * Sets the touch area of an actor.
+   * @param [in] area The new area.
    */
-  void SetTouchAreaOffset(Rect<int> offset)
+  void SetTouchArea(Vector2 area)
   {
-    mTouchAreaOffset = offset;
+    mTouchArea = area;
   }
 
   /**
-   * Retrieve the Actor's touch area offset.
-   * @return The Actor's touch area offset.
+   * Retrieve the Actor's touch area.
+   * @return The Actor's touch area.
    */
-  const Rect<int>& GetTouchAreaOffset() const
+  const Vector2& GetTouchArea() const
   {
-    return mTouchAreaOffset;
+    return mTouchArea;
   }
 
   // Gestures
@@ -2024,7 +2024,7 @@ protected:
   Vector3    mTargetPosition;    ///< Event-side storage for position (not a pointer as most actors will have a position)
   Vector3    mTargetScale;       ///< Event-side storage for scale
   Vector3    mAnimatedSize;      ///< Event-side storage for size animation
-  Rect<int>  mTouchAreaOffset;   ///< touch area offset (left, right, bottom, top)
+  Vector2    mTouchArea;         ///< touch area
 
   ConstString mName;            ///< Name of the actor
   uint32_t    mSortedDepth;     ///< The sorted depth index. A combination of tree traversal and sibling order.
index 111a088..02fc9ce 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -577,12 +577,12 @@ void Actor::PropertyHandler::SetDefaultProperty(Internal::Actor& actor, Property
       break;
     }
 
-    case Dali::DevelActor::Property::TOUCH_AREA_OFFSET:
+    case Dali::DevelActor::Property::TOUCH_AREA:
     {
-      Rect<int> rectValue;
-      if(property.Get(rectValue))
+      Vector2 vec2Value;
+      if(property.Get(vec2Value))
       {
-        actor.SetTouchAreaOffset(rectValue);
+        actor.SetTouchArea(vec2Value);
       }
       break;
     }
@@ -1634,9 +1634,9 @@ bool Actor::PropertyHandler::GetCachedPropertyValue(const Internal::Actor& actor
       break;
     }
 
-    case Dali::DevelActor::Property::TOUCH_AREA_OFFSET:
+    case Dali::DevelActor::Property::TOUCH_AREA:
     {
-      value = actor.GetTouchAreaOffset();
+      value = actor.GetTouchArea();
       break;
     }
 
index 9f3aa92..8659edf 100644 (file)
@@ -105,19 +105,18 @@ bool RayTest::SphereTest(const Internal::Actor& actor, const Vector4& rayOrigin,
     return false;
   }
 
-  const Node&       node            = actor.GetNode();
-  const BufferIndex bufferIndex     = EventThreadServices::Get().GetEventBufferIndex();
-  const Vector3&    translation     = node.GetWorldPosition(bufferIndex);
-  const Vector3&    size            = node.GetSize(bufferIndex);
-  const Vector3&    scale           = node.GetWorldScale(bufferIndex);
-  const Rect<int>&  touchAreaOffset = actor.GetTouchAreaOffset(); // (left, right, bottom, top)
+  const Node&       node        = actor.GetNode();
+  const BufferIndex bufferIndex = EventThreadServices::Get().GetEventBufferIndex();
+  const Vector3&    translation = node.GetWorldPosition(bufferIndex);
+  const Vector3&    size        = actor.GetTouchArea() == Vector2::ZERO ? node.GetSize(bufferIndex) : Vector3(actor.GetTouchArea());
+  const Vector3&    scale       = node.GetWorldScale(bufferIndex);
 
   // Transforms the ray to the local reference system. As the test is against a sphere, only the translation and scale are needed.
-  const Vector3 rayOriginLocal(rayOrigin.x - translation.x - (touchAreaOffset.left + touchAreaOffset.right) * 0.5, rayOrigin.y - translation.y - (touchAreaOffset.top + touchAreaOffset.bottom) * 0.5, rayOrigin.z - translation.z);
+  const Vector3 rayOriginLocal(rayOrigin.x - translation.x, rayOrigin.y - translation.y, rayOrigin.z - translation.z);
 
   // Computing the radius is not needed, a square radius is enough so can just use size but we do need to scale the sphere
-  const float width  = size.width * scale.width + touchAreaOffset.right - touchAreaOffset.left;
-  const float height = size.height * scale.height + touchAreaOffset.bottom - touchAreaOffset.top;
+  const float width  = size.width * scale.width;
+  const float height = size.height * scale.height;
 
   float squareSphereRadius = 0.5f * (width * width + height * height);
 
@@ -154,13 +153,12 @@ bool RayTest::ActorTest(const Internal::Actor& actor, const Vector4& rayOrigin,
       // Ray travels distance * rayDirLocal to intersect with plane.
       distance = a / b;
 
-      const Vector2&   size            = Vector2(node.GetSize(EventThreadServices::Get().GetEventBufferIndex()));
-      const Rect<int>& touchAreaOffset = actor.GetTouchAreaOffset(); // (left, right, bottom, top)
-      hitPointLocal.x                  = rayOriginLocal.x + rayDirLocal.x * distance + size.x * 0.5f;
-      hitPointLocal.y                  = rayOriginLocal.y + rayDirLocal.y * distance + size.y * 0.5f;
+      const Vector2& size = actor.GetTouchArea() == Vector2::ZERO ? Vector2(node.GetSize(EventThreadServices::Get().GetEventBufferIndex())) : actor.GetTouchArea();
+      hitPointLocal.x     = rayOriginLocal.x + rayDirLocal.x * distance + size.x * 0.5f;
+      hitPointLocal.y     = rayOriginLocal.y + rayDirLocal.y * distance + size.y * 0.5f;
 
       // Test with the actor's geometry.
-      hit = (hitPointLocal.x >= touchAreaOffset.left) && (hitPointLocal.x <= (size.x + touchAreaOffset.right) && (hitPointLocal.y >= touchAreaOffset.top) && (hitPointLocal.y <= (size.y + touchAreaOffset.bottom)));
+      hit = (hitPointLocal.x >= 0.f) && (hitPointLocal.x <= size.x) && (hitPointLocal.y >= 0.f) && (hitPointLocal.y <= size.y);
     }
   }