diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 20385a7dae..89188b29d7 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -20,16 +20,28 @@ namespace osu.Game.Graphics.UserInterface { public class OsuTabControl : TabControl { + private readonly Box strip; + protected override Dropdown CreateDropdown() => new OsuTabDropdown(); protected override TabItem 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; public OsuTabControl() { 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) foreach (var val in (T[])Enum.GetValues(typeof(T))) 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 { Direction = FillDirection.Full, @@ -65,6 +83,15 @@ namespace osu.Game.Graphics.UserInterface 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, IHasAccentColour { protected readonly SpriteText Text;