2019-01-24 16:43:03 +08:00
|
|
|
// 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 16:01:14 +08:00
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-02-21 18:04:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-12-05 16:01:14 +08:00
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
2020-12-25 23:50:00 +08:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2018-12-05 16:01:14 +08:00
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public abstract partial class DisableableTabControl<T> : TabControl<T>
|
2018-12-05 16:01:14 +08:00
|
|
|
{
|
2021-07-28 14:30:57 +08:00
|
|
|
public readonly BindableBool Enabled = new BindableBool(true);
|
2018-12-10 15:50:00 +08:00
|
|
|
|
|
|
|
protected override void AddTabItem(TabItem<T> tab, bool addToDropdown = true)
|
2018-12-05 16:01:14 +08:00
|
|
|
{
|
2019-04-25 16:36:17 +08:00
|
|
|
if (tab is DisableableTabItem disableable)
|
2018-12-22 14:00:35 +08:00
|
|
|
disableable.Enabled.BindTo(Enabled);
|
2018-12-10 15:50:00 +08:00
|
|
|
base.AddTabItem(tab, addToDropdown);
|
2018-12-05 16:01:14 +08:00
|
|
|
}
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
protected abstract partial class DisableableTabItem : TabItem<T>
|
2018-12-05 16:01:14 +08:00
|
|
|
{
|
|
|
|
protected DisableableTabItem(T value)
|
|
|
|
: base(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override bool OnClick(ClickEvent e)
|
|
|
|
{
|
2019-02-21 17:56:34 +08:00
|
|
|
if (!Enabled.Value)
|
2018-12-05 16:01:14 +08:00
|
|
|
return true;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
2018-12-05 16:01:14 +08:00
|
|
|
return base.OnClick(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|