From b673ae2c46129d6994b61a351a1567c56f4aef82 Mon Sep 17 00:00:00 2001 From: Thomas Martitz Date: Sun, 31 Oct 2010 11:11:46 +0000 Subject: FS#11686 - Kinetic list scrolling for touchscreen This adds kinetic scrolling to to lists on touchscreen targets and RaaA, like all other OSes on touchscreens have. It's only enabled in the absolute point mode, so for non-touchscreen and in grid mode nothing changes. Kinetic scrolling means that the list keeps scrolling (but is decelerating) after you leave the touchscreen with the finger. Redraw interval and deceleration is hardcoded for now but could be made configurable if desired. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28408 a1c6a512-1295-4272-9138-f99709370657 --- apps/gui/list.c | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'apps/gui/list.c') diff --git a/apps/gui/list.c b/apps/gui/list.c index 70b04c4313..61738fd454 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -550,6 +550,7 @@ static void gui_synclist_scroll_left(struct gui_synclist * lists) } #endif /* HAVE_LCD_BITMAP */ + bool gui_synclist_do_button(struct gui_synclist * lists, int *actionptr, enum list_wrap wrap) { @@ -563,32 +564,38 @@ bool gui_synclist_do_button(struct gui_synclist * lists, #else static int next_item_modifier = 1; static int last_accel_tick = 0; - if (global_settings.list_accel_start_delay) - { - int start_delay = global_settings.list_accel_start_delay * (HZ/2); - int accel_wait = global_settings.list_accel_wait * HZ/2; - if (get_action_statuscode(NULL)&ACTION_REPEAT) + if (action != ACTION_TOUCHSCREEN) + { + if (global_settings.list_accel_start_delay) { - if (!last_accel_tick) - last_accel_tick = current_tick + start_delay; - else if (TIME_AFTER(current_tick, last_accel_tick + accel_wait)) + int start_delay = global_settings.list_accel_start_delay * (HZ/2); + int accel_wait = global_settings.list_accel_wait * HZ/2; + + if (get_action_statuscode(NULL)&ACTION_REPEAT) { - last_accel_tick = current_tick; - next_item_modifier++; + if (!last_accel_tick) + last_accel_tick = current_tick + start_delay; + else if (TIME_AFTER(current_tick, last_accel_tick + accel_wait)) + { + last_accel_tick = current_tick; + next_item_modifier++; + } + } + else if (last_accel_tick) + { + next_item_modifier = 1; + last_accel_tick = 0; } - } - else if (last_accel_tick) - { - next_item_modifier = 1; - last_accel_tick = 0; } } #endif - #if defined(HAVE_TOUCHSCREEN) if (action == ACTION_TOUCHSCREEN) action = *actionptr = gui_synclist_do_touchscreen(lists); + else if (action > ACTION_TOUCHSCREEN_MODE) + /* cancel kinetic if we got a normal button event */ + _gui_synclist_stop_kinetic_scrolling(); #endif switch (wrap) -- cgit v1.2.3