Actor self = Self();
PanGestureDetector panGesture( GetPanGestureDetector() );
- DALI_LOG_SCROLL_STATE("[0x%X] sensitive[%d]", this, int(sensitive));
+ DALI_LOG_SCROLL_STATE("[0x%X] sensitive: before:[%d] setting[%d]", this, int(mSensitive), int(sensitive));
if((!mSensitive) && (sensitive))
{
else if((mSensitive) && (!sensitive))
{
// while the scroll view is panning, the state needs to be reset.
- bool isPanning = self.GetProperty<bool>( mPropertyPanning );
- if ( isPanning )
+ if ( mPanning )
{
PanGesture cancelGesture( Gesture::Cancelled );
OnPan( cancelGesture );
void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, float rotation, float duration,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
+ Actor self( Self() );
+
// Guard against destruction during signal emission
// Note that Emit() methods are called indirectly e.g. from within ScrollView::AnimateTo()
Toolkit::ScrollView handle( GetOwner() );
+ DALI_LOG_SCROLL_STATE("[0x%X] pos[%.2f,%.2f], scale[%.2f,%.2f], rot[%.2f], duration[%.2f] bias[%d, %d]",
+ this, position.x, position.y, scale.x, scale.y, rotation, duration, int(horizontalBias), int(verticalBias));
+
Vector3 currentScrollPosition = GetCurrentScrollPosition();
- Self().SetProperty( mPropertyScrollStartPagePosition, currentScrollPosition );
+ self.SetProperty( mPropertyScrollStartPagePosition, currentScrollPosition );
- if(mScrolling) // are we interrupting a current scroll?
+ if( mScrolling ) // are we interrupting a current scroll?
{
// set mScrolling to false, in case user has code that interrogates mScrolling Getter() in complete.
mScrolling = false;
mScrollCompletedSignalV2.Emit( currentScrollPosition );
}
- Self().SetProperty(mPropertyScrolling, true);
+ if( mPanning ) // are we interrupting a current pan?
+ {
+ DALI_LOG_SCROLL_STATE("[0x%X] Interrupting Pan, set to false", this );
+ mPanning = false;
+ self.SetProperty( mPropertyPanning, false );
+
+ if( mScrollMainInternalPrePositionConstraint )
+ {
+ self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
+ }
+ }
+
+ self.SetProperty(mPropertyScrolling, true);
mScrolling = true;
DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignalV2 1 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
if(!animating)
{
// if not animating, then this pan has completed right now.
- Self().SetProperty(mPropertyScrolling, false);
+ self.SetProperty(mPropertyScrolling, false);
mScrolling = false;
- DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 2 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
+
+ // If we have no duration, then in the next update frame, we will be at the position specified as we just set.
+ // In this scenario, we cannot return the currentScrollPosition as this is out-of-date and should instead return the requested final position
+ Vector3 completedPosition( currentScrollPosition );
+ if( duration <= Math::MACHINE_EPSILON_10 )
+ {
+ completedPosition = position;
+ }
+
+ DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 2 [%.2f, %.2f]", this, completedPosition.x, completedPosition.y);
SetScrollUpdateNotification(false);
- mScrollCompletedSignalV2.Emit( currentScrollPosition );
+ mScrollCompletedSignalV2.Emit( completedPosition );
}
}
void ScrollView::ScrollTo(const Vector3& position, float duration,
DirectionBias horizontalBias, DirectionBias verticalBias)
{
+ DALI_LOG_SCROLL_STATE("[0x%X] position[%.2f, %.2f] duration[%.2f]",
+ this, position.x, position.y, duration, int(horizontalBias), int(verticalBias));
+
TransformTo(position, mScrollPostScale, mScrollPostRotation, duration, horizontalBias, verticalBias);
}
if(mRulerX->IsEnabled())
{
- float dir = VectorInDomain(-mScrollPostPosition.x, -mScrollTargetPosition.x, rulerDomainX.min, rulerDomainX.max, horizontalBias);
- mScrollTargetPosition.x = mScrollPostPosition.x + -dir;
+ float dir = VectorInDomain(-mScrollPrePosition.x, -mScrollTargetPosition.x, rulerDomainX.min, rulerDomainX.max, horizontalBias);
+ mScrollTargetPosition.x = mScrollPrePosition.x + -dir;
}
if(mRulerY->IsEnabled())
{
- float dir = VectorInDomain(-mScrollPostPosition.y, -mScrollTargetPosition.y, rulerDomainY.min, rulerDomainY.max, verticalBias);
- mScrollTargetPosition.y = mScrollPostPosition.y + -dir;
+ float dir = VectorInDomain(-mScrollPrePosition.y, -mScrollTargetPosition.y, rulerDomainY.min, rulerDomainY.max, verticalBias);
+ mScrollTargetPosition.y = mScrollPrePosition.y + -dir;
}
}
{
self.SetProperty(mPropertyPrePosition, mScrollTargetPosition);
mScrollPrePosition = mScrollTargetPosition;
+ mScrollPostPosition = mScrollTargetPosition;
+ WrapPosition(mScrollPostPosition);
}
}
scrollingFinished = true;
}
mInternalXAnimation.Reset();
+ // wrap pre scroll x position and set it
+ if( mWrapMode )
+ {
+ const RulerDomain rulerDomain = mRulerX->GetDomain();
+ mScrollPrePosition.x = -WrapInDomain(-mScrollPrePosition.x, rulerDomain.min, rulerDomain.max);
+ handle.SetProperty(mPropertyPrePosition, mScrollPrePosition);
+ }
SnapInternalXTo(mScrollPostPosition.x);
}
scrollingFinished = true;
}
mInternalYAnimation.Reset();
+ if( mWrapMode )
+ {
+ // wrap pre scroll y position and set it
+ const RulerDomain rulerDomain = mRulerY->GetDomain();
+ mScrollPrePosition.y = -WrapInDomain(-mScrollPrePosition.y, rulerDomain.min, rulerDomain.max);
+ handle.SetProperty(mPropertyPrePosition, mScrollPrePosition);
+ }
SnapInternalYTo(mScrollPostPosition.y);
}
if(!mSensitive)
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Pan Ignored, Insensitive", this);
+
// If another callback on the same original signal disables sensitivity,
// this callback will still be called, so we must suppress it.
return;
{
case Gesture::Started:
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Pan Started", this);
UpdateLocalScrollProperties();
GestureStarted();
mPanning = true;
case Gesture::Continuing:
{
- GestureContinuing(gesture.screenDisplacement, Vector2::ZERO, 0.0f);
+ if ( mPanning )
+ {
+ DALI_LOG_SCROLL_STATE("[0x%X] Pan Continuing", this);
+ GestureContinuing(gesture.screenDisplacement, Vector2::ZERO, 0.0f);
+ }
+ else
+ {
+ // If we do not think we are panning, then we should not do anything here
+ return;
+ }
break;
}
case Gesture::Finished:
case Gesture::Cancelled:
{
- UpdateLocalScrollProperties();
- mLastVelocity = gesture.velocity;
- mPanning = false;
- self.SetProperty( mPropertyPanning, false );
+ if ( mPanning )
+ {
+ DALI_LOG_SCROLL_STATE("[0x%X] Pan %s", this, ( ( gesture.state == Gesture::Finished ) ? "Finished" : "Cancelled" ) );
+
+ UpdateLocalScrollProperties();
+ mLastVelocity = gesture.velocity;
+ mPanning = false;
+ self.SetProperty( mPropertyPanning, false );
- if( mScrollMainInternalPrePositionConstraint )
+ if( mScrollMainInternalPrePositionConstraint )
+ {
+ self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
+ }
+ }
+ else
{
- self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
+ // If we do not think we are panning, then we should not do anything here
+ return;
}
break;
}
SetScrollUpdateNotification(false);
mScrolling = false;
Self().SetProperty(mPropertyScrolling, false);
+
+ if( fabs(mScrollPrePosition.x - mScrollTargetPosition.x) > Math::MACHINE_EPSILON_10 )
+ {
+ SnapInternalXTo(mScrollTargetPosition.x);
+ }
+ if( fabs(mScrollPrePosition.y - mScrollTargetPosition.y) > Math::MACHINE_EPSILON_10 )
+ {
+ SnapInternalYTo(mScrollTargetPosition.y);
+ }
Vector3 currentScrollPosition = GetCurrentScrollPosition();
DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 6 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
mScrollCompletedSignalV2.Emit( currentScrollPosition );