1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:07:23 +08:00

Merge pull request #22045 from frenzibyte/improve-filter-tab-item-ux

Fix multiple highlighting issues with beatmap listing tab items
This commit is contained in:
Dean Herbert 2023-01-06 21:43:58 +08:00 committed by GitHub
commit c41b1d4d89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -103,8 +103,7 @@ namespace osu.Game.Overlays.BeatmapListing
{
private readonly Box selectedUnderline;
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
protected override bool HighlightOnHoverWhenActive => true;
public MultipleSelectionFilterTabItem(T value)
: base(value)
@ -125,7 +124,7 @@ namespace osu.Game.Overlays.BeatmapListing
{
base.UpdateState();
selectedUnderline.FadeTo(Active.Value ? 1 : 0, 200, Easing.OutQuint);
selectedUnderline.FadeColour(IsHovered ? colourProvider.Light1 : GetStateColour(), 200, Easing.OutQuint);
selectedUnderline.FadeColour(IsHovered ? ColourProvider.Content2 : GetStateColour(), 200, Easing.OutQuint);
}
protected override bool OnClick(ClickEvent e)

View File

@ -20,7 +20,7 @@ namespace osu.Game.Overlays.BeatmapListing
public partial class FilterTabItem<T> : TabItem<T>
{
[Resolved]
private OverlayColourProvider colourProvider { get; set; }
protected OverlayColourProvider ColourProvider { get; private set; }
private OsuSpriteText text;
@ -78,12 +78,16 @@ namespace osu.Game.Overlays.BeatmapListing
/// </summary>
protected virtual LocalisableString LabelFor(T value) => (value as Enum)?.GetLocalisableDescription() ?? value.ToString();
protected virtual bool HighlightOnHoverWhenActive => false;
protected virtual void UpdateState()
{
text.FadeColour(IsHovered ? colourProvider.Light1 : GetStateColour(), 200, Easing.OutQuint);
bool highlightHover = IsHovered && (!Active.Value || HighlightOnHoverWhenActive);
text.FadeColour(highlightHover ? ColourProvider.Content2 : GetStateColour(), 200, Easing.OutQuint);
text.Font = text.Font.With(weight: Active.Value ? FontWeight.Bold : FontWeight.Regular);
}
protected virtual Color4 GetStateColour() => Active.Value ? colourProvider.Content1 : colourProvider.Light2;
protected virtual Color4 GetStateColour() => Active.Value ? ColourProvider.Content1 : ColourProvider.Light2;
}
}