From 48e67d5546a1f2855d708832263ec8eb6854aa00 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 11 Feb 2016 00:59:55 +0100 Subject: [PATCH] Create RARCH_MENU_CT_LIST_GET_SELECTION --- menu/cbs/menu_cbs_left.c | 5 ++++- menu/cbs/menu_cbs_right.c | 5 ++++- menu/menu_displaylist.c | 9 +++++++-- menu/menu_driver.c | 19 ++++++++++++------- menu/menu_driver.h | 5 ++--- 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 9bafc1a5e2..d8d4421c11 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -128,6 +128,7 @@ static int action_left_scroll(unsigned type, const char *label, static int action_left_mainmenu(unsigned type, const char *label, bool wraparound) { + menu_ctx_list_t list_info; size_t selection = 0; menu_file_list_cbs_t *cbs = NULL; unsigned push_list = 0; @@ -141,10 +142,12 @@ static int action_left_mainmenu(unsigned type, const char *label, if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); + if (list_size == 1) { menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); - if (menu_driver_list_get_selection() != 0 + if ((list_info.selection != 0) || settings->menu.navigation.wraparound.enable) push_list = 1; } diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 54e041e8c7..80a8f67fec 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -148,6 +148,7 @@ static int action_right_scroll(unsigned type, const char *label, static int action_right_mainmenu(unsigned type, const char *label, bool wraparound) { + menu_ctx_list_t list_info; size_t selection = 0; menu_file_list_cbs_t *cbs = NULL; unsigned push_list = 0; @@ -163,7 +164,9 @@ static int action_right_mainmenu(unsigned type, const char *label, size_t list_size_tabs = menu_driver_list_get_size(MENU_LIST_TABS); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); - if ((menu_driver_list_get_selection() != (list_size_horiz + list_size_tabs)) + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); + + if ((list_info.selection != (list_size_horiz + list_size_tabs)) || settings->menu.navigation.wraparound.enable) push_list = 1; } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 40d2c37901..34a8fa819c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1756,14 +1756,19 @@ static int menu_displaylist_sort_playlist(const content_playlist_entry_t *a, static int menu_displaylist_parse_horizontal_list(menu_displaylist_info_t *info) { + menu_ctx_list_t list_info; char path_playlist[PATH_MAX_LENGTH], lpl_basename[PATH_MAX_LENGTH]; bool is_historylist = false; content_playlist_t *playlist = NULL; settings_t *settings = config_get_ptr(); menu_handle_t *menu = NULL; - struct item_file *item = (struct item_file*) + struct item_file *item = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); + + item = (struct item_file*) menu_driver_list_get_entry(MENU_LIST_HORIZONTAL, - menu_driver_list_get_selection() - (menu_driver_list_get_size(MENU_LIST_TABS)+1)); + list_info.selection - (menu_driver_list_get_size(MENU_LIST_TABS)+1)); if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return -1; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index d4c5e91f63..4b7da0edf9 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -189,13 +189,6 @@ static bool menu_init(menu_handle_t *menu_data) return true; } -size_t menu_driver_list_get_selection(void) -{ - if (!menu_driver_ctx || !menu_driver_ctx->list_get_selection) - return 0; - return menu_driver_ctx->list_get_selection(menu_userdata); -} - size_t menu_driver_list_get_size(menu_list_type_t type) { if (!menu_driver_ctx || !menu_driver_ctx->list_get_size) @@ -658,6 +651,18 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) info->label, info->type); } break; + case RARCH_MENU_CTL_LIST_GET_SELECTION: + { + menu_ctx_list_t *list = (menu_ctx_list_t*)data; + + if (!menu_driver_ctx || !menu_driver_ctx->list_get_selection) + { + list->selection = 0; + return false; + } + list->selection = menu_driver_ctx->list_get_selection(menu_userdata); + } + break; case RARCH_MENU_CTL_LIST_FREE: { menu_ctx_list_t *list = (menu_ctx_list_t*)data; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index 2bec60578d..e21868913c 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -155,6 +155,7 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_LIST_FREE, RARCH_MENU_CTL_LIST_CLEAR, RARCH_MENU_CTL_LIST_SET_SELECTION, + RARCH_MENU_CTL_LIST_GET_SELECTION, RARCH_MENU_CTL_LIST_CACHE, RARCH_MENU_CTL_LIST_INSERT, RARCH_MENU_CTL_LIST_PUSH, @@ -354,6 +355,7 @@ typedef struct menu_ctx_list size_t idx; menu_list_type_t type; unsigned action; + size_t selection; } menu_ctx_list_t; typedef struct menu_ctx_displaylist @@ -431,9 +433,6 @@ size_t menu_driver_list_get_size(menu_list_type_t type); void *menu_driver_list_get_entry(menu_list_type_t type, unsigned i); - -size_t menu_driver_list_get_selection(void); - /* HACK */ extern unsigned int rdb_entry_start_game_selection_ptr;