1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 19:04:06 +08:00

Centralise hover state handling (and fix back-to-front conditionals)

This commit is contained in:
Dean Herbert 2021-12-15 16:44:58 +09:00
parent 6a1f535257
commit ad430a6277

View File

@ -56,7 +56,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
AutoSizeAxes = Axes.Y,
CornerRadius = BeatmapCard.CORNER_RADIUS,
Masking = true,
Unhovered = _ => collapseIfNotHovered(),
Unhovered = _ => updateFromHoverChange(),
Children = new Drawable[]
{
background = new Box
@ -78,10 +78,10 @@ namespace osu.Game.Beatmaps.Drawables.Cards
Alpha = 0,
Hovered = _ =>
{
queueExpandedStateChange(true);
updateFromHoverChange();
return true;
},
Unhovered = _ => collapseIfNotHovered(),
Unhovered = _ => updateFromHoverChange(),
Child = dropdownScroll = new ExpandedContentScrollContainer
{
RelativeSizeAxes = Axes.X,
@ -125,11 +125,8 @@ namespace osu.Game.Beatmaps.Drawables.Cards
public void CancelExpand() => scheduledExpandedChange?.Cancel();
private void collapseIfNotHovered()
{
if (!content.IsHovered && !dropdownContent.IsHovered)
queueExpandedStateChange(false);
}
private void updateFromHoverChange() =>
queueExpandedStateChange(content.IsHovered || dropdownContent.IsHovered, 100);
private void queueExpandedStateChange(bool newState, int delay = 0)
{