osu/osu.Game/Graphics/UserInterface/OsuTabControl.cs

25 lines
881 B
C#
Raw Normal View History

2017-03-05 04:07:47 +00:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-03-15 03:19:41 +00:00
using System;
2017-03-05 04:07:47 +00:00
using osu.Framework.Graphics.UserInterface.Tab;
2017-03-16 00:11:50 +00:00
namespace osu.Game.Graphics.UserInterface
2017-03-05 04:07:47 +00:00
{
2017-03-16 00:11:50 +00:00
public class OsuTabControl<T> : TabControl<T>
2017-03-05 04:07:47 +00:00
{
2017-03-16 00:11:50 +00:00
protected override TabDropDownMenu<T> CreateDropDownMenu() => new OsuTabDropDownMenu<T>();
2017-03-05 04:07:47 +00:00
2017-03-16 00:11:50 +00:00
protected override TabItem<T> CreateTabItem(T value) => new OsuTabItem<T> { Value = value };
2017-03-08 09:19:00 +00:00
2017-03-16 00:11:50 +00:00
public OsuTabControl(float offset = 0) : base(offset)
2017-03-08 09:19:00 +00:00
{
2017-03-15 03:19:41 +00:00
if (!typeof(T).IsEnum)
2017-03-16 00:11:50 +00:00
throw new InvalidOperationException("OsuTabControl only supports enums as the generic type argument");
2017-03-15 03:19:41 +00:00
foreach (var val in (T[])Enum.GetValues(typeof(T)))
AddTab(val);
2017-03-08 09:19:00 +00:00
}
2017-03-05 04:07:47 +00:00
}
}