2019-12-28 09:57:41 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2020-01-08 05:41:52 +08:00
|
|
|
|
using System;
|
2020-01-16 03:41:22 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-01-03 14:01:42 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2019-12-31 23:12:03 +08:00
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
2020-01-03 14:01:42 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osuTK;
|
2019-12-31 23:12:03 +08:00
|
|
|
|
|
2019-12-28 09:57:41 +08:00
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2020-01-08 05:41:52 +08:00
|
|
|
|
public abstract class TabControlOverlayHeader<T> : ControllableOverlayHeader<T>
|
2019-12-28 09:57:41 +08:00
|
|
|
|
{
|
2019-12-31 23:12:03 +08:00
|
|
|
|
protected OverlayHeaderTabControl TabControl;
|
|
|
|
|
|
2020-01-08 05:41:52 +08:00
|
|
|
|
protected override TabControl<T> CreateTabControl() => TabControl = new OverlayHeaderTabControl();
|
2020-01-03 14:01:42 +08:00
|
|
|
|
|
2020-01-16 03:41:22 +08:00
|
|
|
|
protected TabControlOverlayHeader(OverlayColourScheme colourScheme)
|
|
|
|
|
: base(colourScheme)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
TabControl.AccentColour = colours.ForOverlayElement(ColourScheme, 1, 0.75f);
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 05:41:52 +08:00
|
|
|
|
public class OverlayHeaderTabControl : OverlayTabControl<T>
|
2020-01-03 14:01:42 +08:00
|
|
|
|
{
|
|
|
|
|
public OverlayHeaderTabControl()
|
|
|
|
|
{
|
|
|
|
|
BarHeight = 1;
|
|
|
|
|
RelativeSizeAxes = Axes.None;
|
|
|
|
|
AutoSizeAxes = Axes.X;
|
|
|
|
|
Anchor = Anchor.BottomLeft;
|
|
|
|
|
Origin = Anchor.BottomLeft;
|
|
|
|
|
Height = 35;
|
2020-01-08 05:41:52 +08:00
|
|
|
|
|
|
|
|
|
if (typeof(T).IsEnum)
|
|
|
|
|
{
|
|
|
|
|
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
|
|
|
|
AddItem(val);
|
|
|
|
|
}
|
2020-01-03 14:01:42 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-01-08 05:41:52 +08:00
|
|
|
|
protected override TabItem<T> CreateTabItem(T value) => new OverlayHeaderTabItem(value)
|
2020-01-03 14:01:42 +08:00
|
|
|
|
{
|
|
|
|
|
AccentColour = AccentColour,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
protected override TabFillFlowContainer CreateTabFlow() => new TabFillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Spacing = new Vector2(5, 0),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private class OverlayHeaderTabItem : OverlayTabItem
|
|
|
|
|
{
|
2020-01-08 05:41:52 +08:00
|
|
|
|
public OverlayHeaderTabItem(T value)
|
2020-01-03 14:01:42 +08:00
|
|
|
|
: base(value)
|
|
|
|
|
{
|
2020-01-08 05:41:52 +08:00
|
|
|
|
Text.Text = value.ToString().ToLowerInvariant();
|
2020-01-03 14:01:42 +08:00
|
|
|
|
Text.Font = OsuFont.GetFont(size: 14);
|
|
|
|
|
Bar.ExpandedSize = 5;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-12-28 09:57:41 +08:00
|
|
|
|
}
|
|
|
|
|
}
|