Merge pull request #2325 from lakkatv/material

(Menu) Make the mouse left click and the pointer tap use the same cod…
This commit is contained in:
Twinaphex 2015-11-01 20:26:11 +01:00
commit 9bc28461f3
6 changed files with 39 additions and 45 deletions

View File

@ -1426,13 +1426,12 @@ static size_t glui_list_get_selection(void *data)
return glui->categories.selection_ptr;
}
static int glui_pointer_tap(menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
static int glui_pointer_tap(unsigned x, unsigned y, unsigned ptr,
menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action)
{
size_t selection, idx;
unsigned header_height, width, height, i;
bool scroll = false;
menu_input_t *menu_input = menu_input_get_ptr();
menu_handle_t *menu = menu_driver_get_ptr();
glui_handle_t *glui = menu ? (glui_handle_t*)menu->userdata : NULL;
file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0);
@ -1446,20 +1445,19 @@ static int glui_pointer_tap(menu_file_list_cbs_t *cbs,
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
if ((unsigned)menu_input->pointer.start_y < header_height)
if (y < header_height)
{
menu_entries_pop_stack(&selection, 0);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
}
else if ((unsigned)menu_input->pointer.start_y > height - glui->tabs_height)
else if (y > height - glui->tabs_height)
{
for (i = 0; i <= GLUI_SYSTEM_TAB_END; i++)
{
unsigned tab_width = width / (GLUI_SYSTEM_TAB_END + 1);
unsigned start = tab_width * i;
if ((unsigned)menu_input->pointer.start_x >= start &&
(unsigned)menu_input->pointer.start_x < start + tab_width)
if (x >= start && x < start + tab_width)
{
glui->categories.selection_ptr = i;
@ -1471,12 +1469,12 @@ static int glui_pointer_tap(menu_file_list_cbs_t *cbs,
}
}
}
else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1))
else if (ptr <= (menu_entries_get_size() - 1))
{
if (menu_input->pointer.ptr == selection && cbs && cbs->action_select)
if (ptr == selection && cbs && cbs->action_select)
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
idx = menu_input->pointer.ptr;
idx = ptr;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);

View File

@ -840,8 +840,8 @@ static int rgui_environ(menu_environ_cb_t type, void *data)
return 0;
}
static int rgui_pointer_tap(menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
static int rgui_pointer_tap(unsigned x, unsigned y, unsigned ptr,
menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action)
{
size_t selection, idx;
unsigned header_height;
@ -851,17 +851,17 @@ static int rgui_pointer_tap(menu_file_list_cbs_t *cbs,
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
if ((unsigned)menu_input->pointer.start_y < header_height)
if (y < header_height)
{
menu_entries_pop_stack(&selection, 0);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
}
else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1))
else if (ptr <= (menu_entries_get_size() - 1))
{
if (menu_input->pointer.ptr == selection && cbs && cbs->action_select)
if (ptr == selection && cbs && cbs->action_select)
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
idx = menu_input->pointer.ptr;
idx = ptr;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);

View File

@ -2723,8 +2723,8 @@ static bool xmb_menu_init_list(void *data)
return true;
}
static int xmb_pointer_tap(menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
static int xmb_pointer_tap(unsigned x, unsigned y, unsigned ptr,
menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action)
{
size_t selection, idx;
unsigned header_height;
@ -2734,17 +2734,17 @@ static int xmb_pointer_tap(menu_file_list_cbs_t *cbs,
menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection);
menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height);
if ((unsigned)menu_input->pointer.start_y < header_height)
if (y < header_height)
{
menu_entries_pop_stack(&selection, 0);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &selection);
}
else if (menu_input->pointer.ptr <= (menu_entries_get_size() - 1))
else if (ptr <= (menu_entries_get_size() - 1))
{
if (menu_input->pointer.ptr == selection && cbs && cbs->action_select)
if (ptr == selection && cbs && cbs->action_select)
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
idx = menu_input->pointer.ptr;
idx = ptr;
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &idx);
menu_navigation_ctl(MENU_NAVIGATION_CTL_SET, &scroll);

View File

@ -393,14 +393,14 @@ bool menu_environment_cb(menu_environ_cb_t type, void *data)
return false;
}
int menu_driver_pointer_tap(menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action)
int menu_driver_pointer_tap(unsigned x, unsigned y, unsigned ptr,
menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action)
{
int ret = 0;
const menu_ctx_driver_t *driver = menu_ctx_driver_get_ptr();
if (driver->pointer_tap)
ret = driver->pointer_tap(cbs, entry, action);
ret = driver->pointer_tap(x, y, ptr, cbs, entry, action);
return ret;
}

View File

@ -142,8 +142,8 @@ typedef struct menu_ctx_driver
const char *ident;
menu_video_driver_type_t type;
int (*environ_cb)(menu_environ_cb_t type, void *data);
int (*pointer_tap)(menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action);
int (*pointer_tap)(unsigned x, unsigned y, unsigned ptr,
menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action);
} menu_ctx_driver_t;
extern menu_ctx_driver_t menu_ctx_rmenu;
@ -230,8 +230,8 @@ int menu_driver_bind_init(menu_file_list_cbs_t *cbs,
const char *elem0, const char *elem1,
uint32_t label_hash, uint32_t menu_label_hash);
int menu_driver_pointer_tap(menu_file_list_cbs_t *cbs,
menu_entry_t *entry, unsigned action);
int menu_driver_pointer_tap(unsigned x, unsigned y, unsigned ptr,
menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action);
/* HACK */
extern unsigned int rdb_entry_start_game_selection_ptr;

View File

@ -790,8 +790,9 @@ static int menu_input_pointer(unsigned *action)
static int menu_input_mouse_frame(
menu_file_list_cbs_t *cbs, menu_entry_t *entry,
uint64_t input_mouse)
uint64_t input_mouse, unsigned action)
{
int ret;
size_t selection;
menu_input_t *menu_input = menu_input_get_ptr();
@ -799,16 +800,8 @@ static int menu_input_mouse_frame(
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L))
{
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_TOGGLE))
return menu_entry_action(entry, selection, MENU_ACTION_SELECT);
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_L_SET_NAVIGATION))
{
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);
}
ret = menu_driver_pointer_tap(menu_input->mouse.x, menu_input->mouse.y,
menu_input->mouse.ptr, cbs, entry, action);
}
if (BIT64_GET(input_mouse, MOUSE_ACTION_BUTTON_R))
@ -829,7 +822,7 @@ static int menu_input_mouse_frame(
menu_navigation_ctl(MENU_NAVIGATION_CTL_DECREMENT, &decrement_by);
}
return 0;
return ret;
}
static int menu_input_mouse_post_iterate(uint64_t *input_mouse,
@ -1029,7 +1022,9 @@ static int menu_input_pointer_post_iterate(menu_file_list_cbs_t *cbs,
if (menu_input->pointer.oldpressed[0])
{
if (!menu_input->pointer.dragging)
ret = menu_driver_pointer_tap(cbs, entry, action);
ret = menu_driver_pointer_tap(menu_input->pointer.start_x,
menu_input->pointer.start_y, menu_input->pointer.ptr,
cbs, entry, action);
menu_input->pointer.oldpressed[0] = false;
menu_input->pointer.start_x = 0;
@ -1075,9 +1070,10 @@ void menu_input_post_iterate(int *ret, unsigned action)
menu_entry_get(&entry, 0, selection, NULL, false);
if (settings->menu.mouse.enable)
*ret = menu_input_mouse_post_iterate (&menu_input->mouse.state, cbs, action);
*ret = menu_input_mouse_frame(cbs, &entry, menu_input->mouse.state);
{
*ret = menu_input_mouse_post_iterate(&menu_input->mouse.state, cbs, action);
*ret |= menu_input_mouse_frame(cbs, &entry, menu_input->mouse.state, action);
}
if (settings->menu.pointer.enable)
*ret |= menu_input_pointer_post_iterate(cbs, &entry, action);