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();
}
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_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_IMAGE, NULL);

View File

@ -29,16 +29,13 @@
static int action_info_default(unsigned type, const char *label)
{
size_t selection = 0;
menu_displaylist_info_t info = {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))
return 0;
info.list = menu_stack;
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,
msg_hash_to_str(MENU_ENUM_LABEL_INFO_SCREEN),
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,
bool wraparound)
{
size_t selection;
size_t scroll_accel = 0;
unsigned scroll_speed = 0, fast_scroll_speed = 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return menu_cbs_exit();
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel))
return false;
@ -131,7 +130,7 @@ static int action_left_scroll(unsigned type, const char *label,
{
size_t idx = selection - fast_scroll_speed;
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);
}
else
@ -147,7 +146,6 @@ static int action_left_mainmenu(unsigned type, const char *label,
bool wraparound)
{
menu_ctx_list_t list_info;
size_t selection = 0;
unsigned push_list = 0;
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();
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
menu_navigation_set_selection(0);
if ((list_info.selection != 0)
|| settings->menu.navigation.wraparound.enable)
push_list = 1;
@ -172,8 +171,6 @@ static int action_left_mainmenu(unsigned type, const char *label,
else
push_list = 2;
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
switch (push_list)
{
@ -182,12 +179,13 @@ static int action_left_mainmenu(unsigned type, const char *label,
menu_ctx_list_t list_info;
file_list_t *menu_stack = menu_entries_get_menu_stack_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_entries_get_actiondata_at_offset(selection_buf,
selection);
list_info.type = MENU_LIST_HORIZONTAL;
list_info.action = MENU_ACTION_LEFT;
list_info.type = MENU_LIST_HORIZONTAL;
list_info.action = MENU_ACTION_LEFT;
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;
char new_core_path[PATH_MAX_LENGTH];
content_ctx_info_t content_info = {0};
size_t selection = 0;
size_t selection_ptr = 0;
bool playlist_initialized = false;
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))
return menu_cbs_exit();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return menu_cbs_exit();
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,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
size_t selection;
menu_content_ctx_playlist_info_t playlist_info;
content_ctx_info_t content_info = {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))
return menu_cbs_exit();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return menu_cbs_exit();
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;
content_ctx_info_t content_info = {0};
size_t selection = 0;
size_t selection_ptr = 0;
bool playlist_initialized = false;
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))
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);
@ -2054,15 +2045,12 @@ static int action_ok_path_scan_directory(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)
{
size_t selection;
char core_display_name[PATH_MAX_LENGTH];
playlist_t *playlist = NULL;
size_t selection = menu_navigation_get_selection();
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);
retro_assert(playlist != NULL);
@ -2080,7 +2068,7 @@ static int action_ok_core_deferred_set(const char *path,
playlist_write_file(playlist);
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();
}
@ -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,
const char *label, unsigned type, size_t idx, size_t entry_idx)
{
size_t selection;
char core_display_name[PATH_MAX_LENGTH];
playlist_t *playlist = NULL;
size_t selection = menu_navigation_get_selection();
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);
retro_assert(playlist != NULL);
@ -2114,7 +2099,7 @@ static int action_ok_core_deferred_set_current_core(const char *path,
playlist_write_file(playlist);
menu_entries_pop_stack(&selection, 0, 1);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
menu_navigation_set_selection(selection);
return 0;
}
@ -2932,9 +2917,9 @@ static int action_ok_delete_entry(const char *path,
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_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &new_selection_ptr);
menu_navigation_set_selection(new_selection_ptr);
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))
return menu_cbs_exit();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &idx))
return false;
menu_path = menu->scratch2_buf;
content_path = menu->scratch_buf;
menu_path = menu->scratch2_buf;
content_path = menu->scratch_buf;
core_info_get_list(&list);
@ -3894,9 +3876,12 @@ static int action_ok_load_archive_detect_core(const char *path,
}
return 0;
case 0:
return generic_action_ok_displaylist_push(path, NULL,
label, type,
idx, entry_idx, ACTION_OK_DL_DEFERRED_CORE_LIST);
{
idx = menu_navigation_get_selection();
return generic_action_ok_displaylist_push(path, NULL,
label, type,
idx, entry_idx, ACTION_OK_DL_DEFERRED_CORE_LIST);
}
default:
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,
bool wraparound)
{
size_t selection;
size_t scroll_accel = 0;
unsigned scroll_speed = 0, fast_scroll_speed = 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
size_t selection = menu_navigation_get_selection();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SCROLL_ACCEL, &scroll_accel))
return false;
@ -141,7 +140,8 @@ static int action_right_scroll(unsigned type, const char *label,
{
size_t idx = selection + fast_scroll_speed;
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);
}
else
@ -156,17 +156,13 @@ static int action_right_scroll(unsigned type, const char *label,
static int action_right_goto_tab(void)
{
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 *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);
cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection);
list_info.type = MENU_LIST_HORIZONTAL;
list_info.action = MENU_ACTION_RIGHT;
list_info.type = MENU_LIST_HORIZONTAL;
list_info.action = MENU_ACTION_RIGHT;
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_tabs_info;
size_t selection = 0;
settings_t *settings = config_get_ptr();
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_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))
|| settings->menu.navigation.wraparound.enable)

View File

@ -808,26 +808,16 @@ static void mui_render_menu_list(
for (; i < menu_entries_get_end(); i++)
{
int y;
size_t selection;
char rich_label[255];
char entry_value[255];
bool entry_selected = false;
mui_node_t *node = (mui_node_t*)
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] =
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_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));
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
selection = menu_navigation_get_selection();
if (background_rendered || libretro_running)
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)
{
size_t selection;
unsigned width, height, half = 0;
size_t selection = menu_navigation_get_selection();
if (!mui)
return 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0;
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)
{
size_t idx = 0;
size_t stack_size = 0;
file_list_t *menu_stack = NULL;
size_t idx = menu_navigation_get_selection();
if (!mui)
return;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_stack = menu_entries_get_menu_stack_ptr(0);
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)
&& y < (-mui->scroll_y + header_height + node->y + node->line_height)
)
{
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &ii);
}
menu_navigation_set_selection(ii);
}
@ -1949,7 +1932,6 @@ static int mui_pointer_up(void *userdata,
unsigned ptr, menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
{
size_t selection;
unsigned width, height;
unsigned header_height, i;
mui_handle_t *mui = (mui_handle_t*)userdata;
@ -1962,7 +1944,7 @@ static int mui_pointer_up(void *userdata,
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);
}
else if (y > height - mui->tabs_height)
@ -2016,16 +1998,14 @@ static void mui_list_insert(void *userdata,
const char *unused,
size_t list_size)
{
size_t selection;
float scale_factor;
int i = (int)list_size;
mui_node_t *node = NULL;
mui_handle_t *mui = (mui_handle_t*)userdata;
size_t selection = menu_navigation_get_selection();
if (!mui || !list)
return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
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;
enum action_iterate_type iterate_type;
size_t selection = 0;
unsigned file_type = 0;
int ret = 0;
uint32_t hash = 0;
enum msg_hash_enums enum_idx = MSG_UNKNOWN;
const char *label = NULL;
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);
if (!menu)
return 0;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 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))
{
menu_entries_pop_stack(&selection, 0, 0);
menu_navigation_ctl(
MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
menu_navigation_set_selection(selection);
}
else
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;
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))

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)
{
int ret;
size_t selection;
menu_entry_t entry;
nk_menu_handle_t *nk = (nk_menu_handle_t*)userdata;
size_t selection = menu_navigation_get_selection();
if (!nk)
return -1;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0;
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)
{
menu_animation_ctx_ticker_t ticker;
size_t selection;
char entry_path[255];
char entry_value[255];
char message[255];
@ -582,9 +581,7 @@ static void rgui_render(void *data)
char type_str_buf[255];
unsigned entry_spacing = menu_entry_get_spacing((unsigned)i);
bool entry_selected = menu_entry_is_currently_selected((unsigned)i);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
continue;
size_t selection = menu_navigation_get_selection();
if (i > (selection + 100))
continue;
@ -763,12 +760,12 @@ static void rgui_navigation_clear(void *data, bool pending_push)
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;
bool do_set_start = false;
size_t end = menu_entries_get_end();
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
size_t selection = menu_navigation_get_selection();
if (!scroll)
return;
@ -850,25 +847,22 @@ static int rgui_pointer_tap(void *data,
unsigned ptr, menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
{
size_t selection;
unsigned header_height = menu_display_get_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);
}
else if (ptr <= (menu_entries_get_size() - 1))
{
size_t idx;
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)
return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT);
idx = ptr;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_set_selection(ptr);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
}

View File

@ -1073,17 +1073,16 @@ static void xmb_selection_pointer_changed(
{
unsigned i, end, height;
menu_animation_ctx_tag_t tag;
size_t selection, num = 0;
size_t num = 0;
int threshold = 0;
menu_list_t *menu_list = NULL;
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);
if (!xmb)
return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
end = (unsigned)menu_entries_get_end();
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)
{
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);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
size_t selection = menu_navigation_get_selection();
if (xmb->categories.selection_ptr > xmb->categories.selection_ptr_old)
dir = 1;
@ -1868,12 +1864,9 @@ static void xmb_list_open(xmb_handle_t *xmb)
{
menu_animation_ctx_entry_t entry;
size_t selection;
int dir = 0;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
size_t selection = menu_navigation_get_selection();
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)
{
size_t selection;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
size_t selection = menu_navigation_get_selection();
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_white);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
selection = menu_navigation_get_selection();
strlcpy(title_truncated, xmb->title_name, sizeof(title_truncated));
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)
{
size_t selection;
unsigned width, height, i, current, end;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
size_t selection = menu_navigation_get_selection();
video_driver_get_size(&width, &height);
@ -3604,16 +3590,14 @@ static void xmb_list_insert(void *userdata,
const char *unused,
size_t list_size)
{
size_t selection;
int current = 0;
int i = (int)list_size;
xmb_node_t *node = NULL;
xmb_handle_t *xmb = (xmb_handle_t*)userdata;
size_t selection = menu_navigation_get_selection();
if (!xmb || !list)
return;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
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)
{
size_t stack_size, list_size, selection;
size_t stack_size, list_size;
xmb_handle_t *xmb = (xmb_handle_t*)data;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
size_t selection = menu_navigation_get_selection();
if (!xmb)
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(menu_stack, xmb->menu_stack_old);
@ -4059,26 +4042,21 @@ static int xmb_pointer_tap(void *userdata,
menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
{
size_t selection;
unsigned header_height = menu_display_get_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);
}
else if (ptr <= (menu_entries_get_size() - 1))
{
size_t idx;
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)
return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT);
idx = ptr;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_set_selection(ptr);
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);
}
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
selection = menu_navigation_get_selection();
XuiListSetCurSelVisible(m_menulist, selection);
@ -610,31 +609,19 @@ static void xui_populate_entries(void *data,
const char *path,
const char *label, unsigned i)
{
size_t selection;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
(void)label;
(void)path;
size_t selection = menu_navigation_get_selection();
XuiListSetCurSelVisible(m_menulist, selection);
}
static void xui_navigation_clear(void *data, bool pending_push)
{
size_t selection;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
size_t selection = menu_navigation_get_selection();
XuiListSetCurSelVisible(m_menulist, selection);
}
static void xui_navigation_set_visible(void *data)
{
size_t selection;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
size_t selection = menu_navigation_get_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)
{
int ret;
size_t selection;
menu_entry_t entry;
zui_t *zui = (zui_t*)userdata;
size_t selection = menu_navigation_get_selection();
if (!zui)
return -1;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0;
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);
if (info->need_clear)
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_set_selection(idx);
if (info->need_push)
{

View File

@ -948,9 +948,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
break;
case RARCH_MENU_CTL_UPDATE_THUMBNAIL_PATH:
{
size_t selection;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
size_t selection = menu_navigation_get_selection();
if (!menu_driver_ctx || !menu_driver_ctx->update_thumbnail_path)
return false;
@ -966,9 +964,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data)
break;
case RARCH_MENU_CTL_UPDATE_SAVESTATE_THUMBNAIL_PATH:
{
size_t selection;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
size_t selection = menu_navigation_get_selection();
if (!menu_driver_ctx || !menu_driver_ctx->update_savestate_thumbnail_path)
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)
{
size_t list_size, selection;
size_t list_size;
file_list_t *list = (file_list_t*)data;
if (!list)
return false;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
size_t selection = menu_navigation_get_selection();
menu_entries_build_scroll_indices(list);
@ -192,7 +188,7 @@ static bool menu_entries_refresh(void *data)
{
size_t idx = list_size - 1;
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);
}
else if (!list_size)
@ -636,6 +632,8 @@ bool menu_entries_ctl(enum menu_entries_ctl_state state, void *data)
}
break;
case MENU_ENTRIES_CTL_REFRESH:
if (!data)
return false;
return menu_entries_refresh(data);
case MENU_ENTRIES_CTL_CLEAR:
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)
{
size_t selection;
menu_input_t *menu_input = menu_input_get_ptr();
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
size_t selection = menu_navigation_get_selection();
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))
{
size_t selection;
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
size_t selection = menu_navigation_get_selection();
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)
{
size_t selection;
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
size_t selection = menu_navigation_get_selection();
if (cbs && cbs->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)
{
size_t selection;
pointer_oldback = true;
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
menu_entry_action(entry, (unsigned)selection, MENU_ACTION_CANCEL);
menu_entry_action(entry, (unsigned)menu_navigation_get_selection(), MENU_ACTION_CANCEL);
}
}
@ -561,14 +555,11 @@ static int menu_input_pointer_post_iterate(
void menu_input_post_iterate(int *ret, unsigned action)
{
size_t selection;
menu_entry_t entry;
menu_file_list_cbs_t *cbs = NULL;
settings_t *settings = config_get_ptr();
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return;
size_t selection = menu_navigation_get_selection();
if (selection_buf)
cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection);

View File

@ -26,6 +26,18 @@
#include "menu_driver.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)
{
/* Quick jumping indices with L/R.
@ -36,7 +48,6 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
unsigned size;
} scroll_index;
static unsigned scroll_acceleration = 0;
static size_t selection_ptr = 0;
switch (state)
{
@ -47,10 +58,8 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
break;
case MENU_NAVIGATION_CTL_CLEAR:
{
size_t idx = 0;
bool scroll = true;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_set_selection(0);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
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);
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_INCREMENT, NULL);
}
@ -121,7 +131,7 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
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_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 new_selection = menu_list_size - 1;
menu_navigation_ctl(
MENU_NAVIGATION_CTL_SET_SELECTION, &new_selection);
menu_navigation_set_selection(new_selection);
menu_driver_ctl(RARCH_MENU_CTL_NAVIGATION_SET_LAST, NULL);
}
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);
}
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:
scroll_index.size = 0;
break;

View File

@ -35,14 +35,16 @@ enum menu_navigation_ctl_state
MENU_NAVIGATION_CTL_SET_LAST,
MENU_NAVIGATION_CTL_DESCEND_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_ADD_SCROLL_INDEX,
MENU_NAVIGATION_CTL_SET_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);
RETRO_END_DECLS

View File

@ -705,13 +705,10 @@ int menu_action_handle_setting(rarch_setting_t *setting,
case ST_PATH:
if (action == MENU_ACTION_OK)
{
size_t selection;
menu_displaylist_info_t info = {0};
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
const char *name = setting->name;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return -1;
size_t selection = menu_navigation_get_selection();
info.list = menu_stack;
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,
unsigned action, bool wraparound)
{
size_t selection;
int ret = 0;
menu_file_list_cbs_t *cbs = NULL;
file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0);
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return 0;
cbs = menu_entries_get_actiondata_at_offset(selection_buf, selection);
size_t selection = menu_navigation_get_selection();
menu_file_list_cbs_t *cbs = menu_entries_get_actiondata_at_offset(
selection_buf, selection);
if (!cbs)
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)
{
size_t selection;
if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection))
return false;
return (id == selection);
return (id == menu_navigation_get_selection());
}
/* Performs whatever actions are associated with menu entry 'i'.
@ -481,7 +477,7 @@ int menu_entry_select(uint32_t i)
entry.type = 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);

View File

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

View File

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