From 222b7e7be019a3a8b4be2c013dd0ab2ae1f54b6f Mon Sep 17 00:00:00 2001 From: natinusala Date: Mon, 11 Mar 2019 11:20:36 +0100 Subject: [PATCH] ozone: complete content metadata section --- menu/cbs/menu_cbs_sublabel.c | 4 +- menu/drivers/ozone/ozone.c | 58 +++++++++++++++++++++- menu/drivers/ozone/ozone.h | 4 ++ menu/drivers/ozone/ozone_entries.c | 78 ++++++++++++++++++++++++++++-- menu/menu_displaylist.c | 13 +---- 5 files changed, 137 insertions(+), 20 deletions(-) diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index e873d644c1..442e5f6172 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -837,9 +837,9 @@ static int action_bind_sublabel_playlist_entry( unsigned last_played_minute = 0; unsigned last_played_second = 0; - if (!settings->bools.playlist_show_sublabels) + if (!settings->bools.playlist_show_sublabels || string_is_equal(settings->arrays.menu_driver, "ozone")) return 0; - + /* Get current playlist */ playlist = playlist_get_cached(); if (!playlist) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index a2da8d94f7..891ba8ae11 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -439,9 +439,63 @@ static void ozone_update_thumbnail_path(void *data, unsigned i, char pos) if (playlist) { const char *core_name = NULL; + const char *core_label = NULL; playlist_get_index(playlist, i, NULL, NULL, NULL, &core_name, NULL, NULL); + /* Fill core name */ + if (!core_name || string_is_equal(core_name, "DETECT")) + core_label = msg_hash_to_str(MSG_AUTODETECT); + else + core_label = core_name; + + snprintf(ozone->selection_core_name, sizeof(ozone->selection_core_name), + "%s", core_label); + + /* Fill play time if applicable */ + if (settings->bools.content_runtime_log) + { + unsigned runtime_hours = 0; + unsigned runtime_minutes = 0; + unsigned runtime_seconds = 0; + + unsigned last_played_year = 0; + unsigned last_played_month = 0; + unsigned last_played_day = 0; + unsigned last_played_hour = 0; + unsigned last_played_minute = 0; + unsigned last_played_second = 0; + + playlist_get_runtime_index(playlist, i, NULL, NULL, + &runtime_hours, &runtime_minutes, &runtime_seconds, + &last_played_year, &last_played_month, &last_played_day, + &last_played_hour, &last_played_minute, &last_played_second); + + snprintf(ozone->selection_playtime, sizeof(ozone->selection_playtime), "%02u:%02u:%02u", + runtime_hours, runtime_minutes, runtime_seconds); + + if (last_played_year == 0 && last_played_month == 0 && last_played_day == 0 + && last_played_hour == 0 && last_played_minute == 0 && last_played_second == 0) + { + snprintf(ozone->selection_lastplayed, sizeof(ozone->selection_lastplayed), "%s", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PLAYLIST_INLINE_CORE_DISPLAY_NEVER)); + } + else + { + snprintf(ozone->selection_lastplayed, sizeof(ozone->selection_lastplayed), "%04u/%02u/%02u - %02u:%02u:%02u", + last_played_year, last_played_month, last_played_day, + last_played_hour, last_played_minute, last_played_second); + } + } + else + { + snprintf(ozone->selection_playtime, sizeof(ozone->selection_playtime), "%s", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED)); + + snprintf(ozone->selection_lastplayed, sizeof(ozone->selection_lastplayed), "%s", + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED)); + } + if (string_is_equal(core_name, "imageviewer")) { if ( @@ -1940,9 +1994,9 @@ static void ozone_toggle(void *userdata, bool menu_on) { ozone->draw_sidebar = true; ozone->sidebar_offset = 0.0f; - - ozone_sidebar_update_collapse(ozone, false); } + + ozone_sidebar_update_collapse(ozone, false); } static bool ozone_menu_init_list(void *data) diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 27e2c1101d..2c47fb56ee 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -235,6 +235,10 @@ struct ozone_handle uintptr_t thumbnail; uintptr_t left_thumbnail; + + char selection_core_name[255]; + char selection_playtime[64]; + char selection_lastplayed[64]; }; /* If you change this struct, also diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index 25206441ec..26e97c32a7 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -32,8 +32,6 @@ 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; @@ -640,6 +638,38 @@ 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) +{ + ozone_draw_text(video_info, ozone, + title, + title_column_x, + *y + FONT_SIZE_FOOTER, + TEXT_ALIGN_LEFT, + video_info->width, video_info->height, + ozone->fonts.footer, + ozone->theme->text_rgba, + true + ); + + if (font_driver_get_message_width(ozone->fonts.footer, data, strlen(data), 1) > ozone->dimensions.thumbnail_bar_width / 2) + *y += font_driver_get_line_height(ozone->fonts.footer, 1); + + ozone_draw_text(video_info, ozone, + data, + data_column_x, + *y + FONT_SIZE_FOOTER, + TEXT_ALIGN_RIGHT, + video_info->width, video_info->height, + ozone->fonts.footer, + ozone->theme->text_rgba, + true + ); + + *y += font_driver_get_line_height(ozone->fonts.footer, 1) * 1.5; +} + void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_info) { settings_t *settings = config_get_ptr(); @@ -681,7 +711,8 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i unsigned thumb_x_position = x_position + sidebar_width/2 - (ozone->dimensions.thumbnail_width + ozone->dimensions.sidebar_entry_icon_padding) / 2; unsigned thumb_y_position = video_info->height / 2 - ozone->dimensions.thumbnail_height / 2; - thumb_y_position -= ozone->dimensions.thumbnail_height / 2 + ozone->dimensions.sidebar_entry_icon_padding/2; + if (!string_is_equal(ozone->selection_core_name, "imageviewer")) + thumb_y_position -= ozone->dimensions.thumbnail_height / 2 + ozone->dimensions.sidebar_entry_icon_padding/2; ozone_draw_icon(video_info, ozone->dimensions.thumbnail_width, @@ -717,9 +748,46 @@ void ozone_draw_thumbnail_bar(ozone_handle_t *ozone, video_frame_info_t *video_i ozone_pure_white ); } - else + else if (!string_is_equal(ozone->selection_core_name, "imageviewer")) { - /* TODO: Content metadata */ + unsigned y = video_info->height / 2 + ozone->dimensions.sidebar_entry_icon_padding / 2; + unsigned content_metadata_padding = ozone->dimensions.sidebar_entry_icon_padding*3; + unsigned separator_padding = ozone->dimensions.sidebar_entry_icon_padding*2; + unsigned title_column_x = x_position + content_metadata_padding; + unsigned data_column_x = x_position + sidebar_width - content_metadata_padding; + + /* Content metadata */ + y += 10; + + /* Separator */ + menu_display_draw_quad(video_info, + x_position + separator_padding, y, + sidebar_width - separator_padding*2, 1, + video_info->width, video_info->height, + ozone->theme_dynamic.entries_border); + + y += 18; + + /* Core association */ + 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 + ); + + /* 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 + ); + + /* 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 + ); } } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 921a1bc8e2..9c95e66cd5 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -104,14 +104,6 @@ static enum msg_hash_enums new_type = MSG_UNKNOWN; * in playlists */ #define PL_LABEL_SPACER_DEFAULT " | " #define PL_LABEL_SPACER_RGUI " | " -#if defined(__APPLE__) -/* UTF-8 support is currently broken on Apple devices... */ -#define PL_LABEL_SPACER_OZONE " | " -#else -/* - * UCN equivalent: "\u2003\u2022\u2003" */ -#define PL_LABEL_SPACER_OZONE "\xE2\x80\x83\xE2\x80\xA2\xE2\x80\x83" -#endif #define PL_LABEL_SPACER_MAXLEN 37 #ifdef HAVE_NETWORKING @@ -1316,7 +1308,8 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, } /* Check whether core name should be added to playlist entries */ - if (!settings->bools.playlist_show_sublabels && + if (!string_is_equal(settings->arrays.menu_driver, "ozone") && + !settings->bools.playlist_show_sublabels && ((settings->uints.playlist_show_inline_core_name == PLAYLIST_INLINE_CORE_DISPLAY_ALWAYS) || (!is_collection && !(settings->uints.playlist_show_inline_core_name == PLAYLIST_INLINE_CORE_DISPLAY_NEVER)))) { @@ -1326,8 +1319,6 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, * > Note: Only required when showing inline core names */ if (is_rgui) strlcpy(label_spacer, PL_LABEL_SPACER_RGUI, sizeof(label_spacer)); - else if (string_is_equal(settings->arrays.menu_driver, "ozone")) - strlcpy(label_spacer, PL_LABEL_SPACER_OZONE, sizeof(label_spacer)); else strlcpy(label_spacer, PL_LABEL_SPACER_DEFAULT, sizeof(label_spacer)); }