From: Shinwoo Kim Date: Wed, 27 Apr 2022 10:44:01 +0000 (+0900) Subject: [AT-SPI] ScrollView: Use child postion for ScrollToChild X-Git-Tag: dali_2.1.21~4^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F92%2F274392%2F1;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git [AT-SPI] ScrollView: Use child postion for ScrollToChild It was not able to scroll in a child of scroll view if the child is not a child of the first depth. (1) [scroll pane],[(class=ScrollView)],[364,199,656,36],[TextSelectionScrollView] (2) [table],[(class=TableView)],[364,101,901,134],[] (3) [push button],[(class=PushButton)],[364,101,447,134],[Select all] (4) [image],[(class=ImageView)(highlight=)],[364,101,447,134],[] (5) [unknown],[(class=Control)],[811,107,1,122],[] (6) [push button],[(class=PushButton)],[812,101,265,134],[Copy] (7) [unknown],[(class=Control)],[1077,107,1,122],[] (8) [push button],[(class=PushButton)],[1078,101,187,134],[Cut] The node (8) was not able to bring in even though it has highlight. This patch makes node (8) bring in when it grabs highlight. Change-Id: I862a8adcc2bd6212464ffc833a2a0d0cf0a4480c --- diff --git a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 0dceb47..3779e35 100644 --- a/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -530,6 +530,17 @@ void SnapWithVelocity( } } +Dali::Vector2 GetPosition(Dali::Actor actor) +{ + Vector2 screenPosition = actor.GetProperty(Actor::Property::SCREEN_POSITION); + Vector3 size = actor.GetCurrentProperty(Actor::Property::SIZE) * actor.GetCurrentProperty(Actor::Property::WORLD_SCALE); + bool positionUsesAnchorPoint = actor.GetProperty(Actor::Property::POSITION_USES_ANCHOR_POINT); + Vector3 anchorPointOffSet = size * (positionUsesAnchorPoint ? actor.GetCurrentProperty(Actor::Property::ANCHOR_POINT) : AnchorPoint::TOP_LEFT); + Vector2 position = Vector2(screenPosition.x - anchorPointOffSet.x, screenPosition.y - anchorPointOffSet.y); + + return position; +} + } // unnamed namespace namespace Dali @@ -1272,21 +1283,11 @@ bool ScrollView::ScrollViewAccessible::ScrollToChild(Actor child) return false; } - // child can be one of descendants - // find direct child of ScrollView to avoid the ASSERT in ScrollTo - auto parent = child.GetParent(); - while (parent && parent != Self()) - { - child = parent; - parent = child.GetParent(); - } - if (!parent) - { - return false; - } + auto childPosition = GetPosition(child); + auto selfPosition = GetPosition(Self()); + + scrollView.ScrollTo(childPosition - selfPosition, scrollView.GetScrollFlickDuration()); - // FIXME: ScrollTo does not work (snaps back to original position) - scrollView.ScrollTo(child, scrollView.GetScrollFlickDuration()); return true; }