(GLUI) Fix left tab switching when navigation wraparound is false. Also dehardcode some values representing the number of tabs in the menu system.

This commit is contained in:
Jean-André Santoni 2015-10-30 16:28:27 +07:00
parent e36ff60acc
commit ae79d70438
5 changed files with 36 additions and 8 deletions

View File

@ -165,7 +165,9 @@ static int action_right_mainmenu(unsigned type, const char *label,
if (list_size == 1) if (list_size == 1)
{ {
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
if (menu_driver_list_get_selection() != (menu_driver_list_get_size(MENU_LIST_HORIZONTAL) + 3) if (menu_driver_list_get_selection() !=
(menu_driver_list_get_size(MENU_LIST_HORIZONTAL)
+ menu_driver_list_get_size(MENU_LIST_TABS))
|| settings->menu.navigation.wraparound.enable) || settings->menu.navigation.wraparound.enable)
push_list = 1; push_list = 1;
} }

View File

@ -603,12 +603,17 @@ static size_t glui_list_get_size(void *data, menu_list_type_t type)
{ {
size_t list_size = 0; size_t list_size = 0;
/*switch (type) switch (type)
{ {
case MENU_LIST_PLAIN:*/ case MENU_LIST_PLAIN:
list_size = menu_entries_get_stack_size(0); list_size = menu_entries_get_stack_size(0);
/*break; break;
}*/ case MENU_LIST_TABS:
list_size = GLUI_SYSTEM_TAB_END;
break;
default:
break;
}
return list_size; return list_size;
} }
@ -1237,6 +1242,8 @@ static void glui_list_cache(menu_list_type_t type, unsigned action)
break; break;
} }
break; break;
default:
break;
} }
} }
@ -1300,6 +1307,17 @@ static int glui_list_push(menu_displaylist_info_t *info, unsigned type)
return ret; return ret;
} }
static size_t glui_list_get_selection(void *data)
{
menu_handle_t *menu = (menu_handle_t*)data;
glui_handle_t *glui = menu ? (glui_handle_t*)menu->userdata : NULL;
if (!glui)
return 0;
return glui->categories.selection_ptr;
}
menu_ctx_driver_t menu_ctx_glui = { menu_ctx_driver_t menu_ctx_glui = {
NULL, NULL,
glui_get_message, glui_get_message,
@ -1325,7 +1343,7 @@ menu_ctx_driver_t menu_ctx_glui = {
NULL, NULL,
glui_list_cache, glui_list_cache,
glui_list_push, glui_list_push,
NULL, glui_list_get_selection,
glui_list_get_size, glui_list_get_size,
NULL, NULL,
glui_list_set_selection, glui_list_set_selection,

View File

@ -312,6 +312,8 @@ static size_t xmb_list_get_size(void *data, menu_list_type_t type)
if (xmb && xmb->horizontal_list) if (xmb && xmb->horizontal_list)
list_size = file_list_get_size(xmb->horizontal_list); list_size = file_list_get_size(xmb->horizontal_list);
break; break;
case MENU_LIST_TABS:
list_size = XMB_SYSTEM_TAB_END;
} }
return list_size; return list_size;
@ -338,6 +340,8 @@ static void *xmb_list_get_entry(void *data, menu_list_type_t type, unsigned i)
if (i < list_size) if (i < list_size)
ptr = (void*)&xmb->horizontal_list->list[i]; ptr = (void*)&xmb->horizontal_list->list[i];
break; break;
default:
break;
} }
return ptr; return ptr;
@ -2584,6 +2588,8 @@ static void xmb_list_cache(menu_list_type_t type, unsigned action)
break; break;
} }
break; break;
default:
break;
} }
} }

View File

@ -1604,7 +1604,8 @@ static int menu_displaylist_parse_horizontal_list(menu_displaylist_info_t *info)
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr(); menu_handle_t *menu = menu_driver_get_ptr();
struct item_file *item = (struct item_file*) struct item_file *item = (struct item_file*)
menu_driver_list_get_entry(MENU_LIST_HORIZONTAL, menu_driver_list_get_selection() - 4); menu_driver_list_get_entry(MENU_LIST_HORIZONTAL,
menu_driver_list_get_selection() - (menu_driver_list_get_size(MENU_LIST_TABS)+1));
if (!item) if (!item)
return -1; return -1;

View File

@ -31,7 +31,8 @@ extern "C" {
typedef enum typedef enum
{ {
MENU_LIST_PLAIN = 0, MENU_LIST_PLAIN = 0,
MENU_LIST_HORIZONTAL MENU_LIST_HORIZONTAL,
MENU_LIST_TABS
} menu_list_type_t; } menu_list_type_t;
typedef struct menu_file_list_cbs typedef struct menu_file_list_cbs