From: Joogab Yun Date: Thu, 3 Jun 2021 06:43:05 +0000 (+0900) Subject: Add TOUCH_FOCUSABLE property X-Git-Tag: dali_2.0.31~1^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F58%2F259258%2F15;p=platform%2Fcore%2Fuifw%2Fdali-core.git Add TOUCH_FOCUSABLE property This is a property that allows you to have focus even when touched. It works only when KEYBOARD_FOCUSABLE is set to true. KEYBOARD_FOCUSABLE : whether the view can have focus or not TOUCH_FOCUSABLE : Whether the user can focus by touch Change-Id: Id991d7a0bd734718164b874f013e24235476e789 --- diff --git a/automated-tests/src/dali/utc-Dali-Actor.cpp b/automated-tests/src/dali/utc-Dali-Actor.cpp index 12dc2b7..4037c13 100644 --- a/automated-tests/src/dali/utc-Dali-Actor.cpp +++ b/automated-tests/src/dali/utc-Dali-Actor.cpp @@ -2524,6 +2524,30 @@ int UtcDaliActorIsKeyboardFocusable(void) END_TEST; } +int UtcDaliActorSetTouchFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == true); + + actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, false); + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == false); + END_TEST; +} + +int UtcDaliActorIsTouchFocusable(void) +{ + TestApplication application; + + Actor actor = Actor::New(); + + DALI_TEST_CHECK(actor.GetProperty(DevelActor::Property::TOUCH_FOCUSABLE) == false); + END_TEST; +} + int UtcDaliActorRemoveConstraints(void) { tet_infoline(" UtcDaliActorRemoveConstraints"); diff --git a/dali/devel-api/actors/actor-devel.h b/dali/devel-api/actors/actor-devel.h index f46478e..338a293 100644 --- a/dali/devel-api/actors/actor-devel.h +++ b/dali/devel-api/actors/actor-devel.h @@ -159,7 +159,18 @@ enum Type * @note Color of each renderer will be blended with rendering framebuffer. * @note To check the blend equation is supported in the system, use Dali::Capabilities::IsBlendEquationSupported */ - BLEND_EQUATION + BLEND_EQUATION, + + /** + * @brief Sets whether this view can focus by touch. If user sets this to true, the actor will be focused when user touch it. + * @code + * Actor actor = Actor::New(); + * actor.SetProperty(Actor::Property::KEYBOARD_FOCUSABLE, true); // whether the view can have focus or not with keyboard navigation. + * actor.SetProperty(DevelActor::Property::TOUCH_FOCUSABLE, true); // Whether the user can focus by touch, user can set focus by touching the actor. + * @endcode + * @details Name "touchFocusable", type Property::BOOLEAN. + */ + TOUCH_FOCUSABLE }; } // namespace Property diff --git a/dali/internal/event/actors/actor-impl.cpp b/dali/internal/event/actors/actor-impl.cpp index c06b2a4..c669199 100644 --- a/dali/internal/event/actors/actor-impl.cpp +++ b/dali/internal/event/actors/actor-impl.cpp @@ -148,6 +148,7 @@ DALI_PROPERTY("updateSizeHint", VECTOR2, true, false, false, Dali::DevelActor::P 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("blendEquation", INTEGER, true, false, false, Dali::DevelActor::Property::BLEND_EQUATION) +DALI_PROPERTY("touchFocusable", BOOLEAN, true, false, false, Dali::DevelActor::Property::TOUCH_FOCUSABLE) DALI_PROPERTY_TABLE_END(DEFAULT_ACTOR_PROPERTY_START_INDEX, ActorDefaultProperties) // Signals @@ -1332,6 +1333,7 @@ Actor::Actor(DerivedType derivedType, const SceneGraph::Node& node) mSensitive(true), mLeaveRequired(false), mKeyboardFocusable(false), + mTouchFocusable(false), mOnSceneSignalled(false), mInsideOnSizeSet(false), mInheritPosition(true), diff --git a/dali/internal/event/actors/actor-impl.h b/dali/internal/event/actors/actor-impl.h index 2857f87..99236a3 100644 --- a/dali/internal/event/actors/actor-impl.h +++ b/dali/internal/event/actors/actor-impl.h @@ -1319,6 +1319,24 @@ public: } /** + * Set whether this view can focus by touch. + * @param[in] focusable focuable by touch. + */ + void SetTouchFocusable(bool focusable) + { + mTouchFocusable = focusable; + } + + /** + * This returns whether this actor can focus by touch. + * @return true if this actor can focus by touch. + */ + bool IsTouchFocusable() const + { + return mTouchFocusable; + } + + /** * Query whether the application or derived actor type requires intercept touch events. * @return True if intercept touch events are required. */ @@ -2048,6 +2066,7 @@ protected: bool mSensitive : 1; ///< Whether the actor emits touch event signals bool mLeaveRequired : 1; ///< Whether a touch event signal is emitted when the a touch leaves the actor's bounds bool mKeyboardFocusable : 1; ///< Whether the actor should be focusable by keyboard navigation + bool mTouchFocusable : 1; ///< Whether the actor should be focusable by touch bool mOnSceneSignalled : 1; ///< Set to true before OnSceneConnection signal is emitted, and false before OnSceneDisconnection bool mInsideOnSizeSet : 1; ///< Whether we are inside OnSizeSet bool mInheritPosition : 1; ///< Cached: Whether the parent's position should be inherited. diff --git a/dali/internal/event/actors/actor-property-handler.cpp b/dali/internal/event/actors/actor-property-handler.cpp index 111a088..9c28f27 100644 --- a/dali/internal/event/actors/actor-property-handler.cpp +++ b/dali/internal/event/actors/actor-property-handler.cpp @@ -597,6 +597,16 @@ void Actor::PropertyHandler::SetDefaultProperty(Internal::Actor& actor, Property break; } + case Dali::DevelActor::Property::TOUCH_FOCUSABLE: + { + bool value = false; + if(property.Get(value)) + { + actor.SetTouchFocusable(value); + } + break; + } + default: { // this can happen in the case of a non-animatable default property so just do nothing @@ -1646,6 +1656,12 @@ bool Actor::PropertyHandler::GetCachedPropertyValue(const Internal::Actor& actor break; } + case Dali::DevelActor::Property::TOUCH_FOCUSABLE: + { + value = actor.IsTouchFocusable(); + break; + } + default: { // Must be a scene-graph only property diff --git a/dali/internal/event/events/hit-test-algorithm-impl.cpp b/dali/internal/event/events/hit-test-algorithm-impl.cpp index 2cb7b42..1576efe 100644 --- a/dali/internal/event/events/hit-test-algorithm-impl.cpp +++ b/dali/internal/event/events/hit-test-algorithm-impl.cpp @@ -100,8 +100,8 @@ struct ActorTouchableCheck : public HitTestInterface { bool IsActorHittable(Actor* actor) override { - return actor->GetTouchRequired() && // Does the Application or derived actor type require a touch event? - actor->IsHittable(); // Is actor sensitive, visible and on the scene? + return (actor->GetTouchRequired() || actor->IsTouchFocusable()) && // Does the Application or derived actor type require a touch event? or focusable by touch? + actor->IsHittable(); // Is actor sensitive, visible and on the scene? } bool DescendActorHierarchy(Actor* actor) override