From 33af0dec28cf31be0ce7195b90546861efcce76f Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Wed, 10 Nov 2010 15:25:15 +0000 Subject: Touchscreen: Improved scroll threshold Remove the hardcoded (and way too small) scroll threshold (the distance moved in pixels before we think the users wants to scroll) and replace it with something based on the actual DPI of the screen. On Android we call the API for that, on other touchscreens we reimplemented Android's formula (as of 2.2) and calculate it. Flyspray: 11727 git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28548 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/bitmap/list.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'apps/gui/bitmap/list.c') diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index 26e15e7978..268209e1c1 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -486,16 +486,26 @@ void _gui_synclist_stop_kinetic_scrolling(void) * otherwise it returns true even if it didn't actually scroll, * but scrolling mode shouldn't be changed **/ + + +static int scroll_begin_threshold; +static int threshold_accumulation; static bool swipe_scroll(struct gui_synclist * gui_list, int line_height, int difference) { /* fixme */ const enum screen_type screen = screens[SCREEN_MAIN].screen_type; const int nb_lines = viewport_get_nb_lines(&list_text[screen]); + if (UNLIKELY(scroll_begin_threshold == 0)) + scroll_begin_threshold = touchscreen_get_scroll_threshold(); + /* make selecting items easier */ - if (abs(difference) < SCROLL_BEGIN_THRESHOLD && scroll_mode == SCROLL_NONE) + threshold_accumulation += abs(difference); + if (threshold_accumulation < scroll_begin_threshold && scroll_mode == SCROLL_NONE) return false; + threshold_accumulation = 0; + /* does the list even scroll? if no, return but still show * the caller that we would scroll */ if (nb_lines >= gui_list->nb_items) -- cgit v1.2.3