From 9ce5b2a2eda5c7101898476adaa3533e0ba5db82 Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Mon, 19 Sep 2022 11:10:54 +0100 Subject: gui: Remove show/hide selection option in lists The implementation of the "show_selection_marker" option in lists isn't great. It's a cosmetic option used to hide the selection, but it causes the list to do funny things to the selected_item and doesn't play nice with voiced menus, since these rely on the selection to determine what item is spoken. There are only two user-facing lists that use the option, the "Rockbox Info" screen and a menu in the superdom plugin. The rest are debug screens, and cosmetics don't matter much there. Given how little used the option is, and its issues, removing it seems reasonable. Change-Id: I2c70b3e4c74ff3cc6dbac46366a371d271dd2d58 --- apps/gui/bitmap/list-skinned.c | 3 +-- apps/gui/bitmap/list.c | 8 ++------ apps/gui/list.c | 45 +----------------------------------------- apps/gui/list.h | 5 ----- 4 files changed, 4 insertions(+), 57 deletions(-) (limited to 'apps/gui') diff --git a/apps/gui/bitmap/list-skinned.c b/apps/gui/bitmap/list-skinned.c index a67ac8cb0a..bebff821f8 100644 --- a/apps/gui/bitmap/list-skinned.c +++ b/apps/gui/bitmap/list-skinned.c @@ -213,8 +213,7 @@ bool skinlist_draw(struct screen *display, struct gui_synclist *list) if (list_start_item+cur_line+1 > list->nb_items) break; current_drawing_line = list_start_item+cur_line; - is_selected = list->show_selection_marker && - list_start_item+cur_line == list->selected_item; + is_selected = list_start_item+cur_line == list->selected_item; for (viewport = SKINOFFSETTOPTR(get_skin_buffer(wps.data), listcfg[screen]->data->tree); viewport; diff --git a/apps/gui/bitmap/list.c b/apps/gui/bitmap/list.c index b2987e9853..ca58d713d0 100644 --- a/apps/gui/bitmap/list.c +++ b/apps/gui/bitmap/list.c @@ -196,10 +196,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) const int list_start_item = list->start_item[screen]; const bool scrollbar_in_left = (list->scrollbar == SCROLLBAR_LEFT); const bool scrollbar_in_right = (list->scrollbar == SCROLLBAR_RIGHT); - - const bool show_cursor = list->show_selection_marker && - (list->cursor_style == SYNCLIST_CURSOR_NOSTYLE); - + const bool show_cursor = (list->cursor_style == SYNCLIST_CURSOR_NOSTYLE); const bool have_icons = list->callback_get_item_icon && list->show_icons; struct viewport *parent = (list->parent[screen]); @@ -365,8 +362,7 @@ void list_draw(struct screen *display, struct gui_synclist *list) !hide_selection && #endif i >= list->selected_item - && i < list->selected_item + list->selected_size - && list->show_selection_marker) + && i < list->selected_item + list->selected_size) {/* The selected item must be displayed scrolling */ #ifdef HAVE_LCD_COLOR if (list->selection_color) diff --git a/apps/gui/list.c b/apps/gui/list.c index df5df22ca1..98e9fe0ada 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c @@ -191,7 +191,6 @@ void gui_synclist_init(struct gui_synclist * gui_list, gui_list->scheduled_talk_tick = gui_list->last_talked_tick = 0; gui_list->dirty_tick = current_tick; - gui_list->show_selection_marker = true; #ifdef HAVE_LCD_COLOR gui_list->title_color = -1; @@ -200,13 +199,6 @@ void gui_synclist_init(struct gui_synclist * gui_list, #endif } -/* this toggles the selection bar or cursor */ -void gui_synclist_hide_selection_marker(struct gui_synclist * lists, bool hide) -{ - lists->show_selection_marker = !hide; -} - - int gui_list_get_item_offset(struct gui_synclist * gui_list, int item_width, int text_pos, @@ -269,11 +261,7 @@ static void gui_list_put_selection_on_screen(struct gui_synclist * gui_list, const int scroll_limit_up = (nb_lines < gui_list->selected_size+2 ? 0:1); const int scroll_limit_down = (scroll_limit_up+gui_list->selected_size); - if (gui_list->show_selection_marker == false) - { - new_start_item = gui_list->selected_item; - } - else if (gui_list->selected_size >= nb_lines) + if (gui_list->selected_size >= nb_lines) { new_start_item = gui_list->selected_item; } @@ -420,31 +408,7 @@ static void gui_list_select_at_offset(struct gui_synclist * gui_list, 0 : gui_list->nb_items - gui_list->selected_size; edge_beep(gui_list, !gui_list->limit_scroll); } - else if (gui_list->show_selection_marker == false) - { - FOR_NB_SCREENS(i) - { - int nb_lines = list_get_nb_lines(gui_list, i); - if (offset > 0) - { - int screen_top = MAX(0, gui_list->nb_items - nb_lines); - gui_list->start_item[i] = MIN(screen_top, gui_list->start_item[i] + - gui_list->selected_size); - gui_list->selected_item = gui_list->start_item[i]; - } - else - { - gui_list->start_item[i] = MAX(0, gui_list->start_item[i] - - gui_list->selected_size); - gui_list->selected_item = gui_list->start_item[i] + nb_lines; - } -#ifdef HAVE_TOUCHSCREEN - gui_list->y_pos = gui_list->start_item[SCREEN_MAIN] * gui_list->line_height[SCREEN_MAIN]; -#endif - } - return; - } gui_synclist_select_item(gui_list, new_selection); } @@ -950,12 +914,6 @@ bool simplelist_show_list(struct simplelist_info *info) gui_synclist_set_sel_color(&lists, info->selection_color); #endif - if (info->hide_selection) - { - gui_synclist_hide_selection_marker(&lists, true); - wrap = LIST_WRAP_OFF; - } - if (info->action_callback) info->action_callback(ACTION_REDRAW, &lists); @@ -1039,7 +997,6 @@ void simplelist_info_init(struct simplelist_info *info, char* title, info->title = title; info->count = count; info->selection_size = 1; - info->hide_selection = false; info->scroll_all = false; info->hide_theme = false; info->speak_onshow = true; diff --git a/apps/gui/list.h b/apps/gui/list.h index 2df33b7541..388e3d2006 100644 --- a/apps/gui/list.h +++ b/apps/gui/list.h @@ -161,7 +161,6 @@ struct gui_synclist /* whether the text of the whole items of the list have to be * scrolled or only for the selected item */ bool scroll_all; - bool show_selection_marker; /* set to true by default */ int nb_items; int selected_item; @@ -235,8 +234,6 @@ extern void gui_synclist_del_item(struct gui_synclist * lists); extern void gui_synclist_limit_scroll(struct gui_synclist * lists, bool scroll); extern void gui_synclist_set_title(struct gui_synclist * lists, const char * title, enum themable_icons icon); -extern void gui_synclist_hide_selection_marker(struct gui_synclist *lists, - bool hide); extern bool gui_synclist_item_is_onscreen(struct gui_synclist *lists, enum screen_type screen, int item); @@ -304,7 +301,6 @@ struct simplelist_info { const char *title; /* title to show on the list */ int count; /* number of items in the list, each item is selection_size high */ int selection_size; /* list selection size, usually 1 */ - bool hide_selection; bool scroll_all; bool hide_theme; bool speak_onshow; /* list speaks first item or 'empty list' */ @@ -350,7 +346,6 @@ void simplelist_addline(const char *fmt, ...); /* setup the info struct. members not setup in this function need to be assigned manually members set in this function: info.selection_size = 1; - info.hide_selection = false; info.scroll_all = false; info.hide_theme = false; info.speak_onshow = true; -- cgit v1.2.3