1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:07:38 +08:00

make PlayerSettingsGroup expand on hover

This commit is contained in:
integer 2023-01-13 23:07:59 +00:00
parent 0b5c89d01f
commit c3c1d77e8e
2 changed files with 26 additions and 4 deletions

View File

@ -16,7 +16,6 @@ namespace osu.Game.Screens.Play.HUD
{
private const int fade_duration = 200;
public bool ReplayLoaded;
public readonly PlaybackSettings PlaybackSettings;
@ -42,13 +41,12 @@ namespace osu.Game.Screens.Play.HUD
{
//CollectionSettings = new CollectionSettings(),
//DiscussionSettings = new DiscussionSettings(),
PlaybackSettings = new PlaybackSettings(),
VisualSettings = new VisualSettings()
PlaybackSettings = new PlaybackSettings { Expanded = { Value = false } },
VisualSettings = new VisualSettings { Expanded = { Value = false } }
}
};
}
protected override void PopIn() => this.FadeIn(fade_duration);
protected override void PopOut() => this.FadeOut(fade_duration);

View File

@ -4,6 +4,7 @@
#nullable disable
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Game.Overlays;
namespace osu.Game.Screens.Play.PlayerSettings
@ -15,12 +16,35 @@ namespace osu.Game.Screens.Play.PlayerSettings
{
}
private ScheduledDelegate hoverExpandEvent;
protected override bool OnHover(HoverEvent e)
{
updateHoverExpansion();
base.OnHover(e);
// Importantly, return true to correctly take focus away from PlayerLoader.
return true;
}
protected override void OnHoverLost(HoverLostEvent e)
{
if (hoverExpandEvent == null) return;
hoverExpandEvent?.Cancel();
hoverExpandEvent = null;
Expanded.Value = false;
base.OnHoverLost(e);
}
private void updateHoverExpansion()
{
hoverExpandEvent?.Cancel();
if (IsHovered && !Expanded.Value)
hoverExpandEvent = Scheduler.AddDelayed(() => Expanded.Value = true, 0);
}
}
}