X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=base%2Fdali-toolkit%2Finternal%2Fcontrols%2Fscrollable%2Fscroll-view%2Fscroll-view-impl.cpp;h=48f0b9f492305fc5bafa78b734e5a0ccfbed6e63;hb=824cfff2326ae3488e6719919ab149c8ee47b4d5;hp=9cabbf05201be323864fe7d9fdd3264bf64b2da4;hpb=2ce55266059eb3dfc3b8a90a5a3ca266bb84674a;p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git diff --git a/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp b/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp index 9cabbf0..48f0b9f 100644 --- a/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp +++ b/base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp @@ -25,10 +25,10 @@ #include #include -#define ENABLED_SCROLL_STATE_LOGGING +//#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, __PRETTY_FUNCTION__, __LINE__, ## args) +#define DALI_LOG_SCROLL_STATE(format, args...) Dali::Integration::Log::LogMessage(Dali::Integration::Log::DebugInfo, "%s:%d " format "\n", __PRETTY_FUNCTION__, __LINE__, ## args) #else #define DALI_LOG_SCROLL_STATE(format, args...) #endif @@ -51,7 +51,7 @@ const int DEFAULT_REFRESH_INTERVAL_MILLISECONDS = 50; 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 ); @@ -623,7 +623,9 @@ ScrollView::ScrollView() mWrapMode(false), mAxisAutoLock(false), mAlterChild(false), - mDefaultMaxOvershoot(true) + mDefaultMaxOvershoot(true), + mCanScrollHorizontal(true), + mCanScrollVertical(true) { SetRequiresMouseWheelEvents(true); } @@ -939,8 +941,8 @@ void ScrollView::UpdatePropertyDomain(const Vector3& size) if(mRulerX->IsEnabled()) { const Toolkit::RulerDomain& rulerDomain = mRulerX->GetDomain(); - if( fabsf(min.x - rulerDomain.min) > Math::MACHINE_EPSILON_10000 - || fabsf(max.x - rulerDomain.max) > Math::MACHINE_EPSILON_10000 ) + if( fabsf(min.x - rulerDomain.min) > Math::MACHINE_EPSILON_100 + || fabsf(max.x - rulerDomain.max) > Math::MACHINE_EPSILON_100 ) { domainChanged = true; min.x = rulerDomain.min; @@ -954,17 +956,26 @@ void ScrollView::UpdatePropertyDomain(const Vector3& size) mScrollPrePosition.x = Clamp(mScrollPrePosition.x, -(max.x - size.x), -min.x); } } - if( (fabsf(rulerDomain.max - rulerDomain.min) - size.x) > Math::MACHINE_EPSILON_10000 ) + if( (fabsf(rulerDomain.max - rulerDomain.min) - size.x) > Math::MACHINE_EPSILON_100 ) { canScrollHorizontal = true; } } + else if( fabs(min.x) > Math::MACHINE_EPSILON_100 + || fabs(max.x) > Math::MACHINE_EPSILON_100 ) + { + // need to reset to 0 + domainChanged = true; + min.x = 0.0f; + max.x = 0.0f; + canScrollHorizontal = false; + } if(mRulerY->IsEnabled()) { const Toolkit::RulerDomain& rulerDomain = mRulerY->GetDomain(); - if( fabsf(min.y - rulerDomain.min) > Math::MACHINE_EPSILON_10000 - || fabsf(max.y - rulerDomain.max) > Math::MACHINE_EPSILON_10000 ) + if( fabsf(min.y - rulerDomain.min) > Math::MACHINE_EPSILON_100 + || fabsf(max.y - rulerDomain.max) > Math::MACHINE_EPSILON_100 ) { domainChanged = true; min.y = rulerDomain.min; @@ -978,30 +989,43 @@ void ScrollView::UpdatePropertyDomain(const Vector3& size) mScrollPrePosition.y = Clamp(mScrollPrePosition.y, -(max.y - size.y), -min.y); } } - if( (fabsf(rulerDomain.max - rulerDomain.min) - size.y) > Math::MACHINE_EPSILON_10000 ) + if( (fabsf(rulerDomain.max - rulerDomain.min) - size.y) > Math::MACHINE_EPSILON_100 ) { canScrollVertical = true; } } + else if( fabs(min.y) > Math::MACHINE_EPSILON_100 + || fabs(max.y) > Math::MACHINE_EPSILON_100 ) + { + // need to reset to 0 + domainChanged = true; + min.y = 0.0f; + max.y = 0.0f; + canScrollHorizontal = false; + } + // avoid setting properties if possible, otherwise this will cause an entire update as well as triggering constraints using each property we update - if( self.GetProperty(mPropertyCanScrollVertical) != canScrollVertical ) + if( mCanScrollVertical != canScrollVertical ) { + mCanScrollVertical = canScrollVertical; self.SetProperty(mPropertyCanScrollVertical, canScrollVertical); } - if( self.GetProperty(mPropertyCanScrollHorizontal) != canScrollHorizontal ) + if( mCanScrollHorizontal != canScrollHorizontal ) { + mCanScrollHorizontal = canScrollHorizontal; self.SetProperty(mPropertyCanScrollHorizontal, canScrollHorizontal); } 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 ) { mMinScroll = min; mMaxScroll = max; - self.SetProperty(mPropertyPositionMin, min ); - self.SetProperty(mPropertyPositionMax, max ); + self.SetProperty(mPropertyPositionMin, mMinScroll ); + self.SetProperty(mPropertyPositionMax, mMaxScroll ); } } @@ -1028,7 +1052,7 @@ void ScrollView::SetScrollSensitive(bool sensitive) 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)) { @@ -1037,9 +1061,10 @@ void ScrollView::SetScrollSensitive(bool 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( mPropertyPanning ); - if ( isPanning ) + if ( mPanning ) { PanGesture cancelGesture( Gesture::Cancelled ); OnPan( cancelGesture ); @@ -1049,6 +1074,7 @@ void ScrollView::SetScrollSensitive(bool sensitive) mSensitive = sensitive; mGestureStackDepth = 0; + DALI_LOG_SCROLL_STATE("[0x%X] AFTER: panning:[%d]", this, int(mPanning)); } } @@ -1250,14 +1276,19 @@ void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, floa 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; @@ -1265,8 +1296,23 @@ void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, floa 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; + 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, @@ -1283,11 +1329,20 @@ void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, floa 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 ); } } @@ -1304,6 +1359,9 @@ void ScrollView::ScrollTo(const Vector3& position, float duration) 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); } @@ -1445,6 +1503,7 @@ Actor ScrollView::FindClosestActorToPosition(const Vector3& position, FindDirect bool ScrollView::ScrollToSnapPoint() { + DALI_LOG_SCROLL_STATE("[0x%X]", this ); Vector2 stationaryVelocity = Vector2(0.0f, 0.0f); return SnapWithVelocity( stationaryVelocity ); } @@ -1761,14 +1820,14 @@ bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDurat 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; } } @@ -1779,9 +1838,15 @@ bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDurat 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().x, self.GetProperty( mPropertyPrePosition ).Get().y, self.GetProperty( mPropertyPosition ).Get().x, self.GetProperty( mPropertyPosition ).Get().y ); } // Scale Delta /////////////////////////////////////////////////////// @@ -1815,6 +1880,7 @@ bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDurat snapEvent.rotation = rotation; snapEvent.duration = totalDuration; + DALI_LOG_SCROLL_STATE("[0x%X] mSnapStartedSignalV2 [%.2f, %.2f]", this, snapEvent.position.x, snapEvent.position.y); mSnapStartedSignalV2.Emit( snapEvent ); return (mScrollStateFlags & SCROLL_ANIMATION_FLAGS) != 0; @@ -1849,6 +1915,15 @@ void ScrollView::RemoveOverlay(Actor actor) 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() ); @@ -1910,10 +1985,11 @@ void ScrollView::HandleSnapAnimationFinished() 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 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y); + 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; @@ -2026,17 +2102,19 @@ void ScrollView::OnPropertySet( Property::Index index, Property::Value propertyV { 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().x, propertyValue.Get().y); propertyValue.Get(mScrollPrePosition); } } @@ -2062,13 +2140,20 @@ void ScrollView::StopTouchDownTimer() 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; @@ -2088,6 +2173,8 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event) { if(!mSensitive) { + DALI_LOG_SCROLL_STATE("[0x%X], Not Sensitive, ignoring", this); + // Ignore this touch event, if scrollview is insensitive. return false; } @@ -2095,22 +2182,30 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event) // Ignore events with multiple-touch points if (event.GetPointCount() != 1) { + DALI_LOG_SCROLL_STATE("[0x%X], multiple touch, ignoring", this); + return false; } 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 @@ -2129,6 +2224,8 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event) // 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(); } } @@ -2190,6 +2287,7 @@ 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); } @@ -2249,7 +2347,9 @@ 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, self.GetProperty(mPropertyPrePosition).Get().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(); @@ -2268,7 +2368,9 @@ 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, self.GetProperty(mPropertyPrePosition).Get().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(); @@ -2293,30 +2395,54 @@ void ScrollView::OnScrollAnimationFinished( Animation& source ) 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().x, mScrollPostPosition.x ); + if( !(mScrollStateFlags & AnimatingInternalY) ) { 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); + 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().y, mScrollPostPosition.y ); + if( !(mScrollStateFlags & AnimatingInternalX) ) { 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); + 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(); @@ -2329,6 +2455,8 @@ 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(); @@ -2336,6 +2464,8 @@ void ScrollView::OnSnapInternalPositionFinished( Animation& source ) } if( source == mInternalYAnimation ) { + DALI_LOG_SCROLL_STATE("[0x%X] Finished Y PostPosition Animation", this ); + mScrollStateFlags &= ~SCROLL_Y_STATE_MASK; mInternalYAnimation.Reset(); WrapPosition(mScrollPrePosition); @@ -2353,8 +2483,11 @@ void ScrollView::SnapInternalXTo(float position) // 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); @@ -2376,8 +2509,11 @@ void ScrollView::SnapInternalYTo(float 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); @@ -2463,6 +2599,8 @@ void ScrollView::OnPan(PanGesture gesture) 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; @@ -2473,6 +2611,7 @@ void ScrollView::OnPan(PanGesture gesture) { case Gesture::Started: { + DALI_LOG_SCROLL_STATE("[0x%X] Pan Started", this); UpdateLocalScrollProperties(); GestureStarted(); mPanning = true; @@ -2485,21 +2624,45 @@ void ScrollView::OnPan(PanGesture gesture) 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( mScrollMainInternalPrePositionConstraint ) + 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 ) + { + self.RemoveConstraint(mScrollMainInternalPrePositionConstraint); + } + + if( mOvershootIndicator ) + { + mOvershootIndicator->ClearOvershoot(); + } + } + else { - self.RemoveConstraint(mScrollMainInternalPrePositionConstraint); + // If we do not think we are panning, then we should not do anything here + return; } break; } @@ -2525,6 +2688,7 @@ void ScrollView::OnGestureEx(Gesture::State state) 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) || @@ -2539,6 +2703,10 @@ void ScrollView::OnGestureEx(Gesture::State state) { FinishTransform(); } + else + { + DALI_LOG_SCROLL_STATE("[0x%X] mGestureStackDepth[%d]", this, mGestureStackDepth); + } } } @@ -2562,6 +2730,15 @@ void ScrollView::FinishTransform() 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 );