(Ozone) Ensure sidebar display status is updated correctly when performing rapid menu navigation (#12524)

This commit is contained in:
jdgleaver 2021-06-14 12:58:39 +01:00 committed by GitHub
parent 6738fa57aa
commit 642d6c9fb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 50 additions and 19 deletions

View File

@ -726,6 +726,7 @@ static void *ozone_init(void **userdata, bool video_is_threaded)
ozone->animations.thumbnail_bar_position = 0.0f;
ozone->show_thumbnail_bar = false;
ozone->pending_hide_thumbnail_bar = false;
ozone->dimensions_sidebar_width = 0.0f;
ozone->num_search_terms_old = 0;
@ -1352,7 +1353,7 @@ static void ozone_context_reset(void *data, bool is_threaded)
static void ozone_collapse_end(void *userdata)
{
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
ozone->draw_sidebar = false;
ozone->draw_sidebar = false;
}
static void ozone_unload_thumbnail_textures(void *data)
@ -3288,17 +3289,26 @@ static void ozone_list_open(ozone_handle_t *ozone, settings_t *settings)
/* Sidebar animation */
ozone_sidebar_update_collapse(ozone, settings, true);
/* Kill any existing sidebar slide-in/out animations
* before pushing a new one
* > This is required since the 'ozone_collapse_end'
* callback from an unfinished slide-out animation
* may subsequently override the 'draw_sidebar'
* value set at the beginning of the next slide-in
* animation... */
gfx_animation_kill_by_tag(&sidebar_tag);
if (ozone->depth == 1)
{
ozone->draw_sidebar = true;
entry.cb = NULL;
entry.duration = ANIMATION_PUSH_ENTRY_DURATION;
entry.easing_enum = EASING_OUT_QUAD;
entry.subject = &ozone->sidebar_offset;
entry.tag = sidebar_tag;
entry.target_value = 0.0f;
entry.userdata = NULL;
entry.cb = NULL;
entry.duration = ANIMATION_PUSH_ENTRY_DURATION;
entry.easing_enum = EASING_OUT_QUAD;
entry.subject = &ozone->sidebar_offset;
entry.tag = sidebar_tag;
entry.target_value = 0.0f;
entry.userdata = NULL;
gfx_animation_push(&entry);
}

View File

@ -298,6 +298,7 @@ struct ozone_handle
bool cursor_mode;
bool sidebar_collapsed;
bool show_thumbnail_bar;
bool pending_hide_thumbnail_bar;
bool fullscreen_thumbnails_available;
bool show_fullscreen_thumbnails;
bool selection_core_is_viewer;

View File

@ -161,8 +161,9 @@ 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;
ozone_handle_t *ozone = (ozone_handle_t*) userdata;
ozone->show_thumbnail_bar = false;
ozone->pending_hide_thumbnail_bar = false;
}
static void ozone_draw_no_thumbnail_available(
@ -437,34 +438,52 @@ void ozone_entries_update_thumbnail_bar(ozone_handle_t *ozone, bool is_playlist,
gfx_animation_kill_by_tag(&tag);
/* Show it */
if (is_playlist && !ozone->cursor_in_sidebar && !ozone->show_thumbnail_bar && ozone->depth == 1)
/* Show it
* > We only want to trigger a 'show' animation
* if 'show_thumbnail_bar' is currently false.
* However: 'show_thumbnail_bar' is only set
* to false by the 'ozone_thumbnail_bar_hide_end'
* callback. If the above 'gfx_animation_kill_by_tag()'
* kills an existing 'hide' animation, then the
* callback will not fire - so the sidebar will be
* off screen, but a subsequent attempt to show it
* here will fail, since 'show_thumbnail_bar' will
* be a false positive. We therefore require an
* additional 'pending_hide_thumbnail_bar' parameter
* to track mid-animation state changes... */
if (is_playlist &&
!ozone->cursor_in_sidebar &&
(!ozone->show_thumbnail_bar || ozone->pending_hide_thumbnail_bar) &&
(ozone->depth == 1))
{
if (allow_animation)
{
ozone->show_thumbnail_bar = true;
entry.cb = NULL;
entry.userdata = NULL;
entry.target_value = ozone->dimensions.thumbnail_bar_width;
entry.cb = NULL;
entry.userdata = NULL;
entry.target_value = ozone->dimensions.thumbnail_bar_width;
gfx_animation_push(&entry);
}
else
{
ozone->animations.thumbnail_bar_position = ozone->dimensions.thumbnail_bar_width;
ozone->show_thumbnail_bar = true;
ozone->show_thumbnail_bar = true;
}
ozone->pending_hide_thumbnail_bar = false;
}
/* Hide it */
else
{
if (allow_animation)
{
entry.cb = ozone_thumbnail_bar_hide_end;
entry.userdata = ozone;
entry.target_value = 0.0f;
entry.cb = ozone_thumbnail_bar_hide_end;
entry.userdata = ozone;
entry.target_value = 0.0f;
ozone->pending_hide_thumbnail_bar = true;
gfx_animation_push(&entry);
}
else

View File

@ -752,6 +752,7 @@ void ozone_refresh_sidebars(
ozone->animations.thumbnail_bar_position = 0.0f;
ozone->show_thumbnail_bar = false;
}
ozone->pending_hide_thumbnail_bar = false;
/* If sidebar is on-screen, update scroll position */
if (ozone->depth == 1)