mirror of
https://github.com/libretro/RetroArch
synced 2025-02-17 15:41:01 +00:00
Refactor menu_navigation.c
This commit is contained in:
parent
7df7201b31
commit
df35e9fb75
@ -58,7 +58,7 @@ static int glui_entry_iterate(unsigned action)
|
||||
return -1;
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset(
|
||||
menu->menu_list->selection_buf, menu->selection_ptr);
|
||||
menu->menu_list->selection_buf, menu->navigation.selection_ptr);
|
||||
|
||||
menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL);
|
||||
|
||||
@ -396,7 +396,7 @@ static void glui_frame(void)
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
selected = (i == menu->selection_ptr);
|
||||
selected = (i == menu->navigation.selection_ptr);
|
||||
|
||||
menu_animation_ticker_line(entry_title_buf, glui->term_width - (w + 1 + 2),
|
||||
g_extern.frame_count / glui->margin, path_buf, selected);
|
||||
@ -588,13 +588,13 @@ static void glui_navigation_set(bool scroll)
|
||||
if (!scroll)
|
||||
return;
|
||||
|
||||
if (menu->selection_ptr < glui->term_height/2)
|
||||
if (menu->navigation.selection_ptr < glui->term_height/2)
|
||||
menu->begin = 0;
|
||||
else if (menu->selection_ptr >= glui->term_height/2
|
||||
&& menu->selection_ptr <
|
||||
else if (menu->navigation.selection_ptr >= glui->term_height/2
|
||||
&& menu->navigation.selection_ptr <
|
||||
menu_list_get_size(menu->menu_list) - glui->term_height/2)
|
||||
menu->begin = menu->selection_ptr - glui->term_height/2;
|
||||
else if (menu->selection_ptr >=
|
||||
menu->begin = menu->navigation.selection_ptr - glui->term_height/2;
|
||||
else if (menu->navigation.selection_ptr >=
|
||||
menu_list_get_size(menu->menu_list) - glui->term_height/2)
|
||||
menu->begin = menu_list_get_size(menu->menu_list)
|
||||
- glui->term_height;
|
||||
|
@ -46,7 +46,7 @@ static int rgui_entry_iterate(unsigned action)
|
||||
return -1;
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)menu_list_get_actiondata_at_offset(
|
||||
menu->menu_list->selection_buf, menu->selection_ptr);
|
||||
menu->menu_list->selection_buf, menu->navigation.selection_ptr);
|
||||
|
||||
menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL);
|
||||
|
||||
@ -418,9 +418,9 @@ static void rgui_render(void)
|
||||
entry_label, path,
|
||||
path_buf, sizeof(path_buf));
|
||||
|
||||
selected = (i == menu->selection_ptr);
|
||||
selected = (i == menu->navigation.selection_ptr);
|
||||
|
||||
if (i > (menu->selection_ptr + 100))
|
||||
if (i > (menu->navigation.selection_ptr + 100))
|
||||
continue;
|
||||
|
||||
menu_animation_ticker_line(entry_title_buf, RGUI_TERM_WIDTH - (w + 1 + 2),
|
||||
@ -555,13 +555,13 @@ static void rgui_navigation_set(bool scroll)
|
||||
if (!scroll)
|
||||
return;
|
||||
|
||||
if (menu->selection_ptr < RGUI_TERM_HEIGHT/2)
|
||||
if (menu->navigation.selection_ptr < RGUI_TERM_HEIGHT/2)
|
||||
menu->begin = 0;
|
||||
else if (menu->selection_ptr >= RGUI_TERM_HEIGHT/2
|
||||
&& menu->selection_ptr <
|
||||
else if (menu->navigation.selection_ptr >= RGUI_TERM_HEIGHT/2
|
||||
&& menu->navigation.selection_ptr <
|
||||
menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT/2)
|
||||
menu->begin = menu->selection_ptr - RGUI_TERM_HEIGHT/2;
|
||||
else if (menu->selection_ptr >=
|
||||
menu->begin = menu->navigation.selection_ptr - RGUI_TERM_HEIGHT/2;
|
||||
else if (menu->navigation.selection_ptr >=
|
||||
menu_list_get_size(menu->menu_list) - RGUI_TERM_HEIGHT/2)
|
||||
menu->begin = menu_list_get_size(menu->menu_list)
|
||||
- RGUI_TERM_HEIGHT;
|
||||
|
@ -245,7 +245,7 @@ static int xmb_entry_iterate(unsigned action)
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
|
||||
menu_list_get_last_stack(menu->menu_list, NULL, &label, NULL);
|
||||
|
||||
@ -529,7 +529,7 @@ static void xmb_selection_pointer_changed(void)
|
||||
if (!xmb)
|
||||
return;
|
||||
|
||||
current = menu->selection_ptr;
|
||||
current = menu->navigation.selection_ptr;
|
||||
end = menu_list_get_size(menu->menu_list);
|
||||
|
||||
for (i = 0; i < end; i++)
|
||||
@ -818,7 +818,7 @@ static void xmb_list_open(xmb_handle_t *xmb)
|
||||
dir = 1;
|
||||
|
||||
xmb_list_switch_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old);
|
||||
xmb_list_switch_new(xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr);
|
||||
xmb_list_switch_new(xmb, menu->menu_list->selection_buf, dir, menu->navigation.selection_ptr);
|
||||
xmb->categories.active.idx_old = menu->categories.selection_ptr;
|
||||
}
|
||||
|
||||
@ -856,7 +856,7 @@ static void xmb_list_switch(xmb_handle_t *xmb)
|
||||
}
|
||||
|
||||
xmb_list_open_old(xmb, xmb->selection_buf_old, dir, xmb->selection_ptr_old);
|
||||
xmb_list_open_new(xmb, menu->menu_list->selection_buf, dir, menu->selection_ptr);
|
||||
xmb_list_open_new(xmb, menu->menu_list->selection_buf, dir, menu->navigation.selection_ptr);
|
||||
|
||||
switch (xmb->depth)
|
||||
{
|
||||
@ -1155,7 +1155,7 @@ static void xmb_frame(void)
|
||||
xmb_draw_items(xmb, gl,
|
||||
menu->menu_list->selection_buf,
|
||||
menu->menu_list->menu_stack,
|
||||
menu->selection_ptr,
|
||||
menu->navigation.selection_ptr,
|
||||
menu->categories.selection_ptr);
|
||||
|
||||
for (i = 0; i < menu->categories.size; i++)
|
||||
@ -1591,7 +1591,7 @@ static void xmb_list_insert(file_list_t *list,
|
||||
if (!node)
|
||||
return;
|
||||
|
||||
current = menu->selection_ptr;
|
||||
current = menu->navigation.selection_ptr;
|
||||
|
||||
node->alpha = xmb->item.passive.alpha;
|
||||
node->zoom = xmb->item.passive.zoom;
|
||||
@ -1634,7 +1634,7 @@ static void xmb_list_cache(bool horizontal, unsigned action)
|
||||
|
||||
file_list_copy(menu->menu_list->selection_buf, xmb->selection_buf_old);
|
||||
file_list_copy(menu->menu_list->menu_stack, xmb->menu_stack_old);
|
||||
xmb->selection_ptr_old = menu->selection_ptr;
|
||||
xmb->selection_ptr_old = menu->navigation.selection_ptr;
|
||||
|
||||
if(!horizontal)
|
||||
return;
|
||||
|
@ -95,7 +95,7 @@ static int menu_action_handle_setting(rarch_setting_t *setting,
|
||||
setting->default_value.string,
|
||||
setting->name,
|
||||
type,
|
||||
driver.menu->selection_ptr);
|
||||
driver.menu->navigation.selection_ptr);
|
||||
/* fall-through. */
|
||||
case ST_BOOL:
|
||||
case ST_INT:
|
||||
@ -124,7 +124,7 @@ int menu_action_setting_set(unsigned type, const char *label, unsigned action)
|
||||
{
|
||||
rarch_setting_t *setting = menu_action_find_setting(
|
||||
driver.menu->menu_list->selection_buf->list
|
||||
[driver.menu->selection_ptr].label);
|
||||
[driver.menu->navigation.selection_ptr].label);
|
||||
|
||||
if (!setting)
|
||||
return 0;
|
||||
|
@ -76,6 +76,22 @@ typedef struct menu_framebuf
|
||||
size_t pitch;
|
||||
} menu_framebuf_t;
|
||||
|
||||
typedef struct menu_navigation
|
||||
{
|
||||
struct
|
||||
{
|
||||
/* Quick jumping indices with L/R.
|
||||
* Rebuilt when parsing directory. */
|
||||
struct
|
||||
{
|
||||
size_t list[2 * (26 + 2) + 1];
|
||||
unsigned size;
|
||||
} indices;
|
||||
unsigned acceleration;
|
||||
} scroll;
|
||||
size_t selection_ptr;
|
||||
} menu_navigation_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void *userdata;
|
||||
@ -90,6 +106,7 @@ typedef struct
|
||||
size_t begin;
|
||||
|
||||
menu_list_t *menu_list;
|
||||
menu_navigation_t navigation;
|
||||
|
||||
struct
|
||||
{
|
||||
@ -97,7 +114,6 @@ typedef struct
|
||||
size_t size;
|
||||
} categories;
|
||||
|
||||
size_t selection_ptr;
|
||||
bool need_refresh;
|
||||
bool msg_force;
|
||||
bool push_start_screen;
|
||||
@ -111,17 +127,6 @@ typedef struct
|
||||
*/
|
||||
char message_contents[PATH_MAX_LENGTH];
|
||||
|
||||
/* Quick jumping indices with L/R.
|
||||
* Rebuilt when parsing directory. */
|
||||
struct
|
||||
{
|
||||
struct
|
||||
{
|
||||
size_t list[2 * (26 + 2) + 1];
|
||||
unsigned size;
|
||||
} indices;
|
||||
unsigned acceleration;
|
||||
} scroll;
|
||||
|
||||
char default_glslp[PATH_MAX_LENGTH];
|
||||
char default_cgp[PATH_MAX_LENGTH];
|
||||
|
@ -521,7 +521,7 @@ bool menu_entries_init(menu_handle_t *menu)
|
||||
menu->list_settings = setting_data_new(SL_FLAG_ALL);
|
||||
|
||||
menu_list_push_stack(menu->menu_list, "", "Main Menu", MENU_SETTINGS, 0);
|
||||
menu_navigation_clear(true);
|
||||
menu_navigation_clear(&menu->navigation, true);
|
||||
menu_entries_push_list(menu, menu->menu_list->selection_buf,
|
||||
"", "Main Menu", 0, SL_FLAG_MAIN_MENU);
|
||||
|
||||
|
@ -156,7 +156,7 @@ static int archive_open(void)
|
||||
return 0;
|
||||
|
||||
menu_list_get_at_offset(menu->menu_list->selection_buf,
|
||||
menu->selection_ptr, &path, NULL, &type);
|
||||
menu->navigation.selection_ptr, &path, NULL, &type);
|
||||
|
||||
fill_pathname_join(cat_path, menu_path, path, sizeof(cat_path));
|
||||
menu_list_push_stack_refresh(
|
||||
@ -164,7 +164,7 @@ static int archive_open(void)
|
||||
cat_path,
|
||||
menu_label,
|
||||
type,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -202,7 +202,7 @@ static int archive_load(void)
|
||||
return 0;
|
||||
|
||||
menu_list_get_at_offset(menu->menu_list->selection_buf,
|
||||
menu->selection_ptr, &path, NULL, &type);
|
||||
menu->navigation.selection_ptr, &path, NULL, &type);
|
||||
|
||||
ret = rarch_defer_core(g_extern.core_info, menu_path, path, menu_label,
|
||||
menu->deferred_path, sizeof(menu->deferred_path));
|
||||
@ -219,7 +219,7 @@ static int archive_load(void)
|
||||
g_settings.libretro_directory,
|
||||
"deferred_core_list",
|
||||
0,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ static int action_ok_playlist_entry(const char *path,
|
||||
return -1;
|
||||
|
||||
rarch_playlist_load_content(g_defaults.history,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
menu_list_flush_stack(menu->menu_list, MENU_SETTINGS);
|
||||
return -1;
|
||||
}
|
||||
@ -1410,7 +1410,7 @@ static int action_ok_config_load(const char *path,
|
||||
menu->msg_force = true;
|
||||
if (rarch_replace_config(config))
|
||||
{
|
||||
menu_navigation_clear(false);
|
||||
menu_navigation_clear(&menu->navigation, false);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -2164,24 +2164,26 @@ static int action_toggle_scroll(unsigned type, const char *label,
|
||||
if (!menu)
|
||||
return -1;
|
||||
|
||||
scroll_speed = (max(menu->scroll.acceleration, 2) - 2) / 4 + 1;
|
||||
scroll_speed = (max(menu->navigation.scroll.acceleration, 2) - 2) / 4 + 1;
|
||||
fast_scroll_speed = 4 + 4 * scroll_speed;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case MENU_ACTION_LEFT:
|
||||
if (menu->selection_ptr > fast_scroll_speed)
|
||||
menu_navigation_set(menu->selection_ptr - fast_scroll_speed, true);
|
||||
if (menu->navigation.selection_ptr > fast_scroll_speed)
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu->navigation.selection_ptr - fast_scroll_speed, true);
|
||||
else
|
||||
menu_navigation_clear(false);
|
||||
menu_navigation_clear(&menu->navigation, false);
|
||||
break;
|
||||
case MENU_ACTION_RIGHT:
|
||||
if (menu->selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list)))
|
||||
menu_navigation_set(menu->selection_ptr + fast_scroll_speed, true);
|
||||
if (menu->navigation.selection_ptr + fast_scroll_speed < (menu_list_get_size(menu->menu_list)))
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu->navigation.selection_ptr + fast_scroll_speed, true);
|
||||
else
|
||||
{
|
||||
if ((menu_list_get_size(menu->menu_list) > 0))
|
||||
menu_navigation_set_last();
|
||||
menu_navigation_set_last(&menu->navigation);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -2202,7 +2204,7 @@ static int action_toggle_mainmenu(unsigned type, const char *label,
|
||||
{
|
||||
if (!strcmp(driver.menu_ctx->ident, "xmb"))
|
||||
{
|
||||
menu->selection_ptr = 0;
|
||||
menu->navigation.selection_ptr = 0;
|
||||
switch (action)
|
||||
{
|
||||
case MENU_ACTION_LEFT:
|
||||
@ -2223,7 +2225,7 @@ static int action_toggle_mainmenu(unsigned type, const char *label,
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
|
||||
switch (push_list)
|
||||
{
|
||||
@ -3897,7 +3899,7 @@ static int action_bind_up_or_down_generic(unsigned type, const char *label,
|
||||
if (!menu)
|
||||
return -1;
|
||||
|
||||
scroll_speed = (max(menu->scroll.acceleration, 2) - 2) / 4 + 1;
|
||||
scroll_speed = (max(menu->navigation.scroll.acceleration, 2) - 2) / 4 + 1;
|
||||
|
||||
if (menu_list_get_size(menu->menu_list) <= 0)
|
||||
return 0;
|
||||
@ -3905,25 +3907,29 @@ static int action_bind_up_or_down_generic(unsigned type, const char *label,
|
||||
switch (action)
|
||||
{
|
||||
case MENU_ACTION_UP:
|
||||
if (menu->selection_ptr >= scroll_speed)
|
||||
menu_navigation_set(menu->selection_ptr - scroll_speed, true);
|
||||
if (menu->navigation.selection_ptr >= scroll_speed)
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu->navigation.selection_ptr - scroll_speed, true);
|
||||
else
|
||||
{
|
||||
if (g_settings.menu.navigation.wraparound.vertical_enable)
|
||||
menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true);
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu_list_get_size(menu->menu_list) - 1, true);
|
||||
else
|
||||
menu_navigation_set(0, true);
|
||||
menu_navigation_set(&menu->navigation, 0, true);
|
||||
}
|
||||
break;
|
||||
case MENU_ACTION_DOWN:
|
||||
if (menu->selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list)))
|
||||
menu_navigation_set(menu->selection_ptr + scroll_speed, true);
|
||||
if (menu->navigation.selection_ptr + scroll_speed < (menu_list_get_size(menu->menu_list)))
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu->navigation.selection_ptr + scroll_speed, true);
|
||||
else
|
||||
{
|
||||
if (g_settings.menu.navigation.wraparound.vertical_enable)
|
||||
menu_navigation_clear(false);
|
||||
menu_navigation_clear(&menu->navigation, false);
|
||||
else
|
||||
menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true);
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu_list_get_size(menu->menu_list) - 1, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -3956,7 +3962,7 @@ static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path,
|
||||
return 0;
|
||||
|
||||
if (menu->mouse.ptr <= menu_list_get_size(menu->menu_list)-1)
|
||||
menu_navigation_set(menu->mouse.ptr, false);
|
||||
menu_navigation_set(&menu->navigation, menu->mouse.ptr, false);
|
||||
|
||||
if (menu->mouse.left)
|
||||
{
|
||||
@ -3965,7 +3971,8 @@ static int mouse_post_iterate(menu_file_list_cbs_t *cbs, const char *path,
|
||||
menu->mouse.oldleft = true;
|
||||
|
||||
if (cbs && cbs->action_ok)
|
||||
return cbs->action_ok(path, label, type, menu->selection_ptr);
|
||||
return cbs->action_ok(path, label, type,
|
||||
menu->navigation.selection_ptr);
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -4069,13 +4076,13 @@ static int action_iterate_info(const char *label, unsigned action)
|
||||
|
||||
current_setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
menu->list_settings,
|
||||
list->list[menu->selection_ptr].label);
|
||||
list->list[menu->navigation.selection_ptr].label);
|
||||
|
||||
if (current_setting)
|
||||
strlcpy(needle, current_setting->name, sizeof(needle));
|
||||
else if ((current_setting = (rarch_setting_t*)setting_data_find_setting(
|
||||
menu->list_settings,
|
||||
list->list[menu->selection_ptr].label)))
|
||||
list->list[menu->navigation.selection_ptr].label)))
|
||||
{
|
||||
if (current_setting)
|
||||
strlcpy(needle, current_setting->name, sizeof(needle));
|
||||
@ -4084,7 +4091,7 @@ static int action_iterate_info(const char *label, unsigned action)
|
||||
{
|
||||
const char *lbl = NULL;
|
||||
menu_list_get_at_offset(list,
|
||||
menu->selection_ptr, NULL, &lbl,
|
||||
menu->navigation.selection_ptr, NULL, &lbl,
|
||||
&info_type);
|
||||
|
||||
if (lbl)
|
||||
@ -4101,7 +4108,7 @@ static int action_iterate_info(const char *label, unsigned action)
|
||||
}
|
||||
|
||||
if (action == MENU_ACTION_OK)
|
||||
menu_list_pop(menu->menu_list->menu_stack, &menu->selection_ptr);
|
||||
menu_list_pop(menu->menu_list->menu_stack, &menu->navigation.selection_ptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -4205,7 +4212,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action)
|
||||
{
|
||||
menu_list_push_stack(menu->menu_list, "", "",
|
||||
MENU_SETTINGS_CUSTOM_VIEWPORT,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4216,7 +4223,7 @@ static int action_iterate_menu_viewport(const char *label, unsigned action)
|
||||
&& !g_settings.video.scale_integer)
|
||||
{
|
||||
menu_list_push_stack(menu->menu_list, "",
|
||||
"custom_viewport_2", 0, menu->selection_ptr);
|
||||
"custom_viewport_2", 0, menu->navigation.selection_ptr);
|
||||
}
|
||||
break;
|
||||
|
||||
@ -4396,10 +4403,10 @@ static int action_iterate_main(const char *label, unsigned action)
|
||||
|
||||
cbs = (menu_file_list_cbs_t*)
|
||||
menu_list_get_actiondata_at_offset(menu->menu_list->selection_buf,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
|
||||
menu_list_get_at_offset(menu->menu_list->selection_buf,
|
||||
menu->selection_ptr, &path_offset, &label_offset, &type_offset);
|
||||
menu->navigation.selection_ptr, &path_offset, &label_offset, &type_offset);
|
||||
|
||||
mouse_iterate(action);
|
||||
|
||||
@ -4439,20 +4446,20 @@ static int action_iterate_main(const char *label, unsigned action)
|
||||
ret = cbs->action_up_or_down(type_offset, label_offset, action);
|
||||
break;
|
||||
case MENU_ACTION_SCROLL_UP:
|
||||
menu_navigation_descend_alphabet(&menu->selection_ptr);
|
||||
menu_navigation_descend_alphabet(&menu->navigation, &menu->navigation.selection_ptr);
|
||||
break;
|
||||
case MENU_ACTION_SCROLL_DOWN:
|
||||
menu_navigation_ascend_alphabet(&menu->selection_ptr);
|
||||
menu_navigation_ascend_alphabet(&menu->navigation, &menu->navigation.selection_ptr);
|
||||
break;
|
||||
|
||||
case MENU_ACTION_CANCEL:
|
||||
if (cbs && cbs->action_cancel)
|
||||
return cbs->action_cancel(path_offset, label_offset, type_offset, menu->selection_ptr);
|
||||
return cbs->action_cancel(path_offset, label_offset, type_offset, menu->navigation.selection_ptr);
|
||||
break;
|
||||
|
||||
case MENU_ACTION_OK:
|
||||
if (cbs && cbs->action_ok)
|
||||
return cbs->action_ok(path_offset, label_offset, type_offset, menu->selection_ptr);
|
||||
return cbs->action_ok(path_offset, label_offset, type_offset, menu->navigation.selection_ptr);
|
||||
break;
|
||||
case MENU_ACTION_START:
|
||||
if (cbs && cbs->action_start)
|
||||
@ -4514,7 +4521,7 @@ static int action_select_default(unsigned type, const char *label,
|
||||
if (!menu)
|
||||
return 0;
|
||||
menu_list_push_stack(menu->menu_list, "", "info_screen",
|
||||
0, menu->selection_ptr);
|
||||
0, menu->navigation.selection_ptr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ static void menu_input_search_callback(void *userdata, const char *str)
|
||||
return;
|
||||
|
||||
if (str && *str && file_list_search(menu->menu_list->selection_buf, str, &idx))
|
||||
menu_navigation_set(idx, true);
|
||||
menu_navigation_set(&menu->navigation, idx, true);
|
||||
|
||||
menu_input_key_end_line();
|
||||
}
|
||||
@ -482,8 +482,8 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
{
|
||||
first_held = false;
|
||||
trigger_input |= input & input_repeat;
|
||||
menu->scroll.acceleration =
|
||||
min(menu->scroll.acceleration + 1, 64);
|
||||
menu->navigation.scroll.acceleration =
|
||||
min(menu->navigation.scroll.acceleration + 1, 64);
|
||||
}
|
||||
|
||||
initial_held = false;
|
||||
@ -492,7 +492,7 @@ unsigned menu_input_frame(retro_input_t input, retro_input_t trigger_input)
|
||||
{
|
||||
first_held = false;
|
||||
initial_held = true;
|
||||
menu->scroll.acceleration = 0;
|
||||
menu->navigation.scroll.acceleration = 0;
|
||||
}
|
||||
|
||||
menu->mouse.enable = g_settings.menu.mouse_enable;
|
||||
|
@ -36,11 +36,12 @@ static void menu_entries_refresh(file_list_t *list)
|
||||
if (!list)
|
||||
return;
|
||||
|
||||
if (menu->selection_ptr >= menu_list_get_size(menu->menu_list)
|
||||
if (menu->navigation.selection_ptr >= menu_list_get_size(menu->menu_list)
|
||||
&& menu_list_get_size(menu->menu_list))
|
||||
menu_navigation_set(menu_list_get_size(menu->menu_list) - 1, true);
|
||||
menu_navigation_set(&menu->navigation,
|
||||
menu_list_get_size(menu->menu_list) - 1, true);
|
||||
else if (!menu_list_get_size(menu->menu_list))
|
||||
menu_navigation_clear(true);
|
||||
menu_navigation_clear(&menu->navigation, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -97,16 +98,23 @@ static void menu_entries_build_scroll_indices(file_list_t *list)
|
||||
size_t i;
|
||||
int current;
|
||||
bool current_is_dir;
|
||||
menu_navigation_t *nav = NULL;
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
|
||||
if (!menu || !list)
|
||||
return;
|
||||
|
||||
menu->scroll.indices.size = 0;
|
||||
nav = &menu->navigation;
|
||||
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
nav->scroll.indices.size = 0;
|
||||
|
||||
if (!list->size)
|
||||
return;
|
||||
|
||||
menu->scroll.indices.list[menu->scroll.indices.size++] = 0;
|
||||
nav->scroll.indices.list[nav->scroll.indices.size++] = 0;
|
||||
|
||||
current = menu_entries_list_get_first_char(list, 0);
|
||||
current_is_dir = menu_entries_list_elem_is_dir(list, 0);
|
||||
@ -117,13 +125,13 @@ static void menu_entries_build_scroll_indices(file_list_t *list)
|
||||
bool is_dir = menu_entries_list_elem_is_dir(list, i);
|
||||
|
||||
if ((current_is_dir && !is_dir) || (first > current))
|
||||
menu->scroll.indices.list[menu->scroll.indices.size++] = i;
|
||||
nav->scroll.indices.list[nav->scroll.indices.size++] = i;
|
||||
|
||||
current = first;
|
||||
current_is_dir = is_dir;
|
||||
}
|
||||
|
||||
menu->scroll.indices.list[menu->scroll.indices.size++] =
|
||||
nav->scroll.indices.list[nav->scroll.indices.size++] =
|
||||
list->size - 1;
|
||||
}
|
||||
|
||||
@ -241,7 +249,7 @@ void menu_list_flush_stack(menu_list_t *list,
|
||||
|
||||
while (type != final_type)
|
||||
{
|
||||
menu_list_pop(list->menu_stack, &menu->selection_ptr);
|
||||
menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr);
|
||||
file_list_get_last(list->menu_stack, &path, &label, &type);
|
||||
}
|
||||
}
|
||||
@ -261,7 +269,7 @@ void menu_list_flush_stack_by_needle(menu_list_t *list,
|
||||
|
||||
while (strcmp(needle, label) != 0)
|
||||
{
|
||||
menu_list_pop(list->menu_stack, &menu->selection_ptr);
|
||||
menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr);
|
||||
file_list_get_last(list->menu_stack, &path, &label, &type);
|
||||
}
|
||||
}
|
||||
@ -278,7 +286,7 @@ void menu_list_pop_stack(menu_list_t *list)
|
||||
if (driver.menu_ctx->list_cache)
|
||||
driver.menu_ctx->list_cache(false, 0);
|
||||
|
||||
menu_list_pop(list->menu_stack, &menu->selection_ptr);
|
||||
menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr);
|
||||
menu->need_refresh = true;
|
||||
}
|
||||
|
||||
@ -298,7 +306,7 @@ void menu_list_pop_stack_by_needle(menu_list_t *list,
|
||||
|
||||
while (strcmp(needle, label) == 0)
|
||||
{
|
||||
menu_list_pop(list->menu_stack, &menu->selection_ptr);
|
||||
menu_list_pop(list->menu_stack, &menu->navigation.selection_ptr);
|
||||
file_list_get_last(list->menu_stack, &path, &label, &type);
|
||||
}
|
||||
}
|
||||
@ -374,7 +382,7 @@ void menu_list_push_refresh(file_list_t *list,
|
||||
return;
|
||||
|
||||
menu_list_push(list, path, label, type, directory_ptr);
|
||||
menu_navigation_clear(true);
|
||||
menu_navigation_clear(&menu->navigation, true);
|
||||
menu->need_refresh = true;
|
||||
}
|
||||
|
||||
@ -398,7 +406,7 @@ int menu_list_push_stack_refresh(menu_list_t *list, const char *path, const char
|
||||
driver.menu_ctx->list_cache(false, 0);
|
||||
|
||||
menu_list_push_stack(list, path, label, type, directory_ptr);
|
||||
menu_navigation_clear(true);
|
||||
menu_navigation_clear(&menu->navigation, true);
|
||||
menu->need_refresh = true;
|
||||
|
||||
return 0;
|
||||
@ -429,7 +437,7 @@ int menu_list_populate_generic(file_list_t *list, const char *path,
|
||||
if (!menu)
|
||||
return -1;
|
||||
|
||||
menu->scroll.indices.size = 0;
|
||||
menu->navigation.scroll.indices.size = 0;
|
||||
|
||||
menu_entries_build_scroll_indices(list);
|
||||
menu_entries_refresh(list);
|
||||
|
@ -28,13 +28,12 @@
|
||||
*
|
||||
* Clears the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_clear(bool pending_push)
|
||||
void menu_navigation_clear(menu_navigation_t *nav, bool pending_push)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
if (!menu)
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
menu->selection_ptr = 0;
|
||||
nav->selection_ptr = 0;
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_clear)
|
||||
driver.menu_ctx->navigation_clear(pending_push);
|
||||
@ -45,13 +44,12 @@ void menu_navigation_clear(bool pending_push)
|
||||
*
|
||||
* Decrement the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_decrement(void)
|
||||
void menu_navigation_decrement(menu_navigation_t *nav)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
if (!menu)
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
menu->selection_ptr--;
|
||||
nav->selection_ptr--;
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_decrement)
|
||||
driver.menu_ctx->navigation_decrement();
|
||||
@ -62,13 +60,12 @@ void menu_navigation_decrement(void)
|
||||
*
|
||||
* Increment the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_increment(void)
|
||||
void menu_navigation_increment(menu_navigation_t *nav)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
if (!menu)
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
menu->selection_ptr++;
|
||||
nav->selection_ptr++;
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_increment)
|
||||
driver.menu_ctx->navigation_increment();
|
||||
@ -81,13 +78,13 @@ void menu_navigation_increment(void)
|
||||
*
|
||||
* Sets navigation pointer to index @idx.
|
||||
**/
|
||||
void menu_navigation_set(size_t idx, bool scroll)
|
||||
void menu_navigation_set(menu_navigation_t *nav,
|
||||
size_t idx, bool scroll)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
if (!menu)
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
menu->selection_ptr = idx;
|
||||
nav->selection_ptr = idx;
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_set)
|
||||
driver.menu_ctx->navigation_set(scroll);
|
||||
@ -98,13 +95,13 @@ void menu_navigation_set(size_t idx, bool scroll)
|
||||
*
|
||||
* Sets navigation pointer to last index.
|
||||
**/
|
||||
void menu_navigation_set_last(void)
|
||||
void menu_navigation_set_last(menu_navigation_t *nav)
|
||||
{
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
if (!menu)
|
||||
if (!menu || !nav)
|
||||
return;
|
||||
|
||||
menu->selection_ptr = menu_list_get_size(driver.menu->menu_list) - 1;
|
||||
nav->selection_ptr = menu_list_get_size(menu->menu_list) - 1;
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_set_last)
|
||||
driver.menu_ctx->navigation_set_last();
|
||||
@ -120,25 +117,23 @@ void menu_navigation_set_last(void)
|
||||
* If navigation points to an entry called 'Beta',
|
||||
* navigation pointer will be set to an entry called 'Alpha'.
|
||||
**/
|
||||
void menu_navigation_descend_alphabet(size_t *ptr_out)
|
||||
void menu_navigation_descend_alphabet(menu_navigation_t *nav, size_t *ptr_out)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t ptr = *ptr_out;
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
if (!menu)
|
||||
size_t i = 0, ptr = *ptr_out;
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
if (!menu->scroll.indices.size)
|
||||
if (!nav->scroll.indices.size)
|
||||
return;
|
||||
|
||||
if (ptr == 0)
|
||||
return;
|
||||
|
||||
i = menu->scroll.indices.size - 1;
|
||||
i = nav->scroll.indices.size - 1;
|
||||
|
||||
while (i && menu->scroll.indices.list[i - 1] >= ptr)
|
||||
while (i && nav->scroll.indices.list[i - 1] >= ptr)
|
||||
i--;
|
||||
*ptr_out = menu->scroll.indices.list[i - 1];
|
||||
*ptr_out = nav->scroll.indices.list[i - 1];
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet)
|
||||
driver.menu_ctx->navigation_descend_alphabet(ptr_out);
|
||||
@ -154,24 +149,22 @@ void menu_navigation_descend_alphabet(size_t *ptr_out)
|
||||
* If navigation points to an entry called 'Alpha',
|
||||
* navigation pointer will be set to an entry called 'Beta'.
|
||||
**/
|
||||
void menu_navigation_ascend_alphabet(size_t *ptr_out)
|
||||
void menu_navigation_ascend_alphabet(menu_navigation_t *nav, size_t *ptr_out)
|
||||
{
|
||||
size_t i = 0;
|
||||
size_t ptr = *ptr_out;
|
||||
menu_handle_t *menu = menu_driver_resolve();
|
||||
if (!menu)
|
||||
size_t i = 0, ptr = *ptr_out;
|
||||
if (!nav)
|
||||
return;
|
||||
|
||||
if (!menu->scroll.indices.size)
|
||||
if (!nav->scroll.indices.size)
|
||||
return;
|
||||
|
||||
if (ptr == menu->scroll.indices.list[menu->scroll.indices.size - 1])
|
||||
if (ptr == nav->scroll.indices.list[nav->scroll.indices.size - 1])
|
||||
return;
|
||||
|
||||
while (i < menu->scroll.indices.size - 1
|
||||
&& menu->scroll.indices.list[i + 1] <= ptr)
|
||||
while (i < nav->scroll.indices.size - 1
|
||||
&& nav->scroll.indices.list[i + 1] <= ptr)
|
||||
i++;
|
||||
*ptr_out = menu->scroll.indices.list[i + 1];
|
||||
*ptr_out = nav->scroll.indices.list[i + 1];
|
||||
|
||||
if (driver.menu_ctx && driver.menu_ctx->navigation_descend_alphabet)
|
||||
driver.menu_ctx->navigation_descend_alphabet(ptr_out);
|
||||
|
@ -29,21 +29,21 @@ extern "C" {
|
||||
*
|
||||
* Clears the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_clear(bool pending_push);
|
||||
void menu_navigation_clear(menu_navigation_t *nav, bool pending_push);
|
||||
|
||||
/**
|
||||
* menu_navigation_decrement:
|
||||
*
|
||||
* Decrement the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_decrement(void);
|
||||
void menu_navigation_decrement(menu_navigation_t *nav);
|
||||
|
||||
/**
|
||||
* menu_navigation_increment:
|
||||
*
|
||||
* Increment the navigation pointer.
|
||||
**/
|
||||
void menu_navigation_increment(void);
|
||||
void menu_navigation_increment(menu_navigation_t *nav);
|
||||
|
||||
/**
|
||||
* menu_navigation_set:
|
||||
@ -52,14 +52,14 @@ void menu_navigation_increment(void);
|
||||
*
|
||||
* Sets navigation pointer to index @idx.
|
||||
**/
|
||||
void menu_navigation_set(size_t i, bool scroll);
|
||||
void menu_navigation_set(menu_navigation_t *nav, size_t i, bool scroll);
|
||||
|
||||
/**
|
||||
* menu_navigation_set_last:
|
||||
*
|
||||
* Sets navigation pointer to last index.
|
||||
**/
|
||||
void menu_navigation_set_last(void);
|
||||
void menu_navigation_set_last(menu_navigation_t *nav);
|
||||
|
||||
/**
|
||||
* menu_navigation_descend_alphabet:
|
||||
@ -71,7 +71,7 @@ void menu_navigation_set_last(void);
|
||||
* If navigation points to an entry called 'Beta',
|
||||
* navigation pointer will be set to an entry called 'Alpha'.
|
||||
**/
|
||||
void menu_navigation_descend_alphabet(size_t *ptr_out);
|
||||
void menu_navigation_descend_alphabet(menu_navigation_t *nav, size_t *ptr_out);
|
||||
|
||||
/**
|
||||
* menu_navigation_ascends_alphabet:
|
||||
@ -83,7 +83,7 @@ void menu_navigation_descend_alphabet(size_t *ptr_out);
|
||||
* If navigation points to an entry called 'Alpha',
|
||||
* navigation pointer will be set to an entry called 'Beta'.
|
||||
**/
|
||||
void menu_navigation_ascend_alphabet(size_t *ptr_out);
|
||||
void menu_navigation_ascend_alphabet(menu_navigation_t *nav, size_t *ptr_out);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -831,7 +831,7 @@ static int setting_data_action_ok_bind_all(void *data, unsigned action)
|
||||
g_extern.menu.bind_mode_keyboard ?
|
||||
MENU_SETTINGS_CUSTOM_BIND_KEYBOARD :
|
||||
MENU_SETTINGS_CUSTOM_BIND,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
|
||||
if (g_extern.menu.bind_mode_keyboard)
|
||||
{
|
||||
@ -1029,7 +1029,7 @@ static int setting_data_bind_action_ok(void *data, unsigned action)
|
||||
"custom_bind",
|
||||
g_extern.menu.bind_mode_keyboard ?
|
||||
MENU_SETTINGS_CUSTOM_BIND_KEYBOARD : MENU_SETTINGS_CUSTOM_BIND,
|
||||
menu->selection_ptr);
|
||||
menu->navigation.selection_ptr);
|
||||
|
||||
if (g_extern.menu.bind_mode_keyboard)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user