ozone: add core name wrapping for content metadata

This commit is contained in:
natinusala 2019-03-11 16:41:07 +01:00
parent 51cf8b6bfe
commit b193bb7fb8
3 changed files with 29 additions and 15 deletions

View File

@ -389,6 +389,16 @@ static void ozone_free(void *data)
}
}
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_update_thumbnail_path(void *data, unsigned i, char pos)
{
menu_entry_t entry;
@ -452,6 +462,9 @@ static void ozone_update_thumbnail_path(void *data, unsigned i, char pos)
snprintf(ozone->selection_core_name, sizeof(ozone->selection_core_name),
"%s", core_label);
word_wrap(ozone->selection_core_name, ozone->selection_core_name, (unsigned)((float)ozone->dimensions.thumbnail_bar_width * (float)0.66) / ozone->footer_font_glyph_width, false);
ozone->selection_core_name_lines = ozone_count_lines(ozone->selection_core_name);
/* Fill play time if applicable */
if (settings->bools.content_runtime_log || settings->bools.content_runtime_log_aggregate)
{
@ -703,6 +716,7 @@ static void ozone_context_reset(void *data, bool is_threaded)
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->footer_font_glyph_width = FONT_SIZE_FOOTER * 3/4;
/* More realistic font size */
size = font_driver_get_message_width(ozone->fonts.title, "a", 1, 1);
@ -717,6 +731,9 @@ static void ozone_context_reset(void *data, bool is_threaded)
size = font_driver_get_message_width(ozone->fonts.sidebar, "a", 1, 1);
if (size)
ozone->sidebar_font_glyph_width = size;
size = font_driver_get_message_width(ozone->fonts.footer, "a", 1, 1);
if (size)
ozone->footer_font_glyph_width = size;
/* Textures init */
for (i = 0; i < OZONE_TEXTURE_LAST; i++)

View File

@ -143,6 +143,7 @@ struct ozone_handle
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;
ozone_theme_t *theme;
@ -239,6 +240,7 @@ struct ozone_handle
char selection_core_name[255];
char selection_playtime[64];
char selection_lastplayed[64];
unsigned selection_core_name_lines;
};
/* If you change this struct, also
@ -307,4 +309,6 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i
const char *ozone_thumbnails_ident(char pos);
unsigned ozone_count_lines(const char *str);
#endif

View File

@ -183,16 +183,6 @@ void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node
}
}
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 */
@ -650,7 +640,7 @@ static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone,
static void ozone_content_metadata_line(video_frame_info_t *video_info, ozone_handle_t *ozone,
unsigned *y, unsigned title_column_x, unsigned data_column_x,
const char *title, const char *data)
const char *title, const char *data, unsigned lines_count)
{
ozone_draw_text(video_info, ozone,
title,
@ -677,7 +667,7 @@ static void ozone_content_metadata_line(video_frame_info_t *video_info, ozone_ha
true
);
*y += font_driver_get_line_height(ozone->fonts.footer, 1) * 1.5;
*y += (font_driver_get_line_height(ozone->fonts.footer, 1) * 1.5) * lines_count;
}
void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_info)
@ -787,21 +777,24 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i
ozone_content_metadata_line(video_info, ozone,
&y, title_column_x, data_column_x,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_CORE),
ozone->selection_core_name
ozone->selection_core_name,
ozone->selection_core_name_lines
);
/* Playtime */
ozone_content_metadata_line(video_info, ozone,
&y, title_column_x, data_column_x,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_RUNTIME),
ozone->selection_playtime
ozone->selection_playtime,
1
);
/* Last played */
ozone_content_metadata_line(video_info, ozone,
&y, title_column_x, data_column_x,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_SUBLABEL_LAST_PLAYED),
ozone->selection_lastplayed
ozone->selection_lastplayed,
1
);
}
}