1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-12 02:27:25 +08:00
osu-lazer/osu.Game/Screens/Multi/Components/DisableableTabControl.cs

45 lines
1.1 KiB
C#
Raw Normal View History

2018-12-05 16:01:14 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
namespace osu.Game.Screens.Multi.Components
{
public abstract class DisableableTabControl<T> : TabControl<T>
{
public IEnumerable<T> DisabledItems
{
set
{
foreach (var item in value)
(TabMap[item] as DisableableTabItem<T>)?.Disable();
}
}
protected abstract class DisableableTabItem<T> : TabItem<T>
{
protected DisableableTabItem(T value)
: base(value)
{
}
private bool isDisabled;
public void Disable()
{
Alpha = 0.2f;
isDisabled = true;
}
protected override bool OnClick(ClickEvent e)
{
if (isDisabled)
return true;
return base.OnClick(e);
}
}
}
}