Allow configurable speed factor when ItemView is being swiped. 81/24181/1
authorRichard Huang <r.huang@samsung.com>
Fri, 20 Jun 2014 18:31:35 +0000 (19:31 +0100)
committerAdeel Kazmi <adeel.kazmi@samsung.com>
Tue, 8 Jul 2014 17:47:34 +0000 (18:47 +0100)
[problem] No way to configure scroll speed factor separately while panning or flicking.
          Therefore for some layouts you can't get a value to make both panning and
          flicking work.
[cause] Only one scroll speed factor for both panning and flicking.
[solution] New API for configurable speed factor while flicking.

Change-Id: Ia58a4346db0923410fd61005efb38f4d1ca4a843
Signed-off-by: Adeel Kazmi <adeel.kazmi@samsung.com>
base/dali-toolkit/internal/controls/scrollable/item-view/item-view-impl.cpp
base/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.cpp
capi/dali-toolkit/public-api/controls/scrollable/item-view/item-layout.h

index b8899de..55f87ad 100644 (file)
@@ -1349,7 +1349,7 @@ void ItemView::OnPan(PanGesture gesture)
     case Gesture::Continuing:
     {
       mScrollDistance = CalculateScrollDistance(gesture.displacement, *mActiveLayout);
-      mScrollSpeed = Clamp((gesture.GetSpeed() * mActiveLayout->GetScrollSpeedFactor() * MILLISECONDS_PER_SECONDS), 0.0f, mActiveLayout->GetMaximumSwipeSpeed());
+      mScrollSpeed = Clamp((gesture.GetSpeed() * mActiveLayout->GetFlickSpeedFactor() * MILLISECONDS_PER_SECONDS), 0.0f, mActiveLayout->GetMaximumSwipeSpeed());
 
       // Refresh order depends on the direction of the scroll; negative is towards the last item.
       mRefreshOrderHint = mScrollDistance < 0.0f;
index b79c6e7..c4f94f0 100644 (file)
@@ -237,6 +237,12 @@ int ItemLayout::GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Cont
   return itemID;
 }
 
+float ItemLayout::GetFlickSpeedFactor() const
+{
+  // By default, the speed factor while dragging and swiping is the same.
+  return GetScrollSpeedFactor();
+}
+
 } // namespace Toolkit
 
 } // namespace Dali
index 98deaec..5a32df0 100644 (file)
@@ -345,9 +345,9 @@ public:
   virtual void GetYAxisScrollHint(Vector2& scrollHint) const;
 
   /**
-   * @brief Query the scroll speed factor of the layout.
+   * @brief Query the scroll speed factor of the layout while dragging.
    *
-   * This factor is used by the layout to customise its scroll speed while dragging and swiping.
+   * This factor is used by the layout to customise its scroll speed while dragging.
    * The factor will be multiplied with the scroll distance of how many pixels in actor coordinate,
    * and the layout position of the actors in ItemView will be moved by this result.
    * For example, when the speed factor is 0.01, if the scroll distance is 100 pixels, the layout
@@ -387,6 +387,20 @@ public:
    */
   virtual int GetNextFocusItemID(int itemID, int maxItems, Dali::Toolkit::Control::KeyboardFocusNavigationDirection direction, bool loopEnabled);
 
+  /**
+   * @brief Query the flick speed factor of the layout while swipping.
+   *
+   * This factor is used by the layout to customise its scroll speed while swiping.
+   * The factor will be multiplied with the scroll distance of how many pixels in actor coordinate,
+   * and the layout position of the actors in ItemView will be moved by this result.
+   * For example, when the speed factor is 0.01, if the scroll distance is 100 pixels, the layout
+   * position of actors will be moved by 1.
+   * Therefore, the bigger the factor is, the faster the flick speed will be.
+   *
+   * @return The scroll speed factor of the layout.
+   */
+  virtual float GetFlickSpeedFactor() const;
+
 protected:
 
   /**