Turn MENU_NAVIGATION_CTL_{SET|GET}_SELECTION into separate

functions
This commit is contained in:
twinaphex 2017-04-23 14:31:49 +02:00
parent 8e6b7a2751
commit 7ea0528c6b
23 changed files with 127 additions and 257 deletions

View File

@ -55,9 +55,9 @@ static int action_cancel_pop_default(const char *path,
filebrowser_clear_type(); filebrowser_clear_type();
} }
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &new_selection_ptr); new_selection_ptr = menu_navigation_get_selection();
menu_entries_pop_stack(&new_selection_ptr, 0, 1); menu_entries_pop_stack(&new_selection_ptr, 0, 1);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &new_selection_ptr); menu_navigation_set_selection(new_selection_ptr);
menu_driver_ctl(RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH, NULL); menu_driver_ctl(RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH, NULL);
menu_driver_ctl(RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_IMAGE, NULL); menu_driver_ctl(RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_IMAGE, NULL);

View File

@ -29,16 +29,13 @@
static int action_info_default(unsigned type, const char *label) static int action_info_default(unsigned type, const char *label)
{ {
size_t selection = 0;
menu_displaylist_info_t info = {0}; menu_displaylist_info_t info = {0};
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) info.list = menu_stack;
return 0; info.directory_ptr = selection;
info.enum_idx = MENU_ENUM_LABEL_INFO_SCREEN;
info.list = menu_stack;
info.directory_ptr = selection;
info.enum_idx = MENU_ENUM_LABEL_INFO_SCREEN;
strlcpy(info.label, strlcpy(info.label,
msg_hash_to_str(MENU_ENUM_LABEL_INFO_SCREEN), msg_hash_to_str(MENU_ENUM_LABEL_INFO_SCREEN),
sizeof(info.label)); sizeof(info.label));

View File

@ -116,11 +116,10 @@ static int action_left_input_desc(unsigned type, const char *label,
static int action_left_scroll(unsigned type, const char *label, static int action_left_scroll(unsigned type, const char *label,
bool wraparound) bool wraparound)
{ {
size_t selection;
size_t scroll_accel = 0; size_t scroll_accel = 0;
unsigned scroll_speed = 0, fast_scroll_speed = 0; unsigned scroll_speed = 0, fast_scroll_speed = 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) size_t selection = menu_navigation_get_selection();
return menu_cbs_exit();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel))
return false; return false;
@ -131,7 +130,7 @@ static int action_left_scroll(unsigned type, const char *label,
{ {
size_t idx = selection - fast_scroll_speed; size_t idx = selection - fast_scroll_speed;
bool scroll = true; bool scroll = true;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); menu_navigation_set_selection(idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
} }
else else
@ -147,7 +146,6 @@ static int action_left_mainmenu(unsigned type, const char *label,
bool wraparound) bool wraparound)
{ {
menu_ctx_list_t list_info; menu_ctx_list_t list_info;
size_t selection = 0;
unsigned push_list = 0; unsigned push_list = 0;
menu_handle_t *menu = NULL; menu_handle_t *menu = NULL;
@ -164,7 +162,8 @@ static int action_left_mainmenu(unsigned type, const char *label,
{ {
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); menu_navigation_set_selection(0);
if ((list_info.selection != 0) if ((list_info.selection != 0)
|| settings->menu.navigation.wraparound.enable) || settings->menu.navigation.wraparound.enable)
push_list = 1; push_list = 1;
@ -172,8 +171,6 @@ static int action_left_mainmenu(unsigned type, const char *label,
else else
push_list = 2; push_list = 2;
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
switch (push_list) switch (push_list)
{ {
@ -182,12 +179,13 @@ static int action_left_mainmenu(unsigned type, const char *label,
menu_ctx_list_t list_info; menu_ctx_list_t list_info;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
menu_file_list_cbs_t *cbs = menu_file_list_cbs_t *cbs =
menu_entries_get_actiondata_at_offset(selection_buf, menu_entries_get_actiondata_at_offset(selection_buf,
selection); selection);
list_info.type = MENU_LIST_HORIZONTAL; list_info.type = MENU_LIST_HORIZONTAL;
list_info.action = MENU_ACTION_LEFT; list_info.action = MENU_ACTION_LEFT;
menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info);

View File

@ -1325,7 +1325,6 @@ static int action_ok_playlist_entry_collection(const char *path,
menu_content_ctx_playlist_info_t playlist_info; menu_content_ctx_playlist_info_t playlist_info;
char new_core_path[PATH_MAX_LENGTH]; char new_core_path[PATH_MAX_LENGTH];
content_ctx_info_t content_info = {0}; content_ctx_info_t content_info = {0};
size_t selection = 0;
size_t selection_ptr = 0; size_t selection_ptr = 0;
bool playlist_initialized = false; bool playlist_initialized = false;
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
@ -1339,8 +1338,6 @@ static int action_ok_playlist_entry_collection(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit(); return menu_cbs_exit();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return menu_cbs_exit();
new_core_path[0] = '\0'; new_core_path[0] = '\0';
@ -1452,7 +1449,6 @@ static int action_ok_playlist_entry_collection(const char *path,
static int action_ok_playlist_entry(const char *path, static int action_ok_playlist_entry(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx) const char *label, unsigned type, size_t idx, size_t entry_idx)
{ {
size_t selection;
menu_content_ctx_playlist_info_t playlist_info; menu_content_ctx_playlist_info_t playlist_info;
content_ctx_info_t content_info = {0}; content_ctx_info_t content_info = {0};
size_t selection_ptr = 0; size_t selection_ptr = 0;
@ -1465,8 +1461,6 @@ static int action_ok_playlist_entry(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit(); return menu_cbs_exit();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return menu_cbs_exit();
selection_ptr = entry_idx; selection_ptr = entry_idx;
@ -1543,7 +1537,6 @@ static int action_ok_playlist_entry_start_content(const char *path,
{ {
menu_content_ctx_playlist_info_t playlist_info; menu_content_ctx_playlist_info_t playlist_info;
content_ctx_info_t content_info = {0}; content_ctx_info_t content_info = {0};
size_t selection = 0;
size_t selection_ptr = 0; size_t selection_ptr = 0;
bool playlist_initialized = false; bool playlist_initialized = false;
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
@ -1555,8 +1548,6 @@ static int action_ok_playlist_entry_start_content(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit(); return menu_cbs_exit();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return menu_cbs_exit();
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist); menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &tmp_playlist);
@ -2054,15 +2045,12 @@ static int action_ok_path_scan_directory(const char *path,
static int action_ok_core_deferred_set(const char *path, static int action_ok_core_deferred_set(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx) const char *label, unsigned type, size_t idx, size_t entry_idx)
{ {
size_t selection;
char core_display_name[PATH_MAX_LENGTH]; char core_display_name[PATH_MAX_LENGTH];
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
size_t selection = menu_navigation_get_selection();
core_display_name[0] = '\0'; core_display_name[0] = '\0';
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return menu_cbs_exit();
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist); menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
retro_assert(playlist != NULL); retro_assert(playlist != NULL);
@ -2080,7 +2068,7 @@ static int action_ok_core_deferred_set(const char *path,
playlist_write_file(playlist); playlist_write_file(playlist);
menu_entries_pop_stack(&selection, 0, 1); menu_entries_pop_stack(&selection, 0, 1);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); menu_navigation_set_selection(selection);
return menu_cbs_exit(); return menu_cbs_exit();
} }
@ -2088,15 +2076,12 @@ static int action_ok_core_deferred_set(const char *path,
static int action_ok_core_deferred_set_current_core(const char *path, static int action_ok_core_deferred_set_current_core(const char *path,
const char *label, unsigned type, size_t idx, size_t entry_idx) const char *label, unsigned type, size_t idx, size_t entry_idx)
{ {
size_t selection;
char core_display_name[PATH_MAX_LENGTH]; char core_display_name[PATH_MAX_LENGTH];
playlist_t *playlist = NULL; playlist_t *playlist = NULL;
size_t selection = menu_navigation_get_selection();
core_display_name[0] = '\0'; core_display_name[0] = '\0';
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return menu_cbs_exit();
menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist); menu_driver_ctl(RARCH_MENU_CTL_PLAYLIST_GET, &playlist);
retro_assert(playlist != NULL); retro_assert(playlist != NULL);
@ -2114,7 +2099,7 @@ static int action_ok_core_deferred_set_current_core(const char *path,
playlist_write_file(playlist); playlist_write_file(playlist);
menu_entries_pop_stack(&selection, 0, 1); menu_entries_pop_stack(&selection, 0, 1);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); menu_navigation_set_selection(selection);
return 0; return 0;
} }
@ -2932,9 +2917,9 @@ static int action_ok_delete_entry(const char *path,
playlist_delete_index(playlist, rpl_entry_selection_ptr); playlist_delete_index(playlist, rpl_entry_selection_ptr);
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &new_selection_ptr); new_selection_ptr = menu_navigation_get_selection();
menu_entries_pop_stack(&new_selection_ptr, 0, 1); menu_entries_pop_stack(&new_selection_ptr, 0, 1);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &new_selection_ptr); menu_navigation_set_selection(new_selection_ptr);
return 0; return 0;
} }
@ -3857,11 +3842,8 @@ static int action_ok_load_archive_detect_core(const char *path,
if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu))
return menu_cbs_exit(); return menu_cbs_exit();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &idx)) menu_path = menu->scratch2_buf;
return false; content_path = menu->scratch_buf;
menu_path = menu->scratch2_buf;
content_path = menu->scratch_buf;
core_info_get_list(&list); core_info_get_list(&list);
@ -3894,9 +3876,12 @@ static int action_ok_load_archive_detect_core(const char *path,
} }
return 0; return 0;
case 0: case 0:
return generic_action_ok_displaylist_push(path, NULL, {
label, type, idx = menu_navigation_get_selection();
idx, entry_idx, ACTION_OK_DL_DEFERRED_CORE_LIST); return generic_action_ok_displaylist_push(path, NULL,
label, type,
idx, entry_idx, ACTION_OK_DL_DEFERRED_CORE_LIST);
}
default: default:
break; break;
} }

View File

@ -126,11 +126,10 @@ int action_right_input_desc(unsigned type, const char *label,
static int action_right_scroll(unsigned type, const char *label, static int action_right_scroll(unsigned type, const char *label,
bool wraparound) bool wraparound)
{ {
size_t selection;
size_t scroll_accel = 0; size_t scroll_accel = 0;
unsigned scroll_speed = 0, fast_scroll_speed = 0; unsigned scroll_speed = 0, fast_scroll_speed = 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) size_t selection = menu_navigation_get_selection();
return false;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel)) if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel))
return false; return false;
@ -141,7 +140,8 @@ static int action_right_scroll(unsigned type, const char *label,
{ {
size_t idx = selection + fast_scroll_speed; size_t idx = selection + fast_scroll_speed;
bool scroll = true; bool scroll = true;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_set_selection(idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
} }
else else
@ -156,17 +156,13 @@ static int action_right_scroll(unsigned type, const char *label,
static int action_right_goto_tab(void) static int action_right_goto_tab(void)
{ {
menu_ctx_list_t list_info; menu_ctx_list_t list_info;
size_t selection = 0;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
menu_file_list_cbs_t *cbs = NULL; size_t selection = menu_navigation_get_selection();
menu_file_list_cbs_t *cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection);
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); list_info.type = MENU_LIST_HORIZONTAL;
list_info.action = MENU_ACTION_RIGHT;
cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection);
list_info.type = MENU_LIST_HORIZONTAL;
list_info.action = MENU_ACTION_RIGHT;
menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info); menu_driver_ctl(RARCH_MENU_CTL_LIST_CACHE, &list_info);
@ -192,7 +188,6 @@ static int action_right_mainmenu(unsigned type, const char *label,
{ {
menu_ctx_list_t list_horiz_info; menu_ctx_list_t list_horiz_info;
menu_ctx_list_t list_tabs_info; menu_ctx_list_t list_tabs_info;
size_t selection = 0;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
list_horiz_info.type = MENU_LIST_HORIZONTAL; list_horiz_info.type = MENU_LIST_HORIZONTAL;
@ -201,7 +196,7 @@ static int action_right_mainmenu(unsigned type, const char *label,
menu_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_horiz_info); 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_driver_ctl(RARCH_MENU_CTL_LIST_GET_SIZE, &list_tabs_info);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); menu_navigation_set_selection(0);
if ((list_info.selection != (list_horiz_info.size + list_tabs_info.size)) if ((list_info.selection != (list_horiz_info.size + list_tabs_info.size))
|| settings->menu.navigation.wraparound.enable) || settings->menu.navigation.wraparound.enable)

View File

@ -808,26 +808,16 @@ static void mui_render_menu_list(
for (; i < menu_entries_get_end(); i++) for (; i < menu_entries_get_end(); i++)
{ {
int y;
size_t selection;
char rich_label[255]; char rich_label[255];
char entry_value[255]; char entry_value[255];
bool entry_selected = false; bool entry_selected = false;
mui_node_t *node = (mui_node_t*) mui_node_t *node = (mui_node_t*)
menu_entries_get_userdata_at_offset(list, i); menu_entries_get_userdata_at_offset(list, i);
size_t selection = menu_navigation_get_selection();
int y = header_height - mui->scroll_y + sum;
rich_label[0] = rich_label[0] =
entry_value[0] = '\0'; entry_value[0] = '\0';
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
continue;
y = header_height - mui->scroll_y + sum;
/*if ((y - (int)node->line_height) > (int)height
|| ((y + (int)node->line_height) < 0))
continue;*/
menu_entry_get_value((unsigned)i, NULL, entry_value, sizeof(entry_value)); menu_entry_get_value((unsigned)i, NULL, entry_value, sizeof(entry_value));
menu_entry_get_rich_label((unsigned)i, rich_label, sizeof(rich_label)); menu_entry_get_rich_label((unsigned)i, rich_label, sizeof(rich_label));
@ -1255,8 +1245,7 @@ static void mui_frame(void *data, video_frame_info_t *video_info)
menu_entries_get_title(title, sizeof(title)); menu_entries_get_title(title, sizeof(title));
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) selection = menu_navigation_get_selection();
return;
if (background_rendered || libretro_running) if (background_rendered || libretro_running)
menu_display_set_alpha(blue_50, 0.75); menu_display_set_alpha(blue_50, 0.75);
@ -1568,13 +1557,11 @@ static bool mui_load_image(void *userdata, void *data, enum menu_image_type type
static float mui_get_scroll(mui_handle_t *mui) static float mui_get_scroll(mui_handle_t *mui)
{ {
size_t selection;
unsigned width, height, half = 0; unsigned width, height, half = 0;
size_t selection = menu_navigation_get_selection();
if (!mui) if (!mui)
return 0; return 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0;
video_driver_get_size(&width, &height); video_driver_get_size(&width, &height);
@ -1688,15 +1675,13 @@ static int mui_environ(enum menu_environ_cb type, void *data, void *userdata)
static void mui_preswitch_tabs(mui_handle_t *mui, unsigned action) static void mui_preswitch_tabs(mui_handle_t *mui, unsigned action)
{ {
size_t idx = 0;
size_t stack_size = 0; size_t stack_size = 0;
file_list_t *menu_stack = NULL; file_list_t *menu_stack = NULL;
size_t idx = menu_navigation_get_selection();
if (!mui) if (!mui)
return; return;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_stack = menu_entries_get_menu_stack_ptr(0); menu_stack = menu_entries_get_menu_stack_ptr(0);
stack_size = menu_stack->size; stack_size = menu_stack->size;
@ -1933,9 +1918,7 @@ static int mui_pointer_down(void *userdata,
if (y > (-mui->scroll_y + header_height + node->y) if (y > (-mui->scroll_y + header_height + node->y)
&& y < (-mui->scroll_y + header_height + node->y + node->line_height) && y < (-mui->scroll_y + header_height + node->y + node->line_height)
) )
{ menu_navigation_set_selection(ii);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &ii);
}
} }
@ -1949,7 +1932,6 @@ static int mui_pointer_up(void *userdata,
unsigned ptr, menu_file_list_cbs_t *cbs, unsigned ptr, menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action) menu_entry_t *entry, unsigned action)
{ {
size_t selection;
unsigned width, height; unsigned width, height;
unsigned header_height, i; unsigned header_height, i;
mui_handle_t *mui = (mui_handle_t*)userdata; mui_handle_t *mui = (mui_handle_t*)userdata;
@ -1962,7 +1944,7 @@ static int mui_pointer_up(void *userdata,
if (y < header_height) if (y < header_height)
{ {
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); size_t selection = menu_navigation_get_selection();
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL); return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
} }
else if (y > height - mui->tabs_height) else if (y > height - mui->tabs_height)
@ -2016,16 +1998,14 @@ static void mui_list_insert(void *userdata,
const char *unused, const char *unused,
size_t list_size) size_t list_size)
{ {
size_t selection;
float scale_factor; float scale_factor;
int i = (int)list_size; int i = (int)list_size;
mui_node_t *node = NULL; mui_node_t *node = NULL;
mui_handle_t *mui = (mui_handle_t*)userdata; mui_handle_t *mui = (mui_handle_t*)userdata;
size_t selection = menu_navigation_get_selection();
if (!mui || !list) if (!mui || !list)
return; return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
node = (mui_node_t*)menu_entries_get_userdata_at_offset(list, i); node = (mui_node_t*)menu_entries_get_userdata_at_offset(list, i);

View File

@ -70,20 +70,18 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action)
{ {
menu_entry_t entry; menu_entry_t entry;
enum action_iterate_type iterate_type; enum action_iterate_type iterate_type;
size_t selection = 0;
unsigned file_type = 0; unsigned file_type = 0;
int ret = 0; int ret = 0;
uint32_t hash = 0; uint32_t hash = 0;
enum msg_hash_enums enum_idx = MSG_UNKNOWN; enum msg_hash_enums enum_idx = MSG_UNKNOWN;
const char *label = NULL; const char *label = NULL;
menu_handle_t *menu = (menu_handle_t*)data; menu_handle_t *menu = (menu_handle_t*)data;
size_t selection = menu_navigation_get_selection();
menu_entries_get_last_stack(NULL, &label, &file_type, &enum_idx, NULL); menu_entries_get_last_stack(NULL, &label, &file_type, &enum_idx, NULL);
if (!menu) if (!menu)
return 0; return 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0;
menu->menu_state.msg[0] = '\0'; menu->menu_state.msg[0] = '\0';
@ -129,8 +127,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action)
if (menu_input_key_bind_iterate(&bind)) if (menu_input_key_bind_iterate(&bind))
{ {
menu_entries_pop_stack(&selection, 0, 0); menu_entries_pop_stack(&selection, 0, 0);
menu_navigation_ctl( menu_navigation_set_selection(selection);
MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
} }
else else
BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX); BIT64_SET(menu->state, MENU_STATE_RENDER_MESSAGEBOX);
@ -250,7 +247,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action)
{ {
size_t new_selection_ptr = selection; size_t new_selection_ptr = selection;
menu_entries_pop_stack(&new_selection_ptr, 0, 0); menu_entries_pop_stack(&new_selection_ptr, 0, 0);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection); menu_navigation_set_selection(selection);
} }
if (BIT64_GET(menu->state, MENU_STATE_POST_ITERATE)) if (BIT64_GET(menu->state, MENU_STATE_POST_ITERATE))

View File

@ -490,14 +490,12 @@ static bool nk_menu_init_list(void *data)
static int nk_menu_iterate(void *data, void *userdata, enum menu_action action) static int nk_menu_iterate(void *data, void *userdata, enum menu_action action)
{ {
int ret; int ret;
size_t selection;
menu_entry_t entry; menu_entry_t entry;
nk_menu_handle_t *nk = (nk_menu_handle_t*)userdata; nk_menu_handle_t *nk = (nk_menu_handle_t*)userdata;
size_t selection = menu_navigation_get_selection();
if (!nk) if (!nk)
return -1; return -1;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0;
menu_entry_get(&entry, 0, selection, NULL, false); menu_entry_get(&entry, 0, selection, NULL, false);

View File

@ -574,7 +574,6 @@ static void rgui_render(void *data)
for (; i < end; i++, y += FONT_HEIGHT_STRIDE) for (; i < end; i++, y += FONT_HEIGHT_STRIDE)
{ {
menu_animation_ctx_ticker_t ticker; menu_animation_ctx_ticker_t ticker;
size_t selection;
char entry_path[255]; char entry_path[255];
char entry_value[255]; char entry_value[255];
char message[255]; char message[255];
@ -582,9 +581,7 @@ static void rgui_render(void *data)
char type_str_buf[255]; char type_str_buf[255];
unsigned entry_spacing = menu_entry_get_spacing((unsigned)i); unsigned entry_spacing = menu_entry_get_spacing((unsigned)i);
bool entry_selected = menu_entry_is_currently_selected((unsigned)i); bool entry_selected = menu_entry_is_currently_selected((unsigned)i);
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
continue;
if (i > (selection + 100)) if (i > (selection + 100))
continue; continue;
@ -763,12 +760,12 @@ static void rgui_navigation_clear(void *data, bool pending_push)
static void rgui_navigation_set(void *data, bool scroll) static void rgui_navigation_set(void *data, bool scroll)
{ {
size_t selection, start, fb_pitch; size_t start, fb_pitch;
unsigned fb_width, fb_height; unsigned fb_width, fb_height;
bool do_set_start = false; bool do_set_start = false;
size_t end = menu_entries_get_end(); size_t end = menu_entries_get_end();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) size_t selection = menu_navigation_get_selection();
return;
if (!scroll) if (!scroll)
return; return;
@ -850,25 +847,22 @@ static int rgui_pointer_tap(void *data,
unsigned ptr, menu_file_list_cbs_t *cbs, unsigned ptr, menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action) menu_entry_t *entry, unsigned action)
{ {
size_t selection;
unsigned header_height = menu_display_get_header_height(); unsigned header_height = menu_display_get_header_height();
if (y < header_height) if (y < header_height)
{ {
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); size_t selection = menu_navigation_get_selection();
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL); return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
} }
else if (ptr <= (menu_entries_get_size() - 1)) else if (ptr <= (menu_entries_get_size() - 1))
{ {
size_t idx;
bool scroll = false; bool scroll = false;
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); size_t selection = menu_navigation_get_selection();
if (ptr == selection && cbs && cbs->action_select) if (ptr == selection && cbs && cbs->action_select)
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT); return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT);
idx = ptr; menu_navigation_set_selection(ptr);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
} }

View File

@ -1073,17 +1073,16 @@ static void xmb_selection_pointer_changed(
{ {
unsigned i, end, height; unsigned i, end, height;
menu_animation_ctx_tag_t tag; menu_animation_ctx_tag_t tag;
size_t selection, num = 0; size_t num = 0;
int threshold = 0; int threshold = 0;
menu_list_t *menu_list = NULL; menu_list_t *menu_list = NULL;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list); menu_entries_ctl(MENU_ENTRIES_CTL_LIST_GET, &menu_list);
if (!xmb) if (!xmb)
return; return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
end = (unsigned)menu_entries_get_end(); end = (unsigned)menu_entries_get_end();
threshold = xmb->icon.size*10; threshold = xmb->icon.size*10;
@ -1559,12 +1558,9 @@ static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb)
static void xmb_list_switch(xmb_handle_t *xmb) static void xmb_list_switch(xmb_handle_t *xmb)
{ {
menu_animation_ctx_entry_t entry; menu_animation_ctx_entry_t entry;
size_t selection; int dir = -1;
int dir = -1;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
if (xmb->categories.selection_ptr > xmb->categories.selection_ptr_old) if (xmb->categories.selection_ptr > xmb->categories.selection_ptr_old)
dir = 1; dir = 1;
@ -1868,12 +1864,9 @@ static void xmb_list_open(xmb_handle_t *xmb)
{ {
menu_animation_ctx_entry_t entry; menu_animation_ctx_entry_t entry;
size_t selection;
int dir = 0; int dir = 0;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
xmb->depth = (int)xmb_list_get_size(xmb, MENU_LIST_PLAIN); xmb->depth = (int)xmb_list_get_size(xmb, MENU_LIST_PLAIN);
@ -2381,10 +2374,7 @@ static void xmb_render(void *data)
if (settings->menu.pointer.enable || settings->menu.mouse.enable) if (settings->menu.pointer.enable || settings->menu.mouse.enable)
{ {
size_t selection; size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
for (i = 0; i < end; i++) for (i = 0; i < end; i++)
{ {
@ -2627,8 +2617,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
coord_black, coord_black,
coord_white); coord_white);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) selection = menu_navigation_get_selection();
return;
strlcpy(title_truncated, xmb->title_name, sizeof(title_truncated)); strlcpy(title_truncated, xmb->title_name, sizeof(title_truncated));
if (selection > 1) if (selection > 1)
@ -3065,12 +3054,9 @@ static void xmb_layout_psp(xmb_handle_t *xmb, int width)
static void xmb_layout(xmb_handle_t *xmb) static void xmb_layout(xmb_handle_t *xmb)
{ {
size_t selection;
unsigned width, height, i, current, end; unsigned width, height, i, current, end;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
video_driver_get_size(&width, &height); video_driver_get_size(&width, &height);
@ -3604,16 +3590,14 @@ static void xmb_list_insert(void *userdata,
const char *unused, const char *unused,
size_t list_size) size_t list_size)
{ {
size_t selection;
int current = 0; int current = 0;
int i = (int)list_size; int i = (int)list_size;
xmb_node_t *node = NULL; xmb_node_t *node = NULL;
xmb_handle_t *xmb = (xmb_handle_t*)userdata; xmb_handle_t *xmb = (xmb_handle_t*)userdata;
size_t selection = menu_navigation_get_selection();
if (!xmb || !list) if (!xmb || !list)
return; return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i); node = (xmb_node_t*)menu_entries_get_userdata_at_offset(list, i);
@ -3735,15 +3719,14 @@ static void xmb_list_deep_copy(const file_list_t *src, file_list_t *dst)
static void xmb_list_cache(void *data, enum menu_list_type type, unsigned action) static void xmb_list_cache(void *data, enum menu_list_type type, unsigned action)
{ {
size_t stack_size, list_size, selection; size_t stack_size, list_size;
xmb_handle_t *xmb = (xmb_handle_t*)data; xmb_handle_t *xmb = (xmb_handle_t*)data;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
if (!xmb) if (!xmb)
return; return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
xmb_list_deep_copy(selection_buf, xmb->selection_buf_old); xmb_list_deep_copy(selection_buf, xmb->selection_buf_old);
xmb_list_deep_copy(menu_stack, xmb->menu_stack_old); xmb_list_deep_copy(menu_stack, xmb->menu_stack_old);
@ -4059,26 +4042,21 @@ static int xmb_pointer_tap(void *userdata,
menu_file_list_cbs_t *cbs, menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action) menu_entry_t *entry, unsigned action)
{ {
size_t selection;
unsigned header_height = menu_display_get_header_height(); unsigned header_height = menu_display_get_header_height();
if (y < header_height) if (y < header_height)
{ {
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); size_t selection = menu_navigation_get_selection();
return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL); return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
} }
else if (ptr <= (menu_entries_get_size() - 1)) else if (ptr <= (menu_entries_get_size() - 1))
{ {
size_t idx;
bool scroll = false; bool scroll = false;
size_t selection = menu_navigation_get_selection();
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
if (ptr == selection && cbs && cbs->action_select) if (ptr == selection && cbs && cbs->action_select)
return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT); return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT);
idx = ptr; menu_navigation_set_selection(ptr);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
} }

View File

@ -590,8 +590,7 @@ static void xui_render(void *data)
xui_set_list_text(i, msg_left, msg_right); xui_set_list_text(i, msg_left, msg_right);
} }
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) selection = menu_navigation_get_selection();
return;
XuiListSetCurSelVisible(m_menulist, selection); XuiListSetCurSelVisible(m_menulist, selection);
@ -610,31 +609,19 @@ static void xui_populate_entries(void *data,
const char *path, const char *path,
const char *label, unsigned i) const char *label, unsigned i)
{ {
size_t selection; size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
(void)label;
(void)path;
XuiListSetCurSelVisible(m_menulist, selection); XuiListSetCurSelVisible(m_menulist, selection);
} }
static void xui_navigation_clear(void *data, bool pending_push) static void xui_navigation_clear(void *data, bool pending_push)
{ {
size_t selection; size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
XuiListSetCurSelVisible(m_menulist, selection); XuiListSetCurSelVisible(m_menulist, selection);
} }
static void xui_navigation_set_visible(void *data) static void xui_navigation_set_visible(void *data)
{ {
size_t selection; size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
XuiListSetCurSelVisible(m_menulist, selection); XuiListSetCurSelVisible(m_menulist, selection);
} }

View File

@ -1108,14 +1108,12 @@ static void zarch_context_reset(void *data)
static int zarch_iterate(void *data, void *userdata, enum menu_action action) static int zarch_iterate(void *data, void *userdata, enum menu_action action)
{ {
int ret; int ret;
size_t selection;
menu_entry_t entry; menu_entry_t entry;
zui_t *zui = (zui_t*)userdata; zui_t *zui = (zui_t*)userdata;
size_t selection = menu_navigation_get_selection();
if (!zui) if (!zui)
return -1; return -1;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0;
menu_entry_get(&entry, 0, selection, NULL, false); menu_entry_get(&entry, 0, selection, NULL, false);

View File

@ -3737,7 +3737,7 @@ static bool menu_displaylist_push_list_process(menu_displaylist_info_t *info)
menu_entries_ctl(MENU_ENTRIES_CTL_REFRESH, info->list); menu_entries_ctl(MENU_ENTRIES_CTL_REFRESH, info->list);
if (info->need_clear) if (info->need_clear)
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); menu_navigation_set_selection(idx);
if (info->need_push) if (info->need_push)
{ {

View File

@ -948,9 +948,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
break; break;
case RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH: case RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH:
{ {
size_t selection; size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
if (!menu_driver_ctx || !menu_driver_ctx->update_thumbnail_path) if (!menu_driver_ctx || !menu_driver_ctx->update_thumbnail_path)
return false; return false;
@ -966,9 +964,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
break; break;
case RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH: case RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH:
{ {
size_t selection; size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
if (!menu_driver_ctx || !menu_driver_ctx->update_savestate_thumbnail_path) if (!menu_driver_ctx || !menu_driver_ctx->update_savestate_thumbnail_path)
return false; return false;

View File

@ -176,13 +176,9 @@ static void menu_entries_build_scroll_indices(file_list_t *list)
**/ **/
static bool menu_entries_refresh(void *data) static bool menu_entries_refresh(void *data)
{ {
size_t list_size, selection; size_t list_size;
file_list_t *list = (file_list_t*)data; file_list_t *list = (file_list_t*)data;
size_t selection = menu_navigation_get_selection();
if (!list)
return false;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
menu_entries_build_scroll_indices(list); menu_entries_build_scroll_indices(list);
@ -192,7 +188,7 @@ static bool menu_entries_refresh(void *data)
{ {
size_t idx = list_size - 1; size_t idx = list_size - 1;
bool scroll = true; bool scroll = true;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); menu_navigation_set_selection(idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
} }
else if (!list_size) else if (!list_size)
@ -636,6 +632,8 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data)
} }
break; break;
case MENU_ENTRIES_CTL_REFRESH: case MENU_ENTRIES_CTL_REFRESH:
if (!data)
return false;
return menu_entries_refresh(data); return menu_entries_refresh(data);
case MENU_ENTRIES_CTL_CLEAR: case MENU_ENTRIES_CTL_CLEAR:
return menu_entries_clear((file_list_t*)data); return menu_entries_clear((file_list_t*)data);

View File

@ -149,10 +149,8 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse,
{ {
if (!mouse_oldleft) if (!mouse_oldleft)
{ {
size_t selection;
menu_input_t *menu_input = menu_input_get_ptr(); menu_input_t *menu_input = menu_input_get_ptr();
size_t selection = menu_navigation_get_selection();
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
BIT64_SET(*input_mouse, MENU_MOUSE_ACTION_BUTTON_L); BIT64_SET(*input_mouse, MENU_MOUSE_ACTION_BUTTON_L);
@ -282,8 +280,7 @@ static int menu_input_mouse_frame(
if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_BUTTON_R)) if (BIT64_GET(mouse_state, MENU_MOUSE_ACTION_BUTTON_R))
{ {
size_t selection; size_t selection = menu_navigation_get_selection();
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL); menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
} }
@ -515,8 +512,7 @@ static int menu_input_pointer_post_iterate(
{ {
if (menu_input->pointer.counter > 32) if (menu_input->pointer.counter > 32)
{ {
size_t selection; size_t selection = menu_navigation_get_selection();
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
if (cbs && cbs->action_start) if (cbs && cbs->action_start)
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_START); return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_START);
@ -547,10 +543,8 @@ static int menu_input_pointer_post_iterate(
{ {
if (!pointer_oldback) if (!pointer_oldback)
{ {
size_t selection;
pointer_oldback = true; pointer_oldback = true;
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); menu_entry_action(entry, (unsigned)menu_navigation_get_selection(), MENU_ACTION_CANCEL);
menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
} }
} }
@ -561,14 +555,11 @@ static int menu_input_pointer_post_iterate(
void menu_input_post_iterate(int *ret, unsigned action) void menu_input_post_iterate(int *ret, unsigned action)
{ {
size_t selection;
menu_entry_t entry; menu_entry_t entry;
menu_file_list_cbs_t *cbs = NULL; menu_file_list_cbs_t *cbs = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
if (selection_buf) if (selection_buf)
cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection); cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection);

View File

@ -26,6 +26,18 @@
#include "menu_driver.h" #include "menu_driver.h"
#include "menu_navigation.h" #include "menu_navigation.h"
static size_t selection_ptr = 0;
size_t menu_navigation_get_selection(void)
{
return selection_ptr;
}
void menu_navigation_set_selection(size_t val)
{
selection_ptr = val;
}
bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data) bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
{ {
/* Quick jumping indices with L/R. /* Quick jumping indices with L/R.
@ -36,7 +48,6 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
unsigned size; unsigned size;
} scroll_index; } scroll_index;
static unsigned scroll_acceleration = 0; static unsigned scroll_acceleration = 0;
static size_t selection_ptr = 0;
switch (state) switch (state)
{ {
@ -47,10 +58,8 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
break; break;
case MENU_NAVIGATION_CTL_CLEAR: case MENU_NAVIGATION_CTL_CLEAR:
{ {
size_t idx = 0;
bool scroll = true; bool scroll = true;
menu_navigation_set_selection(0);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_CLEAR, data); menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_CLEAR, data);
} }
@ -73,7 +82,8 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
{ {
size_t idx = selection_ptr + (*scroll_speed); size_t idx = selection_ptr + (*scroll_speed);
bool scroll = true; bool scroll = true;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_set_selection(idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL); menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL);
} }
@ -121,7 +131,7 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
idx = 0; idx = 0;
} }
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); menu_navigation_set_selection(idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, NULL); menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, NULL);
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_DECREMENT, NULL); menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_DECREMENT, NULL);
@ -135,8 +145,7 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
{ {
size_t menu_list_size = menu_entries_get_size(); size_t menu_list_size = menu_entries_get_size();
size_t new_selection = menu_list_size - 1; size_t new_selection = menu_list_size - 1;
menu_navigation_ctl( menu_navigation_set_selection(new_selection);
MENU_NAVIGATION_CTL_SET_SELECTION, &new_selection);
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_SET_LAST, NULL); menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_SET_LAST, NULL);
} }
break; break;
@ -192,22 +201,6 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
RARCH_MENU_CTL_NAVIGATION_DESCEND_ALPHABET, ptr_out); RARCH_MENU_CTL_NAVIGATION_DESCEND_ALPHABET, ptr_out);
} }
break; break;
case MENU_NAVIGATION_CTL_GET_SELECTION:
{
size_t *sel = (size_t*)data;
if (!sel)
return false;
*sel = selection_ptr;
}
break;
case MENU_NAVIGATION_CTL_SET_SELECTION:
{
size_t *sel = (size_t*)data;
if (!sel)
return false;
selection_ptr = *sel;
}
break;
case MENU_NAVIGATION_CTL_CLEAR_SCROLL_INDICES: case MENU_NAVIGATION_CTL_CLEAR_SCROLL_INDICES:
scroll_index.size = 0; scroll_index.size = 0;
break; break;

View File

@ -35,14 +35,16 @@ enum menu_navigation_ctl_state
MENU_NAVIGATION_CTL_SET_LAST, MENU_NAVIGATION_CTL_SET_LAST,
MENU_NAVIGATION_CTL_DESCEND_ALPHABET, MENU_NAVIGATION_CTL_DESCEND_ALPHABET,
MENU_NAVIGATION_CTL_ASCEND_ALPHABET, MENU_NAVIGATION_CTL_ASCEND_ALPHABET,
MENU_NAVIGATION_CTL_SET_SELECTION,
MENU_NAVIGATION_CTL_GET_SELECTION,
MENU_NAVIGATION_CTL_CLEAR_SCROLL_INDICES, MENU_NAVIGATION_CTL_CLEAR_SCROLL_INDICES,
MENU_NAVIGATION_CTL_ADD_SCROLL_INDEX, MENU_NAVIGATION_CTL_ADD_SCROLL_INDEX,
MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL, MENU_NAVIGATION_CTL_SET_SCROLL_ACCEL,
MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL
}; };
size_t menu_navigation_get_selection(void);
void menu_navigation_set_selection(size_t val);
bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data); bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data);
RETRO_END_DECLS RETRO_END_DECLS

View File

@ -705,13 +705,10 @@ int menu_action_handle_setting(rarch_setting_t *setting,
case ST_PATH: case ST_PATH:
if (action == MENU_ACTION_OK) if (action == MENU_ACTION_OK)
{ {
size_t selection;
menu_displaylist_info_t info = {0}; menu_displaylist_info_t info = {0};
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
const char *name = setting->name; const char *name = setting->name;
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return -1;
info.list = menu_stack; info.list = menu_stack;
info.directory_ptr = selection; info.directory_ptr = selection;
@ -856,15 +853,11 @@ int menu_setting_set_flags(rarch_setting_t *setting)
int menu_setting_set(unsigned type, const char *label, int menu_setting_set(unsigned type, const char *label,
unsigned action, bool wraparound) unsigned action, bool wraparound)
{ {
size_t selection;
int ret = 0; int ret = 0;
menu_file_list_cbs_t *cbs = NULL;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) menu_file_list_cbs_t *cbs = menu_entries_get_actiondata_at_offset(
return 0; selection_buf, selection);
cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection);
if (!cbs) if (!cbs)
return 0; return 0;

View File

@ -452,11 +452,7 @@ void menu_entry_get(menu_entry_t *entry, size_t stack_idx,
bool menu_entry_is_currently_selected(unsigned id) bool menu_entry_is_currently_selected(unsigned id)
{ {
size_t selection; return (id == menu_navigation_get_selection());
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
return (id == selection);
} }
/* Performs whatever actions are associated with menu entry 'i'. /* Performs whatever actions are associated with menu entry 'i'.
@ -481,7 +477,7 @@ int menu_entry_select(uint32_t i)
entry.type = 0; entry.type = 0;
entry.spacing = 0; entry.spacing = 0;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &i); menu_navigation_set_selection(i);
menu_entry_get(&entry, 0, i, NULL, false); menu_entry_get(&entry, 0, i, NULL, false);

View File

@ -83,15 +83,13 @@ static int menu_input_key_bind_set_mode_common(
enum menu_input_binds_ctl_state state, enum menu_input_binds_ctl_state state,
rarch_setting_t *setting) rarch_setting_t *setting)
{ {
size_t selection;
unsigned bind_type = 0; unsigned bind_type = 0;
menu_displaylist_info_t info = {0}; menu_displaylist_info_t info = {0};
struct retro_keybind *keybind = NULL; struct retro_keybind *keybind = NULL;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
unsigned index_offset = setting->index_offset; unsigned index_offset = setting->index_offset;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
size_t selection = menu_navigation_get_selection();
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
switch (state) switch (state)
{ {
@ -103,10 +101,10 @@ static int menu_input_key_bind_set_mode_common(
bind_type = setting_get_bind_type(setting); bind_type = setting_get_bind_type(setting);
menu_input_binds.begin = bind_type; menu_input_binds.begin = bind_type;
menu_input_binds.last = bind_type; menu_input_binds.last = bind_type;
menu_input_binds.target = keybind; menu_input_binds.target = keybind;
menu_input_binds.user = index_offset; menu_input_binds.user = index_offset;
info.list = menu_stack; info.list = menu_stack;
info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD;
@ -119,10 +117,10 @@ static int menu_input_key_bind_set_mode_common(
menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info); menu_displaylist_ctl(DISPLAYLIST_PROCESS, &info);
break; break;
case MENU_INPUT_BINDS_CTL_BIND_ALL: case MENU_INPUT_BINDS_CTL_BIND_ALL:
menu_input_binds.target = &settings->input.binds menu_input_binds.target = &settings->input.binds
[index_offset][0]; [index_offset][0];
menu_input_binds.begin = MENU_SETTINGS_BIND_BEGIN; menu_input_binds.begin = MENU_SETTINGS_BIND_BEGIN;
menu_input_binds.last = MENU_SETTINGS_BIND_LAST; menu_input_binds.last = MENU_SETTINGS_BIND_LAST;
info.list = menu_stack; info.list = menu_stack;
info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD; info.type = MENU_SETTINGS_CUSTOM_BIND_KEYBOARD;

View File

@ -40,7 +40,7 @@ static void menu_input_search_cb(void *userdata, const char *str)
if (str && *str && file_list_search(selection_buf, str, &idx)) if (str && *str && file_list_search(selection_buf, str, &idx))
{ {
bool scroll = true; bool scroll = true;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx); menu_navigation_set_selection(idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll); menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
} }

View File

@ -157,16 +157,12 @@ void menu_list_flush_stack(menu_list_t *list,
while (menu_list_flush_stack_type( while (menu_list_flush_stack_type(
needle, label, type, final_type) != 0) needle, label, type, final_type) != 0)
{ {
size_t new_selection_ptr; size_t new_selection_ptr = menu_navigation_get_selection();
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION,
&new_selection_ptr);
if (!menu_list_pop_stack(list, idx, &new_selection_ptr, 1)) if (!menu_list_pop_stack(list, idx, &new_selection_ptr, 1))
break; break;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, menu_navigation_set_selection(new_selection_ptr);
&new_selection_ptr);
menu_list = menu_list_get(list, (unsigned)idx); menu_list = menu_list_get(list, (unsigned)idx);