ozone: add right sidebar capability

This commit is contained in:
natinusala 2019-02-27 18:26:31 +01:00
parent 279a2d58db
commit 409db3b1c2
4 changed files with 28 additions and 6 deletions

View File

@ -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 */

View File

@ -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

View File

@ -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 */

View File

@ -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)