summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2021-08-21 10:28:52 +0100
committerAidan MacDonald <amachronic@protonmail.com>2021-08-22 14:45:26 +0000
commit569b165cff2330c5c7dfd6b1aa175008729b4414 (patch)
tree8f18b4cf618fc7d40323d2998951b3f2d1299770
parenta59a629514c5084e23848157671a336202955b53 (diff)
downloadrockbox-569b165cff2330c5c7dfd6b1aa175008729b4414.tar.gz
rockbox-569b165cff2330c5c7dfd6b1aa175008729b4414.zip
touchscreen: handle scrollbar properly when UI viewport is used
Change-Id: I3b55233f4d50f5b8ae38f9f337ebdee6f93ad44e
-rw-r--r--apps/gui/bitmap/list.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c
index 2b5a99fb9f..db8e0504d7 100644
--- a/apps/gui/bitmap/list.c
+++ b/apps/gui/bitmap/list.c
@@ -359,8 +359,7 @@ static enum {
359 SCROLL_KINETIC, /* state after releasing swipe */ 359 SCROLL_KINETIC, /* state after releasing swipe */
360} scroll_mode; 360} scroll_mode;
361 361
362static int scrollbar_scroll(struct gui_synclist * gui_list, 362static int scrollbar_scroll(struct gui_synclist * gui_list, int y)
363 int y)
364{ 363{
365 const int screen = screens[SCREEN_MAIN].screen_type; 364 const int screen = screens[SCREEN_MAIN].screen_type;
366 const int nb_lines = list_get_nb_lines(gui_list, screen); 365 const int nb_lines = list_get_nb_lines(gui_list, screen);
@@ -369,11 +368,9 @@ static int scrollbar_scroll(struct gui_synclist * gui_list,
369 { 368 {
370 /* scrollbar scrolling is still line based */ 369 /* scrollbar scrolling is still line based */
371 y_offset = 0; 370 y_offset = 0;
372 int scrollbar_size = nb_lines*gui_list->line_height[screen]; 371 int scrollbar_size = nb_lines * gui_list->line_height[screen];
373 int actual_y = y - list_text[screen].y; 372 int actual_y = y - list_text[screen].y;
374 373 int new_selection = (actual_y * gui_list->nb_items) / scrollbar_size;
375 int new_selection = (actual_y * gui_list->nb_items)
376 / scrollbar_size;
377 374
378 int start_item = new_selection - nb_lines/2; 375 int start_item = new_selection - nb_lines/2;
379 if(start_item < 0) 376 if(start_item < 0)
@@ -839,7 +836,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
839 hide_selection = true; 836 hide_selection = true;
840 /* similarly to swipe scroll, using the scrollbar grabs 837 /* similarly to swipe scroll, using the scrollbar grabs
841 * focus so the click location is irrelevant */ 838 * focus so the click location is irrelevant */
842 scrollbar_scroll(list, adj_y); 839 scrollbar_scroll(list, y);
843 if (action & BUTTON_REL) 840 if (action & BUTTON_REL)
844 scroll_mode = SCROLL_NONE; 841 scroll_mode = SCROLL_NONE;
845 break; 842 break;