1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Also add an underline to better accent current filters

This commit is contained in:
Dean Herbert 2023-01-06 20:35:58 +09:00
parent 458fe382ed
commit 4319937bc7
2 changed files with 29 additions and 6 deletions

View File

@ -12,6 +12,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osuTK;
@ -100,9 +101,31 @@ namespace osu.Game.Overlays.BeatmapListing
protected partial class MultipleSelectionFilterTabItem : FilterTabItem<T>
{
private readonly Box selectedUnderline;
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
public MultipleSelectionFilterTabItem(T value)
: base(value)
{
// This doesn't match any actual design, but should make it easier for the user to understand
// that filters are applied until we settle on a final design.
AddInternal(selectedUnderline = new Box
{
Depth = float.MaxValue,
RelativeSizeAxes = Axes.X,
Height = 1.5f,
Anchor = Anchor.BottomLeft,
Origin = Anchor.CentreLeft,
});
}
protected override void UpdateState()
{
base.UpdateState();
selectedUnderline.FadeTo(Active.Value ? 1 : 0, 200, Easing.OutQuint);
selectedUnderline.FadeColour(IsHovered ? colourProvider.Light1 : GetStateColour(), 200, Easing.OutQuint);
}
protected override bool OnClick(ClickEvent e)

View File

@ -52,33 +52,33 @@ namespace osu.Game.Overlays.BeatmapListing
{
base.LoadComplete();
updateState();
UpdateState();
FinishTransforms(true);
}
protected override bool OnHover(HoverEvent e)
{
base.OnHover(e);
updateState();
UpdateState();
return true;
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
updateState();
UpdateState();
}
protected override void OnActivated() => updateState();
protected override void OnActivated() => UpdateState();
protected override void OnDeactivated() => updateState();
protected override void OnDeactivated() => UpdateState();
/// <summary>
/// Returns the label text to be used for the supplied <paramref name="value"/>.
/// </summary>
protected virtual LocalisableString LabelFor(T value) => (value as Enum)?.GetLocalisableDescription() ?? value.ToString();
private void updateState()
protected virtual void UpdateState()
{
text.FadeColour(IsHovered ? colourProvider.Light1 : GetStateColour(), 200, Easing.OutQuint);
text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Regular);