diff --git a/gfx/video_crt_switch.c b/gfx/video_crt_switch.c index 1b05103620..56cf854203 100644 --- a/gfx/video_crt_switch.c +++ b/gfx/video_crt_switch.c @@ -240,13 +240,18 @@ void crt_video_restore(void) int crt_compute_dynamic_width(int width) { double p_clock = 15000000; + int min_height = 261; int dynamic_width = 0; #if defined(HAVE_VIDEOCORE) double p_clock = 32000000; #endif + for (int i =0; i < 10; i++) + + + { dynamic_width = (width*1.5)*i; if ((dynamic_width * min_height * ra_core_hz) > p_clock) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 447149fb14..c5a9060cf2 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -149,6 +149,11 @@ static void *ozone_init(void **userdata, bool video_is_threaded) ozone->is_playlist = false; ozone->categories_selection_ptr = 0; 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; @@ -327,6 +332,7 @@ static void ozone_free(void *data) } } +/* TODO: Scale text */ static void ozone_context_reset(void *data, bool is_threaded) { /* Fonts init */ @@ -334,7 +340,7 @@ static void ozone_context_reset(void *data, bool is_threaded) unsigned size; char font_path[PATH_MAX_LENGTH]; - float scale = 1; + float scale = 1; /*TODO: compute that from screen resolution and dpi */ ozone_handle_t *ozone = (ozone_handle_t*) data; @@ -343,11 +349,11 @@ static void ozone_context_reset(void *data, bool is_threaded) ozone->has_all_assets = true; fill_pathname_join(font_path, ozone->assets_path, "regular.ttf", sizeof(font_path)); - ozone->fonts.footer = menu_display_font_file(font_path, FONT_SIZE_FOOTER, is_threaded); - ozone->fonts.entries_label = menu_display_font_file(font_path, FONT_SIZE_ENTRIES_LABEL, is_threaded); + ozone->fonts.footer = menu_display_font_file(font_path, FONT_SIZE_FOOTER, is_threaded); + ozone->fonts.entries_label = menu_display_font_file(font_path, FONT_SIZE_ENTRIES_LABEL, is_threaded); ozone->fonts.entries_sublabel = menu_display_font_file(font_path, FONT_SIZE_ENTRIES_SUBLABEL, is_threaded); - ozone->fonts.time = menu_display_font_file(font_path, FONT_SIZE_TIME, is_threaded); - ozone->fonts.sidebar = menu_display_font_file(font_path, FONT_SIZE_SIDEBAR, is_threaded); + ozone->fonts.time = menu_display_font_file(font_path, FONT_SIZE_TIME, is_threaded); + ozone->fonts.sidebar = menu_display_font_file(font_path, FONT_SIZE_SIDEBAR, is_threaded); fill_pathname_join(font_path, ozone->assets_path, "bold.ttf", sizeof(font_path)); ozone->fonts.title = menu_display_font_file(font_path, FONT_SIZE_TITLE, is_threaded); @@ -364,11 +370,33 @@ static void ozone_context_reset(void *data, bool is_threaded) ozone->has_all_assets = false; } + /* Dimensions */ + ozone->dimensions.header_height = HEADER_HEIGHT * scale; + ozone->dimensions.footer_height = FOOTER_HEIGHT * scale; + + ozone->dimensions.entry_padding_horizontal_half = ENTRY_PADDING_HORIZONTAL_HALF * scale; + ozone->dimensions.entry_padding_horizontal_full = ENTRY_PADDING_HORIZONTAL_FULL * scale; + ozone->dimensions.entry_padding_vertical = ENTRY_PADDING_VERTICAL * scale; + ozone->dimensions.entry_height = ENTRY_HEIGHT * scale; + ozone->dimensions.entry_spacing = ENTRY_SPACING * scale; + ozone->dimensions.entry_icon_size = ENTRY_ICON_SIZE * scale; + ozone->dimensions.entry_icon_padding = ENTRY_ICON_PADDING * scale; + + ozone->dimensions.sidebar_width = SIDEBAR_WIDTH * scale; + ozone->dimensions.sidebar_entry_height = SIDEBAR_ENTRY_HEIGHT * scale; + ozone->dimensions.sidebar_padding_horizontal = SIDEBAR_X_PADDING * scale; + ozone->dimensions.sidebar_padding_vertical = SIDEBAR_Y_PADDING * scale; + ozone->dimensions.sidebar_entry_padding_vertical = SIDEBAR_ENTRY_Y_PADDING * scale; + ozone->dimensions.sidebar_entry_icon_size = SIDEBAR_ENTRY_ICON_SIZE * scale; + ozone->dimensions.sidebar_entry_icon_padding = SIDEBAR_ENTRY_ICON_PADDING * scale; + + ozone->dimensions.cursor_size = CURSOR_SIZE * scale; + /* Naive font size */ - ozone->title_font_glyph_width = FONT_SIZE_TITLE * 3/4; - ozone->entry_font_glyph_width = FONT_SIZE_ENTRIES_LABEL * 3/4; + ozone->title_font_glyph_width = FONT_SIZE_TITLE * 3/4; + ozone->entry_font_glyph_width = FONT_SIZE_ENTRIES_LABEL * 3/4; ozone->sublabel_font_glyph_width = FONT_SIZE_ENTRIES_SUBLABEL * 3/4; - ozone->sidebar_font_glyph_width = FONT_SIZE_SIDEBAR * 3/4; + ozone->sidebar_font_glyph_width = FONT_SIZE_SIDEBAR * 3/4; /* More realistic font size */ size = font_driver_get_message_width(ozone->fonts.title, "a", 1, 1); @@ -475,26 +503,6 @@ static void ozone_context_reset(void *data, bool is_threaded) } ozone_restart_cursor_animation(ozone); - - /* UI dimensions */ - ozone->dimensions.header_height = HEADER_HEIGHT * scale; - ozone->dimensions.footer_height = FOOTER_HEIGHT * scale; - - ozone->dimensions.entry_padding_horizontal_half = ENTRY_PADDING_HORIZONTAL_HALF * scale; - ozone->dimensions.entry_padding_horizontal_full = ENTRY_PADDING_HORIZONTAL_FULL * scale; - ozone->dimensions.entry_padding_vertical = ENTRY_PADDING_VERTRICAL * scale; - ozone->dimensions.entry_height = ENTRY_HEIGHT * scale; - ozone->dimensions.entry_padding = ENTRY_PADDING * scale; - ozone->dimensions.entry_icon_size = ENTRY_ICON_SIZE * scale; - ozone->dimensions.entry_icon_padding = ENTRY_ICON_PADDING * scale; - - ozone->dimensions.sidebar_width = SIDEBAR_WIDTH * scale; - ozone->dimensions.sidebar_entry_height = SIDEBAR_ENTRY_HEIGHT * scale; - ozone->dimensions.sidebar_padding_horizontal = SIDEBAR_X_PADDING * scale; - ozone->dimensions.sidebar_padding_vertical = SIDEBAR_Y_PADDING * scale; - ozone->dimensions.sidebar_entry_padding_vertical = SIDEBAR_ENTRY_Y_PADDING * scale; - ozone->dimensions.sidebar_entry_icon_size = SIDEBAR_ENTRY_ICON_SIZE * scale; - ozone->dimensions.sidebar_entry_icon_padding = SIDEBAR_ENTRY_ICON_PADDING * scale; } } @@ -807,157 +815,6 @@ static void ozone_list_free(file_list_t *list, size_t a, size_t b) ozone_list_clear(list); } -/* Compute new scroll position - * If the center of the currently selected entry is not in the middle - * And if we can scroll so that it's in the middle - * Then scroll - */ -static void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node_t *node) -{ - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); - menu_animation_ctx_tag tag = (uintptr_t) selection_buf; - menu_animation_ctx_entry_t entry; - float new_scroll = 0, entries_middle; - float bottom_boundary, current_selection_middle_onscreen; - unsigned video_info_height; - - video_driver_get_size(NULL, &video_info_height); - - current_selection_middle_onscreen = ozone->dimensions.header_height + ozone->dimensions.entry_padding_vertical + ozone->animations.scroll_y + node->position_y + node->height / 2; - bottom_boundary = video_info_height - ozone->dimensions.header_height - 1 - ozone->dimensions.footer_height; - entries_middle = video_info_height/2; - - new_scroll = ozone->animations.scroll_y - (current_selection_middle_onscreen - entries_middle); - - if (new_scroll + ozone->entries_height < bottom_boundary) - new_scroll = bottom_boundary - ozone->entries_height - ozone->dimensions.entry_padding_vertical * 2; - - if (new_scroll > 0) - new_scroll = 0; - - if (allow_animation) - { - /* 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; - - 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; - - menu_animation_push(&entry); - } - else - { - ozone->selection_old = ozone->selection; - ozone->animations.scroll_y = new_scroll; - } -} - -static unsigned ozone_count_lines(const char *str) -{ - unsigned c = 0; - unsigned lines = 1; - - for (c = 0; str[c]; c++) - lines += (str[c] == '\n'); - return lines; -} - -static void ozone_compute_entries_position(ozone_handle_t *ozone) -{ - /* Compute entries height and adjust scrolling if needed */ - unsigned video_info_height; - unsigned video_info_width; - unsigned lines; - size_t i, entries_end; - file_list_t *selection_buf = NULL; - - menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); - - entries_end = menu_entries_get_size(); - selection_buf = menu_entries_get_selection_buf_ptr(0); - - video_driver_get_size(&video_info_width, &video_info_height); - - ozone->entries_height = 0; - - for (i = 0; i < entries_end; i++) - { - /* Entry */ - menu_entry_t entry; - ozone_node_t *node = NULL; - - menu_entry_init(&entry); - menu_entry_get(&entry, 0, (unsigned)i, NULL, true); - - /* Empty playlist detection: - only one item which icon is - OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO */ - if (ozone->is_playlist && entries_end == 1) - { - menu_texture_item tex = ozone_entries_icon_get_texture(ozone, entry.enum_idx, entry.type, false); - ozone->empty_playlist = tex == ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO]; - } - else - { - ozone->empty_playlist = false; - } - - /* Cache node */ - node = (ozone_node_t*)file_list_get_userdata_at_offset(selection_buf, i); - - if (!node) - continue; - - node->height = ozone->dimensions.entry_height + ozone->dimensions.entry_padding + (entry.sublabel ? 40 : 0); - node->wrap = false; - - if (entry.sublabel) - { - char *sublabel_str = menu_entry_get_sublabel(&entry); - - int sublable_max_width = video_info_width - ozone->dimensions.sidebar_width - - ozone->dimensions.entry_padding_horizontal_half * 2 - ozone->dimensions.entry_icon_padding * 2; - word_wrap(sublabel_str, sublabel_str, sublable_max_width / ozone->sublabel_font_glyph_width, false); - - lines = ozone_count_lines(sublabel_str); - - if (lines > 1) - { - node->height += lines * 15; - node->wrap = true; - } - - free(sublabel_str); - } - - node->position_y = ozone->entries_height; - - ozone->entries_height += node->height; - - menu_entry_free(&entry); - } - - /* Update scrolling */ - ozone->selection = menu_navigation_get_selection(); - ozone_update_scroll(ozone, false, (ozone_node_t*) file_list_get_userdata_at_offset(selection_buf, ozone->selection)); -} - static void ozone_render(void *data, bool is_idle) { size_t i; @@ -974,7 +831,7 @@ static void ozone_render(void *data, bool is_idle) ozone->selection = menu_navigation_get_selection(); - /* TODO Handle pointer & mouse */ + /* TODO: Handle pointer & mouse */ menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); @@ -1372,6 +1229,22 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) font_driver_flush(video_info->width, video_info->height, ozone->fonts.footer, video_info); font_driver_flush(video_info->width, video_info->height, ozone->fonts.entries_label, video_info); + /* Cursor */ + if (ozone->show_cursor) + { + menu_display_set_alpha(ozone_pure_white, 1.0f); + menu_display_draw_cursor( + video_info, + ozone_pure_white, + ozone->dimensions.cursor_size, + ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_POINTER], + menu_input_mouse_state(MENU_MOUSE_X_AXIS), + menu_input_mouse_state(MENU_MOUSE_Y_AXIS), + video_info->width, + video_info->height + ); + } + menu_display_unset_viewport(video_info->width, video_info->height); } @@ -1393,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) @@ -1405,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); @@ -1461,7 +1335,7 @@ static void ozone_populate_entries(void *data, const char *path, const char *lab { menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); - /* TODO Update thumbnails */ + /* TODO: Update thumbnails */ ozone_selection_changed(ozone, false); return; } @@ -1508,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; @@ -1523,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; @@ -1538,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; @@ -1551,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) @@ -1563,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); @@ -1571,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 */ @@ -1594,7 +1474,7 @@ static int ozone_menu_iterate(menu_handle_t *menu, void *userdata, enum menu_act return generic_menu_iterate(menu, userdata, new_action); } -/* TODO Fancy toggle animation */ +/* TODO: Fancy toggle animation */ static void ozone_toggle(void *userdata, bool menu_on) { @@ -1805,6 +1685,12 @@ static int ozone_environ_cb(enum menu_environ_cb type, void *data, void *userdat switch (type) { + case MENU_ENVIRON_ENABLE_MOUSE_CURSOR: + ozone->show_cursor = true; + break; + case MENU_ENVIRON_DISABLE_MOUSE_CURSOR: + ozone->show_cursor = false; + break; case MENU_ENVIRON_RESET_HORIZONTAL_LIST: if (!ozone) return -1; @@ -1894,6 +1780,23 @@ static bool ozone_get_load_content_animation_data(void *userdata, menu_texture_i } #endif +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; +} + menu_ctx_driver_t menu_ctx_ozone = { NULL, /* set_texture */ ozone_messagebox, @@ -1928,7 +1831,7 @@ menu_ctx_driver_t menu_ctx_ozone = { NULL, /* load_image */ "ozone", ozone_environ_cb, - NULL, /* pointer_tap */ + ozone_pointer_tap, 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 eb1ea4a090..26b4bff422 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -27,38 +27,40 @@ typedef struct ozone_handle ozone_handle_t; #include "../../menu_driver.h" #include "../../../retroarch.h" -#define FONT_SIZE_FOOTER 18 -#define FONT_SIZE_TITLE 36 -#define FONT_SIZE_TIME 22 -#define FONT_SIZE_ENTRIES_LABEL 24 -#define FONT_SIZE_ENTRIES_SUBLABEL 18 -#define FONT_SIZE_SIDEBAR 24 +#define ANIMATION_PUSH_ENTRY_DURATION 10 +#define ANIMATION_CURSOR_DURATION 8 +#define ANIMATION_CURSOR_PULSE 30 -#define ANIMATION_PUSH_ENTRY_DURATION 10 -#define ANIMATION_CURSOR_DURATION 8 -#define ANIMATION_CURSOR_PULSE 30 +#define FONT_SIZE_FOOTER 18 +#define FONT_SIZE_TITLE 36 +#define FONT_SIZE_TIME 22 +#define FONT_SIZE_ENTRIES_LABEL 24 +#define FONT_SIZE_ENTRIES_SUBLABEL 18 +#define FONT_SIZE_SIDEBAR 24 #define HEADER_HEIGHT 87 #define FOOTER_HEIGHT 78 -#define ENTRY_PADDING_HORIZONTAL_HALF 60 -#define ENTRY_PADDING_HORIZONTAL_FULL 100 -#define ENTRY_PADDING_VERTRICAL 20 -#define ENTRY_HEIGHT 50 -#define ENTRY_PADDING 0 -#define ENTRY_ICON_SIZE 46 -#define ENTRY_ICON_PADDING 15 +#define ENTRY_PADDING_HORIZONTAL_HALF 60 +#define ENTRY_PADDING_HORIZONTAL_FULL 150 +#define ENTRY_PADDING_VERTICAL 20 +#define ENTRY_HEIGHT 50 +#define ENTRY_SPACING 8 +#define ENTRY_ICON_SIZE 46 +#define ENTRY_ICON_PADDING 15 -#define SIDEBAR_WIDTH 408 -#define SIDEBAR_X_PADDING 40 -#define SIDEBAR_Y_PADDING 20 -#define SIDEBAR_ENTRY_HEIGHT 50 -#define SIDEBAR_ENTRY_Y_PADDING 10 -#define SIDEBAR_ENTRY_ICON_SIZE 40 -#define SIDEBAR_ENTRY_ICON_PADDING 15 +#define SIDEBAR_WIDTH 408 +#define SIDEBAR_X_PADDING 40 +#define SIDEBAR_Y_PADDING 20 +#define SIDEBAR_ENTRY_HEIGHT 50 +#define SIDEBAR_ENTRY_Y_PADDING 10 +#define SIDEBAR_ENTRY_ICON_SIZE 40 +#define SIDEBAR_ENTRY_ICON_PADDING 15 -#define INTERVAL_BATTERY_LEVEL_CHECK (30 * 1000000) -#define INTERVAL_OSK_CURSOR (0.5f * 1000000) +#define CURSOR_SIZE 64 + +#define INTERVAL_BATTERY_LEVEL_CHECK (30 * 1000000) +#define INTERVAL_OSK_CURSOR (0.5f * 1000000) struct ozone_handle { @@ -177,10 +179,10 @@ struct ozone_handle int footer_height; int entry_padding_horizontal_half; - int entry_padding_horizontal_full; /* todo when sidebar is not visible */ + int entry_padding_horizontal_full; /* TODO: when sidebar is not visible */ int entry_padding_vertical; int entry_height; - int entry_padding; + int entry_spacing; int entry_icon_size; int entry_icon_padding; @@ -191,7 +193,15 @@ struct ozone_handle int sidebar_entry_height; int sidebar_entry_icon_size; int sidebar_entry_icon_padding; + + int cursor_size; } dimensions; + + bool show_cursor; + bool cursor_mode; + + int16_t cursor_x_old; + int16_t cursor_y_old; }; /* If you change this struct, also @@ -247,4 +257,8 @@ void ozone_free_list_nodes(file_list_t *list, bool actiondata); bool ozone_is_playlist(ozone_handle_t *ozone, bool depth); +void ozone_compute_entries_position(ozone_handle_t *ozone); + +void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node_t *node); + #endif diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index bb2688c2d9..dc907a7b2c 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -122,8 +122,8 @@ static void ozone_draw_cursor_slice(ozone_handle_t *ozone, unsigned width, unsigned height, size_t y, float alpha) { - ozone_color_alpha(ozone->theme_dynamic.cursor_alpha, alpha); - ozone_color_alpha(ozone->theme_dynamic.cursor_border, alpha); + menu_display_set_alpha(ozone->theme_dynamic.cursor_alpha, alpha); + menu_display_set_alpha(ozone->theme_dynamic.cursor_border, alpha); menu_display_blend_begin(video_info); @@ -164,8 +164,8 @@ static void ozone_draw_cursor_fallback(ozone_handle_t *ozone, unsigned width, unsigned height, size_t y, float alpha) { - ozone_color_alpha(ozone->theme_dynamic.selection_border, alpha); - ozone_color_alpha(ozone->theme_dynamic.selection, alpha); + menu_display_set_alpha(ozone->theme_dynamic.selection_border, alpha); + menu_display_set_alpha(ozone->theme_dynamic.selection, alpha); /* Fill */ menu_display_draw_quad(video_info, x_offset, y, width, height - 5, video_info->width, video_info->height, ozone->theme_dynamic.selection); @@ -197,11 +197,6 @@ void ozone_draw_cursor(ozone_handle_t *ozone, ozone_draw_cursor_fallback(ozone, video_info, x_offset, width, height, y, alpha); } -void ozone_color_alpha(float *color, float alpha) -{ - color[3] = color[7] = color[11] = color[15] = alpha; -} - void ozone_draw_icon( video_frame_info_t *video_info, unsigned icon_width, @@ -249,8 +244,8 @@ void ozone_draw_icon( void ozone_draw_backdrop(video_frame_info_t *video_info, float alpha) { - /* TODO Replace this backdrop by a blur shader on the whole screen if available */ - ozone_color_alpha(ozone_backdrop, alpha); + /* TODO: Replace this backdrop by a blur shader on the whole screen if available */ + menu_display_set_alpha(ozone_backdrop, alpha); menu_display_draw_quad(video_info, 0, 0, video_info->width, video_info->height, video_info->width, video_info->height, ozone_backdrop); } @@ -293,7 +288,7 @@ void ozone_draw_osk(ozone_handle_t *ozone, menu_display_draw_quad(video_info, video_info->width - margin, margin, 1, bottom_end - margin*2, video_info->width, video_info->height, ozone->theme->entries_border); /* Backdrop */ - /* TODO Remove the backdrop if blur shader is available */ + /* TODO: Remove the backdrop if blur shader is available */ menu_display_draw_quad(video_info, margin + 1, margin + 1, video_info->width - margin*2 - 2, bottom_end - margin*2 - 2, video_info->width, video_info->height, ozone_osk_backdrop); /* Placeholder & text*/ @@ -390,7 +385,7 @@ void ozone_draw_messagebox(ozone_handle_t *ozone, } } - ozone_color_alpha(ozone->theme_dynamic.message_background, ozone->animations.messagebox_alpha); + menu_display_set_alpha(ozone->theme_dynamic.message_background, ozone->animations.messagebox_alpha); menu_display_blend_begin(video_info); diff --git a/menu/drivers/ozone/ozone_display.h b/menu/drivers/ozone/ozone_display.h index 5e7b82bcbb..44f3058853 100644 --- a/menu/drivers/ozone/ozone_display.h +++ b/menu/drivers/ozone/ozone_display.h @@ -37,8 +37,6 @@ void ozone_draw_cursor(ozone_handle_t *ozone, unsigned width, unsigned height, size_t y, float alpha); -void ozone_color_alpha(float *color, float alpha); - void ozone_draw_icon( video_frame_info_t *video_info, unsigned icon_width, diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index b8a1dbdc10..69c4725c0f 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -28,6 +28,26 @@ #include "../../menu_driver.h" #include "../../menu_animation.h" +#include "../../../configuration.h" + +static int ozone_get_entries_padding(ozone_handle_t* ozone, bool old_list) +{ + /* TODO: Once we have thumbnails this condition will no longer work + * on playlists (where the sidebar is partially collapsed with depth == 1) */ + if (ozone->depth == 1) + if (old_list) + return ozone->dimensions.entry_padding_horizontal_full; + else + return ozone->dimensions.entry_padding_horizontal_half; + else if (ozone->depth == 2) + if (old_list && ozone->fade_direction == false) /* false = left to right */ + return ozone->dimensions.entry_padding_horizontal_half; + else + return ozone->dimensions.entry_padding_horizontal_full; + else + return ozone->dimensions.entry_padding_horizontal_full; +} + static void ozone_draw_entry_value(ozone_handle_t *ozone, video_frame_info_t *video_info, char *value, @@ -104,27 +124,193 @@ static void ozone_draw_entry_value(ozone_handle_t *ozone, } } +/* Compute new scroll position + * If the center of the currently selected entry is not in the middle + * And if we can scroll so that it's in the middle + * Then scroll + */ +void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node_t *node) +{ + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + menu_animation_ctx_tag tag = (uintptr_t) selection_buf; + menu_animation_ctx_entry_t entry; + float new_scroll = 0, entries_middle; + float bottom_boundary, current_selection_middle_onscreen; + unsigned video_info_height; + + video_driver_get_size(NULL, &video_info_height); + + current_selection_middle_onscreen = ozone->dimensions.header_height + ozone->dimensions.entry_padding_vertical + ozone->animations.scroll_y + node->position_y + node->height / 2; + bottom_boundary = video_info_height - ozone->dimensions.header_height - 1 - ozone->dimensions.footer_height; + entries_middle = video_info_height/2; + + new_scroll = ozone->animations.scroll_y - (current_selection_middle_onscreen - entries_middle); + + if (new_scroll + ozone->entries_height < bottom_boundary) + new_scroll = bottom_boundary - ozone->entries_height - ozone->dimensions.entry_padding_vertical * 2; + + if (new_scroll > 0) + new_scroll = 0; + + if (allow_animation) + { + /* 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; + + 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; + + menu_animation_push(&entry); + } + else + { + ozone->selection_old = ozone->selection; + ozone->animations.scroll_y = new_scroll; + } +} + +static unsigned ozone_count_lines(const char *str) +{ + unsigned c = 0; + unsigned lines = 1; + + for (c = 0; str[c]; c++) + lines += (str[c] == '\n'); + return lines; +} + +void ozone_compute_entries_position(ozone_handle_t *ozone) +{ + /* Compute entries height and adjust scrolling if needed */ + unsigned video_info_height; + unsigned video_info_width; + unsigned lines; + size_t i, entries_end; + + file_list_t *selection_buf = NULL; + int entry_padding = ozone_get_entries_padding(ozone, false); + + menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); + + entries_end = menu_entries_get_size(); + selection_buf = menu_entries_get_selection_buf_ptr(0); + + video_driver_get_size(&video_info_width, &video_info_height); + + ozone->entries_height = 0; + + for (i = 0; i < entries_end; i++) + { + /* Entry */ + menu_entry_t entry; + ozone_node_t *node = NULL; + + menu_entry_init(&entry); + menu_entry_get(&entry, 0, (unsigned)i, NULL, true); + + /* Empty playlist detection: + only one item which icon is + OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO */ + if (ozone->is_playlist && entries_end == 1) + { + menu_texture_item tex = ozone_entries_icon_get_texture(ozone, entry.enum_idx, entry.type, false); + ozone->empty_playlist = tex == ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO]; + } + else + { + ozone->empty_playlist = false; + } + + /* Cache node */ + node = (ozone_node_t*)file_list_get_userdata_at_offset(selection_buf, i); + + if (!node) + continue; + + node->height = ozone->dimensions.entry_height + (entry.sublabel ? ozone->dimensions.entry_spacing + 40 : 0); + node->wrap = false; + + if (entry.sublabel) + { + char *sublabel_str = menu_entry_get_sublabel(&entry); + + int sublabel_max_width = video_info_width - ozone->dimensions.sidebar_width - + entry_padding * 2 - ozone->dimensions.entry_icon_padding * 2; + word_wrap(sublabel_str, sublabel_str, sublabel_max_width / ozone->sublabel_font_glyph_width, false); + + lines = ozone_count_lines(sublabel_str); + + if (lines > 1) + { + node->height += lines * 15; + node->wrap = true; + } + + free(sublabel_str); + } + + node->position_y = ozone->entries_height; + + ozone->entries_height += node->height; + + menu_entry_free(&entry); + } + + /* Update scrolling */ + ozone->selection = menu_navigation_get_selection(); + ozone_update_scroll(ozone, false, (ozone_node_t*) file_list_get_userdata_at_offset(selection_buf, ozone->selection)); +} + void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, unsigned selection, unsigned selection_old, file_list_t *selection_buf, float alpha, float scroll_y, bool is_playlist) { - bool old_list; uint32_t alpha_uint32; size_t i, y, entries_end; float sidebar_offset, bottom_boundary, invert, alpha_anim; unsigned video_info_height, video_info_width, entry_width, button_height; + settings_t *settings = config_get_ptr(); + + 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 cursor_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); + int16_t cursor_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS); + + if (settings->bools.menu_mouse_enable && !ozone->cursor_mode && (cursor_x != ozone->cursor_x_old || cursor_y != ozone->cursor_y_old)) + ozone->cursor_mode = true; + else if (!settings->bools.menu_mouse_enable) + ozone->cursor_mode = false; /* we need to disable it on the fly */ + + ozone->cursor_x_old = cursor_x; + ozone->cursor_y_old = cursor_y; menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); entries_end = file_list_get_size(selection_buf); - old_list = selection_buf == ozone->selection_buf_old; y = ozone->dimensions.header_height + 1 + ozone->dimensions.entry_padding_vertical; sidebar_offset = ozone->sidebar_offset; - entry_width = video_info->width - ozone->dimensions.sidebar_width - ozone->sidebar_offset - ozone->dimensions.entry_padding_horizontal_half * 2; + entry_width = video_info->width - ozone->dimensions.sidebar_width - ozone->sidebar_offset - entry_padding * 2; button_height = ozone->dimensions.entry_height; /* height of the button (entry minus sublabel) */ video_driver_get_size(&video_info_width, &video_info_height); @@ -152,11 +338,15 @@ 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) + + 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); @@ -169,14 +359,29 @@ 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; - ozone_color_alpha(ozone->theme_dynamic.entries_border, alpha); - ozone_color_alpha(ozone->theme_dynamic.entries_checkmark, alpha); + 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 + ozone->dimensions.entry_padding_horizontal_half, - 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 + ozone->dimensions.entry_padding_horizontal_half, - 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); + + /* Cursor */ + if (!old_list && ozone->cursor_mode) + { + 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); + } + } border_iterate: y += node->height; @@ -184,12 +389,12 @@ border_iterate: /* Cursor(s) layer - current */ if (!ozone->cursor_in_sidebar) - ozone_draw_cursor(ozone, video_info, ozone->dimensions.sidebar_width + x_offset + ozone->dimensions.entry_padding_horizontal_half + 3, + ozone_draw_cursor(ozone, video_info, ozone->dimensions.sidebar_width + x_offset + entry_padding + 3, entry_width - 5, button_height + 2, selection_y + scroll_y + 1, ozone->animations.cursor_alpha * alpha); /* Old*/ if (!ozone->cursor_in_sidebar_old) - ozone_draw_cursor(ozone, video_info, ozone->dimensions.sidebar_width + x_offset + ozone->dimensions.entry_padding_horizontal_half + 3, + ozone_draw_cursor(ozone, video_info, ozone->dimensions.sidebar_width + x_offset + entry_padding + 3, entry_width - 5, button_height + 2, old_selection_y + scroll_y + 1, (1-ozone->animations.cursor_alpha) * alpha); /* Icons + text */ @@ -236,14 +441,14 @@ 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); if (ozone->empty_playlist) { unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label, rich_label, (unsigned)strlen(rich_label), 1); - x_offset = (video_info_width - ozone->dimensions.sidebar_width - ozone->dimensions.entry_padding_horizontal_half * 2) / 2 - text_width / 2 - 60; + x_offset = (video_info_width - ozone->dimensions.sidebar_width - entry_padding * 2) / 2 - text_width / 2 - 60; y = video_info_height / 2 - 60; } @@ -252,10 +457,10 @@ border_iterate: if (node->wrap && sublabel_str) { int sublable_max_width = video_info_width - ozone->dimensions.sidebar_width - - ozone->dimensions.entry_padding_horizontal_half * 2 - ozone->dimensions.entry_icon_padding * 2; + entry_padding * 2 - ozone->dimensions.entry_icon_padding * 2; word_wrap(sublabel_str, sublabel_str, sublable_max_width / ozone->sublabel_font_glyph_width, false); } - + /* Icon */ tex = ozone_entries_icon_get_texture(ozone, entry.enum_idx, entry.type, entry_selected); if (tex != ozone->icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_SUBSETTING]) @@ -286,25 +491,25 @@ border_iterate: icon_color = ozone_pure_white; } - ozone_color_alpha(icon_color, alpha); + menu_display_set_alpha(icon_color, alpha); menu_display_blend_begin(video_info); ozone_draw_icon(video_info, ozone->dimensions.entry_icon_size, ozone->dimensions.entry_icon_size, texture, - ozone->dimensions.sidebar_width + x_offset + ozone->dimensions.entry_padding_horizontal_half + ozone->dimensions.entry_icon_padding, + ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.entry_icon_padding, y + scroll_y + ozone->dimensions.entry_height / 2 - ozone->dimensions.entry_icon_size / 2, video_info->width, video_info->height, 0, 1, icon_color); menu_display_blend_end(video_info); if (icon_color == ozone_pure_white) - ozone_color_alpha(icon_color, 1.0f); + menu_display_set_alpha(icon_color, 1.0f); text_offset = 0; } /* Draw text */ - ozone_draw_text(video_info, ozone, rich_label, text_offset + ozone->dimensions.sidebar_width + x_offset + ozone->dimensions.entry_padding_horizontal_half + ozone->dimensions.entry_icon_size + ozone->dimensions.entry_icon_padding * 2, + ozone_draw_text(video_info, ozone, rich_label, text_offset + ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.entry_icon_size + ozone->dimensions.entry_icon_padding * 2, y + ozone->dimensions.entry_height / 2 + FONT_SIZE_ENTRIES_LABEL * 3/8 + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_label, COLOR_TEXT_ALPHA(ozone->theme->text_rgba, alpha_uint32), false); if (sublabel_str) - ozone_draw_text(video_info, ozone, sublabel_str, ozone->dimensions.sidebar_width + x_offset + ozone->dimensions.entry_padding_horizontal_half + ozone->dimensions.entry_icon_padding, + ozone_draw_text(video_info, ozone, sublabel_str, ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.entry_icon_padding, y + ozone->dimensions.entry_height + 1 + 5 + FONT_SIZE_ENTRIES_SUBLABEL + scroll_y, TEXT_ALIGN_LEFT, video_info->width, video_info->height, ozone->fonts.entries_sublabel, COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba, alpha_uint32), false); /* Value */ @@ -317,7 +522,7 @@ border_iterate: menu_animation_ticker(&ticker); - ozone_draw_entry_value(ozone, video_info, entry_value_ticker, ozone->dimensions.sidebar_width + ozone->dimensions.entry_padding_horizontal_half + x_offset + entry_width - ozone->dimensions.entry_icon_padding, + ozone_draw_entry_value(ozone, video_info, entry_value_ticker, ozone->dimensions.sidebar_width + entry_padding + x_offset + entry_width - ozone->dimensions.entry_icon_padding, y + ozone->dimensions.entry_height / 2 + FONT_SIZE_ENTRIES_LABEL * 3/8 + scroll_y, alpha_uint32, &entry); free(entry_rich_label); diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index 424ef0cbe8..22f48e6b4e 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -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); diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 4391372983..b192a03711 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -36,10 +36,12 @@ add_dirs() check_compiler() { if [ "$1" = cxx ]; then COMPILER="$CXX" + FLAGS="$CXXFLAGS" TEMP_CODE="$TEMP_CXX" TEST_C="extern \"C\" { void $2(void); } int main() { $2(); }" else COMPILER="$CC" + FLAGS="$CFLAGS" TEMP_CODE="$TEMP_C" TEST_C="void $2(void); int main(void) { $2(); return 0; }" fi @@ -111,7 +113,7 @@ check_lib() error="${8:-}" answer='no' printf %s "$MSG $lib" - eval "set -- $INCLUDE_DIRS $LIBRARY_DIRS $5 $CFLAGS $LDFLAGS $lib" + eval "set -- $INCLUDE_DIRS $LIBRARY_DIRS $5 $FLAGS $LDFLAGS $lib" "$COMPILER" -o "$TEMP_EXE" "$TEMP_CODE" "$@" >>config.log 2>&1 && answer='yes' printf %s\\n " ... $answer"