mirror of
https://github.com/ppy/osu
synced 2025-02-09 14:47:33 +00:00
Updated TabControl Usage
This commit is contained in:
parent
ee3d3b682f
commit
755fb260db
@ -1,19 +1,11 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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>(GroupMode.All, GroupMode.RecentlyPlayed)
|
||||
filter = new FilterTabControl<GroupMode>
|
||||
{
|
||||
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}");
|
||||
|
@ -1,11 +1,11 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ namespace osu.Game.Screens.Select
|
||||
Anchor = Anchor.TopLeft,
|
||||
Position = new Vector2(0, 23)
|
||||
},
|
||||
groupTabs = new FilterTabControl<GroupMode>(GroupMode.All, GroupMode.RecentlyPlayed)
|
||||
groupTabs = new FilterTabControl<GroupMode>
|
||||
{
|
||||
Width = 230,
|
||||
AutoSort = true
|
||||
@ -141,6 +141,8 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
};
|
||||
groupTabs.PinTab(GroupMode.All);
|
||||
groupTabs.PinTab(GroupMode.RecentlyPlayed);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
@ -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,
|
||||
});
|
||||
|
@ -11,11 +11,7 @@ namespace osu.Game.Screens.Select.Tab
|
||||
|
||||
protected override TabItem<T> CreateTabItem(T value) => new FilterTabItem<T> { 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)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -25,8 +25,7 @@ namespace osu.Game.Screens.Select.Tab
|
||||
|
||||
protected override DropDownHeader CreateHeader() => new FilterTabDropDownHeader();
|
||||
|
||||
protected override IEnumerable<DropDownMenuItem<T>> GetDropDownItems(IEnumerable<KeyValuePair<string, T>> values)
|
||||
=> values.Select(v => new FilterTabDropDownMenuItem<T>(v.Key, v.Value));
|
||||
protected override DropDownMenuItem<T> CreateDropDownItem(string key, T value) => new FilterTabDropDownMenuItem<T>(key, value);
|
||||
|
||||
public FilterTabDropDownMenu()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user