ozone: add rudimentary mouse support (not working)

This commit is contained in:
natinusala 2019-02-12 19:00:40 +01:00
parent 4e79f13139
commit 68e54315c3
3 changed files with 53 additions and 5 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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;