From e1f16f1855add210a35621703c3930c98d2b5c0b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 1 Sep 2020 05:06:21 +0200 Subject: [PATCH] (Ozone) remove abstraction layer ozone_draw_text - just call gfx_display_draw_text directly --- menu/drivers/ozone/ozone.c | 133 +++++++++++++++++++++++------ menu/drivers/ozone/ozone_display.c | 56 ++++++------ menu/drivers/ozone/ozone_display.h | 8 -- menu/drivers/ozone/ozone_entries.c | 109 ++++++++++++++++------- menu/drivers/ozone/ozone_sidebar.c | 43 ++++++++-- 5 files changed, 249 insertions(+), 100 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index 0fb1284010..c89233edf3 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -2010,10 +2010,20 @@ static void ozone_draw_header(ozone_handle_t *ozone, gfx_animation_ticker(&ticker); } - ozone_draw_text(title, + gfx_display_draw_text( + ozone->fonts.title.font, + 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); + ozone->dimensions.header_height / 2 + + ozone->fonts.title.line_centre_offset, + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); /* Icon */ gfx_display_blend_begin(userdata); @@ -2064,10 +2074,20 @@ static void ozone_draw_header(ozone_handle_t *ozone, { timedate_offset = 95 * scale_factor; - ozone_draw_text(msg, + gfx_display_draw_text( + ozone->fonts.time.font, + 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); + ozone->dimensions.header_height / 2 + + ozone->fonts.time.line_centre_offset, + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_RIGHT, + 1.0f, + false, + 1.0f, + false); gfx_display_blend_begin(userdata); ozone_draw_icon( @@ -2101,10 +2121,20 @@ static void ozone_draw_header(ozone_handle_t *ozone, menu_display_timedate(&datetime); - ozone_draw_text(timedate, + gfx_display_draw_text( + ozone->fonts.time.font, + 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); + ozone->dimensions.header_height / 2 + + ozone->fonts.time.line_centre_offset, + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_RIGHT, + 1.0f, + false, + 1.0f, + false); gfx_display_blend_begin(userdata); ozone_draw_icon( @@ -2274,41 +2304,81 @@ static void ozone_draw_footer(ozone_handle_t *ozone, /* Draw labels */ /* > ok */ - ozone_draw_text( + gfx_display_draw_text( + ozone->fonts.footer.font, ozone->footer_labels.ok.str, ok_x + icon_size + icon_padding, footer_text_y, - TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); /* > back */ - ozone_draw_text( + gfx_display_draw_text( + ozone->fonts.footer.font, ozone->footer_labels.back.str, back_x + icon_size + icon_padding, footer_text_y, - TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); /* > search */ - ozone_draw_text( + gfx_display_draw_text( + ozone->fonts.footer.font, ozone->footer_labels.search.str, search_x + icon_size + icon_padding, footer_text_y, - TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); /* > fullscreen_thumbs */ if (fullscreen_thumbnails_available) - ozone_draw_text( - ozone->footer_labels.fullscreen_thumbs.str, - fullscreen_thumbs_x + icon_size + icon_padding, - footer_text_y, - TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); + gfx_display_draw_text( + ozone->fonts.footer.font, + ozone->footer_labels.fullscreen_thumbs.str, + fullscreen_thumbs_x + icon_size + icon_padding, + footer_text_y, + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); /* > metadata_toggle */ if (metadata_override_available) - ozone_draw_text( - ozone->footer_labels.metadata_toggle.str, - metadata_toggle_x + icon_size + icon_padding, - footer_text_y, - TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); + gfx_display_draw_text( + ozone->fonts.footer.font, + ozone->footer_labels.metadata_toggle.str, + metadata_toggle_x + icon_size + icon_padding, + footer_text_y, + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); /* Core title or Switch icon */ if (menu_core_enable) @@ -2376,10 +2446,19 @@ static void ozone_draw_footer(ozone_handle_t *ozone, } /* Draw text */ - ozone_draw_text(core_title_buf, + gfx_display_draw_text( + ozone->fonts.footer.font, + core_title_buf, ticker_x_offset + footer_margin, footer_text_y, - TEXT_ALIGN_LEFT, video_width, video_height, &ozone->fonts.footer, ozone->theme->text_rgba, false); + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); } } else diff --git a/menu/drivers/ozone/ozone_display.c b/menu/drivers/ozone/ozone_display.c index 96a58f015c..dce8aa5e0b 100644 --- a/menu/drivers/ozone/ozone_display.c +++ b/menu/drivers/ozone/ozone_display.c @@ -250,20 +250,6 @@ void ozone_restart_cursor_animation(ozone_handle_t *ozone) ozone->theme->cursor_border_1); } -void ozone_draw_text( - const char *str, float x, - float y, - enum text_alignment text_align, - unsigned width, unsigned height, ozone_font_data_t *font_data, - uint32_t color, - bool draw_outside) -{ - gfx_display_draw_text(font_data->font, str, x, y, - width, height, color, text_align, 1.0f, - false, - 1.0f, draw_outside); -} - void ozone_draw_cursor( ozone_handle_t *ozone, void *userdata, @@ -469,10 +455,20 @@ void ozone_draw_osk(ozone_handle_t *ozone, { const char *msg = list.elems[i].data; - ozone_draw_text(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); + gfx_display_draw_text( + ozone->fonts.entries_label.font, + msg, + margin + padding * 2, /* x */ + margin + padding + + ozone->fonts.entries_label.line_height + + y_offset, /* y */ + video_width, video_height, + text_color, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); /* Cursor */ if (i == list.size - 1) @@ -632,16 +628,20 @@ void ozone_draw_messagebox( const char *msg = list.elems[i].data; if (msg) - ozone_draw_text( - msg, - x - longest_width/2.0, - y + (i * ozone->fonts.footer.line_height) + ozone->fonts.footer.line_ascender, - TEXT_ALIGN_LEFT, - width, height, - &ozone->fonts.footer, - COLOR_TEXT_ALPHA(ozone->theme->text_rgba, (uint32_t)(ozone->animations.messagebox_alpha*255.0f)), - false - ); + gfx_display_draw_text( + ozone->fonts.footer.font, + msg, + x - longest_width/2.0, + y + (i * ozone->fonts.footer.line_height) + + ozone->fonts.footer.line_ascender, + width, + height, + COLOR_TEXT_ALPHA(ozone->theme->text_rgba, (uint32_t)(ozone->animations.messagebox_alpha*255.0f)), + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); } string_list_deinitialize(&list); diff --git a/menu/drivers/ozone/ozone_display.h b/menu/drivers/ozone/ozone_display.h index 32c6cb3dc0..d29cadd391 100644 --- a/menu/drivers/ozone/ozone_display.h +++ b/menu/drivers/ozone/ozone_display.h @@ -21,14 +21,6 @@ #include "../../menu_driver.h" -void ozone_draw_text( - const char *str, float x, - float y, - enum text_alignment text_align, - unsigned width, unsigned height, ozone_font_data_t *font_data, - uint32_t color, - bool draw_outside); - void ozone_draw_cursor( ozone_handle_t *ozone, void *userdata, diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index b683e68d60..e7702d89df 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -129,11 +129,35 @@ static void ozone_draw_entry_value( } if (do_draw_text) - ozone_draw_text(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); + { + gfx_display_draw_text( + ozone->fonts.entries_label.font, + value, + x, + y, + video_width, + video_height, + COLOR_TEXT_ALPHA(ozone->theme->text_selected_rgba, alpha_uint32), + TEXT_ALIGN_RIGHT, + 1.0f, + false, + 1.0f, + false); + } else - ozone_draw_text((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, - COLOR_TEXT_ALPHA((switch_is_on ? ozone->theme->text_selected_rgba : ozone->theme->text_sublabel_rgba), alpha_uint32), false); + gfx_display_draw_text( + ozone->fonts.entries_label.font, + (switch_is_on ? msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ON) : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_OFF)), + x, + y, + video_width, + video_height, + COLOR_TEXT_ALPHA((switch_is_on ? ozone->theme->text_selected_rgba : ozone->theme->text_sublabel_rgba), alpha_uint32), + TEXT_ALIGN_RIGHT, + 1.0f, + false, + 1.0f, + false); } static void ozone_thumbnail_bar_hide_end(void *userdata) @@ -168,16 +192,20 @@ static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone, 0, 1, ozone->theme->entries_icon); gfx_display_blend_end(userdata); - ozone_draw_text( - msg_hash_to_str(MSG_NO_THUMBNAIL_AVAILABLE), - x_position + sidebar_width/2, - video_height/2 + icon_size/2 + ozone->fonts.footer.line_ascender - y_offset, - TEXT_ALIGN_CENTER, - video_width, video_height, - &ozone->fonts.footer, - ozone->theme->text_rgba, - true - ); + gfx_display_draw_text( + ozone->fonts.footer.font, + msg_hash_to_str(MSG_NO_THUMBNAIL_AVAILABLE), + x_position + sidebar_width / 2, + video_height / 2 + icon_size / 2 + + ozone->fonts.footer.line_ascender - y_offset, + video_width, + video_height, + ozone->theme->text_rgba, + TEXT_ALIGN_CENTER, + 1.0f, + false, + 1.0f, + true); } static void ozone_content_metadata_line( @@ -190,16 +218,19 @@ static void ozone_content_metadata_line( uint32_t color, unsigned lines_count) { - ozone_draw_text( - text, - column_x, - *y + ozone->fonts.footer.line_ascender, - TEXT_ALIGN_LEFT, - video_width, video_height, - &ozone->fonts.footer, - color, - true - ); + gfx_display_draw_text( + ozone->fonts.footer.font, + text, + column_x, + *y + ozone->fonts.footer.line_ascender, + video_width, + video_height, + color, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + true); if (lines_count > 0) *y += (unsigned)(ozone->fonts.footer.line_height * (lines_count - 1)) + (unsigned)((float)ozone->fonts.footer.line_height * 1.5f); @@ -770,23 +801,43 @@ border_iterate: } /* Draw text */ - ozone_draw_text(rich_label, + gfx_display_draw_text( + ozone->fonts.entries_label.font, + 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); + y + ozone->dimensions.entry_height / 2.0f + + ozone->fonts.entries_label.line_centre_offset + + scroll_y, + video_width, + video_height, + COLOR_TEXT_ALPHA(ozone->theme->text_rgba, alpha_uint32), + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); if (menu_show_sublabels) { if (!string_is_empty(sublabel_str)) - ozone_draw_text(sublabel_str, + gfx_display_draw_text( + ozone->fonts.entries_sublabel.font, + 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); + video_width, + video_height, + COLOR_TEXT_ALPHA(ozone->theme->text_sublabel_rgba,alpha_uint32), + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + false); } /* Value */ diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index e4defe1ab1..34d1aadc4b 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -338,10 +338,24 @@ void ozone_draw_sidebar( /* Text */ if (!ozone->sidebar_collapsed) - ozone_draw_text(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); + gfx_display_draw_text( + ozone->fonts.sidebar.font, + 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, + video_width, + video_height, + text_color, + TEXT_ALIGN_LEFT, + 1.0f, + false, + 1.0f, + true); y += ozone->dimensions.sidebar_entry_height + ozone->dimensions.sidebar_entry_padding_vertical; } @@ -422,11 +436,24 @@ void ozone_draw_sidebar( gfx_animation_ticker(&ticker); } - ozone_draw_text(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, + gfx_display_draw_text( + ozone->fonts.sidebar.font, + 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, + video_width, + video_height, + text_color, TEXT_ALIGN_LEFT, - video_width, video_height, &ozone->fonts.sidebar, text_color, true); + 1.0f, + false, + 1.0f, + true); console_iterate: y += ozone->dimensions.sidebar_entry_height + ozone->dimensions.sidebar_entry_padding_vertical;