ScrollView: Avoid animating in wrong direction during fast flick
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-impl.h
index c88bf0f..8f2be58 100644 (file)
@@ -1,22 +1,21 @@
 #ifndef __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__
 #define __DALI_TOOLKIT_INTERNAL_SCROLL_VIEW_H__
 
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+//
+// Copyright (c) 2014 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Flora License, Version 1.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://floralicense.org/license/
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an AS IS BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
 
 // EXTERNAL INCLUDES
 #include <dali/dali.h>
@@ -496,7 +495,7 @@ private: // private overriden functions from CustomActorImpl and Controls
   virtual void OnSizeAnimation(Animation& animation, const Vector3& targetSize);
 
   /**
-   * @copydoc Dali::ControlImpl::OnControlSizeSet(const Vector3&)
+   * @copydoc Dali::Control::OnControlSizeSet(const Vector3&)
    */
   virtual void OnControlSizeSet( const Vector3& size );
 
@@ -557,6 +556,21 @@ private: // private overriden functions from CustomActorImpl and Controls
 private:
 
   /**
+   * Start a timer which calls OnTouchDownTimeout()
+   */
+  void StartTouchDownTimer();
+
+  /**
+   * Stop a timer which calls OnTouchDownTimeout()
+   */
+  void StopTouchDownTimer();
+
+  /**
+   * Helper to detect when touch-point has been down (outside of pan gesture)
+   */
+  bool OnTouchDownTimeout();
+
+  /**
    * Called whenever a snap animation has completed
    * @param[in] source the Animation instance that has completed.
    */
@@ -807,7 +821,6 @@ private:
   bool mScrolling;                      ///< Flag indicating whether the scroll view is being scrolled (by user or animation)
   bool mScrollInterrupted;              ///< Flag set for when a down event interrupts a scroll
   unsigned long mTouchDownTime;         ///< The touch down time
-  Vector2 mTouchDownPosition;           ///< The touch down position
 
   bool mSensitive;                      ///< Scroll Sensitivity Flag.
 
@@ -835,7 +848,7 @@ private:
   RulerPtr mRulerScaleX;
   RulerPtr mRulerScaleY;
   RulerPtr mRulerRotation;
-  bool mTouchDownReceived;
+  bool mTouchDownTimeoutReached;
   bool mActorAutoSnapEnabled;           ///< Whether to automatically snap to closest actor.
   bool mAutoResizeContainerEnabled;     ///< Whether to automatically resize container (affects RulerDomain's on X/Y axes)
   bool mWrapMode;                       ///< Whether to wrap contents based on container size.
@@ -852,6 +865,7 @@ private:
   Vector2 mLastVelocity;                ///< Record the last velocity from PanGesture (Finish event doesn't have correct velocity)
   LockAxis mLockAxis;
 
+  Timer mTouchDownTimer;                ///< Used to interrupt snap-animation. This cannot be done in OnTouchEvent without breaking fast flick behavior.
   Timer mOvershootRefreshTimer;
   Timer mRefreshTimer;                  ///< Refresh timer is used to provide the Application developer with updates as animations run.
   int mRefreshIntervalMilliseconds;     ///< Refresh timer interval.
@@ -894,6 +908,8 @@ private:
   ScrollOvershootIndicatorPtr mOvershootIndicator;
 
   Toolkit::ScrollView::SnapStartedSignalV2 mSnapStartedSignalV2;
+
+  bool mInAccessibilityPan : 1; // With AccessibilityPan its easier to move between snap positions
 };
 
 } // namespace Internal