Refactor xmb_list_cache function callback

This commit is contained in:
twinaphex 2015-06-07 11:20:36 +02:00
parent d3102e03c8
commit 2e81d7f8dc
8 changed files with 50 additions and 40 deletions

View File

@ -1870,7 +1870,7 @@ static void xmb_list_delete(file_list_t *list,
list->list[idx].userdata = NULL;
}
static void xmb_list_cache(bool horizontal, unsigned action)
static void xmb_list_cache(menu_list_type_t type, unsigned action)
{
size_t stack_size;
xmb_handle_t *xmb = NULL;
@ -1888,41 +1888,45 @@ static void xmb_list_cache(bool horizontal, unsigned action)
file_list_copy(menu->menu_list->menu_stack, xmb->menu_stack_old);
xmb->selection_ptr_old = menu->navigation.selection_ptr;
if(!horizontal)
return;
xmb->categories.selection_ptr_old = menu->categories.selection_ptr;
switch (action)
switch (type)
{
case MENU_ACTION_LEFT:
menu->categories.selection_ptr--;
case MENU_LIST_PLAIN:
break;
default:
menu->categories.selection_ptr++;
case MENU_LIST_HORIZONTAL:
xmb->categories.selection_ptr_old = menu->categories.selection_ptr;
switch (action)
{
case MENU_ACTION_LEFT:
menu->categories.selection_ptr--;
break;
default:
menu->categories.selection_ptr++;
break;
}
stack_size = menu->menu_list->menu_stack->size;
if (menu->menu_list->menu_stack->list[stack_size - 1].label)
free(menu->menu_list->menu_stack->list[stack_size - 1].label);
menu->menu_list->menu_stack->list[stack_size - 1].label = NULL;
if (menu->categories.selection_ptr == 0)
{
menu->menu_list->menu_stack->list[stack_size - 1].label =
strdup("Main Menu");
menu->menu_list->menu_stack->list[stack_size - 1].type =
MENU_SETTINGS;
}
else
{
menu->menu_list->menu_stack->list[stack_size - 1].label =
strdup("Horizontal Menu");
menu->menu_list->menu_stack->list[stack_size - 1].type =
MENU_SETTING_HORIZONTAL_MENU;
}
break;
}
stack_size = menu->menu_list->menu_stack->size;
if (menu->menu_list->menu_stack->list[stack_size - 1].label)
free(menu->menu_list->menu_stack->list[stack_size - 1].label);
menu->menu_list->menu_stack->list[stack_size - 1].label = NULL;
if (menu->categories.selection_ptr == 0)
{
menu->menu_list->menu_stack->list[stack_size - 1].label =
strdup("Main Menu");
menu->menu_list->menu_stack->list[stack_size - 1].type =
MENU_SETTINGS;
}
else
{
menu->menu_list->menu_stack->list[stack_size - 1].label =
strdup("Horizontal Menu");
menu->menu_list->menu_stack->list[stack_size - 1].type =
MENU_SETTING_HORIZONTAL_MENU;
}
}
static void xmb_context_destroy(void)

View File

@ -1717,7 +1717,7 @@ int menu_displaylist_push_list(menu_displaylist_info_t *info, unsigned type)
menu_list_push(info->list, info->path, info->label, info->type, info->directory_ptr);
break;
case DISPLAYLIST_GENERIC:
menu_driver_list_cache(false, 0);
menu_driver_list_cache(MENU_LIST_PLAIN, 0);
menu_list_push(info->list, info->path, info->label, info->type, info->directory_ptr);
menu_navigation_clear(&menu->navigation, true);

View File

@ -251,12 +251,12 @@ void menu_driver_list_insert(file_list_t *list, const char *path,
menu_entries_cbs_init(list, path, label, type, idx);
}
void menu_driver_list_cache(bool state, unsigned action)
void menu_driver_list_cache(menu_list_type_t type, unsigned action)
{
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
if (driver->list_cache)
driver->list_cache(state, action);
driver->list_cache(type, action);
}
void menu_driver_navigation_increment(void)

View File

@ -254,7 +254,7 @@ typedef struct menu_ctx_driver
void (*list_insert)(file_list_t *list, const char *, const char *, size_t);
void (*list_delete)(file_list_t *list, size_t, size_t);
void (*list_clear)(file_list_t *list);
void (*list_cache)(bool, unsigned);
void (*list_cache)(menu_list_type_t, unsigned);
void (*list_set_selection)(file_list_t *list);
bool (*load_image)(void *data, menu_image_type_t type);
const char *ident;
@ -336,7 +336,7 @@ void menu_driver_navigation_descend_alphabet(size_t *);
void menu_driver_navigation_ascend_alphabet(size_t *);
void menu_driver_list_cache(bool state, unsigned action);
void menu_driver_list_cache(menu_list_type_t type, unsigned action);
void menu_driver_list_delete(file_list_t *list, size_t i, size_t list_size);

View File

@ -162,7 +162,7 @@ static int action_left_mainmenu(unsigned type, const char *label,
switch (push_list)
{
case 1:
menu_driver_list_cache(true, action);
menu_driver_list_cache(MENU_LIST_HORIZONTAL, action);
if (cbs && cbs->action_content_list_switch)
return cbs->action_content_list_switch(

View File

@ -168,7 +168,7 @@ static int action_right_mainmenu(unsigned type, const char *label,
switch (push_list)
{
case 1:
menu_driver_list_cache(true, action);
menu_driver_list_cache(MENU_LIST_HORIZONTAL, action);
if (cbs && cbs->action_content_list_switch)
return cbs->action_content_list_switch(

View File

@ -278,7 +278,7 @@ void menu_list_pop_stack(menu_list_t *list)
if (file_list_get_size(list->menu_stack) <= 1)
return;
menu_driver_list_cache(false, 0);
menu_driver_list_cache(MENU_LIST_PLAIN, 0);
menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr);
menu_set_refresh();

View File

@ -32,6 +32,12 @@ typedef struct menu_list
file_list_t *selection_buf;
} menu_list_t;
typedef enum
{
MENU_LIST_PLAIN = 0,
MENU_LIST_HORIZONTAL,
} menu_list_type_t;
typedef struct menu_file_list_cbs
{
int (*action_iterate)(const char *label, unsigned action);