ScrollView - Set pan start position directly into panning constraint when creating... 00/24200/1
authorJulien Heanley <j.heanley@partner.samsung.com>
Tue, 10 Jun 2014 15:12:28 +0000 (16:12 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 17:48:01 +0000 (18:48 +0100)
[problem]      Displacement value passed into constraint could be a frame behind, meaning we lose the initial pan started frame displacement
[cause]        Update thread was already running at same time as event thread called ApplyConstraint
[solution]     Instead of passing in displacement as a property input, create the constraint with event side pan start position

Change-Id: I0ee55c79b8450cdc68f8e04dad4019001b65966f
Signed-off-by: Julien Heanley <j.heanley@partner.samsung.com>
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

index b5a0751..e4fe48a 100644 (file)
@@ -276,13 +276,15 @@ ScrollView::LockAxis GetLockAxis(const Vector2& panDelta, ScrollView::LockAxis c
  */
 struct InternalPrePositionConstraint
 {
-  InternalPrePositionConstraint(const Vector2& initialPanMask,
+  InternalPrePositionConstraint(const Vector2& initialPanPosition,
+                                const Vector2& initialPanMask,
                                 bool axisAutoLock,
                                 float axisAutoLockGradient,
                                 ScrollView::LockAxis initialLockAxis,
                                 const Vector2& maxOvershoot,
                                 const RulerDomain& domainX, const RulerDomain& domainY)
-  : mInitialPanMask(initialPanMask),
+  : mLocalStart(initialPanPosition),
+    mInitialPanMask(initialPanMask),
     mDomainMin( -domainX.min, -domainY.min ),
     mDomainMax( -domainX.max, -domainY.max ),
     mMaxOvershoot(maxOvershoot),
@@ -297,7 +299,6 @@ struct InternalPrePositionConstraint
 
   Vector3 operator()(const Vector3&    current,
                      const PropertyInput& gesturePositionProperty,
-                     const PropertyInput& gestureDisplacementProperty,
                      const PropertyInput& sizeProperty)
   {
     Vector3 scrollPostPosition = current;
@@ -305,7 +306,6 @@ struct InternalPrePositionConstraint
 
     if(!mWasPanning)
     {
-      mLocalStart = gesturePositionProperty.GetVector2() - gestureDisplacementProperty.GetVector2();
       mPrePosition = current;
       mCurrentPanMask = mInitialPanMask;
       mWasPanning = true;
@@ -2508,6 +2508,7 @@ void ScrollView::OnPan(PanGesture gesture)
     case Gesture::Started:
     {
       DALI_LOG_SCROLL_STATE("[0x%X] Pan Started", this);
+      mPanStartPosition = gesture.position - gesture.displacement;
       UpdateLocalScrollProperties();
       GestureStarted();
       mPanning = true;
@@ -2769,9 +2770,8 @@ void ScrollView::UpdateMainInternalConstraint()
   {
     constraint = Constraint::New<Vector3>( mPropertyPrePosition,
                                                       Source( detector, PanGestureDetector::LOCAL_POSITION ),
-                                                      Source( detector, PanGestureDetector::LOCAL_DISPLACEMENT ),
                                                       Source( self, Actor::SIZE ),
-                                                      InternalPrePositionConstraint( initialPanMask, mAxisAutoLock, mAxisAutoLockGradient, mLockAxis, mMaxOvershoot, mRulerX->GetDomain(), mRulerY->GetDomain() ) );
+                                                      InternalPrePositionConstraint( mPanStartPosition, initialPanMask, mAxisAutoLock, mAxisAutoLockGradient, mLockAxis, mMaxOvershoot, mRulerX->GetDomain(), mRulerY->GetDomain() ) );
     mScrollMainInternalPrePositionConstraint = self.ApplyConstraint( constraint );
   }
 
index 6fc10c9..7d1e38f 100644 (file)
@@ -850,7 +850,7 @@ private:
   unsigned long mTouchDownTime;         ///< The touch down time
 
   int mGestureStackDepth;               ///< How many gestures are currently occuring.
-
+  Vector2 mPanStartPosition;            ///< Where the pan gesture's touch down occured
   Vector3 mPanDelta;                    ///< Amount currently panned.
 
   unsigned int mScrollStateFlags;       ///< flags indicating current state of scrolling