mirror of
https://github.com/libretro/RetroArch
synced 2025-03-20 10:20:51 +00:00
ozone: full mouse support on entries (no sidebar yet)
This commit is contained in:
parent
cb9d227db5
commit
492590a0ae
@ -151,6 +151,10 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
|
||||
ozone->pending_message = NULL;
|
||||
ozone->show_cursor = false;
|
||||
|
||||
ozone->cursor_mode = false;
|
||||
ozone->cursor_x_old = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
||||
ozone->cursor_y_old = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||
|
||||
ozone->system_tab_end = 0;
|
||||
ozone->tabs[ozone->system_tab_end] = OZONE_SYSTEM_TAB_MAIN;
|
||||
if (settings->bools.menu_content_show_settings && !settings->bools.kiosk_mode_enable)
|
||||
@ -1226,7 +1230,6 @@ 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);
|
||||
@ -1241,7 +1244,6 @@ 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);
|
||||
}
|
||||
@ -1264,7 +1266,8 @@ static void ozone_set_header(ozone_handle_t *ozone)
|
||||
static void ozone_animation_end(void *userdata)
|
||||
{
|
||||
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
|
||||
ozone->draw_old_list = false;
|
||||
ozone->draw_old_list = false;
|
||||
ozone->animations.cursor_alpha = 1.0f;
|
||||
}
|
||||
|
||||
static void ozone_list_open(ozone_handle_t *ozone)
|
||||
@ -1276,13 +1279,13 @@ static void ozone_list_open(ozone_handle_t *ozone)
|
||||
/* Left/right animation */
|
||||
ozone->animations.list_alpha = 0.0f;
|
||||
|
||||
entry.cb = ozone_animation_end;
|
||||
entry.duration = ANIMATION_PUSH_ENTRY_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.list_alpha;
|
||||
entry.tag = (uintptr_t) NULL;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = ozone;
|
||||
entry.cb = ozone_animation_end;
|
||||
entry.duration = ANIMATION_PUSH_ENTRY_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.list_alpha;
|
||||
entry.tag = (uintptr_t) NULL;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = ozone;
|
||||
|
||||
menu_animation_push(&entry);
|
||||
|
||||
@ -1379,6 +1382,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act
|
||||
switch (action)
|
||||
{
|
||||
case MENU_ACTION_DOWN:
|
||||
ozone->cursor_mode = false;
|
||||
if (!ozone->cursor_in_sidebar)
|
||||
break;
|
||||
|
||||
@ -1394,6 +1398,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act
|
||||
new_action = MENU_ACTION_NOOP;
|
||||
break;
|
||||
case MENU_ACTION_UP:
|
||||
ozone->cursor_mode = false;
|
||||
if (!ozone->cursor_in_sidebar)
|
||||
break;
|
||||
|
||||
@ -1409,6 +1414,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act
|
||||
new_action = MENU_ACTION_NOOP;
|
||||
break;
|
||||
case MENU_ACTION_LEFT:
|
||||
ozone->cursor_mode = false;
|
||||
if (ozone->cursor_in_sidebar)
|
||||
{
|
||||
new_action = MENU_ACTION_NOOP;
|
||||
@ -1422,6 +1428,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act
|
||||
new_action = MENU_ACTION_NOOP;
|
||||
break;
|
||||
case MENU_ACTION_RIGHT:
|
||||
ozone->cursor_mode = false;
|
||||
if (!ozone->cursor_in_sidebar)
|
||||
{
|
||||
if (ozone->depth == 1)
|
||||
@ -1434,6 +1441,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act
|
||||
new_action = MENU_ACTION_NOOP;
|
||||
break;
|
||||
case MENU_ACTION_OK:
|
||||
ozone->cursor_mode = false;
|
||||
if (ozone->cursor_in_sidebar)
|
||||
{
|
||||
ozone_leave_sidebar(ozone, tag);
|
||||
@ -1442,6 +1450,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act
|
||||
}
|
||||
break;
|
||||
case MENU_ACTION_CANCEL:
|
||||
ozone->cursor_mode = false;
|
||||
if (ozone->cursor_in_sidebar)
|
||||
{
|
||||
/* Go back to main menu tab */
|
||||
@ -1771,7 +1780,6 @@ 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,
|
||||
@ -1788,7 +1796,6 @@ static int ozone_pointer_tap(void *userdata,
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
menu_ctx_driver_t menu_ctx_ozone = {
|
||||
NULL, /* set_texture */
|
||||
@ -1824,11 +1831,7 @@ menu_ctx_driver_t menu_ctx_ozone = {
|
||||
NULL, /* load_image */
|
||||
"ozone",
|
||||
ozone_environ_cb,
|
||||
#if OZONE_ENABLE_MOUSE
|
||||
ozone_pointer_tap,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
NULL, /* update_thumbnail_path */
|
||||
NULL, /* update_thumbnail_image */
|
||||
NULL, /* set_thumbnail_system */
|
||||
|
@ -27,8 +27,6 @@ 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
|
||||
@ -200,6 +198,10 @@ struct ozone_handle
|
||||
} dimensions;
|
||||
|
||||
bool show_cursor;
|
||||
bool cursor_mode;
|
||||
|
||||
int16_t cursor_x_old;
|
||||
int16_t cursor_y_old;
|
||||
};
|
||||
|
||||
/* If you change this struct, also
|
||||
|
@ -155,24 +155,24 @@ void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node
|
||||
/* Cursor animation */
|
||||
ozone->animations.cursor_alpha = 0.0f;
|
||||
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.cursor_alpha;
|
||||
entry.tag = tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.cursor_alpha;
|
||||
entry.tag = tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
|
||||
menu_animation_push(&entry);
|
||||
|
||||
/* Scroll animation */
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.scroll_y;
|
||||
entry.tag = tag;
|
||||
entry.target_value = new_scroll;
|
||||
entry.userdata = NULL;
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.scroll_y;
|
||||
entry.tag = tag;
|
||||
entry.target_value = new_scroll;
|
||||
entry.userdata = NULL;
|
||||
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
@ -287,13 +287,20 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info,
|
||||
|
||||
bool old_list = selection_buf == ozone->selection_buf_old;
|
||||
int x_offset = 0;
|
||||
size_t selection_y = 0;
|
||||
size_t selection_y = 0; /* 0 means no selection (we assume that no entry has y = 0) */
|
||||
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 cursor_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS);
|
||||
int16_t cursor_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||
|
||||
int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS);
|
||||
if (!ozone->cursor_mode && (cursor_x != ozone->cursor_x_old || cursor_y != ozone->cursor_y_old))
|
||||
{
|
||||
ozone->cursor_mode = true;
|
||||
}
|
||||
|
||||
ozone->cursor_x_old = cursor_x;
|
||||
ozone->cursor_y_old = cursor_y;
|
||||
|
||||
menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i);
|
||||
|
||||
@ -333,10 +340,10 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info,
|
||||
|
||||
ozone_node_t *node = NULL;
|
||||
|
||||
if (entry_selected)
|
||||
if (entry_selected && selection_y == 0)
|
||||
selection_y = y;
|
||||
|
||||
if (entry_old_selected)
|
||||
if (entry_old_selected && old_selection_y == 0)
|
||||
old_selection_y = y;
|
||||
|
||||
node = (ozone_node_t*) file_list_get_userdata_at_offset(selection_buf, i);
|
||||
@ -361,15 +368,17 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info,
|
||||
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)
|
||||
/* Cursor */
|
||||
if (!old_list && ozone->cursor_mode)
|
||||
{
|
||||
selection_y = y;
|
||||
menu_input_ctl(MENU_INPUT_CTL_MOUSE_PTR, &i);
|
||||
if ( cursor_x >= border_start_x && cursor_x <= border_start_x + entry_width &&
|
||||
cursor_y >= border_start_y && cursor_y <= border_start_y + button_height)
|
||||
{
|
||||
selection_y = y;
|
||||
menu_navigation_set_selection(i);
|
||||
menu_input_ctl(MENU_INPUT_CTL_MOUSE_PTR, &i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
border_iterate:
|
||||
y += node->height;
|
||||
@ -429,7 +438,7 @@ border_iterate:
|
||||
ticker.s = rich_label;
|
||||
ticker.str = entry_rich_label;
|
||||
ticker.selected = entry_selected && !ozone->cursor_in_sidebar;
|
||||
ticker.len = (entry_width - 60 - text_offset) / ozone->entry_font_glyph_width;
|
||||
ticker.len = (entry_width - entry_padding - text_offset) / ozone->entry_font_glyph_width;
|
||||
|
||||
menu_animation_ticker(&ticker);
|
||||
|
||||
|
@ -256,13 +256,13 @@ void ozone_go_to_sidebar(ozone_handle_t *ozone, uintptr_t tag)
|
||||
/* Cursor animation */
|
||||
ozone->animations.cursor_alpha = 0.0f;
|
||||
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.cursor_alpha;
|
||||
entry.tag = tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.cursor_alpha;
|
||||
entry.tag = tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
@ -281,13 +281,13 @@ void ozone_leave_sidebar(ozone_handle_t *ozone, uintptr_t tag)
|
||||
/* Cursor animation */
|
||||
ozone->animations.cursor_alpha = 0.0f;
|
||||
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.cursor_alpha;
|
||||
entry.tag = tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.cursor_alpha;
|
||||
entry.tag = tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
|
||||
menu_animation_push(&entry);
|
||||
}
|
||||
@ -338,13 +338,13 @@ void ozone_sidebar_goto(ozone_handle_t *ozone, unsigned new_selection)
|
||||
/* Cursor animation */
|
||||
ozone->animations.cursor_alpha = 0.0f;
|
||||
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.cursor_alpha;
|
||||
entry.tag = tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
entry.cb = NULL;
|
||||
entry.duration = ANIMATION_CURSOR_DURATION;
|
||||
entry.easing_enum = EASING_OUT_QUAD;
|
||||
entry.subject = &ozone->animations.cursor_alpha;
|
||||
entry.tag = tag;
|
||||
entry.target_value = 1.0f;
|
||||
entry.userdata = NULL;
|
||||
|
||||
menu_animation_push(&entry);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user