From 410686c8b9dfbe393f23b3bbc1cefb21c499da40 Mon Sep 17 00:00:00 2001 From: Andrei Zavatski Date: Tue, 18 Feb 2020 01:04:25 +0300 Subject: [PATCH] Use dropdown in BeatmapSearchFilterRow --- .../TestSceneBeatmapSearchFilter.cs | 5 +- .../BeatmapListing/BeatmapSearchFilterRow.cs | 46 ++++++++++++++----- 2 files changed, 37 insertions(+), 14 deletions(-) diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs index 30cd34be50..7b4424e568 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneBeatmapSearchFilter.cs @@ -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 resizableContainer; public TestSceneBeatmapSearchFilter() { - Add(resizableContainer = new FillFlowContainer + Add(resizableContainer = new ReverseChildIDFillFlowContainer { Anchor = Anchor.Centre, Origin = Anchor.Centre, diff --git a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs index 0c4f63baca..8be0fca629 100644 --- a/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs +++ b/osu.Game/Overlays/BeatmapListing/BeatmapSearchFilterRow.cs @@ -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 CreateDropdown() => null; + [BackgroundDependencyLoader] + private void load(OverlayColourProvider colourProvider) + { + ((FilterDropdown)Dropdown).AccentColour = colourProvider.Light2; + } + + protected override Dropdown CreateDropdown() => new FilterDropdown(); protected override TabItem CreateTabItem(T value) => new FilterTabItem(value); - protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer - { - AutoSizeAxes = Axes.Both, - Spacing = new Vector2(10), - }; - protected class FilterTabItem : TabItem { 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 + { + protected override DropdownHeader CreateHeader() => new FilterHeader + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight + }; + + private class FilterHeader : OsuTabDropdownHeader + { + public FilterHeader() + { + Background.Height = 1; + } + } + } } } }