From cdd1f901313a15d13531aecf85b97bc668af4793 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Tue, 10 Aug 2021 23:21:41 +0100 Subject: touchscreen: Respect list item selection size Some lists have tall items that span more than one line of text, eg. the bookmark menu or ID3 tag menu. The touchscreen code didn't handle these menus correctly and touching on the lower part of a list item could select "between" two items, leading to incorrect rendering and behavior due to callers relying on the selected item being properly aligned to the selection size. Fix this by ensuring the touch code only generates properly aligned selections. Change-Id: I73945bb0947590517a005754bd447639e22812e2 --- apps/gui/bitmap/list.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'apps/gui/bitmap/list.c') diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index a82595fb37..2b5a99fb9f 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -547,6 +547,8 @@ static bool swipe_scroll(struct gui_synclist * gui_list, int difference) gui_list->start_item[screen] = new_start_item; /* keep selected item in sync */ gui_list->selected_item = new_start_item + selection_offset; + if(gui_list->selected_size > 1) + gui_list->selected_item -= (gui_list->selected_item % gui_list->selected_size); } return true; @@ -737,6 +739,8 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) if (list_start_item+line >= list->nb_items) return ACTION_NONE; list->selected_item = list_start_item+line; + if(list->selected_size > 1) + list->selected_item -= (list->selected_item % list->selected_size); gui_synclist_speak_item(list); } @@ -754,7 +758,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) if (click_loc & LIST) { /* held a single line for a while, bring up the context menu */ - gui_synclist_select_item(list, list_start_item + line); + gui_synclist_select_item(list, list->selected_item); /* don't sent context repeatedly */ action_wait_for_release(); initial_touch = true; @@ -766,7 +770,7 @@ unsigned gui_synclist_do_touchscreen(struct gui_synclist * list) initial_touch = true; if (click_loc & LIST) { /* release on list item enters it */ - gui_synclist_select_item(list, list_start_item + line); + gui_synclist_select_item(list, list->selected_item); return ACTION_STD_OK; } else if (click_loc & TITLE_TEXT) -- cgit v1.2.3