1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00
osu-lazer/osu.Game/Overlays/TabControlOverlayHeader.cs

75 lines
2.4 KiB
C#
Raw Normal View History

// 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.
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
namespace osu.Game.Overlays
{
public abstract class TabControlOverlayHeader<T> : ControllableOverlayHeader<T>
{
2019-12-31 23:12:03 +08:00
protected OverlayHeaderTabControl TabControl;
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);
}
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;
if (typeof(T).IsEnum)
{
foreach (var val in (T[])Enum.GetValues(typeof(T)))
AddItem(val);
}
2020-01-03 14:01:42 +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
{
public OverlayHeaderTabItem(T value)
2020-01-03 14:01:42 +08:00
: base(value)
{
Text.Text = value.ToString().ToLowerInvariant();
2020-01-03 14:01:42 +08:00
Text.Font = OsuFont.GetFont(size: 14);
Bar.ExpandedSize = 5;
}
}
}
}
}