From 142941d950708dc7394a015cc2e57a2bb3db4cff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 7 Jul 2015 17:04:03 +0700 Subject: [PATCH] (XMB) Refresh horizontal menu --- menu/drivers/xmb.c | 36 +++++++++++++++++++++++++++++++++--- menu/menu_displaylist.c | 4 ++++ menu/menu_displaylist.h | 1 + 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 7c7745b480..e8a3cd2cc5 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -240,6 +240,12 @@ static const GLfloat rmb_tex_coord[] = { 1, 0, }; +static void xmb_context_destroy_horizontal_list(xmb_handle_t *xmb, + menu_handle_t *menu); +static void xmb_init_horizontal_list(menu_handle_t *menu, xmb_handle_t *xmb); +static void xmb_context_reset_horizontal_list(xmb_handle_t *xmb, + menu_handle_t *menu, const char *themepath); + static size_t xmb_list_get_selection(void *data) { menu_handle_t *menu = (menu_handle_t*)data; @@ -1032,6 +1038,24 @@ static void xmb_list_open_horizontal_list(xmb_handle_t *xmb, menu_handle_t *menu } } +static void xmb_refresh_horizontal_list(xmb_handle_t *xmb, + menu_handle_t *menu) +{ + settings_t *settings = config_get_ptr(); + + char mediapath[PATH_MAX_LENGTH] = {0}; + char themepath[PATH_MAX_LENGTH] = {0}; + fill_pathname_join(mediapath, settings->assets_directory, "xmb", sizeof(mediapath)); + fill_pathname_join(themepath, mediapath, XMB_THEME, sizeof(themepath)); + + if (xmb->horizontal_list) + free(xmb->horizontal_list); + xmb->horizontal_list = NULL; + xmb_context_destroy_horizontal_list(xmb, menu); + xmb_init_horizontal_list(menu, xmb); + xmb_context_reset_horizontal_list(xmb, menu, themepath); +} + static void xmb_list_open(xmb_handle_t *xmb) { int dir = 0; @@ -1050,6 +1074,12 @@ static void xmb_list_open(xmb_handle_t *xmb) else if (xmb->depth < xmb->old_depth) dir = -1; + /* TODO, call xmb_refresh_horizontal_list when a new scanning process is + started instead of using this condition. It causes a small lag when comming + back to the main menu from a submenu. */ + if (dir == -1 && xmb->depth == 1 && xmb->categories.selection_ptr == 0) + xmb_refresh_horizontal_list(xmb, menu); + xmb_list_open_horizontal_list(xmb, menu); xmb_list_open_old(xmb, xmb->selection_buf_old, @@ -1670,7 +1700,7 @@ static void xmb_init_horizontal_list(menu_handle_t *menu, xmb_handle_t *xmb) strlcpy(info.path, settings->playlist_directory, sizeof(info.path)); strlcpy(info.exts, "lpl", sizeof(info.exts)); - menu_displaylist_push_list(&info, DISPLAYLIST_DATABASE_PLAYLISTS); + menu_displaylist_push_list(&info, DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL); } static void xmb_font(menu_handle_t *menu) @@ -2021,9 +2051,9 @@ static void xmb_context_reset_horizontal_list(xmb_handle_t *xmb, TEXTURE_BACKEND_OPENGL, TEXTURE_FILTER_MIPMAP_LINEAR); texture_image_free(&ti); - - xmb_toggle_horizontal_list(xmb, menu); } + + xmb_toggle_horizontal_list(xmb, menu); } static void xmb_context_reset_textures(xmb_handle_t *xmb, const char *iconpath) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 822b1d45e9..93590c4f68 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2532,6 +2532,10 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type) need_push = true; } break; + case DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL: + menu_list_clear(info->list); + menu_displaylist_parse_generic(info, &need_sort); + break; } if (need_sort) diff --git a/menu/menu_displaylist.h b/menu/menu_displaylist.h index c066945458..eb0ef3a833 100644 --- a/menu/menu_displaylist.h +++ b/menu/menu_displaylist.h @@ -56,6 +56,7 @@ enum DISPLAYLIST_DATABASES, DISPLAYLIST_DATABASE_CURSORS, DISPLAYLIST_DATABASE_PLAYLISTS, + DISPLAYLIST_DATABASE_PLAYLISTS_HORIZONTAL, DISPLAYLIST_DATABASE_QUERY, DISPLAYLIST_DATABASE_ENTRY, DISPLAYLIST_AUDIO_FILTERS,