summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthat <github@that.at>2015-02-15 23:52:28 +0100
committerthat <github@that.at>2015-02-15 23:52:28 +0100
commit10ec0175c8270f223b5fbcdcd1b8299d012eaa57 (patch)
tree58624094898f865db8bdce4d4bb7aff008b6fbbf
parentgui: support scrollable lists without headers (diff)
downloadandroid_bootable_recovery-10ec0175c8270f223b5fbcdcd1b8299d012eaa57.tar
android_bootable_recovery-10ec0175c8270f223b5fbcdcd1b8299d012eaa57.tar.gz
android_bootable_recovery-10ec0175c8270f223b5fbcdcd1b8299d012eaa57.tar.bz2
android_bootable_recovery-10ec0175c8270f223b5fbcdcd1b8299d012eaa57.tar.lz
android_bootable_recovery-10ec0175c8270f223b5fbcdcd1b8299d012eaa57.tar.xz
android_bootable_recovery-10ec0175c8270f223b5fbcdcd1b8299d012eaa57.tar.zst
android_bootable_recovery-10ec0175c8270f223b5fbcdcd1b8299d012eaa57.zip
-rw-r--r--gui/scrolllist.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp
index 05141b1cf..8d9ab42f2 100644
--- a/gui/scrolllist.cpp
+++ b/gui/scrolllist.cpp
@@ -27,9 +27,8 @@ extern "C" {
#include "objects.hpp"
#include "../data.hpp"
-const int SCROLLING_SPEED_DECREMENT = 6; // friction
-const int SCROLLING_FLOOR = 10; // minimum pixels for scrolling to start or stop
-const int SCROLLING_MULTIPLIER = 1; // initial speed of kinetic scrolling
+const float SCROLLING_SPEED_DECREMENT = 0.9; // friction
+const int SCROLLING_FLOOR = 2; // minimum pixels for scrolling to stop
const float SCROLLING_SPEED_LIMIT = 2.5; // maximum number of items to scroll per update
GUIScrollList::GUIScrollList(xml_node<>* node) : GUIObject(node)
@@ -367,6 +366,7 @@ int GUIScrollList::Update(void)
// Handle kinetic scrolling
int maxScrollDistance = actualItemHeight * SCROLLING_SPEED_LIMIT;
+ int oldScrollingSpeed = scrollingSpeed;
if (scrollingSpeed == 0) {
// Do nothing
return 0;
@@ -375,13 +375,17 @@ int GUIScrollList::Update(void)
y_offset += scrollingSpeed;
else
y_offset += maxScrollDistance;
- scrollingSpeed -= SCROLLING_SPEED_DECREMENT;
+ scrollingSpeed *= SCROLLING_SPEED_DECREMENT;
+ if (scrollingSpeed == oldScrollingSpeed)
+ --scrollingSpeed;
} else if (scrollingSpeed < 0) {
if (abs(scrollingSpeed) < maxScrollDistance)
y_offset += scrollingSpeed;
else
y_offset -= maxScrollDistance;
- scrollingSpeed += SCROLLING_SPEED_DECREMENT;
+ scrollingSpeed *= SCROLLING_SPEED_DECREMENT;
+ if (scrollingSpeed == oldScrollingSpeed)
+ ++scrollingSpeed;
}
if (abs(scrollingSpeed) < SCROLLING_FLOOR)
scrollingSpeed = 0;
@@ -506,9 +510,7 @@ int GUIScrollList::NotifyTouch(TOUCH_STATE state, int x, int y)
} else {
// Start kinetic scrolling
scrollingSpeed = lastY - last2Y;
- if (abs(scrollingSpeed) > SCROLLING_FLOOR)
- scrollingSpeed *= SCROLLING_MULTIPLIER;
- else
+ if (abs(scrollingSpeed) < touchDebounce)
scrollingSpeed = 0;
}
case TOUCH_REPEAT: