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=1273cd13a696c7af7e2b6a1b7e76f8f1c31809b6;hp=97844154830ff92863bd850a3d4a5f2f188263ab;hb=ca99959003c0445d5afb437e2be26361dff51623;hpb=0f5a8aaa14ccf06aee1069ef585d83b8506dd099 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 9784415..1273cd1 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,31 +21,30 @@ // EXTERNAL INCLUDES #include // for strcmp #include -#include +#include #include -#include +#include #include #include #include -#include #include +#include #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: @@ -102,7 +101,7 @@ const std::string INTERNAL_MAX_POSITION_PROPERTY_NAME( "internalMaxPosition" ); */ float VectorInDomain(float a, float b, float start, float end, Dali::Toolkit::DirectionBias bias) { - if(bias == Dali::Toolkit::DirectionBiasNone) + if(bias == Dali::Toolkit::DIRECTION_BIAS_NONE) { return ShortestDistanceInDomain( a, b, start, end ); } @@ -113,7 +112,7 @@ float VectorInDomain(float a, float b, float start, float end, Dali::Toolkit::Di if(vect > 0) { // +ve vector - if(bias == Dali::Toolkit::DirectionBiasRight) // going right, take the vector. + if(bias == Dali::Toolkit::DIRECTION_BIAS_RIGHT) // going right, take the vector. { return vect; } @@ -126,7 +125,7 @@ float VectorInDomain(float a, float b, float start, float end, Dali::Toolkit::Di else { // -ve vector - if(bias == Dali::Toolkit::DirectionBiasLeft) // going left, take the vector. + if(bias == Dali::Toolkit::DIRECTION_BIAS_LEFT) // going left, take the vector. { return vect; } @@ -147,9 +146,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; } @@ -253,7 +252,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) @@ -345,8 +344,8 @@ struct InternalPrePositionConstraint mDomainMax = Vector2( -rulerDomainX.max, -rulerDomainY.max ); mClampX = rulerDomainX.enabled; mClampY = rulerDomainY.enabled; - mFixedRulerX = rulerX->GetType() == Ruler::Fixed; - mFixedRulerY = rulerY->GetType() == Ruler::Fixed; + mFixedRulerX = rulerX->GetType() == Ruler::FIXED; + mFixedRulerY = rulerY->GetType() == Ruler::FIXED; } void operator()( Vector2& scrollPostPosition, const PropertyInputContainer& inputs ) @@ -430,9 +429,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 ) { @@ -630,7 +629,7 @@ Dali::Toolkit::ScrollView ScrollView::New() } ScrollView::ScrollView() -: ScrollBase( ControlBehaviour( REQUIRES_WHEEL_EVENTS | DISABLE_STYLE_CHANGE_SIGNALS ) ), // Enable size negotiation +: ScrollBase( ControlBehaviour( DISABLE_STYLE_CHANGE_SIGNALS ) ), // Enable size negotiation mTouchDownTime(0u), mGestureStackDepth(0), mScrollStateFlags(0), @@ -678,8 +677,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; @@ -690,8 +689,8 @@ void ScrollView::OnInitialize() mGestureStackDepth = 0; - self.TouchSignal().Connect( this, &ScrollView::OnTouch ); - EnableGestureDetection( Gesture::Type( Gesture::Pan ) ); + self.TouchedSignal().Connect( this, &ScrollView::OnTouch ); + EnableGestureDetection( GestureType::Value( GestureType::PAN ) ); // By default we'll allow the user to freely drag the scroll view, // while disabling the other rulers. @@ -704,9 +703,12 @@ void ScrollView::OnInitialize() UpdatePropertyDomain(); SetInternalConstraints(); + + // Connect wheel event + self.WheelEventSignal().Connect( this, &ScrollView::OnWheelEvent ); } -void ScrollView::OnStageConnection( int depth ) +void ScrollView::OnSceneConnection( int depth ) { DALI_LOG_SCROLL_STATE("[0x%X]", this); @@ -722,16 +724,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() @@ -1004,7 +1006,7 @@ void ScrollView::SetScrollSensitive(bool sensitive) // while the scroll view is panning, the state needs to be reset. if ( mPanning ) { - PanGesture cancelGesture( Gesture::Cancelled ); + PanGesture cancelGesture = DevelPanGesture::New( GestureState::CANCELLED ); OnPan( cancelGesture ); } @@ -1240,7 +1242,7 @@ void ScrollView::TransformTo(const Vector2& position, float duration, AlphaFunct true, horizontalBias, verticalBias, - Snap); + SNAP); if(!animating) { @@ -1269,12 +1271,12 @@ void ScrollView::ScrollTo(const Vector2& position) void ScrollView::ScrollTo(const Vector2& position, float duration) { - ScrollTo(position, duration, DirectionBiasNone, DirectionBiasNone); + ScrollTo(position, duration, DIRECTION_BIAS_NONE, DIRECTION_BIAS_NONE); } void ScrollView::ScrollTo(const Vector2& position, float duration, AlphaFunction alpha) { - ScrollTo(position, duration, alpha, DirectionBiasNone, DirectionBiasNone); + ScrollTo(position, duration, alpha, DIRECTION_BIAS_NONE, DIRECTION_BIAS_NONE); } void ScrollView::ScrollTo(const Vector2& position, float duration, @@ -1323,8 +1325,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; @@ -1334,7 +1336,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)); } @@ -1526,7 +1528,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 ); @@ -1538,7 +1540,7 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) if(child) { - Vector2 position = DevelHandle::GetCurrentProperty( Self(), Toolkit::ScrollView::Property::SCROLL_POSITION ); + Vector2 position = Self().GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ); // Get center-point of the Actor. Vector3 childPosition = GetPositionOfAnchor(child, AnchorPoint::CENTER); @@ -1561,7 +1563,7 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) Vector2 clampDelta(Vector2::ZERO); ClampPosition(positionSnap); - if( (mRulerX->GetType() == Ruler::Free || mRulerY->GetType() == Ruler::Free) + if( (mRulerX->GetType() == Ruler::FREE || mRulerY->GetType() == Ruler::FREE) && isFreeFlick && !mActorAutoSnapEnabled) { // Calculate target position based on velocity of flick. @@ -1584,12 +1586,12 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) float t = speed / a; - if(mRulerX->IsEnabled() && mRulerX->GetType() == Ruler::Free) + if(mRulerX->IsEnabled() && mRulerX->GetType() == Ruler::FREE) { positionSnap.x += t*u.x*0.5f; } - if(mRulerY->IsEnabled() && mRulerY->GetType() == Ruler::Free) + if(mRulerY->IsEnabled() && mRulerY->GetType() == Ruler::FREE) { positionSnap.y += t*u.y*0.5f; } @@ -1609,7 +1611,7 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) // If Axis is Free and has velocity, then calculate time taken // to reach target based on velocity in axis. - if(mRulerX->IsEnabled() && mRulerX->GetType() == Ruler::Free) + if(mRulerX->IsEnabled() && mRulerX->GetType() == Ruler::FREE) { float deltaX = fabsf(startPosition.x - positionSnap.x); @@ -1623,7 +1625,7 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) } } - if(mRulerY->IsEnabled() && mRulerY->GetType() == Ruler::Free) + if(mRulerY->IsEnabled() && mRulerY->GetType() == Ruler::FREE) { float deltaY = fabsf(startPosition.y - positionSnap.y); @@ -1646,8 +1648,8 @@ bool ScrollView::SnapWithVelocity(Vector2 velocity) bool animating = AnimateTo(positionSnap, positionDuration, alphaFunction, false, - DirectionBiasNone, DirectionBiasNone, - isFlick || isFreeFlick ? Flick : Snap); + DIRECTION_BIAS_NONE, DIRECTION_BIAS_NONE, + isFlick || isFreeFlick ? FLICK : SNAP); return animating; } @@ -1736,7 +1738,7 @@ bool ScrollView::AnimateTo(const Vector2& position, const Vector2& positionDurat } DALI_LOG_SCROLL_STATE("[0x%X] position-changed, mScrollTargetPosition[%.2f, %.2f], mScrollPrePosition[%.2f, %.2f], mScrollPostPosition[%.2f, %.2f]", this, mScrollTargetPosition.x, mScrollTargetPosition.y, mScrollPrePosition.x, mScrollPrePosition.y, mScrollPostPosition.x, mScrollPostPosition.y ); - DALI_LOG_SCROLL_STATE("[0x%X] SCROLL_PRE_POSITION[%.2f, %.2f], SCROLL_POSITION[%.2f, %.2f]", this, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get().x, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get().y, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_POSITION ).Get().x, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_POSITION ).Get().y ); + DALI_LOG_SCROLL_STATE("[0x%X] SCROLL_PRE_POSITION[%.2f, %.2f], SCROLL_POSITION[%.2f, %.2f]", this, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get().x, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get().y, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get().x, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get().y ); } SetScrollUpdateNotification(true); @@ -1779,7 +1781,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 ); } @@ -1833,14 +1835,14 @@ void ScrollView::FindAndUnbindActor(Actor child) Vector2 ScrollView::GetPropertyPrePosition() const { - Vector2 position = DevelHandle::GetCurrentProperty< Vector2 >( Self(), Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ); + Vector2 position = Self().GetCurrentProperty< Vector2 >( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ); WrapPosition(position); return position; } Vector2 ScrollView::GetPropertyPosition() const { - Vector2 position = DevelHandle::GetCurrentProperty< Vector2 >( Self(), Toolkit::ScrollView::Property::SCROLL_POSITION ); + Vector2 position = Self().GetCurrentProperty< Vector2 >( Toolkit::ScrollView::Property::SCROLL_POSITION ); WrapPosition(position); return position; @@ -1970,10 +1972,10 @@ 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 ) + if( scrollBar.GetScrollDirection() == Toolkit::ScrollBar::HORIZONTAL ) { scrollBar.SetScrollPropertySource( Self(), Toolkit::ScrollView::Property::SCROLL_PRE_POSITION_X, @@ -2061,7 +2063,7 @@ bool ScrollView::OnTouchDownTimeout() return false; } -bool ScrollView::OnTouch( Actor actor, const TouchData& touch ) +bool ScrollView::OnTouch( Actor actor, const TouchEvent& touch ) { if(!mSensitive) { @@ -2098,7 +2100,7 @@ bool ScrollView::OnTouch( Actor actor, const TouchData& touch ) else if( ( pointState == PointState::UP ) || ( ( pointState == PointState::INTERRUPTED ) && ( touch.GetHitActor( 0 )== Self() ) ) ) { - DALI_LOG_SCROLL_STATE("[0x%X] %s", this, ( ( pointState == TouchPoint::Up ) ? "Up" : "Interrupted" ) ); + DALI_LOG_SCROLL_STATE("[0x%X] %s", this, ( ( pointState == PointState::UP ) ? "Up" : "Interrupted" ) ); StopTouchDownTimer(); @@ -2127,10 +2129,10 @@ bool ScrollView::OnTouch( Actor actor, const TouchData& touch ) mScrollInterrupted = false; } - return true; + return false; } -bool ScrollView::OnWheelEvent(const WheelEvent& event) +bool ScrollView::OnWheelEvent( Actor actor, const WheelEvent& event) { if(!mSensitive) { @@ -2143,33 +2145,33 @@ bool ScrollView::OnWheelEvent(const WheelEvent& event) if(mRulerX->IsEnabled() && !mRulerY->IsEnabled()) { // If only the ruler in the X axis is enabled, scroll in the X axis. - if(mRulerX->GetType() == Ruler::Free) + 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 { // If the ruler in the Y axis is enabled, scroll in the Y axis. - if(mRulerY->GetType() == Ruler::Free) + 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()); } } @@ -2179,7 +2181,7 @@ bool ScrollView::OnWheelEvent(const WheelEvent& event) void ScrollView::ResetScrolling() { Actor self = Self(); - DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_POSITION ).Get( mScrollPostPosition ); + self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get( mScrollPostPosition ); mScrollPrePosition = mScrollPostPosition; DALI_LOG_SCROLL_STATE("[0x%X] Setting SCROLL_PRE_POSITION To[%.2f, %.2f]", this, mScrollPostPosition.x, mScrollPostPosition.y ); self.SetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION, mScrollPostPosition); @@ -2188,8 +2190,8 @@ void ScrollView::ResetScrolling() void ScrollView::UpdateLocalScrollProperties() { Actor self = Self(); - DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get( mScrollPrePosition ); - DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_POSITION ).Get( mScrollPostPosition ); + self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get( mScrollPrePosition ); + self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get( mScrollPostPosition ); } // private functions @@ -2235,7 +2237,7 @@ void ScrollView::AnimateInternalXTo( float position, float duration, AlphaFuncti if( duration > Math::MACHINE_EPSILON_10 ) { Actor self = Self(); - DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get< Vector2 >().x, position ); + DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get< Vector2 >().x, position ); mInternalXAnimation = Animation::New(duration); DALI_LOG_SCROLL_STATE("[0x%X], mInternalXAnimation[0x%X]", this, mInternalXAnimation.GetObjectPtr() ); mInternalXAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished); @@ -2256,7 +2258,7 @@ void ScrollView::AnimateInternalYTo( float position, float duration, AlphaFuncti if( duration > Math::MACHINE_EPSILON_10 ) { Actor self = Self(); - DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, DevelHandle::GetCurrentProperty( self, Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get< Vector2 >().y, position ); + DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get< Vector2 >().y, position ); mInternalYAnimation = Animation::New(duration); DALI_LOG_SCROLL_STATE("[0x%X], mInternalYAnimation[0x%X]", this, mInternalYAnimation.GetObjectPtr() ); mInternalYAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished); @@ -2283,7 +2285,7 @@ void ScrollView::OnScrollAnimationFinished( Animation& source ) if( source == mInternalXAnimation ) { - DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, DevelHandle::GetCurrentProperty( Self(), SCROLL_PRE_POSITION ).Get< Vector2 >().x, mScrollPostPosition.x ); + DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, Self().GetCurrentProperty( SCROLL_PRE_POSITION ).Get< Vector2 >().x, mScrollPostPosition.x ); if( !(mScrollStateFlags & AnimatingInternalY) ) { @@ -2449,7 +2451,7 @@ void ScrollView::GestureContinuing(const Vector2& panDelta) mPanDelta.y+= panDelta.y; // Save the velocity, there is a bug in PanGesture - // Whereby the Gesture::Finished's velocity is either: + // Whereby the GestureState::FINISHED's velocity is either: // NaN (due to time delta of zero between the last two events) // or 0 (due to position being the same between the last two events) @@ -2462,7 +2464,7 @@ void ScrollView::GestureContinuing(const Vector2& panDelta) } // TODO: Upgrade to use a more powerful gesture detector (one that supports multiple touches on pan - so works as pan and flick gesture) -// BUG: Gesture::Finished doesn't always return velocity on release (due to +// BUG: GestureState::FINISHED doesn't always return velocity on release (due to // timeDelta between last two events being 0 sometimes, or posiiton being the same) void ScrollView::OnPan( const PanGesture& gesture ) { @@ -2480,23 +2482,24 @@ void ScrollView::OnPan( const PanGesture& gesture ) } // translate Gesture input to get useful data... - switch(gesture.state) + switch(gesture.GetState()) { - case Gesture::Started: + case GestureState::STARTED: { DALI_LOG_SCROLL_STATE("[0x%X] Pan Started", this); - mPanStartPosition = gesture.position - gesture.displacement; + const Vector2& position = gesture.GetPosition(); + mPanStartPosition = position - gesture.GetDisplacement(); UpdateLocalScrollProperties(); GestureStarted(); mPanning = true; self.SetProperty( Toolkit::ScrollView::Property::PANNING, true ); - self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, Vector3(gesture.position.x, gesture.position.y, 0.0f) ); + self.SetProperty( Toolkit::ScrollView::Property::START_PAGE_POSITION, Vector3(position.x, position.y, 0.0f) ); UpdateMainInternalConstraint(); 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(); @@ -2508,12 +2511,12 @@ void ScrollView::OnPan( const PanGesture& gesture ) break; } - case Gesture::Continuing: + case GestureState::CONTINUING: { if ( mPanning ) { DALI_LOG_SCROLL_STATE("[0x%X] Pan Continuing", this); - GestureContinuing(gesture.screenDisplacement); + GestureContinuing(gesture.GetScreenDisplacement()); } else { @@ -2523,15 +2526,15 @@ void ScrollView::OnPan( const PanGesture& gesture ) break; } - case Gesture::Finished: - case Gesture::Cancelled: + case GestureState::FINISHED: + case GestureState::CANCELLED: { if ( mPanning ) { - DALI_LOG_SCROLL_STATE("[0x%X] Pan %s", this, ( ( gesture.state == Gesture::Finished ) ? "Finished" : "Cancelled" ) ); + DALI_LOG_SCROLL_STATE("[0x%X] Pan %s", this, ( ( gesture.GetState() == GestureState::FINISHED ) ? "Finished" : "Cancelled" ) ); UpdateLocalScrollProperties(); - mLastVelocity = gesture.velocity; + mLastVelocity = gesture.GetVelocity(); mPanning = false; self.SetProperty( Toolkit::ScrollView::Property::PANNING, false ); @@ -2554,8 +2557,8 @@ void ScrollView::OnPan( const PanGesture& gesture ) break; } - case Gesture::Possible: - case Gesture::Clear: + case GestureState::POSSIBLE: + case GestureState::CLEAR: { // Nothing to do, not needed. break; @@ -2563,14 +2566,14 @@ void ScrollView::OnPan( const PanGesture& gesture ) } // end switch(gesture.state) - OnGestureEx(gesture.state); + OnGestureEx(gesture.GetState()); } -void ScrollView::OnGestureEx(Gesture::State state) +void ScrollView::OnGestureEx(GestureState state) { // call necessary signals for application developer - if(state == Gesture::Started) + if(state == GestureState::STARTED) { Vector2 currentScrollPosition = GetCurrentScrollPosition(); Self().SetProperty(Toolkit::ScrollView::Property::SCROLLING, true); @@ -2578,8 +2581,8 @@ void ScrollView::OnGestureEx(Gesture::State state) DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignal 2 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y); mScrollStartedSignal.Emit( currentScrollPosition ); } - else if( (state == Gesture::Finished) || - (state == Gesture::Cancelled) ) // Finished/default + else if( (state == GestureState::FINISHED) || + (state == GestureState::CANCELLED) ) // Finished/default { // when all the gestures have finished, we finish the transform. // so if a user decides to pan (1 gesture), and then pan+zoom (2 gestures) @@ -2637,7 +2640,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(); @@ -2692,7 +2695,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. @@ -2866,7 +2869,7 @@ void ScrollView::SetInternalConstraints() // MoveActor (scrolling) constraint = Constraint::New( self, Actor::Property::POSITION, MoveActorConstraint ); constraint.AddSource( Source( self, Toolkit::ScrollView::Property::SCROLL_POSITION ) ); - constraint.SetRemoveAction(Constraint::Discard); + constraint.SetRemoveAction(Constraint::DISCARD); ApplyConstraintToBoundActors(constraint); // WrapActor (wrap functionality) @@ -2877,7 +2880,7 @@ void ScrollView::SetInternalConstraints() constraint.AddSource( Source( self, Toolkit::Scrollable::Property::SCROLL_POSITION_MIN ) ); constraint.AddSource( Source( self, Toolkit::Scrollable::Property::SCROLL_POSITION_MAX ) ); constraint.AddSource( Source( self, Toolkit::ScrollView::Property::WRAP ) ); - constraint.SetRemoveAction(Constraint::Discard); + constraint.SetRemoveAction(Constraint::DISCARD); ApplyConstraintToBoundActors(constraint); } @@ -2910,7 +2913,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 )