1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-22 02:22:57 +08:00

Updated TabControl Usage

This commit is contained in:
Kelvin 2017-03-14 19:46:13 -07:00
parent ee3d3b682f
commit 755fb260db
7 changed files with 16 additions and 29 deletions

View File

@ -1,19 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu-framework/master/LICENCE // 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.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface.Tab;
using osu.Framework.Screens.Testing; using osu.Framework.Screens.Testing;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Screens.Select.Filter; using osu.Game.Screens.Select.Filter;
using osu.Game.Screens.Select.Tab; using osu.Game.Screens.Select.Tab;
@ -37,7 +29,7 @@ namespace osu.Desktop.VisualTests.Tests
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
filter = new FilterTabControl<GroupMode>(GroupMode.All, GroupMode.RecentlyPlayed) filter = new FilterTabControl<GroupMode>
{ {
Width = 229, Width = 229,
AutoSort = true AutoSort = true
@ -49,7 +41,10 @@ namespace osu.Desktop.VisualTests.Tests
} }
} }
}); });
filter.PinTab(GroupMode.All);
filter.PinTab(GroupMode.RecentlyPlayed);
filter.ValueChanged += (sender, mode) => filter.ValueChanged += (sender, mode) =>
{ {
Debug.WriteLine($"Selected {mode}"); Debug.WriteLine($"Selected {mode}");

View File

@ -1,11 +1,11 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // 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;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics.Transforms;
using osu.Framework.Graphics.UserInterface;
namespace osu.Game.Graphics.UserInterface namespace osu.Game.Graphics.UserInterface
{ {

View File

@ -110,7 +110,7 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.TopLeft, Anchor = Anchor.TopLeft,
Position = new Vector2(0, 23) Position = new Vector2(0, 23)
}, },
groupTabs = new FilterTabControl<GroupMode>(GroupMode.All, GroupMode.RecentlyPlayed) groupTabs = new FilterTabControl<GroupMode>
{ {
Width = 230, Width = 230,
AutoSort = true AutoSort = true
@ -141,6 +141,8 @@ namespace osu.Game.Screens.Select
} }
} }
}; };
groupTabs.PinTab(GroupMode.All);
groupTabs.PinTab(GroupMode.RecentlyPlayed);
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]

View File

@ -109,10 +109,10 @@ namespace osu.Game.Screens.Select
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
}); });
Add(filter = new FilterControl Add(filter = new FilterControl(filter_height)
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Height = filter_height, AutoSizeAxes = Axes.Y,
FilterChanged = () => filterChanged(), FilterChanged = () => filterChanged(),
Exit = Exit, Exit = Exit,
}); });

View File

@ -11,11 +11,7 @@ namespace osu.Game.Screens.Select.Tab
protected override TabItem<T> CreateTabItem(T value) => new FilterTabItem<T> { Value = value }; protected override TabItem<T> CreateTabItem(T value) => new FilterTabItem<T> { Value = value };
public FilterTabControl(float offset, params T[] pinned) : base(offset, pinned) public FilterTabControl(float offset = 0) : base(offset)
{
}
public FilterTabControl(params T[] pinned) : base(pinned)
{ {
} }
} }

View File

@ -3,23 +3,18 @@
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface.Tab;
using osu.Game.Graphics; using osu.Game.Graphics;
namespace osu.Game.Screens.Select.Tab namespace osu.Game.Screens.Select.Tab
{ {
public class FilterTabDropDownHeader : DropDownHeader public class FilterTabDropDownHeader : TabDropDownHeader
{ {
protected override string Label { get; set; } protected override string Label { get; set; }
private TextAwesome ellipses; private TextAwesome ellipses;
public FilterTabDropDownHeader() { 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[] Foreground.Children = new Drawable[]
{ {
ellipses = new TextAwesome ellipses = new TextAwesome

View File

@ -25,8 +25,7 @@ namespace osu.Game.Screens.Select.Tab
protected override DropDownHeader CreateHeader() => new FilterTabDropDownHeader(); protected override DropDownHeader CreateHeader() => new FilterTabDropDownHeader();
protected override IEnumerable<DropDownMenuItem<T>> GetDropDownItems(IEnumerable<KeyValuePair<string, T>> values) protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) => new FilterTabDropDownMenuItem<T>(key, value);
=> values.Select(v => new FilterTabDropDownMenuItem<T>(v.Key, v.Value));
public FilterTabDropDownMenu() public FilterTabDropDownMenu()
{ {