Tree / Playlist Viewer / Menu: Fix redraw issues

1) Tree_lists was only initialized when booting the player.

In cases where a skin used custom UI viewports of
different sizes, when switching between screens, such as
between root menu, QuickScreen, and tree browser, this
caused list titles to appear with a significant delay,
unless a GUI_EVENT_ACTIONUPDATE was sent.

Tree_lists is now initialized when entering dirbrowse
or when restoring/reloading the list.

This eliminates multiple redundant UI refreshes when
entering the tree browser, due to gui_synclist_draw not
being called twice anymore and by being able to omit
GUI_EVENT_ACTIONUPDATE.

Separate calls to gui_synclist_init_display_settings
have become unnecessary since it is already called
by gui_synclist_init.

2) The synclist is also re-initialized when returning
from the QuickScreen in the Playlist Viewer or
regular menus, or when returning from Settings
menus

Change-Id: I2884249eda55f782e97abad9dc19b3d9d1267fc9
This commit is contained in:
Christian Soffke 2022-12-05 20:05:15 +01:00
parent a9a284c1a0
commit 66a411a1ba
5 changed files with 17 additions and 23 deletions

View file

@ -167,7 +167,7 @@ int main(void)
screens[i].update();
}
list_init();
tree_gui_init();
tree_init();
/* Keep the order of this 3
* Must be done before any code uses the multi-screen API */
#ifdef HAVE_USBSTACK

View file

@ -466,6 +466,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
done = true;
}
}
if (!done)
init_menu_lists(menu, &lists, lists.selected_item, false, vps);
redraw_lists = true;
}
#endif
@ -670,7 +672,9 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
case MT_SETTING_W_TEXT:
{
do_setting_from_menu(temp, vps);
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
init_menu_lists(menu, &lists, selected, false, vps);
redraw_lists = true;
break;
}
case MT_RETURN_ID:

View file

@ -1017,7 +1017,7 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
{
quick_screen_quick(button);
update_playlist(true);
update_lists(&playlist_lists);
prepare_lists(&playlist_lists);
}
break;
#endif

View file

@ -80,7 +80,7 @@
static const struct filetype *filetypes;
static int filetypes_count;
struct gui_synclist tree_lists;
static struct gui_synclist tree_lists;
/* I put it here because other files doesn't use it yet,
* but should be elsewhere since it will be used mostly everywhere */
@ -301,19 +301,10 @@ bool check_rockboxdir(void)
}
/* do this really late in the init sequence */
void tree_gui_init(void)
void tree_init(void)
{
check_rockboxdir();
strcpy(tc.currdir, "/");
gui_synclist_init(&tree_lists, &tree_get_filename, &tc, false, 1, NULL);
gui_synclist_set_voice_callback(&tree_lists, tree_voice_cb);
gui_synclist_set_icon_callback(&tree_lists,
global_settings.show_icons?&tree_get_fileicon:NULL);
#ifdef HAVE_LCD_COLOR
gui_synclist_set_color_callback(&tree_lists, &tree_get_filecolor);
#endif
}
@ -419,6 +410,9 @@ static int update_dir(void)
splash(HZ, ID2P(LANG_SHOWDIR_BUFFER_FULL));
}
}
gui_synclist_init(&tree_lists, &tree_get_filename, &tc, false, 1, NULL);
#ifdef HAVE_TAGCACHE
if (id3db)
{
@ -472,6 +466,10 @@ static int update_dir(void)
gui_synclist_set_nb_items(&tree_lists, tc.filesindir);
gui_synclist_set_icon_callback(&tree_lists,
global_settings.show_icons?tree_get_fileicon:NULL);
gui_synclist_set_voice_callback(&tree_lists, tree_voice_cb);
#ifdef HAVE_LCD_COLOR
gui_synclist_set_color_callback(&tree_lists, &tree_get_filecolor);
#endif
if( tc.selected_item >= tc.filesindir)
tc.selected_item=tc.filesindir-1;
@ -657,8 +655,6 @@ static int dirbrowse(void)
return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */
}
send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
gui_synclist_draw(&tree_lists);
while(1) {
bool restore = false;
if (tc.dirlevel < 0)
@ -706,9 +702,6 @@ static int dirbrowse(void)
#endif
case GO_TO_ROOT: exit_func = true; break;
default:
if (*tc.dirfilter == SHOW_CFG) /* theme changed */
gui_synclist_init_display_settings(&tree_lists);
break;
}
restore = true;
@ -1000,8 +993,6 @@ int rockbox_browse(struct browse_context *browse)
tc.dirfilter = &dirfilter;
tc.sort_dir = global_settings.sort_dir;
gui_synclist_init_display_settings(&tree_lists); /* grab updated settings */
reload_dir = true;
if (*tc.dirfilter >= NUM_FILTER_MODES)
{

View file

@ -102,7 +102,7 @@ struct entry* tree_get_entries(struct tree_context *t);
struct entry* tree_get_entry_at(struct tree_context *t, int index);
void tree_mem_init(void) INIT_ATTR;
void tree_gui_init(void) INIT_ATTR;
void tree_init(void) INIT_ATTR;
char* get_current_file(char* buffer, size_t buffer_len);
void set_dirfilter(int l_dirfilter);
void set_current_file(const char *path);
@ -133,5 +133,4 @@ void tree_restore(void);
bool bookmark_play(char* resume_file, int index, unsigned long elapsed,
unsigned long offset, int seed, char *filename);
extern struct gui_synclist tree_lists;
#endif