Add MENU_CTL_MOUSE_PTR

This commit is contained in:
twinaphex 2015-09-24 19:51:55 +02:00
parent 3fb90871f6
commit aed44e970c
4 changed files with 16 additions and 3 deletions

View File

@ -245,6 +245,7 @@ static void glui_render(void)
if (settings->menu.mouse.enable)
{
unsigned new_mouse_ptr = 0;
bool mouse_scrolldown, mouse_scrollup;
int16_t mouse_y = menu_input_pointer_state(MENU_MOUSE_Y_AXIS);
@ -257,9 +258,11 @@ static void glui_render(void)
if (mouse_scrollup)
menu->scroll_y -= 10;
menu_input->mouse.ptr =
new_mouse_ptr =
(mouse_y - glui->line_height + menu->scroll_y - 16)
/ glui->line_height;
menu_input_ctl(MENU_CTL_MOUSE_PTR, &new_mouse_ptr);
}
if (menu->scroll_y < 0)

View File

@ -454,6 +454,7 @@ static void rgui_render(void)
if (settings->menu.mouse.enable)
{
unsigned new_mouse_ptr;
bool mouse_scrolldown, mouse_scrollup;
menu_input_ctl(MENU_CTL_MOUSE_SCROLL_DOWN, &mouse_scrolldown);
@ -466,7 +467,9 @@ static void rgui_render(void)
if (mouse_scrollup && (menu_entries_get_start() > 0))
menu_entries_set_start(menu_entries_get_start() - 1);
menu_input->mouse.ptr = menu_input->mouse.y / 11 - 2 + menu_entries_get_start();
new_mouse_ptr = menu_input->mouse.y / 11 - 2 + menu_entries_get_start();
menu_input_ctl(MENU_CTL_MOUSE_PTR, &new_mouse_ptr);
}
/* Do not scroll if all items are visible. */

View File

@ -81,6 +81,12 @@ bool menu_input_ctl(enum menu_ctl_state state, void *data)
*ptr = menu_input->mouse.scrollup;
}
return true;
case MENU_CTL_MOUSE_PTR:
{
unsigned *ptr = (unsigned*)data;
menu_input->mouse.ptr = *ptr;
}
return true;
}
return false;

View File

@ -76,7 +76,8 @@ enum menu_input_mouse_state
enum menu_ctl_state
{
MENU_CTL_MOUSE_SCROLL_DOWN = 0,
MENU_CTL_MOUSE_SCROLL_UP
MENU_CTL_MOUSE_SCROLL_UP,
MENU_CTL_MOUSE_PTR
};
enum mouse_action