summaryrefslogtreecommitdiff
path: root/apps/gui/bitmap/list.c
diff options
context:
space:
mode:
authorThomas Martitz <kugel@rockbox.org>2010-11-10 15:25:15 +0000
committerThomas Martitz <kugel@rockbox.org>2010-11-10 15:25:15 +0000
commit33af0dec28cf31be0ce7195b90546861efcce76f (patch)
treef106c9118c9191bff00e1468c98540787081c0e8 /apps/gui/bitmap/list.c
parente134021e1b05f797cffd28c6b4ee72a963ff3812 (diff)
downloadrockbox-33af0dec28cf31be0ce7195b90546861efcce76f.tar.gz
rockbox-33af0dec28cf31be0ce7195b90546861efcce76f.zip
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
Diffstat (limited to 'apps/gui/bitmap/list.c')
-rw-r--r--apps/gui/bitmap/list.c12
1 files changed, 11 insertions, 1 deletions
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)
486 * otherwise it returns true even if it didn't actually scroll, 486 * otherwise it returns true even if it didn't actually scroll,
487 * but scrolling mode shouldn't be changed 487 * but scrolling mode shouldn't be changed
488 **/ 488 **/
489
490
491static int scroll_begin_threshold;
492static int threshold_accumulation;
489static bool swipe_scroll(struct gui_synclist * gui_list, int line_height, int difference) 493static bool swipe_scroll(struct gui_synclist * gui_list, int line_height, int difference)
490{ 494{
491 /* fixme */ 495 /* fixme */
492 const enum screen_type screen = screens[SCREEN_MAIN].screen_type; 496 const enum screen_type screen = screens[SCREEN_MAIN].screen_type;
493 const int nb_lines = viewport_get_nb_lines(&list_text[screen]); 497 const int nb_lines = viewport_get_nb_lines(&list_text[screen]);
494 498
499 if (UNLIKELY(scroll_begin_threshold == 0))
500 scroll_begin_threshold = touchscreen_get_scroll_threshold();
501
495 /* make selecting items easier */ 502 /* make selecting items easier */
496 if (abs(difference) < SCROLL_BEGIN_THRESHOLD && scroll_mode == SCROLL_NONE) 503 threshold_accumulation += abs(difference);
504 if (threshold_accumulation < scroll_begin_threshold && scroll_mode == SCROLL_NONE)
497 return false; 505 return false;
498 506
507 threshold_accumulation = 0;
508
499 /* does the list even scroll? if no, return but still show 509 /* does the list even scroll? if no, return but still show
500 * the caller that we would scroll */ 510 * the caller that we would scroll */
501 if (nb_lines >= gui_list->nb_items) 511 if (nb_lines >= gui_list->nb_items)