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=7d48264f93e481a3dccf5c1d744fe321ec77001e;hp=712cb17b53360ff58971299ef42dc7f2f9632e66;hpb=c039ebb7a115f5516aa792c1aa3bd6370e61acfd;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 712cb17..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 @@ -680,10 +691,12 @@ void ScrollView::OnInitialize() // Connect wheel event self.WheelEventSignal().Connect(this, &ScrollView::OnWheelEvent); - DevelControl::SetAccessibilityConstructor(Self(), [](Dali::Actor actor) { - return std::unique_ptr( - new AccessibleImpl(actor, Dali::Accessibility::Role::SCROLL_PANE)); - }); + self.SetProperty(DevelControl::Property::ACCESSIBILITY_ROLE, Dali::Accessibility::Role::SCROLL_PANE); +} + +DevelControl::ControlAccessible* ScrollView::CreateAccessibleObject() +{ + return new ScrollViewAccessible(Self()); } void ScrollView::OnSceneConnection(int depth) @@ -1262,7 +1275,7 @@ Toolkit::ScrollView::SnapStartedSignalType& ScrollView::SnapStartedSignal() return mSnapStartedSignal; } -bool ScrollView::AccessibleImpl::ScrollToChild(Actor child) +bool ScrollView::ScrollViewAccessible::ScrollToChild(Actor child) { auto scrollView = Dali::Toolkit::ScrollView::DownCast(Self()); if(Toolkit::GetImpl(scrollView).FindClosestActor() == child) @@ -1270,8 +1283,11 @@ bool ScrollView::AccessibleImpl::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; }