Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

Reduce list title glitches when switching between menus

Each time viewportmanager_theme_enable (or _undo) is called,
the SBS title is reset, even if the theme remains enabled.
Thus switching from one menu to another, if do_menu is called
again, briefly results in an empty title before the correct
one is displayed. Even unchanged titles will unnecessarily
flash for a moment. Other theme elements that are drawn using
conditions based on the title, may also appear glitchy.

This patch adds a way to make the status bar title persist by
copying it to a static buffer. Persistent titles are not reset
by toggle_theme (although scrolling will be stopped in
viewportmanager_theme_undo), so that the theme can immediately
display the appropriate title in do_menu, simplelist_show_list,
the yesno screen, or plugins that want to keep the theme enabled.

Change-Id: I1ec8f233b730321793eb7d3cad51496ee1b35440

authored by

Christian Soffke and committed by
Solomon Peachy
18dfd8f6 399230e9

+88 -29
+8 -1
apps/gui/list.c
··· 882 882 struct gui_synclist lists; 883 883 int action, old_line_count = simplelist_line_count; 884 884 list_get_name *getname; 885 - int line_count, ret = false; 885 + int line_count; 886 + bool ret = false; 886 887 887 888 if (info->get_name) 888 889 { ··· 896 897 } 897 898 898 899 FOR_NB_SCREENS(i) 900 + { 901 + sb_set_persistent_title(info->title, info->title_icon, i); 899 902 viewportmanager_theme_enable(i, !info->hide_theme, NULL); 903 + } 900 904 901 905 gui_synclist_init(&lists, getname, info->callback_data, 902 906 info->scroll_all, info->selection_size, NULL); ··· 985 989 #endif 986 990 987 991 FOR_NB_SCREENS(i) 992 + { 993 + sb_set_persistent_title(info->title, info->title_icon, i); 988 994 viewportmanager_theme_undo(i, false); 995 + } 989 996 return ret; 990 997 } 991 998
+20
apps/gui/statusbar-skinned.c
··· 39 39 #include "icon.h" 40 40 #include "icons.h" 41 41 #include "option_select.h" 42 + #include "string-extra.h" 42 43 #ifdef HAVE_TOUCHSCREEN 43 44 #include "sound.h" 44 45 #include "misc.h" ··· 49 50 50 51 static bool sbs_has_title[NB_SCREENS]; 51 52 static const char* sbs_title[NB_SCREENS]; 53 + static char sbs_persistent_title[NB_SCREENS][80]; 52 54 static enum themable_icons sbs_icon[NB_SCREENS]; 53 55 static bool sbs_loaded[NB_SCREENS] = { false }; 54 56 ··· 62 64 return sbs_has_title[screen]; 63 65 } 64 66 67 + bool sb_set_persistent_title(const char* title, enum themable_icons icon, enum screen_type screen) 68 + { 69 + if (!title) 70 + return sb_set_title_text(title, icon, screen); 71 + 72 + strlcpy(sbs_persistent_title[screen], title, sizeof(*sbs_persistent_title)); 73 + return sb_set_title_text((const char *) sbs_persistent_title[screen], icon, screen); 74 + } 75 + 65 76 void sb_skin_has_title(enum screen_type screen) 66 77 { 67 78 sbs_has_title[screen] = true; ··· 71 82 { 72 83 return sbs_has_title[screen] ? sbs_title[screen] : NULL; 73 84 } 85 + 86 + const char* sb_get_persistent_title(enum screen_type screen) 87 + { 88 + return (sbs_has_title[screen] && 89 + sbs_title[screen] == sbs_persistent_title[screen]) ? 90 + sbs_title[screen] : NULL; 91 + 92 + } 93 + 74 94 enum themable_icons sb_get_icon(enum screen_type screen) 75 95 { 76 96 return sbs_has_title[screen] ? sbs_icon[screen] : Icon_NOICON + 2;
+3
apps/gui/statusbar-skinned.h
··· 39 39 40 40 void sb_skin_set_update_delay(int delay); 41 41 bool sb_set_title_text(const char* title, enum themable_icons icon, enum screen_type screen); 42 + bool sb_set_persistent_title(const char* title, enum themable_icons icon, 43 + enum screen_type screen); 42 44 void sb_skin_has_title(enum screen_type screen); 43 45 const char* sb_get_title(enum screen_type screen); 46 + const char* sb_get_persistent_title(enum screen_type screen); 44 47 enum themable_icons sb_get_icon(enum screen_type screen); 45 48 46 49 #ifdef HAVE_TOUCHSCREEN
+4 -1
apps/gui/viewport.c
··· 111 111 FOR_NB_SCREENS(i) 112 112 { 113 113 enable_event = enable_event || is_theme_enabled(i); 114 - sb_set_title_text(NULL, Icon_NOICON, i); 114 + if (!sb_get_persistent_title(i)) 115 + sb_set_title_text(NULL, Icon_NOICON, i); 115 116 } 116 117 toggle_events(enable_event); 117 118 ··· 195 196 panicf("Stack underflow... viewportmanager"); 196 197 197 198 toggle_theme(screen, force_redraw); 199 + if (sb_get_persistent_title(screen)) 200 + screens[screen].scroll_stop(); 198 201 } 199 202 200 203
+2 -2
apps/gui/yesno.c
··· 243 243 yn[i].main_message=main_message; 244 244 yn[i].display=&screens[i]; 245 245 screens[i].scroll_stop(); 246 + sb_set_persistent_title(title, Icon_NOICON, i); 246 247 viewportmanager_theme_enable(i, true, &(yn[i].vp)); 247 - if (sb_set_title_text(title, Icon_NOICON, i)) 248 - send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); 249 248 250 249 yn[i].vp_lines = viewport_get_nb_lines(&(yn[i].vp)); 251 250 } ··· 355 354 FOR_NB_SCREENS(i) 356 355 { 357 356 screens[i].scroll_stop_viewport(&(yn[i].vp)); 357 + sb_set_persistent_title(title, Icon_NOICON, i); 358 358 viewportmanager_theme_undo(i, true); 359 359 } 360 360
+41 -23
apps/menu.c
··· 53 53 #include "viewport.h" 54 54 #include "quickscreen.h" 55 55 #include "shortcuts.h" 56 + #include "statusbar-skinned.h" 56 57 57 58 #include "icons.h" 58 59 ··· 66 67 static int current_subitems[MAX_MENU_SUBITEMS]; 67 68 static int current_subitems_count = 0; 68 69 static int talk_menu_item(int selected_item, void *data); 70 + static char *title_buf; 71 + static size_t title_buf_sz; 69 72 70 73 struct menu_data_t 71 74 { ··· 197 200 return menu_icon; 198 201 } 199 202 203 + static char* init_title(const struct menu_item_ex *menu, int *icon) 204 + { 205 + char *title; 206 + 207 + if (menu->flags&MENU_HAS_DESC) 208 + { 209 + *icon = menu->callback_and_desc->icon_id; 210 + title = P2STR(menu->callback_and_desc->desc); 211 + } 212 + else if (menu->flags&MENU_DYNAMIC_DESC) 213 + { 214 + *icon = menu->menu_get_name_and_icon->icon_id; 215 + title = menu->menu_get_name_and_icon-> 216 + list_get_name(-1, menu->menu_get_name_and_icon-> 217 + list_get_name_data, title_buf, title_buf_sz); 218 + } 219 + else 220 + { 221 + *icon = Icon_NOICON; 222 + title = ""; 223 + } 224 + 225 + if (*icon == Icon_NOICON) 226 + *icon = Icon_Submenu_Entered; 227 + 228 + return title; 229 + } 230 + 200 231 static int init_menu_lists(const struct menu_item_ex *menu, 201 232 struct gui_synclist *lists, int selected, bool callback, 202 233 struct viewport parent[NB_SCREENS]) ··· 236 267 current_submenus_menu = (struct menu_item_ex *)menu; 237 268 238 269 gui_synclist_init(lists,get_menu_item_name,(void*)menu,false,1, parent); 239 - 240 - if (menu->flags&MENU_HAS_DESC) 241 - { 242 - icon = menu->callback_and_desc->icon_id; 243 - title = P2STR(menu->callback_and_desc->desc); 244 - } 245 - else if (menu->flags&MENU_DYNAMIC_DESC) 246 - { 247 - char buffer[80]; 248 - icon = menu->menu_get_name_and_icon->icon_id; 249 - title = menu->menu_get_name_and_icon-> 250 - list_get_name(-1, menu->menu_get_name_and_icon-> 251 - list_get_name_data, buffer, sizeof(buffer)); 252 - } 253 - else 254 - { 255 - icon = Icon_NOICON; 256 - title = ""; 257 - } 258 - 259 - if (icon == Icon_NOICON) 260 - icon = Icon_Submenu_Entered; 270 + title = init_title(menu, &icon); 261 271 gui_synclist_set_title(lists, title, icon); 262 272 gui_synclist_set_icon_callback(lists, global_settings.show_icons?menu_get_icon:NULL); 263 273 if(global_settings.talk_menu) ··· 382 392 int ret = 0; 383 393 int action; 384 394 int start_action; 395 + int icon; 396 + char buf[80], *title; 385 397 struct gui_synclist lists; 386 398 const struct menu_item_ex *temp = NULL; 387 399 const struct menu_item_ex *menu = start_menu; ··· 398 410 touchscreen_set_mode(global_settings.touch_mode); 399 411 #endif 400 412 413 + title_buf = buf; 414 + title_buf_sz = sizeof buf; 415 + title = init_title(menu, &icon); 401 416 FOR_NB_SCREENS(i) 417 + { 418 + sb_set_persistent_title(title, icon, i); 402 419 viewportmanager_theme_enable(i, !hide_theme, NULL); 403 - 420 + } 404 421 struct menu_data_t mstack[MAX_MENUS]; /* menu, selected */ 405 422 int stack_top = 0; 406 423 ··· 785 802 786 803 FOR_NB_SCREENS(i) 787 804 { 805 + sb_set_persistent_title(lists.title, lists.title_icon, i); 788 806 viewportmanager_theme_undo(i, false); 789 807 skinlist_set_cfg(i, NULL); /* Bugfix dangling reference in skin_draw() */ 790 808 }
+1
apps/plugin.c
··· 874 874 875 875 /* new stuff at the end, sort into place next time 876 876 the API gets incompatible */ 877 + sb_set_persistent_title, 877 878 }; 878 879 879 880 static int plugin_buffer_handle;
+2
apps/plugin.h
··· 1026 1026 1027 1027 /* new stuff at the end, sort into place next time 1028 1028 the API gets incompatible */ 1029 + bool (*sb_set_persistent_title)(const char* title, enum themable_icons icon, 1030 + enum screen_type screen); 1029 1031 }; 1030 1032 1031 1033 /* plugin header */
+3 -2
apps/plugins/playing_time.c
··· 560 560 return status; 561 561 } 562 562 563 - /* Only relevant if launched using hotkey from the 564 - WPS. Otherwise theme should be enabled already. */ 565 563 FOR_NB_SCREENS(i) 564 + { 565 + rb->sb_set_persistent_title(rb->str(LANG_PLAYING_TIME), Icon_NOICON, i); 566 566 rb->viewportmanager_theme_enable(i, true, NULL); 567 + } 567 568 568 569 if (playing_time()) 569 570 status = PLUGIN_USB_CONNECTED;
+4
apps/plugins/text_viewer/tv_display.c
··· 300 300 bool show_statusbar = preferences->statusbar; 301 301 302 302 if (is_initialized_vp) 303 + { 304 + rb->sb_set_persistent_title(tv_get_title_text(), Icon_NOICON, SCREEN_MAIN); 303 305 rb->viewportmanager_theme_undo(SCREEN_MAIN, false); 306 + } 304 307 else 305 308 is_initialized_vp = true; 306 309 310 + rb->sb_set_persistent_title(tv_get_title_text(), Icon_NOICON, SCREEN_MAIN); 307 311 rb->viewportmanager_theme_enable(SCREEN_MAIN, show_statusbar, &vp_info); 308 312 vp_info.flags &= ~VP_FLAG_ALIGNMENT_MASK; 309 313 display->set_viewport(&vp_info);