mirror of
https://github.com/libretro/RetroArch
synced 2025-01-30 12:32:52 +00:00
Refactor away menu_navigation_set
This commit is contained in:
parent
f0b093ee2c
commit
8b569e0443
@ -103,7 +103,12 @@ static int action_left_scroll(unsigned type, const char *label,
|
||||
fast_scroll_speed = 4 + 4 * scroll_speed;
|
||||
|
||||
if (selection > fast_scroll_speed)
|
||||
menu_navigation_set(nav, selection - fast_scroll_speed, true);
|
||||
{
|
||||
size_t idx = selection - fast_scroll_speed;
|
||||
bool scroll = true;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool pending_push = false;
|
||||
|
@ -131,7 +131,12 @@ static int action_right_scroll(unsigned type, const char *label,
|
||||
fast_scroll_speed = 4 + 4 * scroll_speed;
|
||||
|
||||
if (selection + fast_scroll_speed < (menu_list_get_size(menu_list)))
|
||||
menu_navigation_set(nav, selection + fast_scroll_speed, true);
|
||||
{
|
||||
size_t idx = selection + fast_scroll_speed;
|
||||
bool scroll = true;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((menu_list_get_size(menu_list) > 0))
|
||||
|
@ -220,7 +220,12 @@ static void menu_list_refresh(file_list_t *list)
|
||||
list_size = menu_list_get_size(menu_list);
|
||||
|
||||
if ((nav->selection_ptr >= list_size) && list_size)
|
||||
menu_navigation_set(nav, list_size - 1, true);
|
||||
{
|
||||
size_t idx = list_size - 1;
|
||||
bool scroll = true;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
else if (!list_size)
|
||||
{
|
||||
bool pending_push = true;
|
||||
|
@ -278,7 +278,11 @@ static void menu_input_search_callback(void *userdata, const char *str)
|
||||
return;
|
||||
|
||||
if (str && *str && file_list_search(menu_list->selection_buf, str, &idx))
|
||||
menu_navigation_set(nav, idx, true);
|
||||
{
|
||||
bool scroll = true;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
|
||||
menu_input_key_end_line();
|
||||
}
|
||||
@ -895,7 +899,12 @@ static int menu_input_mouse_frame(
|
||||
return menu_entry_action(entry, nav->selection_ptr, MENU_ACTION_SELECT);
|
||||
|
||||
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION))
|
||||
menu_navigation_set(nav, menu_input->mouse.ptr, false);
|
||||
{
|
||||
size_t idx = menu_input->mouse.ptr;
|
||||
bool scroll = false;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
}
|
||||
|
||||
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_R))
|
||||
@ -1003,7 +1012,12 @@ static int pointer_tap(menu_file_list_cbs_t *cbs,
|
||||
&& cbs && cbs->action_select)
|
||||
return menu_entry_action(entry, nav->selection_ptr, MENU_ACTION_SELECT);
|
||||
else
|
||||
menu_navigation_set(nav, menu_input->pointer.ptr, false);
|
||||
{
|
||||
size_t idx = menu_input->pointer.ptr;
|
||||
bool scroll = false;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -39,12 +39,15 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
{
|
||||
case MENU_NAVIGATION_CTL_CLEAR:
|
||||
{
|
||||
size_t idx = 0;
|
||||
bool scroll = true;
|
||||
bool *pending_push = (bool*)data;
|
||||
|
||||
if (!pending_push)
|
||||
return false;
|
||||
|
||||
menu_navigation_set(nav, 0, true);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
if (driver->navigation_clear)
|
||||
driver->navigation_clear(*pending_push);
|
||||
}
|
||||
@ -59,7 +62,10 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
|
||||
if ((selection + (*scroll_speed)) < (menu_list_get_size(menu_list)))
|
||||
{
|
||||
menu_navigation_set(nav, selection + (*scroll_speed), true);
|
||||
size_t idx = selection + (*scroll_speed);
|
||||
bool scroll = true;
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL);
|
||||
}
|
||||
else
|
||||
@ -84,6 +90,8 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
return true;
|
||||
case MENU_NAVIGATION_CTL_DECREMENT:
|
||||
{
|
||||
size_t idx = 0;
|
||||
bool scroll = true;
|
||||
size_t selection = nav->selection_ptr;
|
||||
unsigned *scroll_speed = (unsigned*)data;
|
||||
|
||||
@ -91,17 +99,17 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
return false;
|
||||
|
||||
if (selection >= *scroll_speed)
|
||||
menu_navigation_set(nav, selection - *scroll_speed, true);
|
||||
idx = selection - *scroll_speed;
|
||||
else
|
||||
{
|
||||
if (settings->menu.navigation.wraparound.vertical_enable)
|
||||
menu_navigation_set(nav,
|
||||
menu_list_get_size(menu_list) - 1, true);
|
||||
else
|
||||
menu_navigation_set(nav, 0, true);
|
||||
idx = menu_list_get_size(menu_list) - 1;
|
||||
if (!settings->menu.navigation.wraparound.vertical_enable)
|
||||
idx = 0;
|
||||
}
|
||||
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, NULL);
|
||||
|
||||
if (driver->navigation_decrement)
|
||||
driver->navigation_decrement();
|
||||
}
|
||||
@ -165,20 +173,6 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu_navigation_set:
|
||||
* @idx : index to set navigation pointer to.
|
||||
* @scroll : should we scroll when needed?
|
||||
*
|
||||
* Sets navigation pointer to index @idx.
|
||||
**/
|
||||
void menu_navigation_set(menu_navigation_t *nav,
|
||||
size_t idx, bool scroll)
|
||||
{
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
|
||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);
|
||||
}
|
||||
|
||||
/**
|
||||
* menu_navigation_descend_alphabet:
|
||||
* @ptr_out : Amount of indices to 'scroll' to get
|
||||
|
@ -57,15 +57,6 @@ enum menu_navigation_ctl_state
|
||||
MENU_NAVIGATION_CTL_GET_SELECTION
|
||||
};
|
||||
|
||||
/**
|
||||
* menu_navigation_set:
|
||||
* @idx : index to set navigation pointer to.
|
||||
* @scroll : should we scroll when needed?
|
||||
*
|
||||
* Sets navigation pointer to index @idx.
|
||||
**/
|
||||
void menu_navigation_set(menu_navigation_t *nav, size_t i, bool scroll);
|
||||
|
||||
/**
|
||||
* menu_navigation_descend_alphabet:
|
||||
* @ptr_out : Amount of indices to 'scroll' to get
|
||||
|
Loading…
x
Reference in New Issue
Block a user