1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-11 01:07:23 +08:00

Add better selection visibility via another tint layer

This commit is contained in:
Dean Herbert 2025-02-28 16:27:18 +09:00
parent 02b950223c
commit a8fbac0f0d
No known key found for this signature in database

View File

@ -38,6 +38,8 @@ namespace osu.Game.Screens.SelectV2
private Container iconContainer = null!; private Container iconContainer = null!;
private Box activationFlash = null!; private Box activationFlash = null!;
private Box hoverLayer = null!; private Box hoverLayer = null!;
private Box keyboardSelectionLayer = null!;
private Box selectionLayer = null!;
public Container TopLevelContent { get; private set; } = null!; public Container TopLevelContent { get; private set; } = null!;
@ -137,6 +139,24 @@ namespace osu.Game.Screens.SelectV2
hoverLayer = new Box hoverLayer = new Box
{ {
Alpha = 0, Alpha = 0,
Colour = colours.Blue.Opacity(0.1f),
Blending = BlendingParameters.Additive,
RelativeSizeAxes = Axes.Both,
},
selectionLayer = new Box
{
Alpha = 0,
Colour = ColourInfo.GradientHorizontal(colours.Yellow.Opacity(0), colours.Yellow.Opacity(0.5f)),
Blending = BlendingParameters.Additive,
RelativeSizeAxes = Axes.Both,
Width = 0.7f,
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
},
keyboardSelectionLayer = new Box
{
Alpha = 0,
Colour = colours.Yellow.Opacity(0.1f),
Blending = BlendingParameters.Additive, Blending = BlendingParameters.Additive,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, },
@ -151,7 +171,6 @@ namespace osu.Game.Screens.SelectV2
} }
}; };
hoverLayer.Colour = colours.Blue.Opacity(0.1f);
backgroundGradient.Colour = ColourInfo.GradientHorizontal(colourProvider.Background3, colourProvider.Background4); backgroundGradient.Colour = ColourInfo.GradientHorizontal(colourProvider.Background3, colourProvider.Background4);
} }
@ -159,9 +178,27 @@ namespace osu.Game.Screens.SelectV2
{ {
base.LoadComplete(); base.LoadComplete();
Expanded.BindValueChanged(_ => updateDisplay()); Expanded.BindValueChanged(_ => updateDisplay(), true);
Selected.BindValueChanged(_ => updateDisplay());
KeyboardSelected.BindValueChanged(_ => updateDisplay(), true); Selected.BindValueChanged(selected =>
{
if (selected.NewValue)
selectionLayer.FadeIn(100, Easing.OutQuint);
else
selectionLayer.FadeOut(200, Easing.OutQuint);
updateXOffset();
}, true);
KeyboardSelected.BindValueChanged(selected =>
{
if (selected.NewValue)
keyboardSelectionLayer.FadeIn(100, Easing.OutQuint);
else
keyboardSelectionLayer.FadeOut(1000, Easing.OutQuint);
updateXOffset();
}, true);
} }
protected override void PrepareForUse() protected override void PrepareForUse()
@ -211,9 +248,7 @@ namespace osu.Game.Screens.SelectV2
private void updateHover() private void updateHover()
{ {
bool hovered = IsHovered || KeyboardSelected.Value; if (IsHovered)
if (hovered)
hoverLayer.FadeIn(100, Easing.OutQuint); hoverLayer.FadeIn(100, Easing.OutQuint);
else else
hoverLayer.FadeOut(1000, Easing.OutQuint); hoverLayer.FadeOut(1000, Easing.OutQuint);
@ -221,13 +256,13 @@ namespace osu.Game.Screens.SelectV2
protected override bool OnHover(HoverEvent e) protected override bool OnHover(HoverEvent e)
{ {
updateDisplay(); updateHover();
return true; return true;
} }
protected override void OnHoverLost(HoverLostEvent e) protected override void OnHoverLost(HoverLostEvent e)
{ {
updateDisplay(); updateHover();
base.OnHoverLost(e); base.OnHoverLost(e);
} }