mirror of
https://github.com/libretro/RetroArch.git
synced 2024-11-24 00:20:01 +00:00
Start passing around menu_driver_data around properly
This commit is contained in:
parent
d2a1c39f4b
commit
7c314a9165
@ -95,7 +95,13 @@ static int action_select_default(const char *path, const char *label, unsigned t
|
||||
}
|
||||
|
||||
if (action != MENU_ACTION_NOOP)
|
||||
ret = menu_entry_action(&entry, (unsigned)idx, action);
|
||||
{
|
||||
menu_handle_t *menu = NULL;
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu);
|
||||
|
||||
ret = menu_entry_action(&entry, menu, (unsigned)idx, action);
|
||||
}
|
||||
|
||||
menu_entry_free(&entry);
|
||||
|
||||
|
@ -2268,7 +2268,8 @@ static size_t materialui_list_get_selection(void *data)
|
||||
|
||||
/* The pointer or the mouse is pressed down. We use this callback to
|
||||
highlight the entry that has been pressed */
|
||||
static int materialui_pointer_down(void *userdata,
|
||||
static int materialui_pointer_down(void *data,
|
||||
void *userdata,
|
||||
unsigned x, unsigned y,
|
||||
unsigned ptr, menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
@ -2276,22 +2277,16 @@ static int materialui_pointer_down(void *userdata,
|
||||
unsigned width, height;
|
||||
unsigned header_height;
|
||||
size_t entries_end = menu_entries_get_size();
|
||||
materialui_handle_t *mui = (materialui_handle_t*)userdata;
|
||||
materialui_handle_t *mui = (materialui_handle_t*)userdata;
|
||||
|
||||
if (!mui)
|
||||
return 0;
|
||||
|
||||
header_height = menu_display_get_header_height();
|
||||
header_height = menu_display_get_header_height();
|
||||
video_driver_get_size(&width, &height);
|
||||
|
||||
if (y < header_height)
|
||||
{
|
||||
|
||||
}
|
||||
else if (y > height - mui->tabs_height)
|
||||
{
|
||||
|
||||
}
|
||||
if (y < header_height) { }
|
||||
else if (y > height - mui->tabs_height) { }
|
||||
else if (ptr <= (entries_end - 1))
|
||||
{
|
||||
size_t ii;
|
||||
@ -2318,7 +2313,8 @@ static int materialui_pointer_down(void *userdata,
|
||||
If we clicked on the header, we perform a cancel action.
|
||||
If we clicked on the tabs, we switch to a new list.
|
||||
If we clicked on a menu entry, we call the entry action callback. */
|
||||
static int materialui_pointer_up(void *userdata,
|
||||
static int materialui_pointer_up(void *data,
|
||||
void *userdata,
|
||||
unsigned x, unsigned y,
|
||||
unsigned ptr, menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
@ -2326,7 +2322,7 @@ static int materialui_pointer_up(void *userdata,
|
||||
unsigned width, height;
|
||||
unsigned header_height, i;
|
||||
size_t entries_end = menu_entries_get_size();
|
||||
materialui_handle_t *mui = (materialui_handle_t*)userdata;
|
||||
materialui_handle_t *mui = (materialui_handle_t*)userdata;
|
||||
|
||||
if (!mui)
|
||||
return 0;
|
||||
@ -2337,7 +2333,7 @@ static int materialui_pointer_up(void *userdata,
|
||||
if (y < header_height)
|
||||
{
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
|
||||
return menu_entry_action(entry, data, (unsigned)selection, MENU_ACTION_CANCEL);
|
||||
}
|
||||
else if (y > height - mui->tabs_height)
|
||||
{
|
||||
@ -2376,7 +2372,8 @@ static int materialui_pointer_up(void *userdata,
|
||||
)
|
||||
{
|
||||
if (ptr == ii && cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, (unsigned)ii, MENU_ACTION_SELECT);
|
||||
return menu_entry_action(entry, data,
|
||||
(unsigned)ii, MENU_ACTION_SELECT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action)
|
||||
|
||||
menu_entry_init(&entry);
|
||||
menu_entry_get(&entry, 0, selection, NULL, false);
|
||||
ret = menu_entry_action(&entry,
|
||||
ret = menu_entry_action(&entry, menu,
|
||||
(unsigned)selection, (enum menu_action)action);
|
||||
menu_entry_free(&entry);
|
||||
if (ret)
|
||||
|
@ -868,6 +868,7 @@ static int rgui_environ(enum menu_environ_cb type,
|
||||
}
|
||||
|
||||
static int rgui_pointer_tap(void *data,
|
||||
void *userdata,
|
||||
unsigned x, unsigned y,
|
||||
unsigned ptr, menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
@ -877,14 +878,16 @@ static int rgui_pointer_tap(void *data,
|
||||
if (y < header_height)
|
||||
{
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
|
||||
return menu_entry_action(entry, data,
|
||||
(unsigned)selection, MENU_ACTION_CANCEL);
|
||||
}
|
||||
else if (ptr <= (menu_entries_get_size() - 1))
|
||||
{
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
|
||||
if (ptr == selection && cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT);
|
||||
return menu_entry_action(entry, data,
|
||||
(unsigned)selection, MENU_ACTION_SELECT);
|
||||
|
||||
menu_navigation_set_selection(ptr);
|
||||
menu_driver_navigation_set(false);
|
||||
|
@ -5132,7 +5132,8 @@ error:
|
||||
return false;
|
||||
}
|
||||
|
||||
static int xmb_pointer_tap(void *userdata,
|
||||
static int xmb_pointer_tap(void *data,
|
||||
void *userdata,
|
||||
unsigned x, unsigned y, unsigned ptr,
|
||||
menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action)
|
||||
@ -5142,13 +5143,13 @@ static int xmb_pointer_tap(void *userdata,
|
||||
if (y < header_height)
|
||||
{
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
|
||||
return (unsigned)menu_entry_action(entry, data, (unsigned)selection, MENU_ACTION_CANCEL);
|
||||
}
|
||||
else if (ptr <= (menu_entries_get_size() - 1))
|
||||
{
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
if (ptr == selection && cbs && cbs->action_select)
|
||||
return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT);
|
||||
return (unsigned)menu_entry_action(entry, data, (unsigned)selection, MENU_ACTION_SELECT);
|
||||
|
||||
menu_navigation_set_selection(ptr);
|
||||
menu_driver_navigation_set(false);
|
||||
|
@ -2119,7 +2119,8 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
point->retcode = 0;
|
||||
return false;
|
||||
}
|
||||
point->retcode = menu_driver_ctx->pointer_tap(menu_userdata,
|
||||
point->retcode = menu_driver_ctx->pointer_tap(menu_driver_data,
|
||||
menu_userdata,
|
||||
point->x, point->y, point->ptr,
|
||||
point->cbs, point->entry, point->action);
|
||||
}
|
||||
@ -2132,7 +2133,9 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
point->retcode = 0;
|
||||
return false;
|
||||
}
|
||||
point->retcode = menu_driver_ctx->pointer_down(menu_userdata,
|
||||
point->retcode = menu_driver_ctx->pointer_down(
|
||||
menu_driver_data,
|
||||
menu_userdata,
|
||||
point->x, point->y, point->ptr,
|
||||
point->cbs, point->entry, point->action);
|
||||
}
|
||||
@ -2145,7 +2148,9 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
|
||||
point->retcode = 0;
|
||||
return false;
|
||||
}
|
||||
point->retcode = menu_driver_ctx->pointer_up(menu_userdata,
|
||||
point->retcode = menu_driver_ctx->pointer_up(
|
||||
menu_driver_data,
|
||||
menu_userdata,
|
||||
point->x, point->y, point->ptr,
|
||||
point->cbs, point->entry, point->action);
|
||||
}
|
||||
|
@ -486,7 +486,8 @@ typedef struct menu_ctx_driver
|
||||
bool (*load_image)(void *userdata, void *data, enum menu_image_type type);
|
||||
const char *ident;
|
||||
int (*environ_cb)(enum menu_environ_cb type, void *data, void *userdata);
|
||||
int (*pointer_tap)(void *data, unsigned x, unsigned y, unsigned ptr,
|
||||
int (*pointer_tap)(void *data, void *userdata,
|
||||
unsigned x, unsigned y, unsigned ptr,
|
||||
menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action);
|
||||
void (*update_thumbnail_path)(void *data, unsigned i, char pos);
|
||||
@ -496,10 +497,12 @@ typedef struct menu_ctx_driver
|
||||
int (*osk_ptr_at_pos)(void *data, int x, int y, unsigned width, unsigned height);
|
||||
void (*update_savestate_thumbnail_path)(void *data, unsigned i);
|
||||
void (*update_savestate_thumbnail_image)(void *data);
|
||||
int (*pointer_down)(void *data, unsigned x, unsigned y, unsigned ptr,
|
||||
int (*pointer_down)(void *data, void *userdata,
|
||||
unsigned x, unsigned y, unsigned ptr,
|
||||
menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action);
|
||||
int (*pointer_up)(void *data, unsigned x, unsigned y, unsigned ptr,
|
||||
int (*pointer_up)(void *data, void *userdata,
|
||||
unsigned x, unsigned y, unsigned ptr,
|
||||
menu_file_list_cbs_t *cbs,
|
||||
menu_entry_t *entry, unsigned action);
|
||||
} menu_ctx_driver_t;
|
||||
|
@ -286,8 +286,14 @@ static int menu_input_mouse_frame(
|
||||
|
||||
if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_BUTTON_R))
|
||||
{
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
menu_handle_t *menu = NULL;
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu);
|
||||
|
||||
menu_entry_action(entry, menu,
|
||||
(unsigned)selection,
|
||||
MENU_ACTION_CANCEL);
|
||||
}
|
||||
|
||||
if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_WHEEL_DOWN))
|
||||
@ -521,9 +527,15 @@ static int menu_input_pointer_post_iterate(
|
||||
{
|
||||
if (menu_input->pointer.counter > 32)
|
||||
{
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
size_t selection = menu_navigation_get_selection();
|
||||
menu_handle_t *menu = NULL;
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu);
|
||||
|
||||
if (cbs && cbs->action_start)
|
||||
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_START);
|
||||
return menu_entry_action(entry, menu,
|
||||
(unsigned)selection,
|
||||
MENU_ACTION_START);
|
||||
|
||||
}
|
||||
else
|
||||
@ -552,8 +564,14 @@ static int menu_input_pointer_post_iterate(
|
||||
{
|
||||
if (!pointer_oldback)
|
||||
{
|
||||
pointer_oldback = true;
|
||||
menu_entry_action(entry, (unsigned)menu_navigation_get_selection(), MENU_ACTION_CANCEL);
|
||||
menu_handle_t *menu = NULL;
|
||||
pointer_oldback = true;
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu);
|
||||
|
||||
menu_entry_action(entry, menu,
|
||||
(unsigned)menu_navigation_get_selection(),
|
||||
MENU_ACTION_CANCEL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,12 +254,15 @@ void menu_entry_pathdir_extensions(uint32_t i, char *s, size_t len)
|
||||
|
||||
void menu_entry_reset(uint32_t i)
|
||||
{
|
||||
menu_handle_t *menu = NULL;
|
||||
menu_entry_t entry;
|
||||
|
||||
menu_entry_init(&entry);
|
||||
menu_entry_get(&entry, 0, i, NULL, true);
|
||||
|
||||
menu_entry_action(&entry, i, MENU_ACTION_START);
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu);
|
||||
|
||||
menu_entry_action(&entry, menu, i, MENU_ACTION_START);
|
||||
}
|
||||
|
||||
void menu_entry_get_value(menu_entry_t *entry, char *s, size_t len)
|
||||
@ -408,16 +411,21 @@ bool menu_entry_is_currently_selected(unsigned id)
|
||||
int menu_entry_select(uint32_t i)
|
||||
{
|
||||
menu_entry_t entry;
|
||||
menu_handle_t *menu = NULL;
|
||||
|
||||
menu_navigation_set_selection(i);
|
||||
|
||||
menu_entry_init(&entry);
|
||||
menu_entry_get(&entry, 0, i, NULL, false);
|
||||
|
||||
return menu_entry_action(&entry, i, MENU_ACTION_SELECT);
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu);
|
||||
|
||||
return menu_entry_action(&entry, menu, i, MENU_ACTION_SELECT);
|
||||
}
|
||||
|
||||
int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
|
||||
int menu_entry_action(menu_entry_t *entry,
|
||||
void *data,
|
||||
unsigned i, enum menu_action action)
|
||||
{
|
||||
int ret = 0;
|
||||
file_list_t *selection_buf =
|
||||
@ -448,15 +456,9 @@ int menu_entry_action(menu_entry_t *entry, unsigned i, enum menu_action action)
|
||||
break;
|
||||
|
||||
case MENU_ACTION_OK:
|
||||
{
|
||||
menu_handle_t *menu = NULL;
|
||||
|
||||
menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu);
|
||||
|
||||
if (cbs && cbs->action_ok)
|
||||
ret = cbs->action_ok(menu, entry->path,
|
||||
entry->label, entry->type, i, entry->entry_idx);
|
||||
}
|
||||
if (cbs && cbs->action_ok)
|
||||
ret = cbs->action_ok(data, entry->path,
|
||||
entry->label, entry->type, i, entry->entry_idx);
|
||||
break;
|
||||
case MENU_ACTION_START:
|
||||
if (cbs && cbs->action_start)
|
||||
|
@ -113,7 +113,8 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
|
||||
int menu_entry_select(uint32_t i);
|
||||
|
||||
int menu_entry_action(menu_entry_t *entry,
|
||||
unsigned i, enum menu_action action);
|
||||
void *data,
|
||||
unsigned i, enum menu_action action);
|
||||
|
||||
void menu_entry_free(menu_entry_t *entry);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user