-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28653 from peppy/featured-artist-even-more-visible
Update beatmap listing filter overlay to better imply selected filters
- Loading branch information
Showing
3 changed files
with
94 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
// Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the MIT Licence. | ||
// See the LICENCE file in the repository root for full licence text. | ||
|
||
#nullable disable | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Specialized; | ||
using System.Linq; | ||
using JetBrains.Annotations; | ||
using osu.Framework.Allocation; | ||
using osu.Framework.Bindables; | ||
using osu.Framework.Extensions.Color4Extensions; | ||
using osu.Framework.Graphics; | ||
using osu.Framework.Graphics.Containers; | ||
using osu.Framework.Graphics.Shapes; | ||
using osu.Framework.Graphics.Sprites; | ||
using osu.Framework.Input.Events; | ||
using osu.Framework.Localisation; | ||
using osu.Game.Graphics; | ||
using osuTK; | ||
using osuTK.Graphics; | ||
using FontWeight = osu.Game.Graphics.FontWeight; | ||
|
||
namespace osu.Game.Overlays.BeatmapListing | ||
{ | ||
|
@@ -24,7 +26,7 @@ public partial class BeatmapSearchMultipleSelectionFilterRow<T> : BeatmapSearchF | |
{ | ||
public new readonly BindableList<T> Current = new BindableList<T>(); | ||
|
||
private MultipleSelectionFilter filter; | ||
private MultipleSelectionFilter filter = null!; | ||
|
||
public BeatmapSearchMultipleSelectionFilterRow(LocalisableString header) | ||
: base(header) | ||
|
@@ -42,7 +44,6 @@ private void load() | |
/// <summary> | ||
/// Creates a filter control that can be used to simultaneously select multiple values of type <typeparamref name="T"/>. | ||
/// </summary> | ||
[NotNull] | ||
protected virtual MultipleSelectionFilter CreateMultipleSelectionFilter() => new MultipleSelectionFilter(); | ||
|
||
protected partial class MultipleSelectionFilter : FillFlowContainer<MultipleSelectionFilterTabItem> | ||
|
@@ -54,7 +55,7 @@ private void load() | |
{ | ||
RelativeSizeAxes = Axes.X; | ||
AutoSizeAxes = Axes.Y; | ||
Spacing = new Vector2(10, 0); | ||
Spacing = new Vector2(10, 5); | ||
|
||
AddRange(GetValues().Select(CreateTabItem)); | ||
} | ||
|
@@ -69,7 +70,7 @@ protected override void LoadComplete() | |
Current.BindCollectionChanged(currentChanged, true); | ||
} | ||
|
||
private void currentChanged(object sender, NotifyCollectionChangedEventArgs e) | ||
private void currentChanged(object? sender, NotifyCollectionChangedEventArgs e) | ||
{ | ||
foreach (var c in Children) | ||
c.Active.Value = Current.Contains(c.Value); | ||
|
@@ -99,30 +100,91 @@ private void toggleItem(T value, bool active) | |
|
||
protected partial class MultipleSelectionFilterTabItem : FilterTabItem<T> | ||
{ | ||
private readonly Box selectedUnderline; | ||
|
||
protected override bool HighlightOnHoverWhenActive => true; | ||
private Drawable activeContent = null!; | ||
private Circle background = null!; | ||
|
||
public MultipleSelectionFilterTabItem(T value) | ||
: base(value) | ||
{ | ||
} | ||
|
||
[BackgroundDependencyLoader] | ||
private void load() | ||
{ | ||
AutoSizeDuration = 100; | ||
AutoSizeEasing = Easing.OutQuint; | ||
|
||
// 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 | ||
AddInternal(activeContent = new Container | ||
{ | ||
Depth = float.MaxValue, | ||
RelativeSizeAxes = Axes.X, | ||
Height = 1.5f, | ||
Anchor = Anchor.BottomLeft, | ||
Origin = Anchor.CentreLeft, | ||
RelativeSizeAxes = Axes.Both, | ||
Alpha = 0, | ||
Padding = new MarginPadding | ||
{ | ||
Left = -16, | ||
Right = -4, | ||
Vertical = -2 | ||
}, | ||
Children = new Drawable[] | ||
{ | ||
background = new Circle | ||
{ | ||
Colour = Color4.White, | ||
RelativeSizeAxes = Axes.Both, | ||
}, | ||
new SpriteIcon | ||
{ | ||
Icon = FontAwesome.Solid.TimesCircle, | ||
Size = new Vector2(10), | ||
Colour = ColourProvider.Background4, | ||
Position = new Vector2(3, 0.5f), | ||
Anchor = Anchor.CentreLeft, | ||
Origin = Anchor.CentreLeft, | ||
} | ||
} | ||
}); | ||
} | ||
|
||
protected override Color4 ColourActive => ColourProvider.Light1; | ||
|
||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) | ||
{ | ||
return Active.Value | ||
? background.ReceivePositionalInputAt(screenSpacePos) | ||
: base.ReceivePositionalInputAt(screenSpacePos); | ||
} | ||
|
||
protected override void UpdateState() | ||
{ | ||
base.UpdateState(); | ||
selectedUnderline.FadeTo(Active.Value ? 1 : 0, 200, Easing.OutQuint); | ||
selectedUnderline.FadeColour(IsHovered ? ColourProvider.Content2 : GetStateColour(), 200, Easing.OutQuint); | ||
Color4 colour = Active.Value ? ColourActive : ColourNormal; | ||
|
||
if (IsHovered) | ||
colour = Active.Value ? colour.Darken(0.2f) : colour.Lighten(0.2f); | ||
|
||
if (Active.Value) | ||
{ | ||
// This just allows enough spacing for adjacent tab items to show the "x". | ||
Padding = new MarginPadding { Left = 12 }; | ||
|
||
activeContent.FadeIn(200, Easing.OutQuint); | ||
background.FadeColour(colour, 200, Easing.OutQuint); | ||
|
||
// flipping colours | ||
Text.FadeColour(ColourProvider.Background4, 200, Easing.OutQuint); | ||
Text.Font = Text.Font.With(weight: FontWeight.SemiBold); | ||
} | ||
else | ||
{ | ||
Padding = new MarginPadding(); | ||
|
||
activeContent.FadeOut(); | ||
|
||
background.FadeColour(colour, 200, Easing.OutQuint); | ||
Text.FadeColour(colour, 200, Easing.OutQuint); | ||
Text.Font = Text.Font.With(weight: FontWeight.Regular); | ||
} | ||
} | ||
|
||
protected override bool OnClick(ClickEvent e) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters