Refactor menu_navigation_increment
This commit is contained in:
parent
f0b76fa5b0
commit
5f4827f6d9
|
@ -30,7 +30,7 @@ static int action_bind_down_generic(unsigned type, const char *label)
|
||||||
if (menu_list_get_size(menu_list) <= 0)
|
if (menu_list_get_size(menu_list) <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
menu_navigation_increment(nav, scroll_speed);
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, &scroll_speed);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -902,7 +902,10 @@ static int menu_input_mouse_frame(
|
||||||
menu_list_pop_stack(menu_list, &nav->selection_ptr);
|
menu_list_pop_stack(menu_list, &nav->selection_ptr);
|
||||||
|
|
||||||
if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_DOWN))
|
if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_DOWN))
|
||||||
menu_navigation_increment(nav, 1);
|
{
|
||||||
|
unsigned increment_by = 1;
|
||||||
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, &increment_by);
|
||||||
|
}
|
||||||
|
|
||||||
if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_UP))
|
if (BIT64_GET(input_mouse, MOUSE_ACTION_WHEEL_UP))
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,8 +44,36 @@ bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case MENU_NAVIGATION_CTL_INCREMENT:
|
case MENU_NAVIGATION_CTL_INCREMENT:
|
||||||
|
{
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
menu_list_t *menu_list = menu_list_get_ptr();
|
||||||
|
size_t selection = nav->selection_ptr;
|
||||||
|
unsigned *scroll_speed = (unsigned*)data;
|
||||||
|
|
||||||
|
if (!scroll_speed)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if ((selection + (*scroll_speed)) < (menu_list_get_size(menu_list)))
|
||||||
|
{
|
||||||
|
menu_navigation_set(nav, selection + (*scroll_speed), true);
|
||||||
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (settings->menu.navigation.wraparound.vertical_enable)
|
||||||
|
menu_navigation_clear(nav, false);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ((menu_list_get_size(menu_list) > 0))
|
||||||
|
{
|
||||||
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL);
|
||||||
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (driver->navigation_increment)
|
if (driver->navigation_increment)
|
||||||
driver->navigation_increment();
|
driver->navigation_increment();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
case MENU_NAVIGATION_CTL_DECREMENT:
|
case MENU_NAVIGATION_CTL_DECREMENT:
|
||||||
{
|
{
|
||||||
|
@ -130,41 +158,6 @@ void menu_navigation_clear(menu_navigation_t *nav, bool pending_push)
|
||||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);
|
menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* menu_navigation_increment:
|
|
||||||
*
|
|
||||||
* Increment the navigation pointer.
|
|
||||||
**/
|
|
||||||
void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed)
|
|
||||||
{
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
menu_list_t *menu_list = menu_list_get_ptr();
|
|
||||||
size_t selection = nav->selection_ptr;
|
|
||||||
|
|
||||||
if (!nav)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if ((selection + scroll_speed) < (menu_list_get_size(menu_list)))
|
|
||||||
{
|
|
||||||
menu_navigation_set(nav, selection + scroll_speed, true);
|
|
||||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (settings->menu.navigation.wraparound.vertical_enable)
|
|
||||||
menu_navigation_clear(nav, false);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ((menu_list_get_size(menu_list) > 0))
|
|
||||||
{
|
|
||||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_LAST, NULL);
|
|
||||||
menu_navigation_ctl(MENU_NAVIGATION_CTL_INCREMENT, NULL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* menu_navigation_set:
|
* menu_navigation_set:
|
||||||
* @idx : index to set navigation pointer to.
|
* @idx : index to set navigation pointer to.
|
||||||
|
|
|
@ -63,13 +63,6 @@ enum menu_navigation_ctl_state
|
||||||
**/
|
**/
|
||||||
void menu_navigation_clear(menu_navigation_t *nav, bool pending_push);
|
void menu_navigation_clear(menu_navigation_t *nav, bool pending_push);
|
||||||
|
|
||||||
/**
|
|
||||||
* menu_navigation_increment:
|
|
||||||
*
|
|
||||||
* Increment the navigation pointer.
|
|
||||||
**/
|
|
||||||
void menu_navigation_increment(menu_navigation_t *nav, unsigned scroll_speed);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* menu_navigation_set:
|
* menu_navigation_set:
|
||||||
* @idx : index to set navigation pointer to.
|
* @idx : index to set navigation pointer to.
|
||||||
|
@ -112,6 +105,8 @@ void menu_navigation_ascend_alphabet(menu_navigation_t *nav, size_t *ptr_out);
|
||||||
|
|
||||||
size_t menu_navigation_get_selection(menu_navigation_t *nav);
|
size_t menu_navigation_get_selection(menu_navigation_t *nav);
|
||||||
|
|
||||||
|
bool menu_navigation_ctl(enum menu_navigation_ctl_state state, void *data);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue