mirror of
https://github.com/osukey/osukey.git
synced 2025-05-05 21:57:24 +09:00
Add optional strip to OsuTabControl.
This commit is contained in:
parent
306ff09792
commit
f43b009b96
@ -20,16 +20,28 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
{
|
{
|
||||||
public class OsuTabControl<T> : TabControl<T>
|
public class OsuTabControl<T> : TabControl<T>
|
||||||
{
|
{
|
||||||
|
private readonly Box strip;
|
||||||
|
|
||||||
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
|
protected override Dropdown<T> CreateDropdown() => new OsuTabDropdown();
|
||||||
|
|
||||||
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
|
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem(value);
|
||||||
|
|
||||||
|
protected virtual float StripWidth() => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
|
||||||
|
|
||||||
private static bool isEnumType => typeof(T).IsEnum;
|
private static bool isEnumType => typeof(T).IsEnum;
|
||||||
|
|
||||||
public OsuTabControl()
|
public OsuTabControl()
|
||||||
{
|
{
|
||||||
TabContainer.Spacing = new Vector2(10f, 0f);
|
TabContainer.Spacing = new Vector2(10f, 0f);
|
||||||
|
|
||||||
|
Add(strip = new Box
|
||||||
|
{
|
||||||
|
Anchor = Anchor.BottomLeft,
|
||||||
|
Origin = Anchor.BottomLeft,
|
||||||
|
Height = 1,
|
||||||
|
Colour = Color4.White.Opacity(0),
|
||||||
|
});
|
||||||
|
|
||||||
if (isEnumType)
|
if (isEnumType)
|
||||||
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
foreach (var val in (T[])Enum.GetValues(typeof(T)))
|
||||||
AddItem(val);
|
AddItem(val);
|
||||||
@ -57,6 +69,12 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Color4 StripColour
|
||||||
|
{
|
||||||
|
get => strip.Colour;
|
||||||
|
set => strip.Colour = value;
|
||||||
|
}
|
||||||
|
|
||||||
protected override TabFillFlowContainer CreateTabFlow() => new OsuTabFillFlowContainer
|
protected override TabFillFlowContainer CreateTabFlow() => new OsuTabFillFlowContainer
|
||||||
{
|
{
|
||||||
Direction = FillDirection.Full,
|
Direction = FillDirection.Full,
|
||||||
@ -65,6 +83,15 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
Masking = true
|
Masking = true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected override void UpdateAfterChildren()
|
||||||
|
{
|
||||||
|
base.UpdateAfterChildren();
|
||||||
|
|
||||||
|
// dont bother calculating if the strip is invisible
|
||||||
|
if (strip.Colour.MaxAlpha > 0)
|
||||||
|
strip.ResizeWidthTo(StripWidth(), 500, Easing.OutQuint);
|
||||||
|
}
|
||||||
|
|
||||||
public class OsuTabItem : TabItem<T>, IHasAccentColour
|
public class OsuTabItem : TabItem<T>, IHasAccentColour
|
||||||
{
|
{
|
||||||
protected readonly SpriteText Text;
|
protected readonly SpriteText Text;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user