(Ozone+XMB) Thumbnail improvements (#14188)

This commit is contained in:
sonninnos 2022-07-21 16:25:12 +03:00 committed by GitHub
parent 3cf7e881ec
commit 1f244aac01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 126 additions and 55 deletions

View File

@ -616,6 +616,7 @@ struct ozone_handle
bool is_db_manager_list;
bool is_file_list;
bool is_quick_menu;
bool was_quick_menu;
bool is_state_slot;
bool is_contentless_cores;
bool first_frame;
@ -3378,7 +3379,7 @@ static void ozone_update_savestate_thumbnail_path(void *data, unsigned i)
else
ozone->fullscreen_thumbnails_available = false;
}
else
else if (!ozone->skip_thumbnail_reset)
{
ozone->want_thumbnail_bar = false;
ozone->fullscreen_thumbnails_available = false;
@ -4845,9 +4846,8 @@ static void ozone_compute_entries_position(
if (ozone->depth == 1)
sublabel_max_width -= (unsigned) ozone->dimensions_sidebar_width;
if (ozone->show_thumbnail_bar && !ozone->libretro_running)
sublabel_max_width -= ozone->dimensions.thumbnail_bar_width;
if (ozone->show_thumbnail_bar && ozone->depth < 3)
sublabel_max_width += -(ozone->dimensions.thumbnail_bar_width / 2) + ozone->dimensions.sidebar_entry_icon_padding;
(ozone->word_wrap)(wrapped_sublabel_str, sizeof(wrapped_sublabel_str), entry.sublabel,
sublabel_max_width /
@ -4913,6 +4913,7 @@ static void ozone_draw_entries(
size_t y = ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.entry_padding_vertical;
float sidebar_offset = ozone->sidebar_offset;
unsigned entry_width = video_width - (unsigned) ozone->dimensions_sidebar_width - ozone->sidebar_offset - entry_padding * 2 - ozone->animations.thumbnail_bar_position;
unsigned entry_width_max = entry_width + ozone->animations.thumbnail_bar_position;
unsigned button_height = ozone->dimensions.entry_height; /* height of the button (entry minus sublabel) */
float invert = (ozone->fade_direction) ? -1 : 1;
float alpha_anim = old_list ? alpha : 1.0f - alpha;
@ -4921,6 +4922,17 @@ static void ozone_draw_entries(
bottom_boundary = video_info_height - ozone->dimensions.header_height - ozone->dimensions.footer_height;
/* Increase entry width, or rather decrease padding between
* entries and thumbnails when thumbnail bar is visible */
if (ozone->show_thumbnail_bar)
{
entry_width += (entry_padding / 2);
/* Limit entry width to prevent animation bouncing */
if (entry_width > entry_width_max)
entry_width = entry_width_max;
}
if (old_list)
{
alpha = 1.0f - alpha;
@ -5163,9 +5175,8 @@ border_iterate:
if (ozone->depth == 1)
sublabel_max_width -= (unsigned) ozone->dimensions_sidebar_width;
if (ozone->show_thumbnail_bar && !ozone->libretro_running)
sublabel_max_width -= ozone->dimensions.thumbnail_bar_width;
if (ozone->show_thumbnail_bar && ozone->depth < 3)
sublabel_max_width += -(ozone->dimensions.thumbnail_bar_width / 2) + ozone->dimensions.sidebar_entry_icon_padding;
wrapped_sublabel_str[0] = '\0';
(ozone->word_wrap)(wrapped_sublabel_str, sizeof(wrapped_sublabel_str),
@ -5388,8 +5399,8 @@ static void ozone_draw_thumbnail_bar(
bool show_right_thumbnail = false;
bool show_left_thumbnail = false;
unsigned sidebar_height = video_height - ozone->dimensions.header_height - ozone->dimensions.sidebar_gradient_height * 2 - ozone->dimensions.footer_height;
unsigned x_position = video_width - (unsigned) ozone->animations.thumbnail_bar_position;
int thumbnail_x_position = x_position + ozone->dimensions.sidebar_entry_icon_padding;
unsigned x_position = video_width - (unsigned) ozone->animations.thumbnail_bar_position - ozone->dimensions.sidebar_entry_icon_padding;
int thumbnail_x_position = x_position + ozone->dimensions.sidebar_entry_icon_padding + ozone->dimensions.sidebar_entry_icon_padding;
unsigned thumbnail_height = (video_height - ozone->dimensions.header_height - ozone->dimensions.spacer_2px - ozone->dimensions.footer_height - (ozone->dimensions.sidebar_entry_icon_padding * 3)) / 2;
float scale_factor = ozone->last_scale_factor;
gfx_display_ctx_driver_t *dispctx = p_disp->dispctx;
@ -5404,7 +5415,7 @@ static void ozone_draw_thumbnail_bar(
video_height,
x_position,
ozone->dimensions.header_height + ozone->dimensions.spacer_1px,
(unsigned)ozone->animations.thumbnail_bar_position,
(unsigned)ozone->animations.thumbnail_bar_position + ozone->dimensions.sidebar_entry_icon_padding,
ozone->dimensions.sidebar_gradient_height,
video_width,
video_height,
@ -5417,7 +5428,7 @@ static void ozone_draw_thumbnail_bar(
video_height,
x_position,
ozone->dimensions.header_height + ozone->dimensions.spacer_1px + ozone->dimensions.sidebar_gradient_height,
(unsigned)ozone->animations.thumbnail_bar_position,
(unsigned)ozone->animations.thumbnail_bar_position + ozone->dimensions.sidebar_entry_icon_padding,
sidebar_height,
video_width,
video_height,
@ -5430,7 +5441,7 @@ static void ozone_draw_thumbnail_bar(
video_height,
x_position,
video_height - ozone->dimensions.footer_height - ozone->dimensions.sidebar_gradient_height - ozone->dimensions.spacer_1px,
(unsigned) ozone->animations.thumbnail_bar_position,
(unsigned) ozone->animations.thumbnail_bar_position + ozone->dimensions.sidebar_entry_icon_padding,
ozone->dimensions.sidebar_gradient_height + ozone->dimensions.spacer_1px,
video_width,
video_height,
@ -5463,7 +5474,7 @@ static void ozone_draw_thumbnail_bar(
{
thumbnail_width = sidebar_width;
thumbnail_height = (video_height - ozone->dimensions.header_height - ozone->dimensions.footer_height) / 2;
thumbnail_x_position = x_position - (ozone->dimensions.sidebar_entry_icon_padding * 2);
thumbnail_x_position = x_position - ozone->dimensions.sidebar_entry_icon_padding;
}
else
{
@ -6536,9 +6547,11 @@ static void ozone_draw_fullscreen_thumbnails(
/* Do nothing if both thumbnails are missing
* > Note: Baring inexplicable internal errors, this
* can never happen... */
* can never happen...
* > Return instead of error to keep fullscreen
* mode after menu/fullscreen toggle */
if (num_thumbnails < 1)
goto error;
return;
/* Get base thumbnail dimensions + draw positions */
@ -7091,7 +7104,7 @@ static enum menu_action ozone_parse_menu_entry_action(
* valid menu action will disable it... */
if (ozone->show_fullscreen_thumbnails)
{
if (action != MENU_ACTION_NOOP)
if (action != MENU_ACTION_NOOP && action != MENU_ACTION_TOGGLE)
{
ozone_hide_fullscreen_thumbnails(ozone, true);
@ -7140,7 +7153,8 @@ static enum menu_action ozone_parse_menu_entry_action(
{
case MENU_ACTION_START:
ozone->cursor_mode = false;
if (ozone->is_quick_menu && ozone->libretro_running)
if (ozone->is_state_slot ||
(ozone->is_quick_menu && !string_is_empty(ozone->savestate_thumbnail_file_path)))
break;
/* If this is a menu with thumbnails and cursor
@ -7153,6 +7167,17 @@ static enum menu_action ozone_parse_menu_entry_action(
new_action = MENU_ACTION_NOOP;
}
break;
case MENU_ACTION_SCAN:
ozone->cursor_mode = false;
if (ozone->fullscreen_thumbnails_available &&
(ozone->is_state_slot ||
(ozone->is_quick_menu && !string_is_empty(ozone->savestate_thumbnail_file_path))))
{
ozone_show_fullscreen_thumbnails(ozone);
new_action = MENU_ACTION_NOOP;
}
break;
case MENU_ACTION_DOWN:
if (ozone->cursor_in_sidebar)
{
@ -7359,17 +7384,6 @@ static enum menu_action ozone_parse_menu_entry_action(
ozone->cursor_mode = false;
break;
case MENU_ACTION_SCAN:
ozone->cursor_mode = false;
if (ozone->fullscreen_thumbnails_available &&
((ozone->is_quick_menu && !string_is_empty(ozone->savestate_thumbnail_file_path)) ||
(ozone->is_state_slot)))
{
ozone_show_fullscreen_thumbnails(ozone);
new_action = MENU_ACTION_NOOP;
}
break;
default:
/* In all other cases, pass through input
* menu action without intervention */
@ -7724,6 +7738,9 @@ static void ozone_update_thumbnail_image(void *data)
has_thumbnail = gfx_thumbnail_get_path(ozone->thumbnail_path_data, 0, &thumbnail_path);
if (has_thumbnail && !ozone->libretro_running)
ozone->want_thumbnail_bar = true;
if (ozone->show_thumbnail_bar != ozone->want_thumbnail_bar)
ozone->need_compute = true;
}
static void ozone_refresh_thumbnail_image(void *data, unsigned i)
@ -9715,7 +9732,8 @@ static void ozone_selection_changed(ozone_handle_t *ozone, bool allow_animation)
if (ozone->is_playlist && ozone->depth == 1)
{
ozone_set_thumbnail_content(ozone, "");
update_thumbnails = true;
update_thumbnails = true;
ozone->skip_thumbnail_reset = false;
}
/* Database list updates
* (pointless nuisance...) */
@ -9731,7 +9749,9 @@ static void ozone_selection_changed(ozone_handle_t *ozone, bool allow_animation)
(entry_type == FILE_TYPE_IMAGE))
{
ozone_set_thumbnail_content(ozone, "imageviewer");
update_thumbnails = true;
update_thumbnails = true;
ozone->want_thumbnail_bar = true;
ozone->fullscreen_thumbnails_available = true;
}
else
{
@ -9742,6 +9762,8 @@ static void ozone_selection_changed(ozone_handle_t *ozone, bool allow_animation)
* persist, and be shown on the wrong entry) */
gfx_thumbnail_set_content(ozone->thumbnail_path_data, NULL);
ozone_unload_thumbnail_textures(ozone);
update_thumbnails = true;
ozone->want_thumbnail_bar = false;
}
}
@ -10338,6 +10360,7 @@ static void ozone_populate_entries(void *data,
ozone->need_compute = true;
ozone->skip_thumbnail_reset = false;
ozone->was_quick_menu = ozone->is_quick_menu;
ozone->first_onscreen_entry = 0;
ozone->last_onscreen_entry = 0;
@ -10364,8 +10387,12 @@ static void ozone_populate_entries(void *data,
/* Thumbnails
* > Note: Leave current thumbnails loaded when
* opening the quick menu - allows proper fade
* out of the fullscreen thumbnail viewer */
if (!ozone->is_quick_menu && !ozone->is_state_slot)
* out of the fullscreen thumbnail viewer
* > Do not reset thumbnail when returning from quick menu */
if (!ozone->is_quick_menu && ozone->was_quick_menu)
ozone->skip_thumbnail_reset = true;
if (!ozone->is_quick_menu && !ozone->is_state_slot && !ozone->skip_thumbnail_reset)
{
ozone_unload_thumbnail_textures(ozone);
@ -10383,6 +10410,8 @@ static void ozone_populate_entries(void *data,
ozone_set_thumbnail_content(ozone, "");
ozone_update_thumbnail_image(ozone);
}
else if (ozone->is_file_list)
ozone->want_thumbnail_bar = false;
}
}
else if (ozone->is_quick_menu && !ozone->libretro_running)
@ -10393,9 +10422,23 @@ static void ozone_populate_entries(void *data,
}
else if (ozone->is_quick_menu && ozone->libretro_running)
{
ozone->want_thumbnail_bar = false;
ozone_update_savestate_thumbnail_path(ozone, menu_navigation_get_selection());
ozone_update_savestate_thumbnail_image(ozone);
const char *thumbnail_content_path = NULL;
runloop_state_t *runloop_st = runloop_state_get_ptr();
gfx_thumbnail_get_content_path(ozone->thumbnail_path_data, &thumbnail_content_path);
if (!string_is_empty(thumbnail_content_path) &&
!string_is_equal(thumbnail_content_path, runloop_st->runtime_content_path))
{
ozone->want_thumbnail_bar = true;
ozone->skip_thumbnail_reset = true;
ozone_update_thumbnail_image(ozone);
}
else
{
ozone->want_thumbnail_bar = false;
ozone_update_savestate_thumbnail_path(ozone, menu_navigation_get_selection());
ozone_update_savestate_thumbnail_image(ozone);
}
}
/* Fullscreen thumbnails are only enabled on
@ -10405,8 +10448,8 @@ static void ozone_populate_entries(void *data,
(ozone->is_playlist && ozone->depth == 1) ||
(ozone->is_db_manager_list && ozone->depth == 4) ||
(ozone->is_quick_menu && ozone->want_thumbnail_bar) ||
ozone->is_state_slot ||
ozone->is_file_list;
(ozone->is_file_list && ozone->want_thumbnail_bar) ||
ozone->is_state_slot;
if (ozone->fullscreen_thumbnails_available != ozone->want_thumbnail_bar)
ozone->want_thumbnail_bar = ozone->fullscreen_thumbnails_available;
@ -10427,6 +10470,7 @@ static void ozone_toggle(void *userdata, bool menu_on)
* 'save state' option */
if (ozone->is_quick_menu)
{
ozone->skip_thumbnail_reset = false;
gfx_thumbnail_reset(&ozone->thumbnails.savestate);
ozone_update_savestate_thumbnail_path(ozone, menu_navigation_get_selection());
ozone_update_savestate_thumbnail_image(ozone);

View File

@ -1154,6 +1154,8 @@ static void xmb_update_savestate_thumbnail_path(void *data, unsigned i)
if (!((xmb->is_quick_menu || xmb->is_state_slot) && xmb->libretro_running))
return;
xmb->fullscreen_thumbnails_available = false;
if (savestate_thumbnail_enable)
{
menu_entry_t entry;
@ -2540,14 +2542,26 @@ static void xmb_populate_entries(void *data,
* inside xmb_set_thumbnail_content() */
xmb->fullscreen_thumbnails_available =
(xmb->is_playlist || xmb->is_db_manager_list || xmb->is_file_list) &&
!xmb->is_quick_menu &&
!((xmb_system_tab > XMB_SYSTEM_TAB_SETTINGS) && (xmb->depth > 2));
if ((xmb->is_quick_menu &&
(!string_is_empty(xmb->savestate_thumbnail_file_path) || !xmb->libretro_running)) ||
xmb->is_state_slot)
if (xmb->is_state_slot || (xmb->is_quick_menu &&
!string_is_empty(xmb->savestate_thumbnail_file_path)))
xmb->fullscreen_thumbnails_available = true;
if (xmb->is_quick_menu && xmb->depth < 3)
{
const char *thumbnail_content_path = NULL;
runloop_state_t *runloop_st = runloop_state_get_ptr();
gfx_thumbnail_get_content_path(xmb->thumbnail_path_data, &thumbnail_content_path);
if (xmb->libretro_running)
xmb->fullscreen_thumbnails_available = false;
if (!string_is_empty(thumbnail_content_path) &&
!string_is_equal(thumbnail_content_path, runloop_st->runtime_content_path))
xmb->fullscreen_thumbnails_available = true;
}
/* Hack: XMB gets into complete muddle when
* performing 'complex' directory navigation
* via 'load content'. We have to work around
@ -4046,7 +4060,7 @@ static enum menu_action xmb_parse_menu_entry_action(
* valid menu action will disable it... */
if (xmb->show_fullscreen_thumbnails)
{
if (action != MENU_ACTION_NOOP)
if (action != MENU_ACTION_NOOP && action != MENU_ACTION_TOGGLE)
{
xmb_hide_fullscreen_thumbnails(xmb, true);
@ -4107,8 +4121,9 @@ static enum menu_action xmb_parse_menu_entry_action(
}
break;
case MENU_ACTION_START:
if ((xmb->is_quick_menu && xmb->libretro_running) ||
xmb->is_state_slot)
if (xmb->is_state_slot ||
(xmb->is_quick_menu &&
(!string_is_empty(xmb->savestate_thumbnail_file_path) || xmb->depth > 2)))
break;
/* If this is a menu with thumbnails, attempt
@ -4128,8 +4143,8 @@ static enum menu_action xmb_parse_menu_entry_action(
break;
case MENU_ACTION_SCAN:
if (xmb->fullscreen_thumbnails_available &&
((xmb->is_quick_menu && !string_is_empty(xmb->savestate_thumbnail_file_path)) ||
(xmb->is_state_slot)))
((xmb->is_state_slot) ||
(xmb->is_quick_menu && !string_is_empty(xmb->savestate_thumbnail_file_path))))
{
xmb_hide_fullscreen_thumbnails(xmb, false);
xmb_show_fullscreen_thumbnails(xmb, menu_navigation_get_selection());
@ -4738,9 +4753,11 @@ static void xmb_draw_fullscreen_thumbnails(
/* Do nothing if both thumbnails are missing
* > Note: Baring inexplicable internal errors, this
* can never happen... */
* can never happen...
* > Return instead of error to keep fullscreen
* mode after menu/fullscreen toggle */
if (num_thumbnails < 1)
goto error;
return;
/* Get base thumbnail dimensions + draw positions */
@ -5213,7 +5230,17 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
/**************************/
/* Draw thumbnails: START */
/**************************/
xmb->libretro_running = libretro_running;
/* Reset thumbnail bar when starting/closing content */
if (xmb->libretro_running != libretro_running)
{
xmb->libretro_running = libretro_running;
if (xmb->is_quick_menu && libretro_running)
xmb->fullscreen_thumbnails_available = false;
else if (xmb->is_quick_menu && !libretro_running)
xmb->fullscreen_thumbnails_available = true;
}
/* Note: This is incredibly ugly, but there are
* so many combinations here that we would go insane
@ -5243,12 +5270,7 @@ static void xmb_frame(void *data, video_frame_info_t *video_info)
GFX_THUMBNAIL_ALIGN_CENTRE,
1.0f, 1.0f, &thumbnail_shadow);
}
/* This is used for hiding thumbnails when going into sub-levels in the
* Quick Menu as well as when selecting "Information" for a playlist entry.
* NOTE: This is currently a pretty crude check, simply going by menu depth
* and not specifically identifying which menu we're actually in. */
else if (!((xmb_system_tab > XMB_SYSTEM_TAB_SETTINGS) &&
((xmb->depth > 1 && libretro_running) || (xmb->depth > 2 && !libretro_running))))
else if (xmb->fullscreen_thumbnails_available)
{
bool show_right_thumbnail =
(xmb->thumbnails.right.status == GFX_THUMBNAIL_STATUS_AVAILABLE) ||
@ -7109,8 +7131,13 @@ static void xmb_toggle(void *userdata, bool menu_on)
* thumbnail won't update after selecting
* 'save state' option */
if (xmb->is_quick_menu)
{
gfx_thumbnail_reset(&xmb->thumbnails.savestate);
if (xmb->libretro_running)
xmb->fullscreen_thumbnails_available = false;
}
entry.duration = XMB_DELAY * 2;
entry.target_value = 1.0f;
entry.subject = &xmb->alpha;