summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Soffke <christian.soffke@gmail.com>2022-12-05 20:05:15 +0100
committerChristian Soffke <christian.soffke@gmail.com>2022-12-08 00:38:59 -0500
commit66a411a1ba6d3668b002760ce2d26bca42db894f (patch)
tree6af403e9a03c3785f805be1d2600a806ceb61bae
parenta9a284c1a09f960a307d5eb9bcb9f4e92a1e7747 (diff)
downloadrockbox-66a411a1ba6d3668b002760ce2d26bca42db894f.tar.gz
rockbox-66a411a1ba6d3668b002760ce2d26bca42db894f.zip
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
-rw-r--r--apps/main.c2
-rw-r--r--apps/menu.c6
-rw-r--r--apps/playlist_viewer.c2
-rw-r--r--apps/tree.c27
-rw-r--r--apps/tree.h3
5 files changed, 17 insertions, 23 deletions
diff --git a/apps/main.c b/apps/main.c
index f86d91e42e..8cf202243c 100644
--- a/apps/main.c
+++ b/apps/main.c
@@ -167,7 +167,7 @@ int main(void)
167 screens[i].update(); 167 screens[i].update();
168 } 168 }
169 list_init(); 169 list_init();
170 tree_gui_init(); 170 tree_init();
171 /* Keep the order of this 3 171 /* Keep the order of this 3
172 * Must be done before any code uses the multi-screen API */ 172 * Must be done before any code uses the multi-screen API */
173#ifdef HAVE_USBSTACK 173#ifdef HAVE_USBSTACK
diff --git a/apps/menu.c b/apps/menu.c
index eb3adcc037..48eea70454 100644
--- a/apps/menu.c
+++ b/apps/menu.c
@@ -466,6 +466,8 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
466 done = true; 466 done = true;
467 } 467 }
468 } 468 }
469 if (!done)
470 init_menu_lists(menu, &lists, lists.selected_item, false, vps);
469 redraw_lists = true; 471 redraw_lists = true;
470 } 472 }
471#endif 473#endif
@@ -670,7 +672,9 @@ int do_menu(const struct menu_item_ex *start_menu, int *start_selected,
670 case MT_SETTING_W_TEXT: 672 case MT_SETTING_W_TEXT:
671 { 673 {
672 do_setting_from_menu(temp, vps); 674 do_setting_from_menu(temp, vps);
673 send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */ 675 init_menu_lists(menu, &lists, selected, false, vps);
676 redraw_lists = true;
677
674 break; 678 break;
675 } 679 }
676 case MT_RETURN_ID: 680 case MT_RETURN_ID:
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 8f1c5d961d..4abd3ee1c5 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -1017,7 +1017,7 @@ enum playlist_viewer_result playlist_viewer_ex(const char* filename,
1017 { 1017 {
1018 quick_screen_quick(button); 1018 quick_screen_quick(button);
1019 update_playlist(true); 1019 update_playlist(true);
1020 update_lists(&playlist_lists); 1020 prepare_lists(&playlist_lists);
1021 } 1021 }
1022 break; 1022 break;
1023#endif 1023#endif
diff --git a/apps/tree.c b/apps/tree.c
index 1149c19104..fa745319a9 100644
--- a/apps/tree.c
+++ b/apps/tree.c
@@ -80,7 +80,7 @@
80static const struct filetype *filetypes; 80static const struct filetype *filetypes;
81static int filetypes_count; 81static int filetypes_count;
82 82
83struct gui_synclist tree_lists; 83static struct gui_synclist tree_lists;
84 84
85/* I put it here because other files doesn't use it yet, 85/* I put it here because other files doesn't use it yet,
86 * but should be elsewhere since it will be used mostly everywhere */ 86 * but should be elsewhere since it will be used mostly everywhere */
@@ -301,19 +301,10 @@ bool check_rockboxdir(void)
301} 301}
302 302
303/* do this really late in the init sequence */ 303/* do this really late in the init sequence */
304void tree_gui_init(void) 304void tree_init(void)
305{ 305{
306 check_rockboxdir(); 306 check_rockboxdir();
307
308 strcpy(tc.currdir, "/"); 307 strcpy(tc.currdir, "/");
309
310 gui_synclist_init(&tree_lists, &tree_get_filename, &tc, false, 1, NULL);
311 gui_synclist_set_voice_callback(&tree_lists, tree_voice_cb);
312 gui_synclist_set_icon_callback(&tree_lists,
313 global_settings.show_icons?&tree_get_fileicon:NULL);
314#ifdef HAVE_LCD_COLOR
315 gui_synclist_set_color_callback(&tree_lists, &tree_get_filecolor);
316#endif
317} 308}
318 309
319 310
@@ -419,6 +410,9 @@ static int update_dir(void)
419 splash(HZ, ID2P(LANG_SHOWDIR_BUFFER_FULL)); 410 splash(HZ, ID2P(LANG_SHOWDIR_BUFFER_FULL));
420 } 411 }
421 } 412 }
413
414 gui_synclist_init(&tree_lists, &tree_get_filename, &tc, false, 1, NULL);
415
422#ifdef HAVE_TAGCACHE 416#ifdef HAVE_TAGCACHE
423 if (id3db) 417 if (id3db)
424 { 418 {
@@ -472,6 +466,10 @@ static int update_dir(void)
472 gui_synclist_set_nb_items(&tree_lists, tc.filesindir); 466 gui_synclist_set_nb_items(&tree_lists, tc.filesindir);
473 gui_synclist_set_icon_callback(&tree_lists, 467 gui_synclist_set_icon_callback(&tree_lists,
474 global_settings.show_icons?tree_get_fileicon:NULL); 468 global_settings.show_icons?tree_get_fileicon:NULL);
469 gui_synclist_set_voice_callback(&tree_lists, tree_voice_cb);
470#ifdef HAVE_LCD_COLOR
471 gui_synclist_set_color_callback(&tree_lists, &tree_get_filecolor);
472#endif
475 if( tc.selected_item >= tc.filesindir) 473 if( tc.selected_item >= tc.filesindir)
476 tc.selected_item=tc.filesindir-1; 474 tc.selected_item=tc.filesindir-1;
477 475
@@ -657,8 +655,6 @@ static int dirbrowse(void)
657 return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */ 655 return GO_TO_PREVIOUS; /* No files found for rockbox_browse() */
658 } 656 }
659 657
660 send_event(GUI_EVENT_ACTIONUPDATE, (void*)1); /* force a redraw */
661 gui_synclist_draw(&tree_lists);
662 while(1) { 658 while(1) {
663 bool restore = false; 659 bool restore = false;
664 if (tc.dirlevel < 0) 660 if (tc.dirlevel < 0)
@@ -706,9 +702,6 @@ static int dirbrowse(void)
706#endif 702#endif
707 case GO_TO_ROOT: exit_func = true; break; 703 case GO_TO_ROOT: exit_func = true; break;
708 default: 704 default:
709 if (*tc.dirfilter == SHOW_CFG) /* theme changed */
710 gui_synclist_init_display_settings(&tree_lists);
711
712 break; 705 break;
713 } 706 }
714 restore = true; 707 restore = true;
@@ -1000,8 +993,6 @@ int rockbox_browse(struct browse_context *browse)
1000 tc.dirfilter = &dirfilter; 993 tc.dirfilter = &dirfilter;
1001 tc.sort_dir = global_settings.sort_dir; 994 tc.sort_dir = global_settings.sort_dir;
1002 995
1003 gui_synclist_init_display_settings(&tree_lists); /* grab updated settings */
1004
1005 reload_dir = true; 996 reload_dir = true;
1006 if (*tc.dirfilter >= NUM_FILTER_MODES) 997 if (*tc.dirfilter >= NUM_FILTER_MODES)
1007 { 998 {
diff --git a/apps/tree.h b/apps/tree.h
index 56fdb2e0bb..bb9ff87163 100644
--- a/apps/tree.h
+++ b/apps/tree.h
@@ -102,7 +102,7 @@ struct entry* tree_get_entries(struct tree_context *t);
102struct entry* tree_get_entry_at(struct tree_context *t, int index); 102struct entry* tree_get_entry_at(struct tree_context *t, int index);
103 103
104void tree_mem_init(void) INIT_ATTR; 104void tree_mem_init(void) INIT_ATTR;
105void tree_gui_init(void) INIT_ATTR; 105void tree_init(void) INIT_ATTR;
106char* get_current_file(char* buffer, size_t buffer_len); 106char* get_current_file(char* buffer, size_t buffer_len);
107void set_dirfilter(int l_dirfilter); 107void set_dirfilter(int l_dirfilter);
108void set_current_file(const char *path); 108void set_current_file(const char *path);
@@ -133,5 +133,4 @@ void tree_restore(void);
133bool bookmark_play(char* resume_file, int index, unsigned long elapsed, 133bool bookmark_play(char* resume_file, int index, unsigned long elapsed,
134 unsigned long offset, int seed, char *filename); 134 unsigned long offset, int seed, char *filename);
135 135
136extern struct gui_synclist tree_lists;
137#endif 136#endif