1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Add ability to not add all the items if enum

This commit is contained in:
Andrei Zavatski 2019-08-12 12:33:01 +03:00
parent 2bbac7cdfc
commit 144d41f143

View File

@ -31,6 +31,8 @@ namespace osu.Game.Graphics.UserInterface
protected virtual float StripWidth() => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X; protected virtual float StripWidth() => TabContainer.Children.Sum(c => c.IsPresent ? c.DrawWidth + TabContainer.Spacing.X : 0) - TabContainer.Spacing.X;
protected virtual float StripHeight() => 1; protected virtual float StripHeight() => 1;
protected virtual bool AddAllItemsIfEnum => true;
private static bool isEnumType => typeof(T).IsEnum; private static bool isEnumType => typeof(T).IsEnum;
public OsuTabControl() public OsuTabControl()
@ -45,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface
Colour = Color4.White.Opacity(0), Colour = Color4.White.Opacity(0),
}); });
if (isEnumType) if (isEnumType && AddAllItemsIfEnum)
foreach (var val in (T[])Enum.GetValues(typeof(T))) foreach (var val in (T[])Enum.GetValues(typeof(T)))
AddItem(val); AddItem(val);
} }