From b60468ef0b42b0fbb186e956ca8f8d7800284d5d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Artur=20=C5=9Awigo=C5=84?= Date: Fri, 17 Feb 2023 13:51:59 +0100 Subject: [PATCH] [Tizen] Be a bit smarter with SetFocusedActorPosition The previous calculation method was to always use the center point of a given actor, regardless of the position of the touch event that caused it to be focused. In the tricky scenario where a smaller actor is overlaid on top of a bigger actor such that the smaller actor covers the center of the bigger actor, a double-tap-and-hold gesture meant to activate the bigger actor would activate the smaller actor instead. The calculation method introduced by this patch is a little bit better, but still not ideal. However, the HighlightedObjectInfo D-Bus method has only two parameters, the coordinates, taken from GetFocusedActorPosition, which are then forwarded back into the app as a touch event, so there isn't much more that could be done in DALi to address this issue. Change-Id: I03f291f3dece2bd2c10fedd7ce22f8791230b6f4 --- .../accessibility-manager-impl.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp index 853c009..e856ec2 100644 --- a/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp +++ b/dali-toolkit/internal/accessibility-manager/accessibility-manager-impl.cpp @@ -360,11 +360,23 @@ bool AccessibilityManager::DoSetCurrentFocusActor(const unsigned int actorID) actor.Add( GetFocusIndicatorActor() ); } - // Send Focused actor information - Vector2 windowSize = rootActor.GetCurrentProperty(Actor::Property::SIZE); - AccessibilityAdaptor adaptor = AccessibilityAdaptor::Get(); - adaptor.SetFocusedActorPosition( Vector2((actor.GetCurrentProperty(Actor::Property::WORLD_POSITION).x + (windowSize.width / 2)), - (actor.GetCurrentProperty(Actor::Property::WORLD_POSITION).y + (windowSize.height / 2))) ); + auto adaptor = AccessibilityAdaptor::Get(); + Vector2 readPosition = adaptor.GetReadPosition(); + auto actorPosition = actor.GetCurrentProperty(Actor::Property::SCREEN_POSITION); + auto actorSize = actor.GetCurrentProperty(Actor::Property::SIZE); + Rect<> actorRect(actorPosition.x, actorPosition.y, actorSize.width, actorSize.height); + + if(actorRect.Contains(Rect<>(readPosition.x, readPosition.y, 0, 0))) + { + // If the last touched position is within the extents of the actor, + // then use that position. (The center may be covered by some other actor). + adaptor.SetFocusedActorPosition(readPosition); + } + else + { + // Otherwise, use the center point. + adaptor.SetFocusedActorPosition(actorPosition + actorSize / 2); + } // Send notification for the change of focus actor mFocusChangedSignal.Emit( GetCurrentFocusActor(), actor ); -- 2.7.4