Create RARCH_MENU_CTL_LIST_GET_SIZE

This commit is contained in:
twinaphex 2016-02-11 01:07:30 +01:00
parent 48e67d5546
commit b3944a21d5
5 changed files with 41 additions and 20 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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;

View File

@ -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;

View File

@ -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 */