diff options
author | Aidan MacDonald <amachronic@protonmail.com> | 2021-08-10 23:21:41 +0100 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2021-08-10 23:33:00 +0100 |
commit | cdd1f901313a15d13531aecf85b97bc668af4793 (patch) | |
tree | 8bcbfe6179c7597a77195eaaa6ee73f83b24cb13 | |
parent | b103b075034d74550bc77e8af4ba6f2b4e8a65df (diff) |
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
-rw-r--r-- | apps/gui/bitmap/list.c | 8 |
1 files changed, 6 insertions, 2 deletions
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) |