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/debug_menu.c | 13 ------------ apps/gui/bitmap/list-skinned.c | 3 +-- apps/gui/bitmap/list.c | 8 ++------ apps/gui/list.c | 45 +----------------------------------------- apps/gui/list.h | 5 ----- apps/menus/main_menu.c | 3 --- apps/plugin.c | 27 ++++++++++++++----------- apps/plugin.h | 33 +++++++++++++++++-------------- apps/plugins/lrcplayer.c | 1 - apps/plugins/superdom.c | 1 - 10 files changed, 38 insertions(+), 101 deletions(-) diff --git a/apps/debug_menu.c b/apps/debug_menu.c index 1abeac2622..b034f25df0 100644 --- a/apps/debug_menu.c +++ b/apps/debug_menu.c @@ -227,7 +227,6 @@ static bool dbg_os(void) simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:", MAXTHREADS IF_COP( + NUM_CORES ), &xoffset); - info.hide_selection = true; info.scroll_all = false; info.action_callback = dbg_threads_action_callback; info.get_name = threads_getname; @@ -341,7 +340,6 @@ static bool dbg_cpuinfo(void) info.get_name = get_cpuinfo; info.action_callback = cpuinfo_cb; info.timeout = HZ; - info.hide_selection = true; info.scroll_all = true; return simplelist_show_list(&info); } @@ -568,7 +566,6 @@ static bool dbg_partitions(void) struct simplelist_info info; simplelist_info_init(&info, "Partition Info", NUM_DRIVES * 4, NULL); info.selection_size = 2; - info.hide_selection = true; info.scroll_all = true; info.get_name = dbg_partitions_getname; return simplelist_show_list(&info); @@ -1722,7 +1719,6 @@ static bool dbg_ata_smart(void) struct simplelist_info info; simplelist_info_init(&info, "S.M.A.R.T. Data [CONTEXT to dump]", 1, NULL); info.action_callback = ata_smart_callback; - info.hide_selection = true; info.scroll_all = true; return simplelist_show_list(&info); } @@ -1776,7 +1772,6 @@ static bool dbg_disk_info(void) info.title = title; #endif info.action_callback = disk_callback; - info.hide_selection = true; info.scroll_all = true; return simplelist_show_list(&info); } @@ -1845,7 +1840,6 @@ static bool dbg_dircache_info(void) int syncbuild = 0; simplelist_info_init(&info, "Dircache Info", 8, &syncbuild); info.action_callback = dircache_callback; - info.hide_selection = true; info.scroll_all = true; return simplelist_show_list(&info); } @@ -1903,7 +1897,6 @@ static bool dbg_tagcache_info(void) struct simplelist_info info; simplelist_info_init(&info, "Database Info", 8, NULL); info.action_callback = database_callback; - info.hide_selection = true; info.scroll_all = true; /* Don't do nonblock here, must give enough processing time @@ -2176,7 +2169,6 @@ static bool dbg_fm_radio(void) radio_hardware_present() ? "yes" : "no"); info.action_callback = radio_hardware_present()?radio_callback : NULL; - info.hide_selection = true; return simplelist_show_list(&info); } #endif /* CONFIG_TUNER */ @@ -2448,7 +2440,6 @@ static bool dbg_talk(void) else simplelist_info_init(&list, "Voice Information:", 2, &data); list.scroll_all = true; - list.hide_selection = true; list.timeout = HZ; list.get_name = dbg_talk_get_name; @@ -2488,7 +2479,6 @@ static bool dbg_isp1583(void) isp1583.scroll_all = true; simplelist_info_init(&isp1583, "ISP1583", dbg_usb_num_items(), NULL); isp1583.timeout = HZ/100; - isp1583.hide_selection = true; isp1583.get_name = dbg_usb_item; isp1583.action_callback = isp1583_action_callback; return simplelist_show_list(&isp1583); @@ -2514,7 +2504,6 @@ static bool dbg_pic(void) pic.scroll_all = true; simplelist_info_init(&pic, "PIC", pic_dbg_num_items(), NULL); pic.timeout = HZ/100; - pic.hide_selection = true; pic.get_name = pic_dbg_item; pic.action_callback = pic_action_callback; return simplelist_show_list(&pic); @@ -2533,7 +2522,6 @@ static bool dbg_skin_engine(void) #endif simplelist_info_init(&info, "Skin engine usage", 0, NULL); simplelist_set_line_count(0); - info.hide_selection = true; FOR_NB_SCREENS(j) { #if NB_SCREENS > 1 simplelist_addline("%s display:", @@ -2612,7 +2600,6 @@ static bool dbg_boot_data(void) boot_data.payload[i+1], boot_data.payload[i+2], boot_data.payload[i+3]); } - info.hide_selection = true; return simplelist_show_list(&info); } #endif /* defined(HAVE_BOOTDATA) && !defined(SIMULATOR) */ 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; diff --git a/apps/menus/main_menu.c b/apps/menus/main_menu.c index 321f2cdec4..2814c44fe6 100644 --- a/apps/menus/main_menu.c +++ b/apps/menus/main_menu.c @@ -458,9 +458,6 @@ static int show_info(void) struct simplelist_info info; int count = INFO_COUNT + refresh_data(&data) - 1; simplelist_info_init(&info, str(LANG_ROCKBOX_INFO), count, (void*)&data); - info.hide_selection = !global_settings.talk_menu; - if (info.hide_selection) - info.scroll_all = true; info.get_name = info_getname; if(global_settings.talk_menu) info.get_talk = info_speak_item; diff --git a/apps/plugin.c b/apps/plugin.c index eb76eb7753..42965bc581 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -357,6 +357,7 @@ static const struct plugin_api rockbox_api = { action_get_touchscreen_press_in_vp, #endif action_userabort, + core_set_keyremap, /* button */ button_get, @@ -436,6 +437,8 @@ static const struct plugin_api rockbox_api = { tree_get_entry_at, set_current_file, set_dirfilter, + onplay_show_playlist_menu, + browse_id3, /* talking */ talk_id, @@ -519,6 +522,7 @@ static const struct plugin_api rockbox_api = { queue_wait, queue_send, queue_reply, + queue_remove_from_head, #ifdef RB_PROFILE profile_thread, @@ -688,7 +692,9 @@ static const struct plugin_api rockbox_api = { playlist_create, playlist_insert_track, playlist_insert_directory, + playlist_insert_playlist, playlist_shuffle, + warn_on_pl_erase, audio_play, audio_stop, audio_pause, @@ -731,6 +737,7 @@ static const struct plugin_api rockbox_api = { battery_level_safe, battery_time, battery_voltage, + battery_current, #if CONFIG_CHARGING charger_inserted, # if CONFIG_CHARGING >= CHARGING_MONITOR @@ -801,21 +808,19 @@ static const struct plugin_api rockbox_api = { plugin_release_audio_buffer, /* defined in plugin.c */ plugin_tsr, /* defined in plugin.c */ plugin_get_current_filename, - /* new stuff at the end, sort into place next time - the API gets incompatible */ - warn_on_pl_erase, - playlist_insert_playlist, - battery_current, - onplay_show_playlist_menu, - queue_remove_from_head, - core_set_keyremap, plugin_reserve_buffer, + + /* reboot and poweroff */ + sys_poweroff, + sys_reboot, + + /* pathfuncs */ #ifdef HAVE_MULTIVOLUME path_strip_volume, #endif - sys_poweroff, - sys_reboot, - browse_id3, + + /* new stuff at the end, sort into place next time + the API gets incompatible */ }; static int plugin_buffer_handle; diff --git a/apps/plugin.h b/apps/plugin.h index e35909f409..984555fdf2 100644 --- a/apps/plugin.h +++ b/apps/plugin.h @@ -157,12 +157,12 @@ int plugin_open(const char *plugin, const char *parameter); #define PLUGIN_MAGIC 0x526F634B /* RocK */ /* increase this every time the api struct changes */ -#define PLUGIN_API_VERSION 251 +#define PLUGIN_API_VERSION 252 /* update this to latest version if a change to the api struct breaks backwards compatibility (and please take the opportunity to sort in any new function which are "waiting" at the end of the function table) */ -#define PLUGIN_MIN_API_VERSION 245 +#define PLUGIN_MIN_API_VERSION 252 /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */ @@ -406,6 +406,7 @@ struct plugin_api { int (*action_get_touchscreen_press_in_vp)(short *x1, short *y1, struct viewport *vp); #endif bool (*action_userabort)(int timeout); + int (*core_set_keyremap)(struct button_mapping* core_keymap, int count); /* button */ long (*button_get)(bool block); @@ -492,6 +493,10 @@ struct plugin_api { void (*set_current_file)(const char* path); void (*set_dirfilter)(int l_dirfilter); + void (*onplay_show_playlist_menu)(const char* path, void (*playlist_insert_cb)); + bool (*browse_id3)(struct mp3entry *id3, + int playlist_display_index, int playlist_amount); + /* talking */ int (*talk_id)(int32_t id, bool enqueue); int (*talk_file)(const char *root, const char *dir, const char *file, @@ -588,6 +593,7 @@ struct plugin_api { intptr_t (*queue_send)(struct event_queue *q, long id, intptr_t data); void (*queue_reply)(struct event_queue *q, intptr_t retval); + void (*queue_remove_from_head)(struct event_queue *q, long id); #ifdef RB_PROFILE void (*profile_thread)(void); @@ -790,7 +796,10 @@ struct plugin_api { int (*playlist_insert_directory)(struct playlist_info* playlist, const char *dirname, int position, bool queue, bool recurse); + int (*playlist_insert_playlist)(struct playlist_info* playlist, + const char *filename, int position, bool queue); int (*playlist_shuffle)(int random_seed, int start_index); + bool (*warn_on_pl_erase)(void); void (*audio_play)(unsigned long elapsed, unsigned long offset); void (*audio_stop)(void); void (*audio_pause)(void); @@ -850,6 +859,7 @@ struct plugin_api { bool (*battery_level_safe)(void); int (*battery_time)(void); int (*battery_voltage)(void); + int (*battery_current)(void); #if CONFIG_CHARGING bool (*charger_inserted)(void); # if CONFIG_CHARGING >= CHARGING_MONITOR @@ -928,23 +938,16 @@ struct plugin_api { void (*plugin_release_audio_buffer)(void); void (*plugin_tsr)(bool (*exit_callback)(bool reenter)); char* (*plugin_get_current_filename)(void); - /* new stuff at the end, sort into place next time - the API gets incompatible */ - bool (*warn_on_pl_erase)(void); - int (*playlist_insert_playlist)(struct playlist_info* playlist, - const char *filename, int position, bool queue); - int (*battery_current)(void); - void (*onplay_show_playlist_menu)(const char* path, void (*playlist_insert_cb)); - void (*queue_remove_from_head)(struct event_queue *q, long id); - int (*core_set_keyremap)(struct button_mapping* core_keymap, int count); size_t (*plugin_reserve_buffer)(size_t buffer_size); + /* reboot and poweroff */ + void (*sys_poweroff)(void); + void (*sys_reboot)(void); + /* pathfuncs */ #ifdef HAVE_MULTIVOLUME int (*path_strip_volume)(const char *name, const char **nameptr, bool greedy); #endif - void (*sys_poweroff)(void); - void (*sys_reboot)(void); - bool (*browse_id3)(struct mp3entry *id3, - int playlist_display_index, int playlist_amount); + /* new stuff at the end, sort into place next time + the API gets incompatible */ }; /* plugin header */ diff --git a/apps/plugins/lrcplayer.c b/apps/plugins/lrcplayer.c index f42b96b5b3..6c26db7a33 100644 --- a/apps/plugins/lrcplayer.c +++ b/apps/plugins/lrcplayer.c @@ -2437,7 +2437,6 @@ static bool lrc_debug_menu(void) { struct simplelist_info info; rb->simplelist_info_init(&info, "Debug Menu", 6, NULL); - info.hide_selection = true; info.scroll_all = true; info.get_name = lrc_debug_data; return rb->simplelist_show_list(&info); diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c index 50027a30c6..6969f76165 100644 --- a/apps/plugins/superdom.c +++ b/apps/plugins/superdom.c @@ -1450,7 +1450,6 @@ static int show_inventory(void) { struct simplelist_info info; rb->simplelist_info_init(&info, "Inventory", 9, NULL); - info.hide_selection = true; info.get_name = inventory_data; if(rb->simplelist_show_list(&info)) { -- cgit v1.2.3