From 409db3b1c2fd5da21a617ff94015163896a314e9 Mon Sep 17 00:00:00 2001 From: natinusala Date: Wed, 27 Feb 2019 18:26:31 +0100 Subject: [PATCH] ozone: add right sidebar capability --- menu/drivers/ozone/ozone.c | 6 +++++- menu/drivers/ozone/ozone.h | 9 ++++++++- menu/drivers/ozone/ozone_entries.c | 17 +++++++++++++---- menu/drivers/ozone/ozone_sidebar.c | 2 ++ 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/menu/drivers/ozone/ozone.c b/menu/drivers/ozone/ozone.c index d3ad825f15..56c93db027 100644 --- a/menu/drivers/ozone/ozone.c +++ b/menu/drivers/ozone/ozone.c @@ -159,6 +159,9 @@ static void *ozone_init(void **userdata, bool video_is_threaded) ozone->sidebar_collapsed = false; ozone->animations.sidebar_text_alpha = 1.0f; + ozone->animations.thumbnail_bar_position = 0.0f; + ozone->show_thumbnail_bar = false; + ozone_sidebar_update_collapse(ozone, false); ozone->system_tab_end = 0; @@ -395,7 +398,6 @@ static void ozone_context_reset(void *data, bool is_threaded) ozone->dimensions.sidebar_entry_icon_size = SIDEBAR_ENTRY_ICON_SIZE * scale; ozone->dimensions.sidebar_entry_icon_padding = SIDEBAR_ENTRY_ICON_PADDING * scale; - ozone->dimensions.sidebar_width_normal = SIDEBAR_WIDTH * scale; ozone->dimensions.sidebar_width_collapsed = ozone->dimensions.sidebar_entry_icon_size + ozone->dimensions.sidebar_entry_icon_padding * 2 @@ -403,6 +405,8 @@ static void ozone_context_reset(void *data, bool is_threaded) ozone->dimensions.sidebar_width = (float) ozone->dimensions.sidebar_width_normal; + ozone->dimensions.thumbnail_bar_width = ozone->dimensions.sidebar_width_normal/2; + ozone->dimensions.cursor_size = CURSOR_SIZE * scale; /* Naive font size */ diff --git a/menu/drivers/ozone/ozone.h b/menu/drivers/ozone/ozone.h index 83ba36e822..323d2380a3 100644 --- a/menu/drivers/ozone/ozone.h +++ b/menu/drivers/ozone/ozone.h @@ -124,6 +124,7 @@ struct ozone_handle float messagebox_alpha; float sidebar_text_alpha; + float thumbnail_bar_position; /* 0 = hidden */ } animations; bool fade_direction; /* false = left to right, true = right to left */ @@ -143,7 +144,7 @@ struct ozone_handle unsigned entry_font_glyph_width; unsigned sublabel_font_glyph_width; unsigned sidebar_font_glyph_width; - + ozone_theme_t *theme; struct { @@ -207,6 +208,8 @@ struct ozone_handle int sidebar_entry_icon_padding; int cursor_size; + + int thumbnail_bar_width; } dimensions; bool show_cursor; @@ -216,6 +219,8 @@ struct ozone_handle int16_t cursor_y_old; bool sidebar_collapsed; + + bool show_thumbnail_bar; }; /* If you change this struct, also @@ -277,4 +282,6 @@ void ozone_update_scroll(ozone_handle_t *ozone, bool allow_animation, ozone_node void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation); +void ozone_entries_update_thumbnail_bar(ozone_handle_t *ozone, bool is_playlist, bool allow_animation); + #endif diff --git a/menu/drivers/ozone/ozone_entries.c b/menu/drivers/ozone/ozone_entries.c index edc68337db..267fc5517f 100644 --- a/menu/drivers/ozone/ozone_entries.c +++ b/menu/drivers/ozone/ozone_entries.c @@ -120,7 +120,7 @@ static void ozone_draw_entry_value(ozone_handle_t *ozone, { ozone_draw_text(video_info, 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_info->width, video_info->height, ozone->fonts.entries_label, - COLOR_TEXT_ALPHA(switch_is_on ? ozone->theme->text_selected_rgba : ozone->theme->text_sublabel_rgba, alpha_uint32), false); + COLOR_TEXT_ALPHA((switch_is_on ? ozone->theme->text_selected_rgba : ozone->theme->text_sublabel_rgba), alpha_uint32), false); } } @@ -277,6 +277,11 @@ void ozone_compute_entries_position(ozone_handle_t *ozone) ozone_update_scroll(ozone, false, (ozone_node_t*) file_list_get_userdata_at_offset(selection_buf, ozone->selection)); } +void ozone_entries_update_thumbnail_bar(ozone_handle_t *ozone, bool is_playlist, bool allow_animation) +{ + /* TODO Animate it and draw it */ +} + 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, @@ -310,7 +315,7 @@ void ozone_draw_entries(ozone_handle_t *ozone, video_frame_info_t *video_info, entries_end = file_list_get_size(selection_buf); y = ozone->dimensions.header_height + 1 + ozone->dimensions.entry_padding_vertical; sidebar_offset = ozone->sidebar_offset; - entry_width = video_info->width - (unsigned) ozone->dimensions.sidebar_width - ozone->sidebar_offset - entry_padding * 2; + entry_width = video_info->width - (unsigned) ozone->dimensions.sidebar_width - ozone->sidebar_offset - entry_padding * 2 - ozone->animations.thumbnail_bar_position; button_height = ozone->dimensions.entry_height; /* height of the button (entry minus sublabel) */ video_driver_get_size(&video_info_width, &video_info_height); @@ -461,9 +466,13 @@ border_iterate: if (node->wrap && sublabel_str) { - int sublable_max_width = video_info_width - (unsigned) ozone->dimensions.sidebar_width - + int sublabel_max_width = video_info_width - (unsigned) ozone->dimensions.sidebar_width - entry_padding * 2 - ozone->dimensions.entry_icon_padding * 2; - word_wrap(sublabel_str, sublabel_str, sublable_max_width / ozone->sublabel_font_glyph_width, false); + + if (ozone->show_thumbnail_bar) + sublabel_max_width -= ozone->dimensions.thumbnail_bar_width; + + word_wrap(sublabel_str, sublabel_str, sublabel_max_width / ozone->sublabel_font_glyph_width, false); } /* Icon */ diff --git a/menu/drivers/ozone/ozone_sidebar.c b/menu/drivers/ozone/ozone_sidebar.c index 65e0a8ed7f..a7ee2cdc70 100644 --- a/menu/drivers/ozone/ozone_sidebar.c +++ b/menu/drivers/ozone/ozone_sidebar.c @@ -395,6 +395,8 @@ void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation) ozone->sidebar_collapsed = false; } } + + ozone_entries_update_thumbnail_bar(ozone, is_playlist, allow_animation); } void ozone_sidebar_goto(ozone_handle_t *ozone, unsigned new_selection)