From 545e5fd6abdbc90c074728587fbe5c053a01186d Mon Sep 17 00:00:00 2001 From: jdgleaver Date: Wed, 8 Apr 2020 15:15:39 +0100 Subject: [PATCH] (Ozone) Enable proper vertical text alignment + thumbnail display improvements --- menu/drivers/ozone/ozone.c | 318 ++++++++++++++--------------- menu/drivers/ozone/ozone.h | 53 +++-- menu/drivers/ozone/ozone_display.c | 40 ++-- menu/drivers/ozone/ozone_display.h | 2 +- menu/drivers/ozone/ozone_entries.c | 193 ++++++++++------- menu/drivers/ozone/ozone_sidebar.c | 21 +- menu/drivers/ozone/ozone_theme.c | 6 +- 7 files changed, 340 insertions(+), 293 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 281d126986..4c2be418b0 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -56,6 +56,7 @@ ozone_node_t *ozone_alloc_node(void) node->icon = 0; node->content_icon = 0; node->fullpath = NULL; + node->sublabel_lines = 0; return node; } @@ -354,12 +355,12 @@ static void ozone_free(void *data) if (ozone) { - video_coord_array_free(&ozone->raster_blocks.footer.carr); - video_coord_array_free(&ozone->raster_blocks.title.carr); - video_coord_array_free(&ozone->raster_blocks.time.carr); - video_coord_array_free(&ozone->raster_blocks.entries_label.carr); - video_coord_array_free(&ozone->raster_blocks.entries_sublabel.carr); - video_coord_array_free(&ozone->raster_blocks.sidebar.carr); + video_coord_array_free(&ozone->fonts.footer.raster_block.carr); + video_coord_array_free(&ozone->fonts.title.raster_block.carr); + video_coord_array_free(&ozone->fonts.time.raster_block.carr); + video_coord_array_free(&ozone->fonts.entries_label.raster_block.carr); + video_coord_array_free(&ozone->fonts.entries_sublabel.raster_block.carr); + video_coord_array_free(&ozone->fonts.sidebar.raster_block.carr); font_driver_bind_block(NULL, NULL); @@ -468,11 +469,45 @@ static void ozone_refresh_thumbnail_image(void *data, unsigned i) ozone_update_thumbnail_image(ozone); } +static bool ozone_init_font( + ozone_font_data_t *font_data, + bool is_threaded, char *font_path, float font_size) +{ + int glyph_width = 0; + + /* Free existing */ + if (font_data->font) + { + gfx_display_font_free(font_data->font); + font_data->font = NULL; + } + + /* Cache approximate dimensions */ + font_data->line_height = (int)(font_size + 0.5f); + font_data->glyph_width = (int)((font_size * (3.0f / 4.0f)) + 0.5f); + + /* Create font */ + font_data->font = gfx_display_font_file(font_path, font_size, is_threaded); + + if (!font_data->font) + return false; + + /* Get font metadata */ + glyph_width = font_driver_get_message_width(font_data->font, "a", 1, 1.0f); + if (glyph_width > 0) + font_data->glyph_width = glyph_width; + font_data->line_height = font_driver_get_line_height(font_data->font, 1.0f); + font_data->line_ascender = font_driver_get_line_ascender(font_data->font, 1.0f); + font_data->line_centre_offset = font_driver_get_line_centre_offset(font_data->font, 1.0f); + + return true; +} + /* Determines the size of all menu elements */ static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded) { - int font_size; float scale_factor; + bool font_inited; char font_path[PATH_MAX_LENGTH]; font_path[0] = '\0'; @@ -531,115 +566,33 @@ static void ozone_set_layout(ozone_handle_t *ozone, bool is_threaded) ozone->pointer_active_delta = CURSOR_ACTIVE_DELTA * scale_factor; /* Initialise fonts */ - - /* > Free existing */ - if (ozone->fonts.footer) - { - gfx_display_font_free(ozone->fonts.footer); - ozone->fonts.footer = NULL; - } - if (ozone->fonts.entries_label) - { - gfx_display_font_free(ozone->fonts.entries_label); - ozone->fonts.entries_label = NULL; - } - if (ozone->fonts.entries_sublabel) - { - gfx_display_font_free(ozone->fonts.entries_sublabel); - ozone->fonts.entries_sublabel = NULL; - } - if (ozone->fonts.time) - { - gfx_display_font_free(ozone->fonts.time); - ozone->fonts.time = NULL; - } - if (ozone->fonts.sidebar) - { - gfx_display_font_free(ozone->fonts.sidebar); - ozone->fonts.sidebar = NULL; - } - if (ozone->fonts.title) - { - gfx_display_font_free(ozone->fonts.title); - ozone->fonts.title = NULL; - } - - /* > Cache 'naive' font heights */ - ozone->title_font_glyph_height = FONT_SIZE_TITLE * scale_factor; - ozone->entry_font_glyph_height = FONT_SIZE_ENTRIES_LABEL * scale_factor; - ozone->sublabel_font_glyph_height = FONT_SIZE_ENTRIES_SUBLABEL * scale_factor; - ozone->footer_font_glyph_height = FONT_SIZE_FOOTER * scale_factor; - ozone->sidebar_font_glyph_height = FONT_SIZE_SIDEBAR * scale_factor; - ozone->time_font_glyph_height = FONT_SIZE_TIME * scale_factor; - - /* > Create 'bold' font objects */ fill_pathname_join(font_path, ozone->assets_path, "bold.ttf", sizeof(font_path)); - ozone->fonts.title = gfx_display_font_file(font_path, ozone->title_font_glyph_height, is_threaded); - /* > Create 'regular' font objects */ + font_inited = ozone_init_font(&ozone->fonts.title, + is_threaded, font_path, FONT_SIZE_TITLE * scale_factor); + ozone->has_all_assets = ozone->has_all_assets && font_inited; + fill_pathname_join(font_path, ozone->assets_path, "regular.ttf", sizeof(font_path)); - ozone->fonts.entries_label = gfx_display_font_file(font_path, ozone->entry_font_glyph_height, is_threaded); - ozone->fonts.entries_sublabel = gfx_display_font_file(font_path, ozone->sublabel_font_glyph_height, is_threaded); - ozone->fonts.footer = gfx_display_font_file(font_path, ozone->footer_font_glyph_height, is_threaded); - ozone->fonts.sidebar = gfx_display_font_file(font_path, ozone->sidebar_font_glyph_height, is_threaded); - ozone->fonts.time = gfx_display_font_file(font_path, ozone->time_font_glyph_height, is_threaded); - /* > Check for missing assets */ - if (!ozone->fonts.title || - !ozone->fonts.entries_label || - !ozone->fonts.entries_sublabel || - !ozone->fonts.footer || - !ozone->fonts.sidebar || - !ozone->fonts.time) - ozone->has_all_assets = false; + font_inited = ozone_init_font(&ozone->fonts.footer, + is_threaded, font_path, FONT_SIZE_FOOTER * scale_factor); + ozone->has_all_assets = ozone->has_all_assets && font_inited; - /* > Cache 'naive' font widths */ - ozone->title_font_glyph_width = ozone->title_font_glyph_height * 3.0f/4.0f; - ozone->entry_font_glyph_width = ozone->entry_font_glyph_height * 3.0f/4.0f; - ozone->sublabel_font_glyph_width = ozone->sublabel_font_glyph_height * 3.0f/4.0f; - ozone->footer_font_glyph_width = ozone->footer_font_glyph_height * 3.0f/4.0f; - ozone->sidebar_font_glyph_width = ozone->sidebar_font_glyph_height * 3.0f/4.0f; - ozone->time_font_glyph_width = ozone->time_font_glyph_height * 3.0f/4.0f; + font_inited = ozone_init_font(&ozone->fonts.time, + is_threaded, font_path, FONT_SIZE_TIME * scale_factor); + ozone->has_all_assets = ozone->has_all_assets && font_inited; - /* > Determine more realistic font widths */ - font_size = font_driver_get_message_width(ozone->fonts.title, "a", 1, 1); - if (font_size > 0) - ozone->title_font_glyph_width = (unsigned)font_size; - font_size = font_driver_get_message_width(ozone->fonts.entries_label, "a", 1, 1); - if (font_size > 0) - ozone->entry_font_glyph_width = (unsigned)font_size; - font_size = font_driver_get_message_width(ozone->fonts.entries_sublabel, "a", 1, 1); - if (font_size > 0) - ozone->sublabel_font_glyph_width = (unsigned)font_size; - font_size = font_driver_get_message_width(ozone->fonts.footer, "a", 1, 1); - if (font_size > 0) - ozone->footer_font_glyph_width = (unsigned)font_size; - font_size = font_driver_get_message_width(ozone->fonts.sidebar, "a", 1, 1); - if (font_size > 0) - ozone->sidebar_font_glyph_width = (unsigned)font_size; - font_size = font_driver_get_message_width(ozone->fonts.time, "a", 1, 1); - if (font_size > 0) - ozone->time_font_glyph_width = (unsigned)font_size; + font_inited = ozone_init_font(&ozone->fonts.entries_label, + is_threaded, font_path, FONT_SIZE_ENTRIES_LABEL * scale_factor); + ozone->has_all_assets = ozone->has_all_assets && font_inited; - /* > Get actual font heights */ - font_size = font_driver_get_line_height(ozone->fonts.title, 1.0f); - if (font_size > 0) - ozone->title_font_glyph_height = (unsigned)font_size; - font_size = font_driver_get_line_height(ozone->fonts.entries_label, 1.0f); - if (font_size > 0) - ozone->entry_font_glyph_height = (unsigned)font_size; - font_size = font_driver_get_line_height(ozone->fonts.entries_sublabel, 1.0f); - if (font_size > 0) - ozone->sublabel_font_glyph_height = (unsigned)font_size; - font_size = font_driver_get_line_height(ozone->fonts.footer, 1.0f); - if (font_size > 0) - ozone->footer_font_glyph_height = (unsigned)font_size; - font_size = font_driver_get_line_height(ozone->fonts.sidebar, 1.0f); - if (font_size > 0) - ozone->sidebar_font_glyph_height = (unsigned)font_size; - font_size = font_driver_get_line_height(ozone->fonts.time, 1.0f); - if (font_size > 0) - ozone->time_font_glyph_height = (unsigned)font_size; + font_inited = ozone_init_font(&ozone->fonts.entries_sublabel, + is_threaded, font_path, FONT_SIZE_ENTRIES_SUBLABEL * scale_factor); + ozone->has_all_assets = ozone->has_all_assets && font_inited; + + font_inited = ozone_init_font(&ozone->fonts.sidebar, + is_threaded, font_path, FONT_SIZE_SIDEBAR * scale_factor); + ozone->has_all_assets = ozone->has_all_assets && font_inited; /* Multiple sidebar parameters are set via animations * > ozone_refresh_sidebars() cancels any existing @@ -783,6 +736,14 @@ static void ozone_unload_thumbnail_textures(void *data) gfx_thumbnail_reset(&ozone->thumbnails.left); } +static void INLINE ozone_font_free(ozone_font_data_t *font_data) +{ + if (font_data->font) + gfx_display_font_free(font_data->font); + + font_data->font = NULL; +} + static void ozone_context_destroy(void *data) { unsigned i; @@ -812,19 +773,13 @@ static void ozone_context_destroy(void *data) video_driver_texture_unload(&gfx_display_white_texture); - gfx_display_font_free(ozone->fonts.footer); - gfx_display_font_free(ozone->fonts.title); - gfx_display_font_free(ozone->fonts.time); - gfx_display_font_free(ozone->fonts.entries_label); - gfx_display_font_free(ozone->fonts.entries_sublabel); - gfx_display_font_free(ozone->fonts.sidebar); - - ozone->fonts.footer = NULL; - ozone->fonts.title = NULL; - ozone->fonts.time = NULL; - ozone->fonts.entries_label = NULL; - ozone->fonts.entries_sublabel = NULL; - ozone->fonts.sidebar = NULL; + /* Fonts */ + ozone_font_free(&ozone->fonts.footer); + ozone_font_free(&ozone->fonts.title); + ozone_font_free(&ozone->fonts.time); + ozone_font_free(&ozone->fonts.entries_label); + ozone_font_free(&ozone->fonts.entries_sublabel); + ozone_font_free(&ozone->fonts.sidebar); tag = (uintptr_t) &ozone_default_theme; gfx_animation_kill_by_tag(&tag); @@ -1530,7 +1485,7 @@ static void ozone_draw_header(ozone_handle_t *ozone, /* Title */ if (use_smooth_ticker) { - ticker_smooth.font = ozone->fonts.title; + ticker_smooth.font = ozone->fonts.title.font; ticker_smooth.selected = true; ticker_smooth.field_width = (video_width - (128 + 47 + 180) * scale_factor); ticker_smooth.src_str = ozone->show_fullscreen_thumbnails ? ozone->fullscreen_thumbnail_label : ozone->title; @@ -1542,14 +1497,17 @@ static void ozone_draw_header(ozone_handle_t *ozone, else { ticker.s = title; - ticker.len = (video_width - (128 + 47 + 180) * scale_factor) / ozone->title_font_glyph_width; + ticker.len = (video_width - (128 + 47 + 180) * scale_factor) / ozone->fonts.title.glyph_width; ticker.str = ozone->show_fullscreen_thumbnails ? ozone->fullscreen_thumbnail_label : ozone->title; ticker.selected = true; gfx_animation_ticker(&ticker); } - ozone_draw_text(ozone, title, ticker_x_offset + 128 * scale_factor, ozone->dimensions.header_height / 2 + ozone->title_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.title, ozone->theme->text_rgba, false); + ozone_draw_text(ozone, title, + ticker_x_offset + 128 * scale_factor, + ozone->dimensions.header_height / 2 + ozone->fonts.title.line_centre_offset, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.title, ozone->theme->text_rgba, false); /* Icon */ gfx_display_blend_begin(userdata); @@ -1600,7 +1558,10 @@ static void ozone_draw_header(ozone_handle_t *ozone, { timedate_offset = 95 * scale_factor; - ozone_draw_text(ozone, msg, video_width - 85 * scale_factor, ozone->dimensions.header_height / 2 + ozone->time_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_RIGHT, video_width, video_height, ozone->fonts.time, ozone->theme->text_rgba, false); + ozone_draw_text(ozone, msg, + video_width - 85 * scale_factor, + ozone->dimensions.header_height / 2 + ozone->fonts.time.line_centre_offset, + TEXT_ALIGN_RIGHT, video_width, video_height, &ozone->fonts.time, ozone->theme->text_rgba, false); gfx_display_blend_begin(userdata); ozone_draw_icon( @@ -1633,7 +1594,10 @@ static void ozone_draw_header(ozone_handle_t *ozone, menu_display_timedate(&datetime); - ozone_draw_text(ozone, timedate, video_width - (85 * scale_factor) - timedate_offset, ozone->dimensions.header_height / 2 + ozone->time_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_RIGHT, video_width, video_height, ozone->fonts.time, ozone->theme->text_rgba, false); + ozone_draw_text(ozone, timedate, + video_width - (85 * scale_factor) - timedate_offset, + ozone->dimensions.header_height / 2 + ozone->fonts.time.line_centre_offset, + TEXT_ALIGN_RIGHT, video_width, video_height, &ozone->fonts.time, ozone->theme->text_rgba, false); gfx_display_blend_begin(userdata); ozone_draw_icon( @@ -1681,7 +1645,10 @@ static void ozone_draw_footer(ozone_handle_t *ozone, { char core_title[255]; menu_entries_get_core_title(core_title, sizeof(core_title)); - ozone_draw_text(ozone, core_title, 59 * scale_factor, video_height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.footer, ozone->theme->text_rgba, false); + ozone_draw_text(ozone, core_title, + 59 * scale_factor, + video_height - ozone->dimensions.footer_height / 2 + ozone->fonts.footer.line_centre_offset, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); } else ozone_draw_icon( @@ -1764,21 +1731,30 @@ static void ozone_draw_footer(ozone_handle_t *ozone, (input_menu_swap_ok_cancel_buttons) ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_OK) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK), - video_width - back_width, video_height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.footer, ozone->theme->text_rgba, false); + video_width - back_width, + video_height - ozone->dimensions.footer_height / 2 + ozone->fonts.footer.line_centre_offset, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); + ozone_draw_text(ozone, (input_menu_swap_ok_cancel_buttons) ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_BACK) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_BASIC_MENU_CONTROLS_OK), - video_width - ok_width, video_height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.footer, ozone->theme->text_rgba, false); + video_width - ok_width, + video_height - ozone->dimensions.footer_height / 2 + ozone->fonts.footer.line_centre_offset, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); ozone_draw_text(ozone, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SEARCH), - video_width - search_width, video_height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.footer, ozone->theme->text_rgba, false); + video_width - search_width, + video_height - ozone->dimensions.footer_height / 2 + ozone->fonts.footer.line_centre_offset, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); if (ozone->is_playlist && !ozone->cursor_in_sidebar) ozone_draw_text(ozone, msg_hash_to_str(MSG_CHANGE_THUMBNAIL_TYPE), - video_width - thumb_width, video_height - ozone->dimensions.footer_height / 2 + ozone->footer_font_glyph_height * 3.0f/10.0f, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.footer, ozone->theme->text_rgba, false); + video_width - thumb_width, + video_height - ozone->dimensions.footer_height / 2 + ozone->fonts.footer.line_centre_offset, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); } @@ -1830,7 +1806,7 @@ void ozone_update_content_metadata(ozone_handle_t *ozone) { unsigned metadata_len = (ozone->dimensions.thumbnail_bar_width - ((ozone->dimensions.sidebar_entry_icon_padding * 2) * 2)) / - ozone->footer_font_glyph_width; + ozone->fonts.footer.glyph_width; word_wrap(ozone->selection_core_name, ozone->selection_core_name, metadata_len, true, 0); ozone->selection_core_name_lines = ozone_count_lines(ozone->selection_core_name); } @@ -2087,6 +2063,31 @@ static void ozone_messagebox_fadeout_cb(void *userdata) ozone->should_draw_messagebox = false; } +static void INLINE ozone_font_bind(ozone_font_data_t *font_data) +{ + font_driver_bind_block(font_data->font, &font_data->raster_block); + font_data->raster_block.carr.coords.vertices = 0; +} + +static void INLINE ozone_font_unbind(ozone_font_data_t *font_data) +{ + font_driver_bind_block(font_data->font, NULL); +} + +void ozone_font_flush( + unsigned video_width, unsigned video_height, + ozone_font_data_t *font_data) +{ + /* Flushing is slow - only do it if font + * has actually been used */ + if (!font_data || + (font_data->raster_block.carr.coords.vertices == 0)) + return; + + font_driver_flush(video_width, video_height, font_data->font); + font_data->raster_block.carr.coords.vertices = 0; +} + static void ozone_frame(void *data, video_frame_info_t *video_info) { gfx_animation_ctx_entry_t entry; @@ -2165,19 +2166,12 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) gfx_display_set_viewport(video_width, video_height); /* Clear text */ - font_driver_bind_block(ozone->fonts.footer, &ozone->raster_blocks.footer); - font_driver_bind_block(ozone->fonts.title, &ozone->raster_blocks.title); - font_driver_bind_block(ozone->fonts.time, &ozone->raster_blocks.time); - font_driver_bind_block(ozone->fonts.entries_label, &ozone->raster_blocks.entries_label); - font_driver_bind_block(ozone->fonts.entries_sublabel, &ozone->raster_blocks.entries_sublabel); - font_driver_bind_block(ozone->fonts.sidebar, &ozone->raster_blocks.sidebar); - - ozone->raster_blocks.footer.carr.coords.vertices = 0; - ozone->raster_blocks.title.carr.coords.vertices = 0; - ozone->raster_blocks.time.carr.coords.vertices = 0; - ozone->raster_blocks.entries_label.carr.coords.vertices = 0; - ozone->raster_blocks.entries_sublabel.carr.coords.vertices = 0; - ozone->raster_blocks.sidebar.carr.coords.vertices = 0; + ozone_font_bind(&ozone->fonts.footer); + ozone_font_bind(&ozone->fonts.title); + ozone_font_bind(&ozone->fonts.time); + ozone_font_bind(&ozone->fonts.entries_label); + ozone_font_bind(&ozone->fonts.entries_sublabel); + ozone_font_bind(&ozone->fonts.sidebar); /* Background */ if (libretro_running && @@ -2274,14 +2268,12 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) video_height); /* Flush first layer of text */ - font_driver_flush(video_width, video_height, ozone->fonts.footer); - font_driver_flush(video_width, video_height, ozone->fonts.title); - font_driver_flush(video_width, video_height, ozone->fonts.time); - - font_driver_bind_block(ozone->fonts.footer, NULL); - font_driver_bind_block(ozone->fonts.title, NULL); - font_driver_bind_block(ozone->fonts.time, NULL); - font_driver_bind_block(ozone->fonts.entries_label, NULL); + ozone_font_flush(video_width, video_height, &ozone->fonts.footer); + ozone_font_flush(video_width, video_height, &ozone->fonts.title); + ozone_font_flush(video_width, video_height, &ozone->fonts.time); + ozone_font_flush(video_width, video_height, &ozone->fonts.entries_label); + ozone_font_flush(video_width, video_height, &ozone->fonts.entries_sublabel); + ozone_font_flush(video_width, video_height, &ozone->fonts.sidebar); /* Draw fullscreen thumbnails, if required */ ozone_draw_fullscreen_thumbnails(ozone, @@ -2290,9 +2282,6 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) video_height); /* Message box & OSK - second layer of text */ - ozone->raster_blocks.footer.carr.coords.vertices = 0; - ozone->raster_blocks.entries_label.carr.coords.vertices = 0; - if (ozone->should_draw_messagebox || draw_osk) { /* Fade in animation */ @@ -2356,10 +2345,11 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) video_width, video_height, ozone->pending_message); - } - font_driver_flush(video_width, video_height, ozone->fonts.footer); - font_driver_flush(video_width, video_height, ozone->fonts.entries_label); + /* Flush second layer of text */ + ozone_font_flush(video_width, video_height, &ozone->fonts.footer); + ozone_font_flush(video_width, video_height, &ozone->fonts.entries_label); + } /* Cursor */ if (ozone->show_cursor && (ozone->pointer.type != MENU_POINTER_DISABLED)) @@ -2382,6 +2372,14 @@ static void ozone_frame(void *data, video_frame_info_t *video_info) ); } + /* Unbind fonts */ + ozone_font_unbind(&ozone->fonts.footer); + ozone_font_unbind(&ozone->fonts.title); + ozone_font_unbind(&ozone->fonts.time); + ozone_font_unbind(&ozone->fonts.entries_label); + ozone_font_unbind(&ozone->fonts.entries_sublabel); + ozone_font_unbind(&ozone->fonts.sidebar); + gfx_display_unset_viewport(video_width, video_height); } diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 958ec3a050..7dafb54b99 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -86,28 +86,30 @@ enum ozone_onscreen_entry_position_type OZONE_ONSCREEN_ENTRY_CENTRE }; +/* This structure holds all objects + metadata + * corresponding to a particular font */ +typedef struct +{ + font_data_t *font; + video_font_raster_block_t raster_block; + int glyph_width; + int line_height; + int line_ascender; + int line_centre_offset; +} ozone_font_data_t; + struct ozone_handle { struct { - font_data_t *footer; - font_data_t *title; - font_data_t *time; - font_data_t *entries_label; - font_data_t *entries_sublabel; - font_data_t *sidebar; + ozone_font_data_t footer; + ozone_font_data_t title; + ozone_font_data_t time; + ozone_font_data_t entries_label; + ozone_font_data_t entries_sublabel; + ozone_font_data_t sidebar; } fonts; - struct - { - video_font_raster_block_t footer; - video_font_raster_block_t title; - video_font_raster_block_t time; - video_font_raster_block_t entries_label; - video_font_raster_block_t entries_sublabel; - video_font_raster_block_t sidebar; - } raster_blocks; - uintptr_t textures[OZONE_THEME_TEXTURE_LAST]; uintptr_t icons_textures[OZONE_ENTRIES_ICONS_TEXTURE_LAST]; uintptr_t tab_textures[OZONE_TAB_TEXTURE_LAST]; @@ -157,20 +159,6 @@ struct ozone_handle bool draw_sidebar; float sidebar_offset; - unsigned title_font_glyph_width; - unsigned entry_font_glyph_width; - unsigned sublabel_font_glyph_width; - unsigned footer_font_glyph_width; - unsigned sidebar_font_glyph_width; - unsigned time_font_glyph_width; - - unsigned title_font_glyph_height; - unsigned entry_font_glyph_height; - unsigned sublabel_font_glyph_height; - unsigned footer_font_glyph_height; - unsigned sidebar_font_glyph_height; - unsigned time_font_glyph_height; - ozone_theme_t *theme; struct { @@ -304,6 +292,7 @@ typedef struct ozone_node unsigned height; unsigned position_y; bool wrap; + unsigned sublabel_lines; char *fullpath; /* Console tabs */ @@ -388,4 +377,8 @@ unsigned ozone_count_lines(const char *str); void ozone_update_content_metadata(ozone_handle_t *ozone); +void ozone_font_flush( + unsigned video_width, unsigned video_height, + ozone_font_data_t *font_data); + #endif diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index 3116c6c8c1..14c77487f9 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -100,11 +100,11 @@ void ozone_draw_text( const char *str, float x, float y, enum text_alignment text_align, - unsigned width, unsigned height, font_data_t* font, + unsigned width, unsigned height, ozone_font_data_t *font_data, uint32_t color, bool draw_outside) { - gfx_display_draw_text(font, str, x, y, + gfx_display_draw_text(font_data->font, str, x, y, width, height, color, text_align, 1.0f, false, 1.0, draw_outside); @@ -443,7 +443,7 @@ void ozone_draw_osk(ozone_handle_t *ozone, text_color = ozone_theme_light.text_sublabel_rgba; } - word_wrap(message, text, (video_width - margin*2 - padding*2) / ozone->entry_font_glyph_width, true, 0); + word_wrap(message, text, (video_width - margin*2 - padding*2) / ozone->fonts.entries_label.glyph_width, true, 0); list = string_split(message, "\n"); @@ -451,14 +451,17 @@ void ozone_draw_osk(ozone_handle_t *ozone, { const char *msg = list->elems[i].data; - ozone_draw_text(ozone, msg, margin + padding * 2, margin + padding + ozone->sublabel_font_glyph_height + y_offset, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.entries_label, text_color, false); + ozone_draw_text(ozone, msg, + margin + padding * 2, + margin + padding + ozone->fonts.entries_label.line_height + y_offset, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.entries_label, text_color, false); /* Cursor */ if (i == list->size - 1) { if (ozone->osk_cursor) { - unsigned cursor_x = draw_placeholder ? 0 : font_driver_get_message_width(ozone->fonts.entries_label, msg, (unsigned)strlen(msg), 1); + unsigned cursor_x = draw_placeholder ? 0 : font_driver_get_message_width(ozone->fonts.entries_label.font, msg, (unsigned)strlen(msg), 1); gfx_display_draw_quad( userdata, video_width, @@ -484,7 +487,7 @@ void ozone_draw_osk(ozone_handle_t *ozone, video_width, video_height, ozone->theme->textures[OZONE_THEME_TEXTURE_CURSOR_STATIC], - ozone->fonts.entries_label, + ozone->fonts.entries_label.font, input_event_get_osk_grid(), input_event_get_osk_ptr(), ozone->theme->text_rgba); @@ -507,7 +510,7 @@ void ozone_draw_messagebox( unsigned width = video_width; unsigned height = video_height; - if (!list || !ozone || !ozone->fonts.footer) + if (!list || !ozone || !ozone->fonts.footer.font) { if (list) string_list_free(list); @@ -522,7 +525,7 @@ void ozone_draw_messagebox( y_position = height / 4; x = width / 2; - y = y_position - (list->size * ozone->footer_font_glyph_height) / 2; + y = y_position - (list->size * ozone->fonts.footer.line_height) / 2; /* find the longest line width */ for (i = 0; i < list->size; i++) @@ -534,7 +537,7 @@ void ozone_draw_messagebox( { longest = len; longest_width = font_driver_get_message_width( - ozone->fonts.footer, msg, (unsigned)strlen(msg), 1); + ozone->fonts.footer.font, msg, (unsigned)strlen(msg), 1); } } @@ -542,12 +545,19 @@ void ozone_draw_messagebox( gfx_display_blend_begin(userdata); - if (ozone->has_all_assets) /* avoid drawing a black box if there's no assets */ + /* Avoid drawing a black box if there's no assets */ + if (ozone->has_all_assets) { - int slice_x = x - longest_width/2 - 48 * scale_factor; - int slice_y = (list->size > 1) ? y : y - (ozone->footer_font_glyph_height / 2); + /* Note: The fact that we use a texture slice here + * makes things very messy + * > The actual size and offset of a texture slice + * is quite 'loose', and depends upon source image + * size, draw size and scale factor... */ unsigned slice_new_w = longest_width + 48 * 2 * scale_factor; - unsigned slice_new_h = ozone->footer_font_glyph_height * (list->size + 2); + unsigned slice_new_h = ozone->fonts.footer.line_height * (list->size + 2); + int slice_x = x - longest_width/2 - 48 * scale_factor; + int slice_y = y - ozone->fonts.footer.line_height + + ((slice_new_h >= 256) ? (16.0f * scale_factor) : (16.0f * ((float)slice_new_h / 256.0f))); gfx_display_draw_texture_slice( userdata, @@ -573,10 +583,10 @@ void ozone_draw_messagebox( ozone_draw_text(ozone, msg, x - longest_width/2.0, - y + (i + 1) * ozone->footer_font_glyph_height, + y + (i * ozone->fonts.footer.line_height) + ozone->fonts.footer.line_ascender, TEXT_ALIGN_LEFT, width, height, - ozone->fonts.footer, + &ozone->fonts.footer, COLOR_TEXT_ALPHA(ozone->theme->text_rgba, (uint32_t)(ozone->animations.messagebox_alpha*255.0f)), false ); diff --git a/menu/drivers/ozone/ozone_display.h b/menu/drivers/ozone/ozone_display.h index 5a21466cbf..58da55087a 100644 --- a/menu/drivers/ozone/ozone_display.h +++ b/menu/drivers/ozone/ozone_display.h @@ -26,7 +26,7 @@ void ozone_draw_text( const char *str, float x, float y, enum text_alignment text_align, - unsigned width, unsigned height, font_data_t* font, + unsigned width, unsigned height, ozone_font_data_t *font_data, uint32_t color, bool draw_outside); diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index 724a4e582d..9645154515 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -129,12 +129,12 @@ static void ozone_draw_entry_value( if (do_draw_text) { - ozone_draw_text(ozone, value, x, y, TEXT_ALIGN_RIGHT, video_width, video_height, ozone->fonts.entries_label, COLOR_TEXT_ALPHA(ozone->theme->text_selected_rgba, alpha_uint32), false); + ozone_draw_text(ozone, value, x, y, TEXT_ALIGN_RIGHT, video_width, video_height, &ozone->fonts.entries_label, COLOR_TEXT_ALPHA(ozone->theme->text_selected_rgba, alpha_uint32), false); } else { ozone_draw_text(ozone, (switch_is_on ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)), - x, y, TEXT_ALIGN_RIGHT, video_width, video_height, ozone->fonts.entries_label, + x, y, TEXT_ALIGN_RIGHT, video_width, video_height, &ozone->fonts.entries_label, COLOR_TEXT_ALPHA((switch_is_on ? ozone->theme->text_selected_rgba : ozone->theme->text_sublabel_rgba), alpha_uint32), false); } } @@ -219,7 +219,6 @@ 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; @@ -270,8 +269,9 @@ void ozone_compute_entries_position(ozone_handle_t *ozone) if (!node) continue; - node->height = ozone->dimensions.entry_height; - node->wrap = false; + node->height = ozone->dimensions.entry_height; + node->wrap = false; + node->sublabel_lines = 0; menu_entry_get_sublabel(&entry, &sublabel_str); @@ -296,13 +296,13 @@ void ozone_compute_entries_position(ozone_handle_t *ozone) sublabel_max_width -= ozone->dimensions.thumbnail_bar_width; } - word_wrap(wrapped_sublabel_str, sublabel_str, sublabel_max_width / ozone->sublabel_font_glyph_width, false, 0); + word_wrap(wrapped_sublabel_str, sublabel_str, sublabel_max_width / ozone->fonts.entries_sublabel.glyph_width, false, 0); - lines = ozone_count_lines(wrapped_sublabel_str); + node->sublabel_lines = ozone_count_lines(wrapped_sublabel_str); - if (lines > 1) + if (node->sublabel_lines > 1) { - node->height += (lines - 1) * ozone->sublabel_font_glyph_height; + node->height += (node->sublabel_lines - 1) * ozone->fonts.entries_sublabel.line_height; node->wrap = true; } } @@ -555,7 +555,7 @@ border_iterate: if (use_smooth_ticker) { ticker_smooth.idx = gfx_animation_get_ticker_pixel_idx(); - ticker_smooth.font = ozone->fonts.entries_label; + ticker_smooth.font = ozone->fonts.entries_label.font; ticker_smooth.font_scale = 1.0f; ticker_smooth.type_enum = menu_ticker_type; ticker_smooth.spacer = ticker_spacer; @@ -605,7 +605,7 @@ border_iterate: ticker.s = rich_label; ticker.str = entry_rich_label; ticker.selected = entry_selected && !ozone->cursor_in_sidebar; - ticker.len = (entry_width - entry_padding - (10 * scale_factor) - ozone->dimensions.entry_icon_padding) / ozone->entry_font_glyph_width; + ticker.len = (entry_width - entry_padding - (10 * scale_factor) - ozone->dimensions.entry_icon_padding) / ozone->fonts.entries_label.glyph_width; gfx_animation_ticker(&ticker); } @@ -614,7 +614,7 @@ border_iterate: { /* Note: This entry can never be selected, so ticker_x_offset * is irrelevant here (i.e. this text will never scroll) */ - unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label, rich_label, (unsigned)strlen(rich_label), 1); + unsigned text_width = font_driver_get_message_width(ozone->fonts.entries_label.font, rich_label, (unsigned)strlen(rich_label), 1); x_offset = (video_info_width - (unsigned) ozone->dimensions.sidebar_width - entry_padding * 2) / 2 - text_width / 2 - 60 * scale_factor; y = video_info_height / 2 - 60 * scale_factor; } @@ -628,14 +628,16 @@ border_iterate: int sublabel_max_width = video_info_width - entry_padding * 2 - ozone->dimensions.entry_icon_padding * 2; - if (ozone->show_thumbnail_bar) - sublabel_max_width -= ozone->dimensions.thumbnail_bar_width; - if (ozone->depth == 1) + { sublabel_max_width -= (unsigned) ozone->dimensions.sidebar_width; + if (ozone->show_thumbnail_bar) + sublabel_max_width -= ozone->dimensions.thumbnail_bar_width; + } + wrapped_sublabel_str[0] = '\0'; - word_wrap(wrapped_sublabel_str, sublabel_str, sublabel_max_width / ozone->sublabel_font_glyph_width, false, 0); + word_wrap(wrapped_sublabel_str, sublabel_str, sublabel_max_width / ozone->fonts.entries_sublabel.glyph_width, false, 0); sublabel_str = wrapped_sublabel_str; } } @@ -696,14 +698,18 @@ border_iterate: } /* Draw text */ - ozone_draw_text(ozone, rich_label, ticker_x_offset + text_offset + (unsigned) 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 + ozone->entry_font_glyph_height * 3.0f/10.0f + scroll_y, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.entries_label, COLOR_TEXT_ALPHA(ozone->theme->text_rgba, alpha_uint32), false); + ozone_draw_text(ozone, rich_label, + ticker_x_offset + text_offset + (unsigned) 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.0f + ozone->fonts.entries_label.line_centre_offset + scroll_y, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.entries_label, COLOR_TEXT_ALPHA(ozone->theme->text_rgba, alpha_uint32), false); if (menu_show_sublabels) { if (!string_is_empty(sublabel_str)) - ozone_draw_text(ozone, sublabel_str, (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.entry_icon_padding, - y + ozone->dimensions.entry_height + ozone->dimensions.spacer_1px + ozone->dimensions.spacer_5px + ozone->sublabel_font_glyph_height + scroll_y, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.entries_sublabel, COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba, alpha_uint32), false); + ozone_draw_text(ozone, sublabel_str, + (unsigned) ozone->dimensions.sidebar_width + x_offset + entry_padding + ozone->dimensions.entry_icon_padding, + y + ozone->dimensions.entry_height - ozone->dimensions.spacer_1px + (node->height - ozone->dimensions.entry_height - (node->sublabel_lines * ozone->fonts.entries_sublabel.line_height))/2.0f + ozone->fonts.entries_sublabel.line_ascender + scroll_y, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.entries_sublabel, COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba, alpha_uint32), false); } /* Value */ @@ -711,7 +717,7 @@ border_iterate: { ticker_smooth.selected = entry_selected && !ozone->cursor_in_sidebar; ticker_smooth.field_width = (entry_width - ozone->dimensions.entry_icon_size - ozone->dimensions.entry_icon_padding * 2 - - ((unsigned)utf8len(entry_rich_label) * ozone->entry_font_glyph_width)); + ((unsigned)utf8len(entry_rich_label) * ozone->fonts.entries_label.glyph_width)); ticker_smooth.src_str = entry_value; ticker_smooth.dst_str = entry_value_ticker; ticker_smooth.dst_str_len = sizeof(entry_value_ticker); @@ -727,7 +733,7 @@ border_iterate: ticker.str = entry_value; ticker.selected = entry_selected && !ozone->cursor_in_sidebar; ticker.len = (entry_width - ozone->dimensions.entry_icon_size - ozone->dimensions.entry_icon_padding * 2 - - ((unsigned)utf8len(entry_rich_label) * ozone->entry_font_glyph_width)) / ozone->entry_font_glyph_width; + ((unsigned)utf8len(entry_rich_label) * ozone->fonts.entries_label.glyph_width)) / ozone->fonts.entries_label.glyph_width; gfx_animation_ticker(&ticker); } @@ -738,7 +744,7 @@ border_iterate: video_height, entry_value_ticker, value_x_offset + (unsigned) ozone->dimensions.sidebar_width + entry_padding + x_offset + entry_width - ozone->dimensions.entry_icon_padding, - y + ozone->dimensions.entry_height / 2 + ozone->entry_font_glyph_height * 3.0f/10.0f + scroll_y, + y + ozone->dimensions.entry_height / 2 + ozone->fonts.entries_label.line_centre_offset + scroll_y, alpha_uint32, &entry); @@ -747,10 +753,10 @@ icons_iterate: } /* Text layer */ - font_driver_flush(video_width, video_height, ozone->fonts.entries_label); + ozone_font_flush(video_width, video_height, &ozone->fonts.entries_label); if (menu_show_sublabels) - font_driver_flush(video_width, video_height, ozone->fonts.entries_sublabel); + ozone_font_flush(video_width, video_height, &ozone->fonts.entries_sublabel); } static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone, @@ -773,7 +779,7 @@ static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone, icon_size, ozone->icons_textures[icon], x_position + sidebar_width/2 - icon_size/2, - video_height / 2 - icon_size/2 - y_offset, + video_height/2 - icon_size/2 - y_offset, video_width, video_height, 0, 1, ozone->theme->entries_icon); @@ -783,10 +789,10 @@ static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone, ozone, msg_hash_to_str(MSG_NO_THUMBNAIL_AVAILABLE), x_position + sidebar_width/2, - video_height / 2 - icon_size/2 + ozone->footer_font_glyph_height * 4 - y_offset, + video_height/2 + icon_size/2 + ozone->fonts.footer.line_ascender - y_offset, TEXT_ALIGN_CENTER, video_width, video_height, - ozone->fonts.footer, + &ozone->fonts.footer, ozone->theme->text_rgba, true ); @@ -804,16 +810,16 @@ static void ozone_content_metadata_line( ozone_draw_text(ozone, text, column_x, - *y + ozone->footer_font_glyph_height, + *y + ozone->fonts.footer.line_ascender, TEXT_ALIGN_LEFT, video_width, video_height, - ozone->fonts.footer, + &ozone->fonts.footer, ozone->theme->text_rgba, true ); if (lines_count > 0) - *y += (unsigned)(ozone->footer_font_glyph_height * (lines_count - 1)) + (unsigned)((float)ozone->footer_font_glyph_height * 1.5f); + *y += (unsigned)(ozone->fonts.footer.line_height * (lines_count - 1)) + (unsigned)((float)ozone->fonts.footer.line_height * 1.5f); } void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, @@ -827,12 +833,16 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, unsigned thumbnail_width = sidebar_width - (ozone->dimensions.sidebar_entry_icon_padding * 2); int right_thumbnail_y_position = 0; int left_thumbnail_y_position = 0; + int bottom_row_y_position = 0; bool show_right_thumbnail = false; bool show_left_thumbnail = false; unsigned sidebar_height = video_height - ozone->dimensions.header_height - ozone->dimensions.sidebar_gradient_height * 2 - ozone->dimensions.footer_height; unsigned x_position = video_width - (unsigned) ozone->animations.thumbnail_bar_position; int thumbnail_x_position = x_position + ozone->dimensions.sidebar_entry_icon_padding; unsigned thumbnail_height = (video_height - ozone->dimensions.header_height - ozone->dimensions.spacer_2px - ozone->dimensions.footer_height - (ozone->dimensions.sidebar_entry_icon_padding * 3)) / 2; + float scale_factor = ozone->last_scale_factor; + enum gfx_thumbnail_alignment right_thumbnail_alignment; + enum gfx_thumbnail_alignment left_thumbnail_alignment; /* Background */ if (!libretro_running || (menu_framebuffer_opacity >= 1.0f)) @@ -881,10 +891,10 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_LEFT) && !ozone->selection_core_is_viewer; - /* If user requested "left" thumbnail instead of content metadata - * and no thumbnails are available, show a centred message and - * return immediately */ - if (!show_right_thumbnail && !show_left_thumbnail && gfx_thumbnail_is_enabled(ozone->thumbnail_path_data, GFX_THUMBNAIL_LEFT)) + /* If this entry is associated with the image viewer + * and no right thumbnail is available, show a centred + * message and return immediately */ + if (ozone->selection_core_is_viewer && !show_right_thumbnail) { ozone_draw_no_thumbnail_available( ozone, @@ -895,29 +905,36 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, return; } - /* Top row : thumbnail or no thumbnail available message */ - if (show_right_thumbnail) + /* Top row + * > Displays one item, with the following order + * of preference: + * 1) Right thumbnail, if available + * 2) Left thumbnail, if available + * 3) 'No thumbnail available' message */ + + /* > If this entry is associated with the image viewer + * core, there can be only one thumbnail and no + * content metadata -> centre image vertically */ + if (ozone->selection_core_is_viewer) { - enum gfx_thumbnail_alignment alignment = GFX_THUMBNAIL_ALIGN_BOTTOM; + right_thumbnail_y_position = + ozone->dimensions.header_height + + ((thumbnail_height / 2) + + (int)(1.5f * (float)ozone->dimensions.sidebar_entry_icon_padding)); - /* If this entry is associated with the image viewer - * core, there can be only one thumbnail and no - * content metadata - * > Centre image vertically */ - if (ozone->selection_core_is_viewer) - { - right_thumbnail_y_position = - ozone->dimensions.header_height + - ((thumbnail_height / 2) + - (int)(1.5f * (float)ozone->dimensions.sidebar_entry_icon_padding)); + right_thumbnail_alignment = GFX_THUMBNAIL_ALIGN_CENTRE; + } + else + { + right_thumbnail_y_position = + ozone->dimensions.header_height + ozone->dimensions.spacer_1px + + ozone->dimensions.sidebar_entry_icon_padding; - alignment = GFX_THUMBNAIL_ALIGN_CENTRE; - } - else - right_thumbnail_y_position = - ozone->dimensions.header_height + ozone->dimensions.spacer_1px + - ozone->dimensions.sidebar_entry_icon_padding; + right_thumbnail_alignment = GFX_THUMBNAIL_ALIGN_BOTTOM; + } + /* > If we have a right thumbnail, show it */ + if (show_right_thumbnail) gfx_thumbnail_draw( userdata, video_width, @@ -927,33 +944,51 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, (float)right_thumbnail_y_position, thumbnail_width, thumbnail_height, - alignment, + right_thumbnail_alignment, 1.0f, 1.0f, NULL); - } - else - { - /* If thumbnails are disabled, we don't know the thumbnail - * height but we still need to move it to leave room for the - * content metadata panel */ - unsigned y_offset = thumbnail_height / 2; - + /* > If we have neither a right thumbnail nor + * a left thumbnail to show in its place, + * display 'no thumbnail available' message */ + else if (!show_left_thumbnail) ozone_draw_no_thumbnail_available(ozone, userdata, video_width, video_height, x_position, sidebar_width, - y_offset); - } + thumbnail_height / 2); - /* Bottom row : "left" thumbnail or content metadata */ - left_thumbnail_y_position = - ozone->dimensions.header_height + ozone->dimensions.spacer_1px + + /* Bottom row + * > Displays one item, with the following order + * of preference: + * 1) Left thumbnail, if available *and* right + * thumbnail has been placed in the top row + * 2) Content metadata */ + + /* > Get baseline 'start' position of bottom row */ + bottom_row_y_position = ozone->dimensions.header_height + ozone->dimensions.spacer_1px + thumbnail_height + (ozone->dimensions.sidebar_entry_icon_padding * 2); - if (show_right_thumbnail && show_left_thumbnail) + /* > If we have a left thumbnail, show it */ + if (show_left_thumbnail) { + /* Normally a right thumbnail will be shown + * in the top row - if so, left thumbnail + * goes at the bottom */ + if (show_right_thumbnail) + { + left_thumbnail_y_position = bottom_row_y_position; + left_thumbnail_alignment = GFX_THUMBNAIL_ALIGN_TOP; + } + /* If right thumbnail is missing, shift left + * thumbnail up to the top row */ + else + { + left_thumbnail_y_position = right_thumbnail_y_position; + left_thumbnail_alignment = right_thumbnail_alignment; + } + gfx_thumbnail_draw( userdata, video_width, @@ -963,10 +998,18 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, (float)left_thumbnail_y_position, thumbnail_width, thumbnail_height, - GFX_THUMBNAIL_ALIGN_TOP, + left_thumbnail_alignment, 1.0f, 1.0f, NULL); } - else if (!ozone->selection_core_is_viewer) + + /* > Display content metadata in the bottom + * row if: + * - This is *not* image viewer content + * - There is no left thumbnail *or* + * left thumbnail has been shifted to + * the top row */ + if (!ozone->selection_core_is_viewer && + (!show_left_thumbnail || !show_right_thumbnail)) { char ticker_buf[255]; gfx_animation_ctx_ticker_t ticker; @@ -979,7 +1022,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, enum gfx_animation_ticker_type menu_ticker_type = (enum gfx_animation_ticker_type) settings->uints.menu_ticker_type; - unsigned y = (unsigned)left_thumbnail_y_position; + unsigned y = (unsigned)bottom_row_y_position; unsigned separator_padding = ozone->dimensions.sidebar_entry_icon_padding*2; unsigned column_x = x_position + separator_padding; @@ -995,7 +1038,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, ticker_smooth.x_offset = &ticker_x_offset; ticker_smooth.dst_str_width = NULL; - ticker_smooth.font = ozone->fonts.footer; + ticker_smooth.font = ozone->fonts.footer.font; ticker_smooth.selected = true; ticker_smooth.field_width = sidebar_width - (separator_padding * 2); ticker_smooth.dst_str = ticker_buf; @@ -1008,7 +1051,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, ticker.spacer = ticker_spacer; ticker.selected = true; - ticker.len = (sidebar_width - (separator_padding * 2)) / ozone->footer_font_glyph_width; + ticker.len = (sidebar_width - (separator_padding * 2)) / ozone->fonts.footer.glyph_width; ticker.s = ticker_buf; } } @@ -1028,7 +1071,7 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_height, ozone->theme_dynamic.entries_border); - y += 18; + y += 18 * scale_factor; if (scroll_content_metadata) { diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index 17e552fb53..c30e5f2865 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -132,7 +132,7 @@ void ozone_draw_sidebar( if (use_smooth_ticker) { ticker_smooth.idx = gfx_animation_get_ticker_pixel_idx(); - ticker_smooth.font = ozone->fonts.sidebar; + ticker_smooth.font = ozone->fonts.sidebar.font; ticker_smooth.font_scale = 1.0f; ticker_smooth.type_enum = menu_ticker_type; ticker_smooth.spacer = ticker_spacer; @@ -285,8 +285,10 @@ void ozone_draw_sidebar( /* Text */ if (!ozone->sidebar_collapsed) - ozone_draw_text(ozone, title, ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + ozone->dimensions.sidebar_entry_icon_padding * 2 + ozone->dimensions.sidebar_entry_icon_size, - y + ozone->dimensions.sidebar_entry_height / 2 + ozone->sidebar_font_glyph_height * 3.0f/10.0f + ozone->animations.scroll_y_sidebar, TEXT_ALIGN_LEFT, video_width, video_height, ozone->fonts.sidebar, text_color, true); + ozone_draw_text(ozone, title, + ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + ozone->dimensions.sidebar_entry_icon_padding * 2 + ozone->dimensions.sidebar_entry_icon_size, + y + ozone->dimensions.sidebar_entry_height / 2.0f + ozone->fonts.sidebar.line_centre_offset + ozone->animations.scroll_y_sidebar, + TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.sidebar, text_color, true); y += ozone->dimensions.sidebar_entry_height + ozone->dimensions.sidebar_entry_padding_vertical; } @@ -359,7 +361,7 @@ void ozone_draw_sidebar( } else { - ticker.len = (entry_width - ozone->dimensions.sidebar_entry_icon_size - 40 * scale_factor) / ozone->sidebar_font_glyph_width; + ticker.len = (entry_width - ozone->dimensions.sidebar_entry_icon_size - 40 * scale_factor) / ozone->fonts.sidebar.glyph_width; ticker.s = console_title; ticker.selected = selected; ticker.str = node->console_name; @@ -367,9 +369,11 @@ void ozone_draw_sidebar( gfx_animation_ticker(&ticker); } - ozone_draw_text(ozone, console_title, ticker_x_offset + ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + ozone->dimensions.sidebar_entry_icon_padding * 2 + ozone->dimensions.sidebar_entry_icon_size, - y + ozone->dimensions.sidebar_entry_height / 2 + ozone->sidebar_font_glyph_height * 3.0f/10.0f + ozone->animations.scroll_y_sidebar, TEXT_ALIGN_LEFT, - video_width, video_height, ozone->fonts.sidebar, text_color, true); + ozone_draw_text(ozone, console_title, + ticker_x_offset + ozone->sidebar_offset + ozone->dimensions.sidebar_padding_horizontal + ozone->dimensions.sidebar_entry_icon_padding * 2 + ozone->dimensions.sidebar_entry_icon_size, + y + ozone->dimensions.sidebar_entry_height / 2 + ozone->fonts.sidebar.line_centre_offset + ozone->animations.scroll_y_sidebar, + TEXT_ALIGN_LEFT, + video_width, video_height, &ozone->fonts.sidebar, text_color, true); console_iterate: y += ozone->dimensions.sidebar_entry_height + ozone->dimensions.sidebar_entry_padding_vertical; @@ -378,8 +382,7 @@ console_iterate: gfx_display_blend_end(userdata); } - font_driver_flush(video_width, video_height, ozone->fonts.sidebar); - ozone->raster_blocks.sidebar.carr.coords.vertices = 0; + ozone_font_flush(video_width, video_height, &ozone->fonts.sidebar); gfx_display_scissor_end(userdata, video_width, video_height); diff --git a/menu/drivers/ozone/ozone_theme.c b/menu/drivers/ozone/ozone_theme.c index e390c42746..ab118fcc23 100644 --- a/menu/drivers/ozone/ozone_theme.c +++ b/menu/drivers/ozone/ozone_theme.c @@ -100,9 +100,9 @@ ozone_theme_t ozone_theme_nord = { 0x8FBCBBFF, /* text_sublabel_rgba */ /* Sidebar color */ - ozone_sidebar_background_nord, /* sidebar_background */ - ozone_sidebar_gradient_top_nord, /* sidebar_top_gradient */ - ozone_sidebar_gradient_bottom_nord, /* sidebar_bottom_gradient */ + ozone_sidebar_background_nord, /* sidebar_background */ + ozone_sidebar_gradient_top_nord, /* sidebar_top_gradient */ + ozone_sidebar_gradient_bottom_nord, /* sidebar_bottom_gradient */ /* Fancy cursor colors */ ozone_border_0_nord, /* cursor_border_0 */