X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fscroll-view%2Fscroll-view-impl.cpp;h=986040bbd8b43f6a979e86ca991f2700f2b86c5e;hb=HEAD;hp=a4d724daa4f332ae3201449f2bd7baaacb408f86;hpb=36b6c48b03fa926529904947f222aadebbf0c1ff;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git 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 a4d724d..986040b 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 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. @@ -44,7 +44,7 @@ //#define ENABLED_SCROLL_STATE_LOGGING #ifdef ENABLED_SCROLL_STATE_LOGGING -#define DALI_LOG_SCROLL_STATE(format, ...) Dali::Integration::Log::LogMessageWithFunctionLine(Dali::Integration::Log::DebugInfo, "%s:%d " format "\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) +#define DALI_LOG_SCROLL_STATE(format, ...) Dali::Integration::Log::LogMessageWithFunctionLine(Dali::Integration::Log::INFO, "%s:%d " format "\n", __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__) #else #define DALI_LOG_SCROLL_STATE(format, ...) #endif @@ -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,8 +1283,11 @@ bool ScrollView::ScrollViewAccessible::ScrollToChild(Actor child) return false; } - // FIXME: ScrollTo does not work (snaps back to original position) - scrollView.ScrollTo(child, scrollView.GetScrollFlickDuration()); + auto childPosition = GetPosition(child); + auto selfPosition = GetPosition(Self()); + + scrollView.ScrollTo(childPosition - selfPosition, scrollView.GetScrollFlickDuration()); + return true; }