From 931d4329010ef38c8376a636c1e080adea3736ba Mon Sep 17 00:00:00 2001 From: Wonsik Jung Date: Fri, 15 Sep 2023 11:47:59 +0900 Subject: [PATCH] [Tizen] Make Hittable and touch required function be public Make Hittable and touch required function be public to use in dali-toolkit Change-Id: Ib43dc98caebe4f191e2f82f1816b78b5599f21a8 --- automated-tests/src/dali/utc-Dali-Actor.cpp | 54 ++++++++++++++++++++++++++++- dali/devel-api/actors/actor-devel.cpp | 10 ++++++ dali/devel-api/actors/actor-devel.h | 17 +++++++++ dali/internal/event/actors/actor-impl.h | 35 +++++++++---------- 4 files changed, 96 insertions(+), 20 deletions(-) diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 8294c99..4f661b6 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -11751,4 +11751,56 @@ int UtcDaliActorCalculateLookAt(void) DALI_TEST_EQUALS(actorQuaternion, Quaternion(), TEST_LOCATION); END_TEST; -} \ No newline at end of file +} + +int UtcDaliActorIsHittable(void) +{ + TestApplication application; + + Actor parent = Actor::New(); + Vector4 parentColor(1.0f, 0.5f, 0.0f, 0.8f); + parent.SetProperty(Actor::Property::COLOR, parentColor); + application.GetScene().Add(parent); + + Actor actor = Actor::New(); + Vector4 childColor(0.5f, 0.6f, 0.5f, 1.0f); + actor.SetProperty(Actor::Property::COLOR, childColor); + parent.Add(actor); + + actor.SetProperty(Actor::Property::SENSITIVE, true); + actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true); + actor.SetProperty(Actor::Property::VISIBLE, true); + + application.SendNotification(); + application.Render(); + + DALI_TEST_CHECK(DevelActor::IsHittable(actor) == true); + + actor.SetProperty(Actor::Property::SENSITIVE, false); + DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false); + actor.SetProperty(Actor::Property::SENSITIVE, true); + + actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, false); + DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false); + actor.SetProperty(DevelActor::Property::USER_INTERACTION_ENABLED, true); + + actor.SetProperty(Actor::Property::VISIBLE, false); + application.SendNotification(); + application.Render(); + DALI_TEST_CHECK(DevelActor::IsHittable(actor) == false); + + END_TEST; +} + +int UtcDaliActorGetTouchRequired(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + DALI_TEST_CHECK(DevelActor::GetTouchRequired(actor) == false); + + actor.TouchedSignal().Connect(TestTouchCallback); + DALI_TEST_CHECK(DevelActor::GetTouchRequired(actor) == true); + + END_TEST; +} diff --git a/dali/devel-api/actors/actor-devel.cpp b/dali/devel-api/actors/actor-devel.cpp index 8289468..98588ef 100644 --- a/dali/devel-api/actors/actor-devel.cpp +++ b/dali/devel-api/actors/actor-devel.cpp @@ -85,6 +85,16 @@ void LookAt(Actor actor, Vector3 target, Vector3 up, Vector3 localForward, Vecto GetImplementation(actor).SetOrientation(orientation); } +bool IsHittable(Actor actor) +{ + return GetImplementation(actor).IsHittable(); +} + +bool GetTouchRequired(Actor actor) +{ + return GetImplementation(actor).GetTouchRequired(); +} + } // namespace DevelActor } // namespace Dali diff --git a/dali/devel-api/actors/actor-devel.h b/dali/devel-api/actors/actor-devel.h index 02130de..06a2bb4 100644 --- a/dali/devel-api/actors/actor-devel.h +++ b/dali/devel-api/actors/actor-devel.h @@ -433,6 +433,23 @@ DALI_CORE_API Vector4 GetWorldColor(Actor actor); */ DALI_CORE_API void LookAt(Actor actor, Vector3 target, Vector3 up = Vector3::YAXIS, Vector3 localForward = Vector3::ZAXIS, Vector3 localUp = Vector3::YAXIS); +/** + * Query whether the actor is actually hittable. This method checks whether the actor is + * sensitive, has the visibility flag set to true and is not fully transparent. + * + * @param[in] actor The actor for whether is hittable or not + * @return true, if it can be hit, false otherwise. + */ +DALI_CORE_API bool IsHittable(Actor actor); + +/** + * Query whether the application or derived actor type requires touch events. + * + * @param[in] actor The actor for whether is required for touch event or not. + * @return True if touch events are required. + */ +DALI_CORE_API bool GetTouchRequired(Actor actor); + } // namespace DevelActor } // namespace Dali diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 4557a03..308f6fa 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1239,6 +1239,22 @@ public: } /** + * @copydoc Dali::DevelActor::IsHittable() + */ + bool IsHittable() const + { + return (IsUserInteractionEnabled()) && IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected(); + } + + /** + * @copydoc Dali::DevelActor::GetTouchRequired() + */ + bool GetTouchRequired() const + { + return !mTouchedSignal.Empty(); + } + + /** * Set whether this view can focus by touch. * @param[in] focusable focuable by touch. */ @@ -1275,15 +1291,6 @@ public: } /** - * Query whether the application or derived actor type requires touch events. - * @return True if touch events are required. - */ - bool GetTouchRequired() const - { - return !mTouchedSignal.Empty(); - } - - /** * Query whether the application or derived actor type requires hover events. * @return True if hover events are required. */ @@ -1302,16 +1309,6 @@ public: } /** - * Query whether the actor is actually hittable. This method checks whether the actor is - * sensitive, has the visibility flag set to true and is not fully transparent. - * @return true, if it can be hit, false otherwise. - */ - bool IsHittable() const - { - return (IsUserInteractionEnabled()) && IsSensitive() && IsVisible() && (GetCurrentWorldColor().a > FULLY_TRANSPARENT) && IsNodeConnected(); - } - - /** * Query whether the actor captures all touch after it starts even if touch leaves its boundary. * @return true, if it captures all touch after start */ -- 2.7.4