From 68e54315c37d1887c36e04e6f234b87560b4ba1c Mon Sep 17 00:00:00 2001 From: natinusala Date: Tue, 12 Feb 2019 19:00:40 +0100 Subject: [PATCH] ozone: add rudimentary mouse support (not working) --- menu/drivers/ozone/ozone.c | 27 ++++++++++++++++++++++++++- menu/drivers/ozone/ozone.h | 2 ++ menu/drivers/ozone/ozone_entries.c | 29 +++++++++++++++++++++++++---- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 72ce1f42a9..c4448d93b1 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -1226,6 +1226,7 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) font_driver_flush(video_info->width, video_info->height, ozone->fonts.entries_label, video_info); /* Cursor */ +#if OZONE_ENABLE_MOUSE if (ozone->show_cursor) { menu_display_set_alpha(ozone_pure_white, 1.0f); @@ -1240,6 +1241,7 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) video_info->height ); } +#endif menu_display_unset_viewport(video_info->width, video_info->height); } @@ -1769,6 +1771,25 @@ static bool ozone_get_load_content_animation_data(void *userdata, menu_texture_i } #endif +#if OZONE_ENABLE_MOUSE +static int ozone_pointer_tap(void *userdata, + unsigned x, unsigned y, unsigned ptr, + menu_file_list_cbs_t *cbs, + menu_entry_t *entry, unsigned action) +{ + ozone_handle_t *ozone = (ozone_handle_t*) userdata; + + size_t selection = menu_navigation_get_selection(); + if (ptr == selection && cbs && cbs->action_select) + return (unsigned)menu_entry_action(entry, (unsigned)selection, MENU_ACTION_SELECT); + + menu_navigation_set_selection(ptr); + menu_driver_navigation_set(false); + + return 0; +} +#endif + menu_ctx_driver_t menu_ctx_ozone = { NULL, /* set_texture */ ozone_messagebox, @@ -1803,7 +1824,11 @@ menu_ctx_driver_t menu_ctx_ozone = { NULL, /* load_image */ "ozone", ozone_environ_cb, - NULL, /* pointer_tap */ +#if OZONE_ENABLE_MOUSE + ozone_pointer_tap, +#else + NULL, +#endif NULL, /* update_thumbnail_path */ NULL, /* update_thumbnail_image */ NULL, /* set_thumbnail_system */ diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 62cd70e909..7eea03b8e8 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -27,6 +27,8 @@ typedef struct ozone_handle ozone_handle_t; #include "../../menu_driver.h" #include "../../../retroarch.h" +#define OZONE_ENABLE_MOUSE 0 /* TODO: remove this define once it works */ + #define ANIMATION_PUSH_ENTRY_DURATION 10 #define ANIMATION_CURSOR_DURATION 8 #define ANIMATION_CURSOR_PULSE 30 diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index e90ef5e105..ab462401cd 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -289,6 +289,10 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, size_t old_selection_y = 0; int entry_padding = ozone_get_entries_padding(ozone, old_list); + int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); + + int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS); + menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); entries_end = file_list_get_size(selection_buf); @@ -322,7 +326,11 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, { bool entry_selected = selection == i; bool entry_old_selected = selection_old == i; + + int border_start_x, border_start_y; + ozone_node_t *node = NULL; + if (entry_selected) selection_y = y; @@ -339,14 +347,27 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, else if (y + scroll_y - node->height - 20 > bottom_boundary) goto border_iterate; + border_start_x = ozone->dimensions.sidebar_width + x_offset + entry_padding; + border_start_y = y + scroll_y; + menu_display_set_alpha(ozone->theme_dynamic.entries_border, alpha); menu_display_set_alpha(ozone->theme_dynamic.entries_checkmark, alpha); /* Borders */ - menu_display_draw_quad(video_info, ozone->dimensions.sidebar_width + x_offset + entry_padding, - y + scroll_y, entry_width, 1, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); - menu_display_draw_quad(video_info, ozone->dimensions.sidebar_width + x_offset + entry_padding, - y + button_height + scroll_y, entry_width, 1, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); + menu_display_draw_quad(video_info, border_start_x, + border_start_y, entry_width, 1, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); + menu_display_draw_quad(video_info, border_start_x, + border_start_y + button_height, entry_width, 1, video_info->width, video_info->height, ozone->theme_dynamic.entries_border); + + /* Mouse click */ +#if OZONE_ENABLE_MOUSE + if (mouse_x >= border_start_x && mouse_x <= border_start_x + entry_width + && mouse_y >= border_start_y && mouse_y <= border_start_y + button_height) + { + selection_y = y; + menu_input_ctl(MENU_INPUT_CTL_MOUSE_PTR, &i); + } +#endif border_iterate: y += node->height;