const float FLICK_SPEED_THRESHOLD = 500.0f; ///< Flick threshold in pixels/ms
const float FREE_FLICK_SPEED_THRESHOLD = 200.0f; ///< Free-Flick threshold in pixels/ms
const float AUTOLOCK_AXIS_MINIMUM_DISTANCE2 = 100.0f; ///< Auto-lock axis after minimum distance squared.
-const float FLICK_ORTHO_ANGLE_RANGE = 60.0f; ///< degrees. (if >45, then supports diagonal flicking)
+const float FLICK_ORTHO_ANGLE_RANGE = 75.0f; ///< degrees. (if >45, then supports diagonal flicking)
const unsigned int MAXIMUM_NUMBER_OF_VALUES = 5; ///< Number of values to use for weighted pan calculation.
const Vector2 DEFAULT_MOUSE_WHEEL_SCROLL_DISTANCE_STEP_PROPORTION = Vector2(0.17f, 0.1f); ///< The step of horizontal scroll distance in the proportion of stage size for each mouse wheel event received.
const unsigned long MINIMUM_TIME_BETWEEN_DOWN_AND_UP_FOR_RESET( 150u );
mFrictionCoefficient(Toolkit::ScrollView::DEFAULT_FRICTION_COEFFICIENT),
mFlickSpeedCoefficient(Toolkit::ScrollView::DEFAULT_FLICK_SPEED_COEFFICIENT),
mMaxFlickSpeed(Toolkit::ScrollView::DEFAULT_MAX_FLICK_SPEED),
- mPropertiesUpdated(false),
mInAccessibilityPan(false),
mInitialized(false),
mScrolling(false),
}
if( scrollPositionChanged )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Domain Changed, setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
}
if( domainChanged )
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))
{
+ DALI_LOG_SCROLL_STATE("[0x%X] BEFORE: panning:[%d]", this, int(mPanning));
+
// 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 );
mSensitive = sensitive;
mGestureStackDepth = 0;
+ DALI_LOG_SCROLL_STATE("[0x%X] AFTER: panning:[%d]", this, int(mPanning));
}
}
unsigned int ScrollView::GetCurrentPage() const
{
// in case animation is currently taking place.
- Vector3 position = GetCurrentScrollPosition();
+ Vector3 position = GetPropertyPosition();
Actor self = Self();
unsigned int page = 0;
unsigned int volume = 0;
// if rulerX is enabled, then get page count (columns)
- page = mRulerX->GetPageFromPosition(position.x, mWrapMode);
- volume = mRulerY->GetPageFromPosition(position.y, mWrapMode);
+ page = mRulerX->GetPageFromPosition(-position.x, mWrapMode);
+ volume = mRulerY->GetPageFromPosition(-position.y, mWrapMode);
pagesPerVolume = mRulerX->GetTotalPages();
return volume * pagesPerVolume + page;
Vector3 ScrollView::GetCurrentScrollPosition() const
{
- if( mPropertiesUpdated )
- {
- return -mScrollPostPosition;
- }
return -GetPropertyPosition();
}
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 );
- PreAnimatedScrollSetup();
+ 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;
+ DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 1 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
+ mScrollCompletedSignalV2.Emit( currentScrollPosition );
+ }
- Vector3 scrollStartPosition = GetCurrentScrollPosition();
+ if( mPanning ) // are we interrupting a current pan?
+ {
+ DALI_LOG_SCROLL_STATE("[0x%X] Interrupting Pan, set to false", this );
+ mPanning = false;
+ mGestureStackDepth = 0;
+ 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);
+ mScrollStartedSignalV2.Emit( currentScrollPosition );
bool animating = AnimateTo(-position,
Vector3::ONE * duration,
scale,
verticalBias,
Snap);
- if( !mScrolling )
- {
- DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignalV2 1 [%.2f, %.2f]", this, scrollStartPosition.x, scrollStartPosition.y);
- ScrollingStarted(scrollStartPosition);
- }
-
if(!animating)
{
- DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 1 [%.2f, %.2f]", this, -mScrollPostPosition.x, -mScrollPostPosition.y);
- ScrollingStopped(-mScrollPostPosition);
+ // if not animating, then this pan has completed right now.
+ self.SetProperty(mPropertyScrolling, false);
+ mScrolling = false;
+
+ // 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( 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);
}
bool ScrollView::ScrollToSnapPoint()
{
+ DALI_LOG_SCROLL_STATE("[0x%X]", this );
Vector2 stationaryVelocity = Vector2(0.0f, 0.0f);
return SnapWithVelocity( stationaryVelocity );
}
StopAnimation(mSnapAnimation);
StopAnimation(mInternalXAnimation);
StopAnimation(mInternalYAnimation);
-
- // clear scrolling flags
mScrollStateFlags = 0;
-
// remove scroll animation flags
HandleStoppedAnimation();
}
totalDuration = std::max(totalDuration, positionDuration.x);
totalDuration = std::max(totalDuration, positionDuration.y);
}
+ else
+ {
+ // try to animate for a frame, on some occasions update will be changing scroll value while event side thinks it hasnt changed
+ totalDuration = 0.01f;
+ positionChanged = true;
+ }
if(scaleChanged)
{
// a horizonal/vertical wall.delay
AnimateInternalXTo(mScrollTargetPosition.x, positionDuration.x, alpha);
AnimateInternalYTo(mScrollTargetPosition.y, positionDuration.y, alpha);
- }
- if( !(mScrollStateFlags & SCROLL_ANIMATION_FLAGS) )
- {
- mScrollTargetPosition = position;
- WrapPosition(mScrollTargetPosition);
- self.SetProperty(mPropertyPrePosition, mScrollTargetPosition);
- mScrollPrePosition = mScrollPostPosition = mScrollTargetPosition;
+ if( !(mScrollStateFlags & SCROLL_ANIMATION_FLAGS) )
+ {
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollTargetPosition.x, mScrollTargetPosition.y );
+ self.SetProperty(mPropertyPrePosition, mScrollTargetPosition);
+ mScrollPrePosition = mScrollTargetPosition;
+ mScrollPostPosition = mScrollTargetPosition;
+ WrapPosition(mScrollPostPosition);
+ }
+
+ 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] mPropertyPrePosition[%.2f, %.2f], mPropertyPosition[%.2f, %.2f]", this, self.GetProperty( mPropertyPrePosition ).Get<Vector3>().x, self.GetProperty( mPropertyPrePosition ).Get<Vector3>().y, self.GetProperty( mPropertyPosition ).Get<Vector3>().x, self.GetProperty( mPropertyPosition ).Get<Vector3>().y );
}
// Scale Delta ///////////////////////////////////////////////////////
mInternalActor.Remove( actor );
}
+void ScrollView::SetOvershootEffectColor( const Vector4& color )
+{
+ mOvershootEffectColor = color;
+ if( mOvershootIndicator )
+ {
+ mOvershootIndicator->SetOvershootEffectColor( color );
+ }
+}
+
void ScrollView::SetScrollingDirection( Radian direction, Radian threshold )
{
PanGestureDetector panGesture( GetPanGestureDetector() );
Vector3 ScrollView::GetPropertyPrePosition() const
{
- return Self().GetProperty<Vector3>(mPropertyPrePosition);
+ Vector3 position = Self().GetProperty<Vector3>(mPropertyPrePosition);
+ WrapPosition(position);
+ return position;
}
Vector3 ScrollView::GetPropertyPosition() const
{
- return Self().GetProperty<Vector3>(mPropertyPosition);
+ Vector3 position = Self().GetProperty<Vector3>(mPropertyPosition);
+ WrapPosition(position);
+
+ return position;
}
Vector3 ScrollView::GetPropertyScale() const
void ScrollView::HandleSnapAnimationFinished()
{
// Emit Signal that scrolling has completed.
+ mScrolling = false;
Actor self = Self();
self.SetProperty(mPropertyScrolling, false);
Vector3 deltaPosition(mScrollPrePosition);
+ UpdateLocalScrollProperties();
WrapPosition(mScrollPrePosition);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
+ Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 3 current[%.2f, %.2f], mScrollTargetPosition[%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y, -mScrollTargetPosition.x, -mScrollTargetPosition.y );
+ mScrollCompletedSignalV2.Emit( currentScrollPosition );
+
mDomainOffset += deltaPosition - mScrollPostPosition;
self.SetProperty(mPropertyDomainOffset, mDomainOffset);
HandleStoppedAnimation();
-
- DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 2 [%.2f, %.2f]", this, GetCurrentScrollPosition().x, GetCurrentScrollPosition().y);
- ScrollingStopped(GetCurrentScrollPosition());
}
void ScrollView::SetScrollUpdateNotification( bool enabled )
// Guard against destruction during signal emission
Toolkit::ScrollView handle( GetOwner() );
- // sometimes notification isnt removed quickly enough, dont emit signal if not scrolling
- if( mScrolling )
- {
- Vector3 currentScrollPosition = GetCurrentScrollPosition();
- mScrollUpdatedSignalV2.Emit( currentScrollPosition );
- }
+ Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ mScrollUpdatedSignalV2.Emit( currentScrollPosition );
}
bool ScrollView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
{
self.GetProperty(mPropertyPrePosition).Get(mScrollPrePosition);
propertyValue.Get(mScrollPrePosition.x);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
}
else if( index == mPropertyY )
{
self.GetProperty(mPropertyPrePosition).Get(mScrollPrePosition);
propertyValue.Get(mScrollPrePosition.y);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
}
else if( index == mPropertyPrePosition )
{
- DALI_LOG_SCROLL_STATE("[0x%X]", this);
+ DALI_LOG_SCROLL_STATE("[0x%X]: mPropertyPrePosition[%.2f, %.2f]", this, propertyValue.Get<Vector3>().x, propertyValue.Get<Vector3>().y);
propertyValue.Get(mScrollPrePosition);
}
}
bool ScrollView::OnTouchDownTimeout()
{
+ DALI_LOG_SCROLL_STATE("[0x%X]", this);
+
mTouchDownTimeoutReached = true;
- if( mScrollStateFlags & (SCROLL_ANIMATION_FLAGS | SNAP_ANIMATION_FLAGS) )
+ unsigned int currentScrollStateFlags( mScrollStateFlags ); // Cleared in StopAnimation so keep local copy for comparison
+ if( currentScrollStateFlags & (SCROLL_ANIMATION_FLAGS | SNAP_ANIMATION_FLAGS) )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Scrolling Or snapping flags set, stopping animation", this);
+
StopAnimation();
- if( mScrollStateFlags & SCROLL_ANIMATION_FLAGS )
+ if( currentScrollStateFlags & SCROLL_ANIMATION_FLAGS )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Scrolling flags set, emitting signal", this);
+
mScrollInterrupted = true;
// reset domain offset as scrolling from original plane.
mDomainOffset = Vector3::ZERO;
Self().SetProperty(mPropertyDomainOffset, Vector3::ZERO);
UpdateLocalScrollProperties();
- mPropertiesUpdated = true;
- DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 3 [%.2f, %.2f]", this, GetCurrentScrollPosition().x, GetCurrentScrollPosition().y);
- ScrollingStopped(GetCurrentScrollPosition());
-
- // make sure scroll view returns actual property value and not locally stored value once we return from this function
- mPropertiesUpdated = false;
+ Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 4 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
+ mScrollCompletedSignalV2.Emit( currentScrollPosition );
}
}
{
if(!mSensitive)
{
+ DALI_LOG_SCROLL_STATE("[0x%X], Not Sensitive, ignoring", this);
+
// Ignore this touch event, if scrollview is insensitive.
return false;
}
// Ignore events with multiple-touch points
if (event.GetPointCount() != 1)
{
+ DALI_LOG_SCROLL_STATE("[0x%X], multiple touch, ignoring", this);
+
return false;
}
- UpdateLocalScrollProperties();
- mPropertiesUpdated = true;
-
if( event.GetPoint(0).state == TouchPoint::Down )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Down", this);
+
if(mGestureStackDepth==0)
{
mTouchDownTime = event.time;
// This allows time for a pan-gesture to start, to avoid breaking snap-animation behavior with fast flicks.
// If touch-down does not become a pan (after timeout interval), then snap-animation can be interrupted.
+ mTouchDownTimeoutReached = false;
+ mScrollInterrupted = false;
StartTouchDownTimer();
}
}
else if( event.GetPoint(0).state == TouchPoint::Up )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Up", this);
+
StopTouchDownTimer();
// if the user touches and releases without enough movement to go
mLastVelocity = Vector2( 0.0f, 0.0f );
}
+ UpdateLocalScrollProperties();
// Only finish the transform if scrolling was interrupted on down or if we are scrolling
if ( mScrollInterrupted || mScrolling )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Calling FinishTransform", this);
+
FinishTransform();
}
}
mScrollInterrupted = false;
}
- // no longer guarantee local properties are up to date
- mPropertiesUpdated = false;
-
return true;
}
return true;
}
+void ScrollView::ResetScrolling()
+{
+ Actor self = Self();
+ self.GetProperty(mPropertyPosition).Get(mScrollPostPosition);
+ mScrollPrePosition = mScrollPostPosition;
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPostPosition.x, mScrollPostPosition.y );
+ self.SetProperty(mPropertyPrePosition, mScrollPostPosition);
+}
+
void ScrollView::UpdateLocalScrollProperties()
{
- if( !mPropertiesUpdated )
- {
- // only update local properties if we are not currently handler an event originating from this scroll view
- Actor self = Self();
- self.GetProperty(mPropertyPrePosition).Get(mScrollPrePosition);
- self.GetProperty(mPropertyPosition).Get(mScrollPostPosition);
- }
+ Actor self = Self();
+ self.GetProperty(mPropertyPrePosition).Get(mScrollPrePosition);
+ self.GetProperty(mPropertyPosition).Get(mScrollPostPosition);
}
// private functions
Actor self = Self();
- Vector3 deltaPosition(mScrollPrePosition);
+ Vector3 deltaPosition(mScrollPostPosition);
+ WrapPosition(mScrollPostPosition);
mDomainOffset += deltaPosition - mScrollPostPosition;
Self().SetProperty(mPropertyDomainOffset, mDomainOffset);
- StopAnimation();
+
+ if( mScrollStateFlags & SCROLL_X_STATE_MASK )
+ {
+ // already performing animation on internal x position
+ StopAnimation(mInternalXAnimation);
+ }
+
+ if( mScrollStateFlags & SCROLL_Y_STATE_MASK )
+ {
+ // already performing animation on internal y position
+ StopAnimation(mInternalYAnimation);
+ }
+
+ mScrollStateFlags = 0;
mScrollPostScale = GetPropertyScale();
mScrollPreScale = mScrollPostScale;
mScrollPreRotation = mScrollPostRotation;
-
- // animated scroll needs update notification
- SetScrollUpdateNotification(true);
}
void ScrollView::FinaliseAnimatedScroll()
if( duration > Math::MACHINE_EPSILON_10 )
{
Actor self = Self();
+ DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(mPropertyPrePosition).Get<Vector3>().x, position );
mInternalXAnimation = Animation::New(duration);
+ DALI_LOG_SCROLL_STATE("[0x%X], mInternalXAnimation[0x%X]", this, mInternalXAnimation.GetObjectPtr() );
mInternalXAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished);
mInternalXAnimation.AnimateTo( Property(self, mPropertyPrePosition, 0), position, alpha, duration);
mInternalXAnimation.Play();
if( duration > Math::MACHINE_EPSILON_10 )
{
Actor self = Self();
+ DALI_LOG_SCROLL_STATE("[0x%X], Animating from[%.2f] to[%.2f]", this, self.GetProperty(mPropertyPrePosition).Get<Vector3>().y, position );
mInternalYAnimation = Animation::New(duration);
+ DALI_LOG_SCROLL_STATE("[0x%X], mInternalYAnimation[0x%X]", this, mInternalYAnimation.GetObjectPtr() );
mInternalYAnimation.FinishedSignal().Connect(this, &ScrollView::OnScrollAnimationFinished);
mInternalYAnimation.AnimateTo( Property(self, mPropertyPrePosition, 1), position, alpha, TimePeriod(duration));
mInternalYAnimation.Play();
// update our local scroll positions
UpdateLocalScrollProperties();
- mPropertiesUpdated = true;
if( source == mSnapAnimation )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] mSnapAnimation[0x%X]", this, mSnapAnimation.GetObjectPtr() );
+
// generic snap animation used for scaling and rotation
mSnapAnimation.Reset();
}
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(mPropertyPrePosition).Get<Vector3>().x, mScrollPostPosition.x );
+
if( !(mScrollStateFlags & AnimatingInternalY) )
{
scrollingFinished = true;
{
const RulerDomain rulerDomain = mRulerX->GetDomain();
mScrollPrePosition.x = -WrapInDomain(-mScrollPrePosition.x, rulerDomain.min, rulerDomain.max);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
handle.SetProperty(mPropertyPrePosition, mScrollPrePosition);
}
SnapInternalXTo(mScrollPostPosition.x);
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(mPropertyPrePosition).Get<Vector3>().y, mScrollPostPosition.y );
+
if( !(mScrollStateFlags & AnimatingInternalX) )
{
scrollingFinished = true;
// wrap pre scroll y position and set it
const RulerDomain rulerDomain = mRulerY->GetDomain();
mScrollPrePosition.y = -WrapInDomain(-mScrollPrePosition.y, rulerDomain.min, rulerDomain.max);
+ DALI_LOG_SCROLL_STATE("[0x%X] Setting mPropertyPrePosition To[%.2f, %.2f]", this, mScrollPrePosition.x, mScrollPrePosition.y );
handle.SetProperty(mPropertyPrePosition, mScrollPrePosition);
}
SnapInternalYTo(mScrollPostPosition.y);
}
+ DALI_LOG_SCROLL_STATE("[0x%X] scrollingFinished[%d] Animation[0x%X]", this, scrollingFinished, source.GetObjectPtr());
+
if(scrollingFinished)
{
HandleSnapAnimationFinished();
}
- mPropertiesUpdated = false;
}
void ScrollView::OnSnapInternalPositionFinished( Animation& source )
UpdateLocalScrollProperties();
if( source == mInternalXAnimation )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Finished X PostPosition Animation", this );
+
// clear internal x animation flags
mScrollStateFlags &= ~SCROLL_X_STATE_MASK;
mInternalXAnimation.Reset();
}
if( source == mInternalYAnimation )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Finished Y PostPosition Animation", this );
+
mScrollStateFlags &= ~SCROLL_Y_STATE_MASK;
mInternalYAnimation.Reset();
WrapPosition(mScrollPrePosition);
// if internal x not equal to inputed parameter, animate it
float duration = std::min(fabsf((position - mScrollPrePosition.x) / mMaxOvershoot.x) * mSnapOvershootDuration, mSnapOvershootDuration);
+ DALI_LOG_SCROLL_STATE("[0x%X] duration[%.2f]", this, duration );
if( duration > Math::MACHINE_EPSILON_1 )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Starting X Snap Animation to[%.2f]", this, position );
+
mInternalXAnimation = Animation::New(duration);
mInternalXAnimation.FinishedSignal().Connect(this, &ScrollView::OnSnapInternalPositionFinished);
mInternalXAnimation.AnimateTo(Property(self, mPropertyPrePosition, 0), position);
// if internal y not equal to inputed parameter, animate it
float duration = std::min(fabsf((position - mScrollPrePosition.y) / mMaxOvershoot.y) * mSnapOvershootDuration, mSnapOvershootDuration);
+ DALI_LOG_SCROLL_STATE("[0x%X] duration[%.2f]", this, duration );
if( duration > Math::MACHINE_EPSILON_1 )
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Starting Y Snap Animation to[%.2f]", this, position );
+
mInternalYAnimation = Animation::New(duration);
mInternalYAnimation.FinishedSignal().Connect(this, &ScrollView::OnSnapInternalPositionFinished);
mInternalYAnimation.AnimateTo(Property(self, mPropertyPrePosition, 1), position);
mScaleDelta = Vector3::ONE;
mRotationDelta = 0.0f;
mLastVelocity = Vector2(0.0f, 0.0f);
+ if( !mScrolling )
+ {
+ mLockAxis = LockPossible;
+ }
- // inform application that animated scroll has been interrupted
- if( mScrolling )
+ if( mScrollStateFlags & SCROLL_X_STATE_MASK )
{
- DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 4 [%.2f, %.2f]", this, GetCurrentScrollPosition().x, GetCurrentScrollPosition().y);
- ScrollingStopped(GetCurrentScrollPosition());
+ StopAnimation(mInternalXAnimation);
+ }
+ if( mScrollStateFlags & SCROLL_Y_STATE_MASK )
+ {
+ StopAnimation(mInternalYAnimation);
+ }
+ mScrollStateFlags = 0;
+
+ 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;
+ // send negative scroll position since scroll internal scroll position works as an offset for actors,
+ // give applications the position within the domain from the scroll view's anchor position
+ DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 5 [%.2f, %.2f]", this, -mScrollPostPosition.x, -mScrollPostPosition.y);
+ mScrollCompletedSignalV2.Emit( -mScrollPostPosition );
}
- DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignalV2 2 [%.2f, %.2f]", this, GetCurrentScrollPosition().x, GetCurrentScrollPosition().y);
- ScrollingStarted(GetCurrentScrollPosition());
}
}
} // end if mAxisAutoLock
}
-void ScrollView::ScrollingStarted( const Vector3& position )
-{
- Self().SetProperty(mPropertyScrolling, true);
- mScrolling = true;
- mLockAxis = LockPossible;
-
- mScrollStartedSignalV2.Emit( position );
-}
-
-void ScrollView::ScrollingStopped( const Vector3& position )
-{
- Self().SetProperty(mPropertyScrolling, false);
- mScrolling = false;
- SetScrollUpdateNotification(false);
-
- mScrollCompletedSignalV2.Emit( position );
-}
-
// TODO: Upgrade to use a more powerful gesture detector (one that supports multiple touches on pan - so works as pan and flick gesture)
// TODO: Reimplement Scaling (pinching 2+ points)
// TODO: Reimplment Rotation (pinching 2+ points)
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;
}
- UpdateLocalScrollProperties();
- mPropertiesUpdated = true;
// translate Gesture input to get useful data...
switch(gesture.state)
{
case Gesture::Started:
{
+ DALI_LOG_SCROLL_STATE("[0x%X] Pan Started", this);
+ UpdateLocalScrollProperties();
GestureStarted();
mPanning = true;
self.SetProperty( mPropertyPanning, 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:
{
- mLastVelocity = gesture.velocity;
- mPanning = false;
- self.SetProperty( mPropertyPanning, false );
-
- if( mScrollMainInternalPrePositionConstraint )
+ if ( mPanning )
{
- self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
+ 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 )
+ {
+ self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
+ }
+
+ if( mOvershootIndicator )
+ {
+ mOvershootIndicator->ClearOvershoot();
+ }
}
- mGestureStackDepth--;
- if(mGestureStackDepth==0)
+ else
{
- FinishTransform();
+ // If we do not think we are panning, then we should not do anything here
+ return;
}
break;
}
// Nothing to do, not needed.
break;
}
+
} // end switch(gesture.state)
- // can no longer guarantee local properties are latest
- mPropertiesUpdated = false;
+ OnGestureEx(gesture.state);
+}
+
+void ScrollView::OnGestureEx(Gesture::State state)
+{
+ // call necessary signals for application developer
+
+ if(state == Gesture::Started)
+ {
+ Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ Self().SetProperty(mPropertyScrolling, true);
+ mScrolling = true;
+ DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignalV2 2 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
+ mScrollStartedSignalV2.Emit( currentScrollPosition );
+ }
+ else if( (state == Gesture::Finished) ||
+ (state == Gesture::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)
+ // then stop panning (back to 1 gesture), and then stop zooming (0 gestures).
+ // this is the point we end, and perform necessary snapping.
+ mGestureStackDepth--;
+ if(mGestureStackDepth==0)
+ {
+ FinishTransform();
+ }
+ else
+ {
+ DALI_LOG_SCROLL_STATE("[0x%X] mGestureStackDepth[%d]", this, mGestureStackDepth);
+ }
+ }
}
void ScrollView::UpdateTransform()
{
SnapInternalYTo(mScrollTargetPosition.y);
}
- if( !(mScrollStateFlags & SNAP_ANIMATION_FLAGS) )
- {
- // set final position
- WrapPosition(mScrollTargetPosition);
- mScrollPrePosition = mScrollTargetPosition;
- self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
- }
- DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 5 [%.2f, %.2f]", this, GetCurrentScrollPosition().x, GetCurrentScrollPosition().y);
- ScrollingStopped(GetCurrentScrollPosition());
+ Vector3 currentScrollPosition = GetCurrentScrollPosition();
+ DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 6 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
+ mScrollCompletedSignalV2.Emit( currentScrollPosition );
}
}