Change overshoot to have constant speed as a property
[platform/core/uifw/dali-toolkit.git] / base / dali-toolkit / internal / controls / scrollable / scroll-view / scroll-view-impl.cpp
index ff6fbb9..e2df7a5 100644 (file)
 #include <dali-toolkit/internal/controls/scrollable/scroll-view/scroll-view-impl.h>
 
 // EXTERNAL INCLUDES
+#include <dali/public-api/animation/constraints.h>
+#include <dali/public-api/common/stage.h>
 #include <dali/public-api/events/mouse-wheel-event.h>
+#include <dali/public-api/events/touch-event.h>
+#include <dali/public-api/object/type-registry.h>
 #include <dali/integration-api/debug.h>
 
 // INTERNAL INCLUDES
@@ -57,8 +61,6 @@ const float FLICK_ORTHO_ANGLE_RANGE = 75.0f;
 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 );
-const float DEFAULT_OVERSHOOT_ANIMATION_DURATION = 0.35f;  // time in seconds
-const Vector2 OVERSCROLL_CLAMP(1.0f, 1.0f);                // maximum overscroll allowed in pixels when overshoot indicator is being used
 const float TOUCH_DOWN_TIMER_INTERVAL = 100.0f;
 const float DEFAULT_SCROLL_UPDATE_DISTANCE( 30.0f );                               ///< Default distance to travel in pixels for scroll update signal
 
@@ -1208,10 +1210,10 @@ Vector3 ScrollView::GetDomainSize() const
 void ScrollView::TransformTo(const Vector3& position,
                              DirectionBias horizontalBias, DirectionBias verticalBias)
 {
-  TransformTo(position, mSnapDuration, horizontalBias, verticalBias);
+  TransformTo(position, mSnapDuration, mSnapAlphaFunction, horizontalBias, verticalBias);
 }
 
-void ScrollView::TransformTo(const Vector3& position, float duration,
+void ScrollView::TransformTo(const Vector3& position, float duration, AlphaFunction alpha,
                              DirectionBias horizontalBias, DirectionBias verticalBias)
 {
   Actor self( Self() );
@@ -1254,7 +1256,7 @@ void ScrollView::TransformTo(const Vector3& position, float duration,
   mScrollStartedSignalV2.Emit( currentScrollPosition );
   bool animating = AnimateTo(-position,
                              Vector3::ONE * duration,
-                             mSnapAlphaFunction,
+                             alpha,
                              true,
                              horizontalBias,
                              verticalBias,
@@ -1290,13 +1292,22 @@ void ScrollView::ScrollTo(const Vector3& position, float duration)
   ScrollTo(position, duration, DirectionBiasNone, DirectionBiasNone);
 }
 
+void ScrollView::ScrollTo(const Vector3& position, float duration, AlphaFunction alpha)
+{
+  ScrollTo(position, duration, alpha, DirectionBiasNone, DirectionBiasNone);
+}
+
 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));
+  ScrollTo(position, duration, mSnapAlphaFunction, horizontalBias, verticalBias);
+}
 
-  TransformTo(position, duration, horizontalBias, verticalBias);
+void ScrollView::ScrollTo(const Vector3& position, float duration, AlphaFunction alpha,
+                DirectionBias horizontalBias, DirectionBias verticalBias)
+{
+  DALI_LOG_SCROLL_STATE("[0x%X] position[%.2f, %.2f] duration[%.2f], bias[%d, %d]", this, position.x, position.y, duration, int(horizontalBias), int(verticalBias));
+  TransformTo(position, duration, alpha, horizontalBias, verticalBias);
 }
 
 void ScrollView::ScrollTo(unsigned int page)
@@ -1763,7 +1774,6 @@ void ScrollView::SetOvershootEnabled(bool enabled)
   }
   if( enabled )
   {
-    mMaxOvershoot = OVERSCROLL_CLAMP;
     mOvershootIndicator->AttachToScrollable(*this);
   }
   else
@@ -2422,7 +2432,7 @@ void ScrollView::GestureContinuing(const Vector2& panDelta)
 // TODO: Upgrade to use a more powerful gesture detector (one that supports multiple touches on pan - so works as pan and flick gesture)
 // BUG: Gesture::Finished doesn't always return velocity on release (due to
 // timeDelta between last two events being 0 sometimes, or posiiton being the same)
-void ScrollView::OnPan(PanGesture gesture)
+void ScrollView::OnPan( const PanGesture& gesture )
 {
   // Guard against destruction during signal emission
   // Note that Emit() methods are called indirectly e.g. from within ScrollView::OnGestureEx()