touchscreen: handle scrollbar properly when UI viewport is used

Change-Id: I3b55233f4d50f5b8ae38f9f337ebdee6f93ad44e
This commit is contained in:
Aidan MacDonald 2021-08-21 10:28:52 +01:00
parent a59a629514
commit 569b165cff
1 changed files with 4 additions and 7 deletions

View File

@ -359,8 +359,7 @@ static enum {
SCROLL_KINETIC, /* state after releasing swipe */ SCROLL_KINETIC, /* state after releasing swipe */
} scroll_mode; } scroll_mode;
static int scrollbar_scroll(struct gui_synclist * gui_list, static int scrollbar_scroll(struct gui_synclist * gui_list, int y)
int y)
{ {
const int screen = screens[SCREEN_MAIN].screen_type; const int screen = screens[SCREEN_MAIN].screen_type;
const int nb_lines = list_get_nb_lines(gui_list, screen); const int nb_lines = list_get_nb_lines(gui_list, screen);
@ -369,11 +368,9 @@ static int scrollbar_scroll(struct gui_synclist * gui_list,
{ {
/* scrollbar scrolling is still line based */ /* scrollbar scrolling is still line based */
y_offset = 0; y_offset = 0;
int scrollbar_size = nb_lines*gui_list->line_height[screen]; int scrollbar_size = nb_lines * gui_list->line_height[screen];
int actual_y = y - list_text[screen].y; int actual_y = y - list_text[screen].y;
int new_selection = (actual_y * gui_list->nb_items) / scrollbar_size;
int new_selection = (actual_y * gui_list->nb_items)
/ scrollbar_size;
int start_item = new_selection - nb_lines/2; int start_item = new_selection - nb_lines/2;
if(start_item < 0) if(start_item < 0)
@ -839,7 +836,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list)
hide_selection = true; hide_selection = true;
/* similarly to swipe scroll, using the scrollbar grabs /* similarly to swipe scroll, using the scrollbar grabs
* focus so the click location is irrelevant */ * focus so the click location is irrelevant */
scrollbar_scroll(list, adj_y); scrollbar_scroll(list, y);
if (action & BUTTON_REL) if (action & BUTTON_REL)
scroll_mode = SCROLL_NONE; scroll_mode = SCROLL_NONE;
break; break;