Revert "ScrollView - Store properties in local values for GetCurrentScrollPosition" 66/24166/1
authorJonghyun Ho <jonghyun.ho@samsung.com>
Sat, 14 Jun 2014 03:21:32 +0000 (12:21 +0900)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 17:47:06 +0000 (18:47 +0100)
Change-Id: I50d5d429f72c8fc58d3053fb8c493f38c87a228b
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.cpp
base/dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h
base/dali-toolkit/public-api/controls/scrollable/scroll-view/scroll-view.cpp

index 97f4145..0dabb5a 100644 (file)
@@ -611,7 +611,6 @@ ScrollView::ScrollView()
   mFrictionCoefficient(Toolkit::ScrollView::DEFAULT_FRICTION_COEFFICIENT),
   mFlickSpeedCoefficient(Toolkit::ScrollView::DEFAULT_FLICK_SPEED_COEFFICIENT),
   mMaxFlickSpeed(Toolkit::ScrollView::DEFAULT_MAX_FLICK_SPEED),
   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),
   mInAccessibilityPan(false),
   mInitialized(false),
   mScrolling(false),
@@ -1223,7 +1222,7 @@ Vector2 ScrollView::GetMouseWheelScrollDistanceStep() const
 unsigned int ScrollView::GetCurrentPage() const
 {
   // in case animation is currently taking place.
 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;
 
   Actor self = Self();
   unsigned int page = 0;
@@ -1231,8 +1230,8 @@ unsigned int ScrollView::GetCurrentPage() const
   unsigned int volume = 0;
 
   // if rulerX is enabled, then get page count (columns)
   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;
   pagesPerVolume = mRulerX->GetTotalPages();
 
   return volume * pagesPerVolume + page;
@@ -1240,10 +1239,6 @@ unsigned int ScrollView::GetCurrentPage() const
 
 Vector3 ScrollView::GetCurrentScrollPosition() const
 {
 
 Vector3 ScrollView::GetCurrentScrollPosition() const
 {
-  if( mPropertiesUpdated )
-  {
-    return -mScrollPostPosition;
-  }
   return -GetPropertyPosition();
 }
 
   return -GetPropertyPosition();
 }
 
@@ -1285,10 +1280,19 @@ void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, floa
   Vector3 currentScrollPosition = GetCurrentScrollPosition();
   Self().SetProperty( mPropertyScrollStartPagePosition, currentScrollPosition );
 
   Vector3 currentScrollPosition = GetCurrentScrollPosition();
   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();
+  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,
   bool animating = AnimateTo(-position,
                              Vector3::ONE * duration,
                              scale,
@@ -1301,16 +1305,14 @@ void ScrollView::TransformTo(const Vector3& position, const Vector3& scale, floa
                              verticalBias,
                              Snap);
 
                              verticalBias,
                              Snap);
 
-  if( !mScrolling )
-  {
-    DALI_LOG_SCROLL_STATE("[0x%X] mScrollStartedSignalV2 1 [%.2f, %.2f]", this, scrollStartPosition.x, scrollStartPosition.y);
-    ScrollingStarted(scrollStartPosition);
-  }
-
   if(!animating)
   {
   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;
+    DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 2 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
+    SetScrollUpdateNotification(false);
+    mScrollCompletedSignalV2.Emit( currentScrollPosition );
   }
 }
 
   }
 }
 
@@ -1718,10 +1720,7 @@ void ScrollView::StopAnimation(void)
   StopAnimation(mSnapAnimation);
   StopAnimation(mInternalXAnimation);
   StopAnimation(mInternalYAnimation);
   StopAnimation(mSnapAnimation);
   StopAnimation(mInternalXAnimation);
   StopAnimation(mInternalYAnimation);
-
-  // clear scrolling flags
   mScrollStateFlags = 0;
   mScrollStateFlags = 0;
-
   // remove scroll animation flags
   HandleStoppedAnimation();
 }
   // remove scroll animation flags
   HandleStoppedAnimation();
 }
@@ -1757,6 +1756,12 @@ bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDurat
     totalDuration = std::max(totalDuration, positionDuration.x);
     totalDuration = std::max(totalDuration, positionDuration.y);
   }
     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)
   {
 
   if(scaleChanged)
   {
@@ -1796,14 +1801,14 @@ bool ScrollView::AnimateTo(const Vector3& position, const Vector3& positionDurat
     // a horizonal/vertical wall.delay
     AnimateInternalXTo(mScrollTargetPosition.x, positionDuration.x, alpha);
     AnimateInternalYTo(mScrollTargetPosition.y, positionDuration.y, alpha);
     // 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) )
+    {
+      self.SetProperty(mPropertyPrePosition, mScrollTargetPosition);
+      mScrollPrePosition = mScrollTargetPosition;
+      mScrollPostPosition = mScrollTargetPosition;
+      WrapPosition(mScrollPostPosition);
+    }
   }
 
   // Scale Delta ///////////////////////////////////////////////////////
   }
 
   // Scale Delta ///////////////////////////////////////////////////////
@@ -1899,12 +1904,17 @@ void ScrollView::FindAndUnbindActor(Actor child)
 
 Vector3 ScrollView::GetPropertyPrePosition() const
 {
 
 Vector3 ScrollView::GetPropertyPrePosition() const
 {
-  return Self().GetProperty<Vector3>(mPropertyPrePosition);
+  Vector3 position = Self().GetProperty<Vector3>(mPropertyPrePosition);
+  WrapPosition(position);
+  return position;
 }
 
 Vector3 ScrollView::GetPropertyPosition() const
 {
 }
 
 Vector3 ScrollView::GetPropertyPosition() const
 {
-  return Self().GetProperty<Vector3>(mPropertyPosition);
+  Vector3 position = Self().GetProperty<Vector3>(mPropertyPosition);
+  WrapPosition(position);
+
+  return position;
 }
 
 Vector3 ScrollView::GetPropertyScale() const
 }
 
 Vector3 ScrollView::GetPropertyScale() const
@@ -1920,20 +1930,23 @@ void ScrollView::HandleStoppedAnimation()
 void ScrollView::HandleSnapAnimationFinished()
 {
   // Emit Signal that scrolling has completed.
 void ScrollView::HandleSnapAnimationFinished()
 {
   // Emit Signal that scrolling has completed.
+  mScrolling = false;
   Actor self = Self();
   self.SetProperty(mPropertyScrolling, false);
 
   Vector3 deltaPosition(mScrollPrePosition);
 
   Actor self = Self();
   self.SetProperty(mPropertyScrolling, false);
 
   Vector3 deltaPosition(mScrollPrePosition);
 
+  UpdateLocalScrollProperties();
   WrapPosition(mScrollPrePosition);
   self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
 
   WrapPosition(mScrollPrePosition);
   self.SetProperty(mPropertyPrePosition, mScrollPrePosition);
 
+  Vector3 currentScrollPosition = GetCurrentScrollPosition();
+  DALI_LOG_SCROLL_STATE("[0x%X] mScrollCompletedSignalV2 3 [%.2f, %.2f]", this, currentScrollPosition.x, currentScrollPosition.y);
+  mScrollCompletedSignalV2.Emit( currentScrollPosition );
+
   mDomainOffset += deltaPosition - mScrollPostPosition;
   self.SetProperty(mPropertyDomainOffset, mDomainOffset);
   HandleStoppedAnimation();
   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 )
 }
 
 void ScrollView::SetScrollUpdateNotification( bool enabled )
@@ -1970,12 +1983,8 @@ void ScrollView::OnScrollUpdateNotification(Dali::PropertyNotification& source)
   // Guard against destruction during signal emission
   Toolkit::ScrollView handle( GetOwner() );
 
   // 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 )
 }
 
 bool ScrollView::DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor )
@@ -2094,12 +2103,9 @@ bool ScrollView::OnTouchDownTimeout()
       Self().SetProperty(mPropertyDomainOffset, Vector3::ZERO);
 
       UpdateLocalScrollProperties();
       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 );
     }
   }
 
     }
   }
 
@@ -2120,9 +2126,6 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event)
     return false;
   }
 
     return false;
   }
 
-  UpdateLocalScrollProperties();
-  mPropertiesUpdated = true;
-
   if( event.GetPoint(0).state == TouchPoint::Down )
   {
     if(mGestureStackDepth==0)
   if( event.GetPoint(0).state == TouchPoint::Down )
   {
     if(mGestureStackDepth==0)
@@ -2150,6 +2153,7 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event)
         mLastVelocity = Vector2( 0.0f, 0.0f );
       }
 
         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 )
       {
       // Only finish the transform if scrolling was interrupted on down or if we are scrolling
       if ( mScrollInterrupted || mScrolling )
       {
@@ -2160,9 +2164,6 @@ bool ScrollView::OnTouchEvent(const TouchEvent& event)
     mScrollInterrupted = false;
   }
 
     mScrollInterrupted = false;
   }
 
-  // no longer guarantee local properties are up to date
-  mPropertiesUpdated = false;
-
   return true;
 }
 
   return true;
 }
 
@@ -2212,15 +2213,19 @@ bool ScrollView::OnMouseWheelEvent(const MouseWheelEvent& event)
   return true;
 }
 
   return true;
 }
 
+void ScrollView::ResetScrolling()
+{
+  Actor self = Self();
+  self.GetProperty(mPropertyPosition).Get(mScrollPostPosition);
+  mScrollPrePosition = mScrollPostPosition;
+  self.SetProperty(mPropertyPrePosition, mScrollPostPosition);
+}
+
 void ScrollView::UpdateLocalScrollProperties()
 {
 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
 }
 
 // private functions
@@ -2232,10 +2237,24 @@ void ScrollView::PreAnimatedScrollSetup()
 
   Actor self = Self();
 
 
   Actor self = Self();
 
-  Vector3 deltaPosition(mScrollPrePosition);
+  Vector3 deltaPosition(mScrollPostPosition);
+  WrapPosition(mScrollPostPosition);
   mDomainOffset += deltaPosition - mScrollPostPosition;
   Self().SetProperty(mPropertyDomainOffset, mDomainOffset);
   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();
 
 
   mScrollPostScale = GetPropertyScale();
 
@@ -2244,9 +2263,6 @@ void ScrollView::PreAnimatedScrollSetup()
 
   mScrollPreScale = mScrollPostScale;
   mScrollPreRotation = mScrollPostRotation;
 
   mScrollPreScale = mScrollPostScale;
   mScrollPreRotation = mScrollPostRotation;
-
-  // animated scroll needs update notification
-  SetScrollUpdateNotification(true);
 }
 
 void ScrollView::FinaliseAnimatedScroll()
 }
 
 void ScrollView::FinaliseAnimatedScroll()
@@ -2302,7 +2318,6 @@ void ScrollView::OnScrollAnimationFinished( Animation& source )
 
   // update our local scroll positions
   UpdateLocalScrollProperties();
 
   // update our local scroll positions
   UpdateLocalScrollProperties();
-  mPropertiesUpdated = true;
 
   if( source == mSnapAnimation )
   {
 
   if( source == mSnapAnimation )
   {
@@ -2348,7 +2363,6 @@ void ScrollView::OnScrollAnimationFinished( Animation& source )
   {
     HandleSnapAnimationFinished();
   }
   {
     HandleSnapAnimationFinished();
   }
-  mPropertiesUpdated = false;
 }
 
 void ScrollView::OnSnapInternalPositionFinished( Animation& source )
 }
 
 void ScrollView::OnSnapInternalPositionFinished( Animation& source )
@@ -2430,15 +2444,30 @@ void ScrollView::GestureStarted()
     mScaleDelta = Vector3::ONE;
     mRotationDelta = 0.0f;
     mLastVelocity = Vector2(0.0f, 0.0f);
     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());
   }
 }
 
   }
 }
 
@@ -2463,24 +2492,6 @@ void ScrollView::GestureContinuing(const Vector2& panDelta, const Vector2& scale
   } // end if mAxisAutoLock
 }
 
   } // 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)
 // 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)
@@ -2498,14 +2509,13 @@ void ScrollView::OnPan(PanGesture gesture)
     // this callback will still be called, so we must suppress it.
     return;
   }
     // 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:
     {
 
   // translate Gesture input to get useful data...
   switch(gesture.state)
   {
     case Gesture::Started:
     {
+      UpdateLocalScrollProperties();
       GestureStarted();
       mPanning = true;
       self.SetProperty( mPropertyPanning, true );
       GestureStarted();
       mPanning = true;
       self.SetProperty( mPropertyPanning, true );
@@ -2524,6 +2534,7 @@ void ScrollView::OnPan(PanGesture gesture)
     case Gesture::Finished:
     case Gesture::Cancelled:
     {
     case Gesture::Finished:
     case Gesture::Cancelled:
     {
+      UpdateLocalScrollProperties();
       mLastVelocity = gesture.velocity;
       mPanning = false;
       self.SetProperty( mPropertyPanning, false );
       mLastVelocity = gesture.velocity;
       mPanning = false;
       self.SetProperty( mPropertyPanning, false );
@@ -2532,11 +2543,6 @@ void ScrollView::OnPan(PanGesture gesture)
       {
         self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
       }
       {
         self.RemoveConstraint(mScrollMainInternalPrePositionConstraint);
       }
-      mGestureStackDepth--;
-      if(mGestureStackDepth==0)
-      {
-        FinishTransform();
-      }
       break;
     }
 
       break;
     }
 
@@ -2546,10 +2552,37 @@ void ScrollView::OnPan(PanGesture gesture)
       // Nothing to do, not needed.
       break;
     }
       // Nothing to do, not needed.
       break;
     }
+
   } // end switch(gesture.state)
 
   } // 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();
+    }
+  }
 }
 
 void ScrollView::UpdateTransform()
 }
 
 void ScrollView::UpdateTransform()
@@ -2581,15 +2614,9 @@ void ScrollView::FinishTransform()
     {
       SnapInternalYTo(mScrollTargetPosition.y);
     }
     {
       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 );
   }
 }
 
   }
 }
 
index f60d3de..3f8562f 100644 (file)
@@ -614,6 +614,13 @@ private:
   bool OnTouchDownTimeout();
 
   /**
   bool OnTouchDownTimeout();
 
   /**
+   * Called whenever a snap animation has completed
+   * @param[in] source the Animation instance that has completed.
+   * Resets all scrolling animations and states, leaving current scroll position at mPropertyPosition
+   */
+  void ResetScrolling();
+
+  /**
    * Updates mScrollInternalPosition, mScrollPrePosition and mScrollPostPosition from their property counterparts
    */
   void UpdateLocalScrollProperties();
    * Updates mScrollInternalPosition, mScrollPrePosition and mScrollPostPosition from their property counterparts
    */
   void UpdateLocalScrollProperties();
@@ -698,25 +705,18 @@ private:
   void GestureContinuing(const Vector2& panDelta, const Vector2& scaleDelta, float rotationDelta);
 
   /**
   void GestureContinuing(const Vector2& panDelta, const Vector2& scaleDelta, float rotationDelta);
 
   /**
-   * Called when either pan starts or animated scroll starts
-   *
-   * @param[in] scroll position where scrolling started in positive scroll coordinates (scroll properties are negative)
-   */
-  void ScrollingStarted( const Vector3& position );
-
-  /**
-   * Called when scrolling stops, either due to interruption from pan or when scroll animation finishes
+   * Called upon pan gesture event.
    *
    *
-   * @param[in] scroll position where scrolling stopped in positive scroll coordinates (scroll properties are negative)
+   * @param[in] gesture The gesture event.
    */
    */
-  void ScrollingStopped( const Vector3& position );
+  void OnPan(PanGesture pan);
 
   /**
 
   /**
-   * Called upon pan gesture event.
+   * Extension of the above gestures.
    *
    * @param[in] gesture The gesture event.
    */
    *
    * @param[in] gesture The gesture event.
    */
-  void OnPan(PanGesture pan);
+  void OnGestureEx(Gesture::State state);
 
   /**
    * Performs snapping while taking into account Velocity of gesture
 
   /**
    * Performs snapping while taking into account Velocity of gesture
@@ -929,6 +929,7 @@ private:
   Animation mInternalXAnimation;        ///< Animates mPropertyX to a snap position or application requested scroll position
   Animation mInternalYAnimation;        ///< Animates mPropertyY to a snap position or application requested scroll position
 
   Animation mInternalXAnimation;        ///< Animates mPropertyX to a snap position or application requested scroll position
   Animation mInternalYAnimation;        ///< Animates mPropertyY to a snap position or application requested scroll position
 
+
   Vector2 mLastVelocity;                ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
   LockAxis mLockAxis;
 
   Vector2 mLastVelocity;                ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
   LockAxis mLockAxis;
 
@@ -976,8 +977,7 @@ private:
 
   Toolkit::ScrollView::SnapStartedSignalV2 mSnapStartedSignalV2;
 
 
   Toolkit::ScrollView::SnapStartedSignalV2 mSnapStartedSignalV2;
 
-  bool mPropertiesUpdated:1;              ///< Flag telling us when we can return local values to application or if we have to return the property
-  bool mInAccessibilityPan:1;             ///< With AccessibilityPan its easier to move between snap positions
+  bool mInAccessibilityPan : 1;           ///< With AccessibilityPan its easier to move between snap positions
   bool mInitialized:1;
   bool mScrolling:1;                      ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
   bool mScrollInterrupted:1;              ///< Flag set for when a down event interrupts a scroll
   bool mInitialized:1;
   bool mScrolling:1;                      ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
   bool mScrollInterrupted:1;              ///< Flag set for when a down event interrupts a scroll
index 84a7df9..ff8fd79 100644 (file)
@@ -233,10 +233,6 @@ unsigned int FixedRuler::GetPageFromPosition(float position, bool wrap) const
   // spacing must be present.
   if(mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1)
   {
   // spacing must be present.
   if(mEnabled && fabsf(mSpacing) > Math::MACHINE_EPSILON_1)
   {
-    if( wrap )
-    {
-      position = WrapInDomain(position, mDomain.min, mDomain.max);
-    }
     page = floor((position - mDomain.min) / mSpacing + 0.5f);
 
     if(wrap)
     page = floor((position - mDomain.min) / mSpacing + 0.5f);
 
     if(wrap)