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.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Screens.Select.FooterV2;
using osuTK;
using osuTK.Input;
namespace osu.Game.Tests.Visual.SongSelect
@ -51,15 +50,13 @@ public void SetUp() => Schedule(() =>
});
footer.AddButton(new FooterButtonOptionsV2());
InputManager.MoveMouseTo(Vector2.Zero);
overlay.Hide();
});
[Test]
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]

View File

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