1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:43:04 +08:00

Adjust footer button colour handling to read better and take into account mouse down

This commit is contained in:
Dean Herbert 2023-02-03 16:24:19 +09:00
parent 80fd1a0bc7
commit a1200b8fe8
2 changed files with 33 additions and 17 deletions

View File

@ -10,7 +10,6 @@ using osu.Framework.Testing;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Overlays.Mods; using osu.Game.Overlays.Mods;
using osu.Game.Screens.Select.FooterV2; using osu.Game.Screens.Select.FooterV2;
using osuTK;
using osuTK.Input; using osuTK.Input;
namespace osu.Game.Tests.Visual.SongSelect namespace osu.Game.Tests.Visual.SongSelect
@ -51,15 +50,13 @@ namespace osu.Game.Tests.Visual.SongSelect
}); });
footer.AddButton(new FooterButtonOptionsV2()); footer.AddButton(new FooterButtonOptionsV2());
InputManager.MoveMouseTo(Vector2.Zero);
overlay.Hide(); overlay.Hide();
}); });
[Test] [Test]
public void TestState() public void TestState()
{ {
AddRepeatStep("toggle options state", () => this.ChildrenOfType<FooterButtonV2>().Last().Enabled.Toggle(), 20); AddToggleStep("set options enabled state", state => this.ChildrenOfType<FooterButtonV2>().Last().Enabled.Value = state);
} }
[Test] [Test]

View File

@ -18,6 +18,7 @@ using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Overlays; using osu.Game.Overlays;
using osuTK; using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Select.FooterV2 namespace osu.Game.Screens.Select.FooterV2
{ {
@ -148,12 +149,28 @@ namespace osu.Game.Screens.Select.FooterV2
public GlobalAction? Hotkey; public GlobalAction? Hotkey;
private bool handlingMouse;
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
updateDisplay(); updateDisplay();
return true; return true;
} }
protected override bool OnMouseDown(MouseDownEvent e)
{
handlingMouse = true;
updateDisplay();
return base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseUpEvent e)
{
handlingMouse = false;
updateDisplay();
base.OnMouseUp(e);
}
protected override void OnHoverLost(HoverLostEvent e) => updateDisplay(); protected override void OnHoverLost(HoverLostEvent e) => updateDisplay();
public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e) public virtual bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
@ -168,25 +185,27 @@ namespace osu.Game.Screens.Select.FooterV2
private void updateDisplay() private void updateDisplay()
{ {
Color4 backgroundColour = colourProvider.Background3;
if (!Enabled.Value) if (!Enabled.Value)
{ {
backgroundBox.FadeColour(colourProvider.Background3.Darken(0.3f), transition_length, Easing.OutQuint); backgroundColour = colourProvider.Background3.Darken(0.4f);
return;
} }
else
if (OverlayState.Value == Visibility.Visible)
{ {
backgroundBox.FadeColour(buttonAccentColour.Darken(0.5f), transition_length, Easing.OutQuint); if (OverlayState.Value == Visibility.Visible)
return; backgroundColour = buttonAccentColour.Darken(0.5f);
if (IsHovered)
{
backgroundColour = backgroundColour.Lighten(0.3f);
if (handlingMouse)
backgroundColour = backgroundColour.Lighten(0.3f);
}
} }
if (IsHovered) backgroundBox.FadeColour(backgroundColour, transition_length, Easing.OutQuint);
{
backgroundBox.FadeColour(colourProvider.Background3.Lighten(0.3f), transition_length, Easing.OutQuint);
return;
}
backgroundBox.FadeColour(colourProvider.Background3, transition_length, Easing.OutQuint);
} }
} }
} }