/*
- * 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.
// EXTERNAL INCLUDES
#include <cstring> // for strcmp
#include <dali/public-api/animation/constraints.h>
-#include <dali/public-api/common/stage.h>
+#include <dali/devel-api/common/stage.h>
#include <dali/public-api/events/wheel-event.h>
-#include <dali/public-api/events/touch-data.h>
+#include <dali/public-api/events/touch-event.h>
#include <dali/public-api/object/type-registry.h>
#include <dali/public-api/object/type-registry-helper.h>
#include <dali/public-api/object/property-map.h>
+#include <dali/devel-api/object/property-helper-devel.h>
+#include <dali/devel-api/events/pan-gesture-devel.h>
#include <dali/integration-api/debug.h>
// INTERNAL INCLUDES
-#include <dali-toolkit/public-api/controls/scroll-bar/scroll-bar.h>
+#include <dali-toolkit/devel-api/controls/scroll-bar/scroll-bar.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.h>
#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view-constraints.h>
+#include <dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-mode.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-overshoot-indicator-impl.h>
#include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-effect-impl.h>
//#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:
*/
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 );
}
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;
}
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;
}
*/
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;
}
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_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)
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 )
// 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 )
{
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;
mGestureStackDepth = 0;
- self.TouchSignal().Connect( this, &ScrollView::OnTouch );
+ self.TouchedSignal().Connect( this, &ScrollView::OnTouch );
EnableGestureDetection( Gesture::Type( Gesture::Pan ) );
// By default we'll allow the user to freely drag the scroll view,
SetInternalConstraints();
}
-void ScrollView::OnStageConnection( int depth )
+void ScrollView::OnSceneConnection( int depth )
{
DALI_LOG_SCROLL_STATE("[0x%X]", this);
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()
// while the scroll view is panning, the state needs to be reset.
if ( mPanning )
{
- PanGesture cancelGesture( Gesture::Cancelled );
+ PanGesture cancelGesture = DevelPanGesture::New( Gesture::Cancelled );
OnPan( cancelGesture );
}
true,
horizontalBias,
verticalBias,
- Snap);
+ SNAP);
if(!animating)
{
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,
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;
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));
}
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 );
if(child)
{
- Vector2 position = Self().GetProperty<Vector2>(Toolkit::ScrollView::Property::SCROLL_POSITION);
+ Vector2 position = Self().GetCurrentProperty<Vector2>( Toolkit::ScrollView::Property::SCROLL_POSITION );
// Get center-point of the Actor.
Vector3 childPosition = GetPositionOfAnchor(child, AnchorPoint::CENTER);
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.
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;
}
// 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);
}
}
- if(mRulerY->IsEnabled() && mRulerY->GetType() == Ruler::Free)
+ if(mRulerY->IsEnabled() && mRulerY->GetType() == Ruler::FREE)
{
float deltaY = fabsf(startPosition.y - positionSnap.y);
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;
}
}
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, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector2>().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector2>().y, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector2>().x, self.GetProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector2>().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<Vector2>().x, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_PRE_POSITION ).Get<Vector2>().y, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector2>().x, self.GetCurrentProperty( Toolkit::ScrollView::Property::SCROLL_POSITION ).Get<Vector2>().y );
}
SetScrollUpdateNotification(true);
void ScrollView::AddOverlay(Actor actor)
{
- actor.SetDrawMode( DrawMode::OVERLAY_2D );
+ actor.SetProperty( Actor::Property::DRAW_MODE, DrawMode::OVERLAY_2D );
mInternalActor.Add( actor );
}
Vector2 ScrollView::GetPropertyPrePosition() const
{
- Vector2 position = Self().GetProperty<Vector2>(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 = Self().GetProperty<Vector2>(Toolkit::ScrollView::Property::SCROLL_POSITION);
+ Vector2 position = Self().GetCurrentProperty< Vector2 >( Toolkit::ScrollView::Property::SCROLL_POSITION );
WrapPosition(position);
return position;
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,
return false;
}
-bool ScrollView::OnTouch( Actor actor, const TouchData& touch )
+bool ScrollView::OnTouch( Actor actor, const TouchEvent& touch )
{
if(!mSensitive)
{
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();
mScrollInterrupted = false;
}
- return true;
+ return false;
}
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());
}
}
void ScrollView::ResetScrolling()
{
Actor self = Self();
- self.GetProperty(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);
void ScrollView::UpdateLocalScrollProperties()
{
Actor self = Self();
- self.GetProperty(Toolkit::ScrollView::Property::SCROLL_PRE_POSITION).Get(mScrollPrePosition);
- self.GetProperty(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
if( duration > Math::MACHINE_EPSILON_10 )
{
Actor self = Self();
- DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(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);
if( duration > Math::MACHINE_EPSILON_10 )
{
Actor self = Self();
- DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(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);
if( source == mInternalXAnimation )
{
- DALI_LOG_SCROLL_STATE("[0x%X] mInternalXAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalXAnimation.GetObjectPtr(), mScrollTargetPosition.x, Self().GetProperty(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) )
{
if( source == mInternalYAnimation )
{
- DALI_LOG_SCROLL_STATE("[0x%X] mInternalYAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalYAnimation.GetObjectPtr(), mScrollTargetPosition.y, Self().GetProperty(SCROLL_PRE_POSITION).Get<Vector2>().y, mScrollPostPosition.y );
+ DALI_LOG_SCROLL_STATE("[0x%X] mInternalYAnimation[0x%X], expected[%.2f], actual[%.2f], post[%.2f]", this, mInternalYAnimation.GetObjectPtr(), mScrollTargetPosition.y, DevelHandle::GetProperty( Self(), SCROLL_PRE_POSITION ).Get< Vector2 >().y, mScrollPostPosition.y );
if( !(mScrollStateFlags & AnimatingInternalX) )
{
}
// translate Gesture input to get useful data...
- switch(gesture.state)
+ switch(gesture.GetState())
{
case Gesture::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();
if ( mPanning )
{
DALI_LOG_SCROLL_STATE("[0x%X] Pan Continuing", this);
- GestureContinuing(gesture.screenDisplacement);
+ GestureContinuing(gesture.GetScreenDisplacement());
}
else
{
{
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() == Gesture::Finished ) ? "Finished" : "Cancelled" ) );
UpdateLocalScrollProperties();
- mLastVelocity = gesture.velocity;
+ mLastVelocity = gesture.GetVelocity();
mPanning = false;
self.SetProperty( Toolkit::ScrollView::Property::PANNING, false );
} // end switch(gesture.state)
- OnGestureEx(gesture.state);
+ OnGestureEx(gesture.GetState());
}
void ScrollView::OnGestureEx(Gesture::State state)
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();
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.
// MoveActor (scrolling)
constraint = Constraint::New<Vector3>( 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)
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);
}
scrollViewImpl.SetWheelScrollDistanceStep( value.Get<Vector2>() );
break;
}
+ case Toolkit::ScrollView::Property::SCROLL_MODE:
+ {
+ Property::Map* map = value.GetMap();
+ if( map )
+ {
+ scrollViewImpl.SetScrollMode( *map );
+ }
+ }
}
}
}
return value;
}
+void ScrollView::SetScrollMode( const Property::Map& scrollModeMap )
+{
+ Toolkit::RulerPtr rulerX, rulerY;
+
+ // Check the scroll mode in the X axis
+ bool xAxisScrollEnabled = true;
+ Property::Value* valuePtr = scrollModeMap.Find( Toolkit::ScrollMode::X_AXIS_SCROLL_ENABLED, "xAxisScrollEnabled" );
+ if( valuePtr && valuePtr->GetType() == Property::BOOLEAN )
+ {
+ valuePtr->Get( xAxisScrollEnabled );
+ }
+
+ if( !xAxisScrollEnabled )
+ {
+ // Default ruler and disabled
+ rulerX = new Toolkit::DefaultRuler();
+ rulerX->Disable();
+ }
+ else
+ {
+ valuePtr = scrollModeMap.Find( Toolkit::ScrollMode::X_AXIS_SNAP_TO_INTERVAL, "xAxisSnapToInterval" );
+ float xAxisSnapToInterval = 0.0f;
+ if( valuePtr && valuePtr->Get( xAxisSnapToInterval ) )
+ {
+ // Fixed ruler and enabled
+ rulerX = new Toolkit::FixedRuler( xAxisSnapToInterval );
+ }
+ else
+ {
+ // Default ruler and enabled
+ rulerX = new Toolkit::DefaultRuler();
+ }
+
+ valuePtr = scrollModeMap.Find( Toolkit::ScrollMode::X_AXIS_SCROLL_BOUNDARY, "xAxisScrollBoundary" );
+ float xAxisScrollBoundary = 0.0f;
+ if( valuePtr && valuePtr->Get( xAxisScrollBoundary ) )
+ {
+ // By default ruler domain is disabled unless set
+ rulerX->SetDomain( Toolkit::RulerDomain( 0, xAxisScrollBoundary, true ) );
+ }
+ }
+
+ // Check the scroll mode in the Y axis
+ bool yAxisScrollEnabled = true;
+ valuePtr = scrollModeMap.Find( Toolkit::ScrollMode::Y_AXIS_SCROLL_ENABLED, "yAxisScrollEnabled" );
+ if( valuePtr && valuePtr->GetType() == Property::BOOLEAN )
+ {
+ valuePtr->Get( yAxisScrollEnabled );
+ }
+
+ if( !yAxisScrollEnabled )
+ {
+ // Default ruler and disabled
+ rulerY = new Toolkit::DefaultRuler();
+ rulerY->Disable();
+ }
+ else
+ {
+ valuePtr = scrollModeMap.Find( Toolkit::ScrollMode::Y_AXIS_SNAP_TO_INTERVAL, "yAxisSnapToInterval" );
+ float yAxisSnapToInterval = 0.0f;
+ if( valuePtr && valuePtr->Get( yAxisSnapToInterval ) )
+ {
+ // Fixed ruler and enabled
+ rulerY = new Toolkit::FixedRuler(yAxisSnapToInterval);
+ }
+ else
+ {
+ // Default ruler and enabled
+ rulerY = new Toolkit::DefaultRuler();
+ }
+
+ valuePtr = scrollModeMap.Find( Toolkit::ScrollMode::Y_AXIS_SCROLL_BOUNDARY, "yAxisScrollBoundary" );
+ float yAxisScrollBoundary = 0.0f;
+ if( valuePtr && valuePtr->Get( yAxisScrollBoundary ) )
+ {
+ // By default ruler domain is disabled unless set
+ rulerY->SetDomain( Toolkit::RulerDomain( 0, yAxisScrollBoundary, true ) );
+ }
+ }
+
+ SetRulerX(rulerX);
+ SetRulerY(rulerY);
+}
+
} // namespace Internal
} // namespace Toolkit