diff --git a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs index d534acbdc8..6ea957b5d0 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseTabControl.cs @@ -1,19 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE -using System; -using System.Collections.Generic; using System.Diagnostics; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.UserInterface.Tab; using osu.Framework.Screens.Testing; -using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using osu.Game.Screens.Select.Filter; using osu.Game.Screens.Select.Tab; @@ -37,7 +29,7 @@ namespace osu.Desktop.VisualTests.Tests AutoSizeAxes = Axes.Both, Children = new Drawable[] { - filter = new FilterTabControl(GroupMode.All, GroupMode.RecentlyPlayed) + filter = new FilterTabControl { Width = 229, AutoSort = true @@ -49,7 +41,10 @@ namespace osu.Desktop.VisualTests.Tests } } }); - + + filter.PinTab(GroupMode.All); + filter.PinTab(GroupMode.RecentlyPlayed); + filter.ValueChanged += (sender, mode) => { Debug.WriteLine($"Selected {mode}"); diff --git a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs index 786636ce1a..14615417f7 100644 --- a/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs +++ b/osu.Game/Graphics/UserInterface/OsuDropDownMenu.cs @@ -1,11 +1,11 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework.Graphics.Transforms; -using osu.Framework.Graphics.UserInterface; using OpenTK; using OpenTK.Graphics; using osu.Framework.Extensions.Color4Extensions; +using osu.Framework.Graphics.Transforms; +using osu.Framework.Graphics.UserInterface; namespace osu.Game.Graphics.UserInterface { diff --git a/osu.Game/Screens/Select/FilterControl.cs b/osu.Game/Screens/Select/FilterControl.cs index 06e909924a..3ab65f3d42 100644 --- a/osu.Game/Screens/Select/FilterControl.cs +++ b/osu.Game/Screens/Select/FilterControl.cs @@ -110,7 +110,7 @@ namespace osu.Game.Screens.Select Anchor = Anchor.TopLeft, Position = new Vector2(0, 23) }, - groupTabs = new FilterTabControl(GroupMode.All, GroupMode.RecentlyPlayed) + groupTabs = new FilterTabControl { Width = 230, AutoSort = true @@ -141,6 +141,8 @@ namespace osu.Game.Screens.Select } } }; + groupTabs.PinTab(GroupMode.All); + groupTabs.PinTab(GroupMode.RecentlyPlayed); } [BackgroundDependencyLoader] diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index ca8b353c57..132f737d22 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -109,10 +109,10 @@ namespace osu.Game.Screens.Select Anchor = Anchor.CentreRight, Origin = Anchor.CentreRight, }); - Add(filter = new FilterControl + Add(filter = new FilterControl(filter_height) { RelativeSizeAxes = Axes.X, - Height = filter_height, + AutoSizeAxes = Axes.Y, FilterChanged = () => filterChanged(), Exit = Exit, }); diff --git a/osu.Game/Screens/Select/Tab/FilterTabControl.cs b/osu.Game/Screens/Select/Tab/FilterTabControl.cs index f36c088cf3..5dd0c24ba1 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabControl.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabControl.cs @@ -11,11 +11,7 @@ namespace osu.Game.Screens.Select.Tab protected override TabItem CreateTabItem(T value) => new FilterTabItem { Value = value }; - public FilterTabControl(float offset, params T[] pinned) : base(offset, pinned) - { - } - - public FilterTabControl(params T[] pinned) : base(pinned) + public FilterTabControl(float offset = 0) : base(offset) { } } diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs index 3c77b12010..8ba4d9c402 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownHeader.cs @@ -3,23 +3,18 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Primitives; -using osu.Framework.Graphics.UserInterface; +using osu.Framework.Graphics.UserInterface.Tab; using osu.Game.Graphics; namespace osu.Game.Screens.Select.Tab { - public class FilterTabDropDownHeader : DropDownHeader + public class FilterTabDropDownHeader : TabDropDownHeader { protected override string Label { get; set; } private TextAwesome ellipses; public FilterTabDropDownHeader() { - Background.Hide(); // don't need a background - RelativeSizeAxes = Axes.None; - AutoSizeAxes = Axes.Both; - Foreground.RelativeSizeAxes = Axes.None; - Foreground.AutoSizeAxes = Axes.Both; Foreground.Children = new Drawable[] { ellipses = new TextAwesome diff --git a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs index 0ac2ff07d3..df96711e0c 100644 --- a/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs +++ b/osu.Game/Screens/Select/Tab/FilterTabDropDownMenu.cs @@ -25,8 +25,7 @@ namespace osu.Game.Screens.Select.Tab protected override DropDownHeader CreateHeader() => new FilterTabDropDownHeader(); - protected override IEnumerable> GetDropDownItems(IEnumerable> values) - => values.Select(v => new FilterTabDropDownMenuItem(v.Key, v.Value)); + protected override DropDownMenuItem CreateDropDownItem(string key, T value) => new FilterTabDropDownMenuItem(key, value); public FilterTabDropDownMenu() {