From b3944a21d58a2a00abb59e221474f869ad690a30 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 11 Feb 2016 01:07:30 +0100 Subject: [PATCH] Create RARCH_MENU_CTL_LIST_GET_SIZE --- menu/cbs/menu_cbs_left.c | 9 ++++++--- menu/cbs/menu_cbs_right.c | 24 +++++++++++++++++------- menu/menu_displaylist.c | 5 ++++- menu/menu_driver.c | 18 +++++++++++------- menu/menu_driver.h | 5 +++-- 5 files changed, 41 insertions(+), 20 deletions(-) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index d8d4421c11..edf341f554 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -137,14 +137,17 @@ static int action_left_mainmenu(unsigned type, const char *label, settings_t *settings = config_get_ptr(); menu_handle_t *menu = NULL; unsigned action = MENU_ACTION_LEFT; - size_t list_size = menu_driver_list_get_size(MENU_LIST_PLAIN); - + 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) + list_info.type = MENU_LIST_PLAIN; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_info); + + if (list_info.size == 1) { menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); if ((list_info.selection != 0) diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 80a8f67fec..9adf72df20 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -156,17 +156,27 @@ static int action_right_mainmenu(unsigned type, const char *label, file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); settings_t *settings = config_get_ptr(); unsigned action = MENU_ACTION_RIGHT; - size_t list_size = menu_driver_list_get_size(MENU_LIST_PLAIN); - if (list_size == 1) + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); + + list_info.type = MENU_LIST_PLAIN; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_info); + + if (list_info.size == 1) { - size_t list_size_horiz = menu_driver_list_get_size(MENU_LIST_HORIZONTAL); - size_t list_size_tabs = menu_driver_list_get_size(MENU_LIST_TABS); + menu_ctx_list_t list_horiz_info; + menu_ctx_list_t list_tabs_info; + + list_horiz_info.type = MENU_LIST_HORIZONTAL; + list_tabs_info.type = MENU_LIST_TABS; + + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_horiz_info); + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_tabs_info); + menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); - menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); - - if ((list_info.selection != (list_size_horiz + list_size_tabs)) + if ((list_info.selection != (list_horiz_info.size + list_tabs_info.size)) || settings->menu.navigation.wraparound.enable) push_list = 1; } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 34a8fa819c..c72b8b900a 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1765,10 +1765,13 @@ static int menu_displaylist_parse_horizontal_list(menu_displaylist_info_t *info) struct item_file *item = NULL; menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SELECTION, &list_info); + + list_info.type = MENU_LIST_TABS; + menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_info); item = (struct item_file*) menu_driver_list_get_entry(MENU_LIST_HORIZONTAL, - list_info.selection - (menu_driver_list_get_size(MENU_LIST_TABS)+1)); + list_info.selection - (list_info.size +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 4b7da0edf9..93adddd217 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_size(menu_list_type_t type) -{ - if (!menu_driver_ctx || !menu_driver_ctx->list_get_size) - return 0; - return menu_driver_ctx->list_get_size(menu_userdata, type); -} - void *menu_driver_list_get_entry(menu_list_type_t type, unsigned i) { if (!menu_driver_ctx || !menu_driver_ctx->list_get_entry) @@ -651,6 +644,17 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) info->label, info->type); } break; + case RARCH_MENU_CTL_LIST_GET_SIZE: + { + menu_ctx_list_t *list = (menu_ctx_list_t*)data; + if (!menu_driver_ctx || !menu_driver_ctx->list_get_size) + { + list->size = 0; + return false; + } + list->size = menu_driver_ctx->list_get_size(menu_userdata, list->type); + } + break; case RARCH_MENU_CTL_LIST_GET_SELECTION: { menu_ctx_list_t *list = (menu_ctx_list_t*)data; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index e21868913c..70bd6a0d22 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -156,6 +156,7 @@ enum rarch_menu_ctl_state RARCH_MENU_CTL_LIST_CLEAR, RARCH_MENU_CTL_LIST_SET_SELECTION, RARCH_MENU_CTL_LIST_GET_SELECTION, + RARCH_MENU_CTL_LIST_GET_SIZE, RARCH_MENU_CTL_LIST_CACHE, RARCH_MENU_CTL_LIST_INSERT, RARCH_MENU_CTL_LIST_PUSH, @@ -356,6 +357,8 @@ typedef struct menu_ctx_list menu_list_type_t type; unsigned action; size_t selection; + size_t size; + void *entry; } menu_ctx_list_t; typedef struct menu_ctx_displaylist @@ -429,8 +432,6 @@ const char *menu_driver_find_ident(int index); **/ const char* config_get_menu_driver_options(void); -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); /* HACK */