This commit is contained in:
twinaphex 2020-06-26 17:45:35 +02:00
parent 3aafed5030
commit 011806bce8
4 changed files with 164 additions and 153 deletions

View File

@ -94,35 +94,6 @@ static void ozone_cursor_animation_cb(void *userdata)
ozone_animate_cursor(ozone, ozone->theme_dynamic.cursor_border, target);
}
void ozone_restart_cursor_animation(ozone_handle_t *ozone)
{
uintptr_t tag = (uintptr_t) &ozone_default_theme;
if (!ozone->has_all_assets)
return;
ozone->theme_dynamic.cursor_state = 1;
memcpy(ozone->theme_dynamic.cursor_border, ozone->theme->cursor_border_0, sizeof(ozone->theme_dynamic.cursor_border));
gfx_animation_kill_by_tag(&tag);
ozone_animate_cursor(ozone, ozone->theme_dynamic.cursor_border, ozone->theme->cursor_border_1);
}
void ozone_draw_text(
ozone_handle_t *ozone,
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);
}
static void ozone_draw_cursor_slice(
ozone_handle_t *ozone,
void *userdata,
@ -258,6 +229,37 @@ static void ozone_draw_cursor_fallback(
ozone->theme_dynamic.selection_border);
}
void ozone_restart_cursor_animation(ozone_handle_t *ozone)
{
uintptr_t tag = (uintptr_t) &ozone_default_theme;
if (!ozone->has_all_assets)
return;
ozone->theme_dynamic.cursor_state = 1;
memcpy(ozone->theme_dynamic.cursor_border, ozone->theme->cursor_border_0, sizeof(ozone->theme_dynamic.cursor_border));
gfx_animation_kill_by_tag(&tag);
ozone_animate_cursor(ozone, ozone->theme_dynamic.cursor_border, ozone->theme->cursor_border_1);
}
void ozone_draw_text(
ozone_handle_t *ozone,
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,

View File

@ -140,6 +140,77 @@ static void ozone_draw_entry_value(
}
}
static void ozone_thumbnail_bar_hide_end(void *userdata)
{
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
ozone->show_thumbnail_bar = false;
}
static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone,
void *userdata,
unsigned video_width,
unsigned video_height,
unsigned x_position,
unsigned sidebar_width,
unsigned y_offset)
{
unsigned icon = OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO;
unsigned icon_size = (unsigned)((float)ozone->dimensions.sidebar_entry_icon_size * 1.5f);
gfx_display_blend_begin(userdata);
ozone_draw_icon(
userdata,
video_width,
video_height,
icon_size,
icon_size,
ozone->icons_textures[icon],
x_position + sidebar_width/2 - icon_size/2,
video_height/2 - icon_size/2 - y_offset,
video_width,
video_height,
0, 1, ozone->theme->entries_icon);
gfx_display_blend_end(userdata);
ozone_draw_text(
ozone,
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
);
}
static void ozone_content_metadata_line(
unsigned video_width,
unsigned video_height,
ozone_handle_t *ozone,
unsigned *y,
unsigned column_x,
const char *text,
uint32_t color,
unsigned lines_count)
{
ozone_draw_text(ozone,
text,
column_x,
*y + ozone->fonts.footer.line_ascender,
TEXT_ALIGN_LEFT,
video_width, video_height,
&ozone->fonts.footer,
color,
true
);
if (lines_count > 0)
*y += (unsigned)(ozone->fonts.footer.line_height * (lines_count - 1)) + (unsigned)((float)ozone->fonts.footer.line_height * 1.5f);
}
/* Compute new scroll position
* If the center of the currently selected entry is not in the middle
* And if we can scroll so that it's in the middle
@ -316,12 +387,6 @@ 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));
}
static void ozone_thumbnail_bar_hide_end(void *userdata)
{
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
ozone->show_thumbnail_bar = false;
}
void ozone_entries_update_thumbnail_bar(ozone_handle_t *ozone, bool is_playlist, bool allow_animation)
{
struct gfx_animation_ctx_entry entry;
@ -765,70 +830,6 @@ border_iterate:
ozone_font_flush(video_width, video_height, &ozone->fonts.entries_sublabel);
}
static void ozone_draw_no_thumbnail_available(ozone_handle_t *ozone,
void *userdata,
unsigned video_width,
unsigned video_height,
unsigned x_position,
unsigned sidebar_width,
unsigned y_offset)
{
unsigned icon = OZONE_ENTRIES_ICONS_TEXTURE_CORE_INFO;
unsigned icon_size = (unsigned)((float)ozone->dimensions.sidebar_entry_icon_size * 1.5f);
gfx_display_blend_begin(userdata);
ozone_draw_icon(
userdata,
video_width,
video_height,
icon_size,
icon_size,
ozone->icons_textures[icon],
x_position + sidebar_width/2 - icon_size/2,
video_height/2 - icon_size/2 - y_offset,
video_width,
video_height,
0, 1, ozone->theme->entries_icon);
gfx_display_blend_end(userdata);
ozone_draw_text(
ozone,
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
);
}
static void ozone_content_metadata_line(
unsigned video_width,
unsigned video_height,
ozone_handle_t *ozone,
unsigned *y,
unsigned column_x,
const char *text,
uint32_t color,
unsigned lines_count)
{
ozone_draw_text(ozone,
text,
column_x,
*y + ozone->fonts.footer.line_ascender,
TEXT_ALIGN_LEFT,
video_width, video_height,
&ozone->fonts.footer,
color,
true
);
if (lines_count > 0)
*y += (unsigned)(ozone->fonts.footer.line_height * (lines_count - 1)) + (unsigned)((float)ozone->fonts.footer.line_height * 1.5f);
}
void ozone_draw_thumbnail_bar(ozone_handle_t *ozone,
void *userdata,
unsigned video_width,

View File

@ -103,6 +103,44 @@ unsigned ozone_system_tabs_icons[OZONE_SYSTEM_TAB_LAST] = {
OZONE_TAB_TEXTURE_SCAN_CONTENT
};
static void ozone_sidebar_collapse_end(void *userdata)
{
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
ozone->sidebar_collapsed = true;
}
static float ozone_sidebar_get_scroll_y(
ozone_handle_t *ozone, unsigned video_height)
{
float scroll_y =
ozone->animations.scroll_y_sidebar;
float selected_position_y =
ozone_get_selected_sidebar_y_position(ozone);
float current_selection_middle_onscreen =
ozone->dimensions.header_height
+ ozone->dimensions.spacer_1px
+ ozone->animations.scroll_y_sidebar
+ selected_position_y
+ ozone->dimensions.sidebar_entry_height / 2.0f;
float bottom_boundary =
(float)video_height
- (ozone->dimensions.header_height + ozone->dimensions.spacer_1px)
- ozone->dimensions.footer_height;
float entries_middle = (float)video_height / 2.0f;
float entries_height = ozone_get_sidebar_height(ozone);
if (current_selection_middle_onscreen != entries_middle)
scroll_y = ozone->animations.scroll_y_sidebar - (current_selection_middle_onscreen - entries_middle);
if (scroll_y + entries_height < bottom_boundary)
scroll_y = bottom_boundary - entries_height - ozone->dimensions.sidebar_padding_vertical;
if (scroll_y > 0.0f)
return 0.0f;
return scroll_y;
}
void ozone_draw_sidebar(
ozone_handle_t *ozone,
void *userdata,
@ -114,23 +152,24 @@ void ozone_draw_sidebar(
{
size_t y;
int entry_width;
unsigned i, sidebar_height, selection_y,
selection_old_y, horizontal_list_size;
char console_title[255];
unsigned i, sidebar_height;
gfx_animation_ctx_ticker_t ticker;
gfx_animation_ctx_ticker_smooth_t ticker_smooth;
static const char* const ticker_spacer = OZONE_TICKER_SPACER;
unsigned ticker_x_offset = 0;
settings_t *settings = config_get_ptr();
uint32_t text_alpha = ozone->animations.sidebar_text_alpha * 255.0f;
bool use_smooth_ticker = settings->bools.menu_ticker_smooth;
float scale_factor = ozone->last_scale_factor;
static const char* const
ticker_spacer = OZONE_TICKER_SPACER;
unsigned ticker_x_offset = 0;
settings_t *settings = config_get_ptr();
uint32_t text_alpha = ozone->animations.sidebar_text_alpha
* 255.0f;
bool use_smooth_ticker = settings->bools.menu_ticker_smooth;
float scale_factor = ozone->last_scale_factor;
enum gfx_animation_ticker_type
menu_ticker_type = (enum gfx_animation_ticker_type)settings->uints.menu_ticker_type;
selection_y = 0;
selection_old_y = 0;
horizontal_list_size = 0;
menu_ticker_type = (enum gfx_animation_ticker_type)
settings->uints.menu_ticker_type;
unsigned selection_y = 0;
unsigned selection_old_y = 0;
unsigned horizontal_list_size = 0;
if (!ozone->draw_sidebar)
return;
@ -399,13 +438,13 @@ void ozone_go_to_sidebar(ozone_handle_t *ozone, uintptr_t tag)
/* Cursor animation */
ozone->animations.cursor_alpha = 0.0f;
entry.cb = NULL;
entry.duration = ANIMATION_CURSOR_DURATION;
entry.easing_enum = EASING_OUT_QUAD;
entry.subject = &ozone->animations.cursor_alpha;
entry.tag = tag;
entry.target_value = 1.0f;
entry.userdata = NULL;
entry.cb = NULL;
entry.duration = ANIMATION_CURSOR_DURATION;
entry.easing_enum = EASING_OUT_QUAD;
entry.subject = &ozone->animations.cursor_alpha;
entry.tag = tag;
entry.target_value = 1.0f;
entry.userdata = NULL;
gfx_animation_push(&entry);
@ -455,13 +494,6 @@ unsigned ozone_get_sidebar_height(ozone_handle_t *ozone)
(ozone->horizontal_list && ozone->horizontal_list->size > 0 ? ozone->dimensions.sidebar_entry_padding_vertical + ozone->dimensions.spacer_1px : 0);
}
static void ozone_sidebar_collapse_end(void *userdata)
{
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
ozone->sidebar_collapsed = true;
}
void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation)
{
/* Collapse sidebar if needed */
@ -499,8 +531,9 @@ void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation)
}
else
{
ozone->animations.sidebar_text_alpha = 0.0f;
ozone->dimensions.sidebar_width = ozone->dimensions.sidebar_width_collapsed;
ozone->animations.sidebar_text_alpha = 0.0f;
ozone->dimensions.sidebar_width =
ozone->dimensions.sidebar_width_collapsed;
ozone_sidebar_collapse_end(ozone);
}
}
@ -536,30 +569,6 @@ void ozone_sidebar_update_collapse(ozone_handle_t *ozone, bool allow_animation)
ozone_entries_update_thumbnail_bar(ozone, is_playlist, allow_animation);
}
static float ozone_sidebar_get_scroll_y(
ozone_handle_t *ozone, unsigned video_height)
{
float scroll_y = ozone->animations.scroll_y_sidebar;
float selected_position_y =
ozone_get_selected_sidebar_y_position(ozone);
float current_selection_middle_onscreen =
ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->animations.scroll_y_sidebar + selected_position_y + ozone->dimensions.sidebar_entry_height / 2.0f;
float bottom_boundary = (float)video_height - (ozone->dimensions.header_height + ozone->dimensions.spacer_1px) - ozone->dimensions.footer_height;
float entries_middle = (float)video_height / 2.0f;
float entries_height = ozone_get_sidebar_height(ozone);
if (current_selection_middle_onscreen != entries_middle)
scroll_y = ozone->animations.scroll_y_sidebar - (current_selection_middle_onscreen - entries_middle);
if (scroll_y + entries_height < bottom_boundary)
scroll_y = bottom_boundary - entries_height - ozone->dimensions.sidebar_padding_vertical;
if (scroll_y > 0.0f)
return 0.0f;
return scroll_y;
}
void ozone_sidebar_goto(ozone_handle_t *ozone, unsigned new_selection)
{
unsigned video_info_height;

View File

@ -146,7 +146,6 @@ static float ozone_border_1_nord[16] = COLOR_HEX_TO_FLOAT(0x88C0D0, 1.0f);
static float ozone_border_0_gruvbox_dark[16] = COLOR_HEX_TO_FLOAT(0xAF3A03, 1.0f);
static float ozone_border_1_gruvbox_dark[16] = COLOR_HEX_TO_FLOAT(0xFE8019, 1.0f);
ozone_theme_t ozone_theme_light = {
COLOR_HEX_TO_FLOAT(0xEBEBEB, 1.00),
ozone_background_libretro_running_light,