1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 09:47:22 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/Components/DisableableTabControl.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

40 lines
1.1 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-12-05 17:01:14 +09:00
2022-06-17 16:37:17 +09:00
#nullable disable
2019-02-21 19:04:31 +09:00
using osu.Framework.Bindables;
2018-12-05 17:01:14 +09:00
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
namespace osu.Game.Screens.OnlinePlay.Components
2018-12-05 17:01:14 +09:00
{
public abstract class DisableableTabControl<T> : TabControl<T>
{
public readonly BindableBool Enabled = new BindableBool(true);
2018-12-10 16:50:00 +09:00
protected override void AddTabItem(TabItem<T> tab, bool addToDropdown = true)
2018-12-05 17:01:14 +09:00
{
2019-04-25 17:36:17 +09:00
if (tab is DisableableTabItem disableable)
2018-12-22 15:00:35 +09:00
disableable.Enabled.BindTo(Enabled);
2018-12-10 16:50:00 +09:00
base.AddTabItem(tab, addToDropdown);
2018-12-05 17:01:14 +09:00
}
2019-04-25 17:36:17 +09:00
protected abstract class DisableableTabItem : TabItem<T>
2018-12-05 17:01:14 +09:00
{
protected DisableableTabItem(T value)
: base(value)
{
}
protected override bool OnClick(ClickEvent e)
{
2019-02-21 18:56:34 +09:00
if (!Enabled.Value)
2018-12-05 17:01:14 +09:00
return true;
2019-02-28 13:31:40 +09:00
2018-12-05 17:01:14 +09:00
return base.OnClick(e);
}
}
}
}