Make volume controls stay open when hovered

Closes #2743.
This commit is contained in:
Dean Herbert 2018-06-07 01:14:43 +09:00
parent dd75cd973b
commit 17ba129e61
1 changed files with 18 additions and 11 deletions

View File

@ -9,6 +9,7 @@
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Input.Bindings;
@ -86,16 +87,10 @@ protected override void LoadComplete()
{
base.LoadComplete();
volumeMeterMaster.Bindable.ValueChanged += _ => settingChanged();
volumeMeterEffect.Bindable.ValueChanged += _ => settingChanged();
volumeMeterMusic.Bindable.ValueChanged += _ => settingChanged();
muteButton.Current.ValueChanged += _ => settingChanged();
}
private void settingChanged()
{
Show();
schedulePopOut();
volumeMeterMaster.Bindable.ValueChanged += _ => Show();
volumeMeterEffect.Bindable.ValueChanged += _ => Show();
volumeMeterMusic.Bindable.ValueChanged += _ => Show();
muteButton.Current.ValueChanged += _ => Show();
}
public bool Adjust(GlobalAction action)
@ -140,10 +135,22 @@ protected override void PopOut()
this.FadeOut(100);
}
protected override bool OnMouseMove(InputState state)
{
// keep the scheduled event correctly timed as long as we have movement.
schedulePopOut();
return base.OnMouseMove(state);
}
private void schedulePopOut()
{
popOutDelegate?.Cancel();
this.Delay(1000).Schedule(Hide, out popOutDelegate);
this.Delay(1000).Schedule(() =>
{
// only actually hide if the mouse isn't within our bounds.
if (!ScreenSpaceDrawQuad.Contains(GetContainingInputManager().CurrentState.Mouse.Position))
Hide();
}, out popOutDelegate);
}
}
}