X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=dali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fscroll-view%2Fscroll-view-impl.cpp;h=a4ebfa94490ba1a4f2ebb747505d84977184db01;hp=d422e6e931d397b372927a7cc8ed92166af17b9a;hb=be93fd772a1b1b09425ac0aaec1ea1b64e9a9e60;hpb=dc1b9bcdb0aae8a6c0cea63cd57678f19e7742d4 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 d422e6e..a4ebfa9 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) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2020 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. @@ -21,9 +21,9 @@ // EXTERNAL INCLUDES #include // for strcmp #include -#include +#include #include -#include +#include #include #include #include @@ -31,20 +31,19 @@ #include // INTERNAL INCLUDES -#include +#include #include #include -#include -#include +#include #include #include //#define ENABLED_SCROLL_STATE_LOGGING #ifdef ENABLED_SCROLL_STATE_LOGGING -#define DALI_LOG_SCROLL_STATE(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s:%d " format "\n", __PRETTY_FUNCTION__, __LINE__, ## args) +#define DALI_LOG_SCROLL_STATE(format, ...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s:%d " format "\n", __PRETTY_FUNCTION__, __LINE__, ## __VA_ARGS__) #else -#define DALI_LOG_SCROLL_STATE(format, args...) +#define DALI_LOG_SCROLL_STATE(format, ...) #endif // TODO: Change to two class system: @@ -146,9 +145,9 @@ float VectorInDomain(float a, float b, float start, float end, Dali::Toolkit::Di */ Vector3 GetPositionOfAnchor(Actor &actor, const Vector3 &anchor) { - Vector3 childPosition = actor.GetCurrentPosition(); - Vector3 childAnchor = - actor.GetCurrentAnchorPoint() + anchor; - Vector3 childSize = actor.GetCurrentSize(); + Vector3 childPosition = actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); + Vector3 childAnchor = - actor.GetCurrentProperty< Vector3 >( Actor::Property::ANCHOR_POINT ) + anchor; + Vector3 childSize = actor.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); return childPosition + childAnchor * childSize; } @@ -252,7 +251,7 @@ DALI_PROPERTY_REGISTRATION( Toolkit, ScrollView, "wrapEnabled", B DALI_PROPERTY_REGISTRATION( Toolkit, ScrollView, "panningEnabled", BOOLEAN, PANNING_ENABLED ) DALI_PROPERTY_REGISTRATION( Toolkit, ScrollView, "axisAutoLockEnabled", BOOLEAN, AXIS_AUTO_LOCK_ENABLED ) DALI_PROPERTY_REGISTRATION( Toolkit, ScrollView, "wheelScrollDistanceStep", VECTOR2, WHEEL_SCROLL_DISTANCE_STEP ) -DALI_DEVEL_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scrollMode", MAP, SCROLL_MODE ) +DALI_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scrollMode", MAP, SCROLL_MODE ) DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scrollPosition", VECTOR2, SCROLL_POSITION) DALI_ANIMATABLE_PROPERTY_REGISTRATION( Toolkit, ScrollView, "scrollPrePosition", VECTOR2, SCROLL_PRE_POSITION) @@ -429,9 +428,9 @@ struct InternalPrePositionConstraint // Note: A further 1.0f is subtracted to handle a compensation that happens later within the flick handling code in SnapWithVelocity(). // When a flick is completed, an adjustment of 1.0f is sometimes made to allow for the scenario where: // A flick finishes before the update thread has advanced the scroll position past the previous snap point. - Vector2 pageSizeLimit( size.x - ( 1.0f + 1.0f ), size.y - ( 1.0f - 1.0f ) ); - Vector2 minPosition( mStartPosition.x - pageSizeLimit.x, mStartPosition.y - pageSizeLimit.y ); - Vector2 maxPosition( mStartPosition.x + pageSizeLimit.x, mStartPosition.y + pageSizeLimit.y ); + Vector2 viewPageSizeLimit( size.x - ( 1.0f + 1.0f ), size.y - ( 1.0f - 1.0f ) ); + Vector2 minPosition( mStartPosition.x - viewPageSizeLimit.x, mStartPosition.y - viewPageSizeLimit.y ); + Vector2 maxPosition( mStartPosition.x + viewPageSizeLimit.x, mStartPosition.y + viewPageSizeLimit.y ); if( mFixedRulerX ) { @@ -677,8 +676,8 @@ void ScrollView::OnInitialize() mInternalActor = Actor::New(); self.Add(mInternalActor); - mInternalActor.SetParentOrigin(ParentOrigin::CENTER); - mInternalActor.SetAnchorPoint(AnchorPoint::CENTER); + mInternalActor.SetProperty( Actor::Property::PARENT_ORIGIN,ParentOrigin::CENTER ); + mInternalActor.SetProperty( Actor::Property::ANCHOR_POINT,AnchorPoint::CENTER); mInternalActor.SetResizePolicy( ResizePolicy::FILL_TO_PARENT, Dimension::ALL_DIMENSIONS ); mAlterChild = true; @@ -705,7 +704,7 @@ void ScrollView::OnInitialize() SetInternalConstraints(); } -void ScrollView::OnStageConnection( int depth ) +void ScrollView::OnSceneConnection( int depth ) { DALI_LOG_SCROLL_STATE("[0x%X]", this); @@ -721,16 +720,16 @@ void ScrollView::OnStageConnection( int depth ) EnableScrollOvershoot(true); } - ScrollBase::OnStageConnection( depth ); + ScrollBase::OnSceneConnection( depth ); } -void ScrollView::OnStageDisconnection() +void ScrollView::OnSceneDisconnection() { DALI_LOG_SCROLL_STATE("[0x%X]", this); StopAnimation(); - ScrollBase::OnStageDisconnection(); + ScrollBase::OnSceneDisconnection(); } ScrollView::~ScrollView() @@ -1322,8 +1321,8 @@ void ScrollView::ScrollTo(Actor &actor, float duration) DALI_ASSERT_ALWAYS(actor.GetParent() == Self()); Actor self = Self(); - Vector3 size = self.GetCurrentSize(); - Vector3 position = actor.GetCurrentPosition(); + Vector3 size = self.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); + Vector3 position = actor.GetCurrentProperty< Vector3 >( Actor::Property::POSITION ); Vector2 prePosition = GetPropertyPrePosition(); position.GetVectorXY() -= prePosition; @@ -1333,7 +1332,7 @@ void ScrollView::ScrollTo(Actor &actor, float duration) Actor ScrollView::FindClosestActor() { Actor self = Self(); - Vector3 size = self.GetCurrentSize(); + Vector3 size = self.GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); return FindClosestActorToPosition(Vector3(size.width * 0.5f,size.height * 0.5f,0.0f)); } @@ -1525,7 +1524,7 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) if(mActorAutoSnapEnabled) { - Vector3 size = Self().GetCurrentSize(); + Vector3 size = Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); Actor child = FindClosestActorToPosition( Vector3(size.width * 0.5f,size.height * 0.5f,0.0f), horizontal, vertical ); @@ -1778,7 +1777,7 @@ void ScrollView::EnableScrollOvershoot(bool enable) void ScrollView::AddOverlay(Actor actor) { - actor.SetDrawMode( DrawMode::OVERLAY_2D ); + actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D ); mInternalActor.Add( actor ); } @@ -1969,7 +1968,7 @@ void ScrollView::OnChildAdd(Actor& child) if( scrollBar ) { mScrollBar = scrollBar; - scrollBar.SetName("ScrollBar"); + scrollBar.SetProperty( Dali::Actor::Property::NAME,"ScrollBar"); mInternalActor.Add( scrollBar ); if( scrollBar.GetScrollDirection() == Toolkit::ScrollBar::Horizontal ) @@ -2060,7 +2059,7 @@ bool ScrollView::OnTouchDownTimeout() return false; } -bool ScrollView::OnTouch( Actor actor, const TouchData& touch ) +bool ScrollView::OnTouch( Actor actor, const TouchEvent& touch ) { if(!mSensitive) { @@ -2126,7 +2125,7 @@ bool ScrollView::OnTouch( Actor actor, const TouchData& touch ) mScrollInterrupted = false; } - return true; + return false; } bool ScrollView::OnWheelEvent(const WheelEvent& event) @@ -2145,14 +2144,14 @@ bool ScrollView::OnWheelEvent(const WheelEvent& event) if(mRulerX->GetType() == Ruler::Free) { // Free panning mode - targetScrollPosition.x += event.z * mWheelScrollDistanceStep.x; + targetScrollPosition.x += event.GetDelta() * mWheelScrollDistanceStep.x; ClampPosition(targetScrollPosition); ScrollTo(-targetScrollPosition); } else if(!mScrolling) { // Snap mode, only respond to the event when the previous snap animation is finished. - ScrollTo(GetCurrentPage() - event.z); + ScrollTo(GetCurrentPage() - event.GetDelta()); } } else @@ -2161,14 +2160,14 @@ bool ScrollView::OnWheelEvent(const WheelEvent& event) if(mRulerY->GetType() == Ruler::Free) { // Free panning mode - targetScrollPosition.y += event.z * mWheelScrollDistanceStep.y; + targetScrollPosition.y += event.GetDelta() * mWheelScrollDistanceStep.y; ClampPosition(targetScrollPosition); ScrollTo(-targetScrollPosition); } else if(!mScrolling) { // Snap mode, only respond to the event when the previous snap animation is finished. - ScrollTo(GetCurrentPage() - event.z * mRulerX->GetTotalPages()); + ScrollTo(GetCurrentPage() - event.GetDelta() * mRulerX->GetTotalPages()); } } @@ -2495,7 +2494,7 @@ void ScrollView::OnPan( const PanGesture& gesture ) Toolkit::ScrollBar scrollBar = mScrollBar.GetHandle(); if( scrollBar && mTransientScrollBar ) { - Vector3 size = Self().GetCurrentSize(); + Vector3 size = Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); const Toolkit::RulerDomain& rulerDomainX = mRulerX->GetDomain(); const Toolkit::RulerDomain& rulerDomainY = mRulerY->GetDomain(); @@ -2636,7 +2635,7 @@ void ScrollView::FinishTransform() Vector2 ScrollView::GetOvershoot(Vector2& position) const { - Vector3 size = Self().GetCurrentSize(); + Vector3 size = Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); Vector2 overshoot; const RulerDomain rulerDomainX = mRulerX->GetDomain(); @@ -2691,7 +2690,7 @@ void ScrollView::ClampPosition(Vector2& position) const void ScrollView::ClampPosition(Vector2& position, ClampState2D &clamped) const { - Vector3 size = Self().GetCurrentSize(); + Vector3 size = Self().GetCurrentProperty< Vector3 >( Actor::Property::SIZE ); position.x = -mRulerX->Clamp(-position.x, size.width, 1.0f, clamped.x); // NOTE: X & Y rulers think in -ve coordinate system. position.y = -mRulerY->Clamp(-position.y, size.height, 1.0f, clamped.y); // That is scrolling RIGHT (e.g. 100.0, 0.0) means moving LEFT. @@ -2909,7 +2908,7 @@ void ScrollView::SetProperty( BaseObject* object, Property::Index index, const P scrollViewImpl.SetWheelScrollDistanceStep( value.Get() ); break; } - case Toolkit::DevelScrollView::Property::SCROLL_MODE: + case Toolkit::ScrollView::Property::SCROLL_MODE: { Property::Map* map = value.GetMap(); if( map )