1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:57:36 +08:00

Use dropdown in BeatmapSearchFilterRow

This commit is contained in:
Andrei Zavatski 2020-02-18 01:04:25 +03:00
parent ae942388a2
commit 410686c8b9
2 changed files with 37 additions and 14 deletions

View File

@ -7,6 +7,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapListing;
@ -26,11 +27,11 @@ namespace osu.Game.Tests.Visual.UserInterface
[Cached]
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
private readonly FillFlowContainer resizableContainer;
private readonly ReverseChildIDFillFlowContainer<Drawable> resizableContainer;
public TestSceneBeatmapSearchFilter()
{
Add(resizableContainer = new FillFlowContainer
Add(resizableContainer = new ReverseChildIDFillFlowContainer<Drawable>
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,

View File

@ -51,15 +51,13 @@ namespace osu.Game.Overlays.BeatmapListing
{
new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Font = OsuFont.GetFont(size: 10),
Text = headerName.ToUpper()
},
CreateFilter().With(f =>
{
f.Anchor = Anchor.CentreLeft;
f.Origin = Anchor.CentreLeft;
f.Current = current;
})
}
@ -74,7 +72,12 @@ namespace osu.Game.Overlays.BeatmapListing
{
public BeatmapSearchFilter()
{
AutoSizeAxes = Axes.Both;
Anchor = Anchor.BottomLeft;
Origin = Anchor.BottomLeft;
RelativeSizeAxes = Axes.X;
Height = 15;
TabContainer.Spacing = new Vector2(10, 0);
if (typeof(T).IsEnum)
{
@ -83,16 +86,16 @@ namespace osu.Game.Overlays.BeatmapListing
}
}
protected override Dropdown<T> CreateDropdown() => null;
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
((FilterDropdown)Dropdown).AccentColour = colourProvider.Light2;
}
protected override Dropdown<T> CreateDropdown() => new FilterDropdown();
protected override TabItem<T> CreateTabItem(T value) => new FilterTabItem(value);
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
{
AutoSizeAxes = Axes.Both,
Spacing = new Vector2(10),
};
protected class FilterTabItem : TabItem<T>
{
protected virtual float TextSize => 13;
@ -106,6 +109,8 @@ namespace osu.Game.Overlays.BeatmapListing
: base(value)
{
AutoSizeAxes = Axes.Both;
Anchor = Anchor.BottomLeft;
Origin = Anchor.BottomLeft;
AddRangeInternal(new Drawable[]
{
text = new OsuSpriteText
@ -148,6 +153,23 @@ namespace osu.Game.Overlays.BeatmapListing
private Color4 getStateColour() => IsHovered ? colourProvider.Light1 : colourProvider.Light3;
}
private class FilterDropdown : OsuTabDropdown<T>
{
protected override DropdownHeader CreateHeader() => new FilterHeader
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight
};
private class FilterHeader : OsuTabDropdownHeader
{
public FilterHeader()
{
Background.Height = 1;
}
}
}
}
}
}