From 130e3a77d80f726bd7a7275fde65465adcd58482 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 5 Mar 2017 09:49:22 +0100 Subject: [PATCH] (GLUI) Fix the menu entry being selected while we try to scroll --- menu/drivers/materialui.c | 67 +++++++++++---------------------------- 1 file changed, 19 insertions(+), 48 deletions(-) diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 953f231935..d2fe2ef76c 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1898,48 +1898,6 @@ static size_t mui_list_get_selection(void *data) return mui->categories.selection_ptr; } -static int mui_pointer_down(void *userdata, - unsigned x, unsigned y, - unsigned ptr, menu_file_list_cbs_t *cbs, - menu_entry_t *entry, unsigned action) -{ - unsigned width, height; - unsigned header_height, i; - mui_handle_t *mui = (mui_handle_t*)userdata; - - if (!mui) - return 0; - - header_height = menu_display_get_header_height(); - video_driver_get_size(&width, &height); - - if (y < header_height) - { - // do nothing - } - else if (y > height - mui->tabs_height) - { - // do nothing - } - else if (ptr <= (menu_entries_get_size() - 1)) - { - size_t ii = 0; - file_list_t *list = menu_entries_get_selection_buf_ptr(0); - for (ii = 0; ii < menu_entries_get_size(); ii++) - { - mui_node_t *node = (mui_node_t*) - menu_entries_get_userdata_at_offset(list, ii); - - if (y > (-mui->scroll_y + header_height + node->y) - && y < (-mui->scroll_y + header_height + node->y + node->line_height) - ) - menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &ii); - } - } - - return 0; -} - static int mui_pointer_up(void *userdata, unsigned x, unsigned y, unsigned ptr, menu_file_list_cbs_t *cbs, @@ -1985,11 +1943,24 @@ static int mui_pointer_up(void *userdata, } else if (ptr <= (menu_entries_get_size() - 1)) { - size_t idx; - bool scroll = false; - menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); - if (ptr == selection && cbs && cbs->action_select) - return menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT); + size_t ii = 0; + file_list_t *list = menu_entries_get_selection_buf_ptr(0); + for (ii = 0; ii < menu_entries_get_size(); ii++) + { + mui_node_t *node = (mui_node_t*) + menu_entries_get_userdata_at_offset(list, ii); + + if (y > (-mui->scroll_y + header_height + node->y) + && y < (-mui->scroll_y + header_height + node->y + node->line_height) + ) + { + menu_navigation_ctl(MENU_NAVIGATION_CTL_SET_SELECTION, &ii); + if (ptr == ii && cbs && cbs->action_select) + return menu_entry_action(entry, (unsigned)ii, MENU_ACTION_SELECT); + } + } + + } return 0; @@ -2099,6 +2070,6 @@ menu_ctx_driver_t menu_ctx_mui = { mui_osk_ptr_at_pos, NULL, NULL, - mui_pointer_down, + NULL, mui_pointer_up, };