2019-11-08 11:47:42 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-11-08 11:55:22 +08:00
|
|
|
using System;
|
2019-11-08 11:47:42 +08:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
{
|
2019-11-08 12:14:23 +08:00
|
|
|
/// <summary>
|
|
|
|
/// An <see cref="OsuMenuItem"/> with three possible states.
|
|
|
|
/// </summary>
|
2021-05-20 18:34:53 +08:00
|
|
|
public abstract class TernaryStateMenuItem : StatefulMenuItem<TernaryState>
|
2019-11-08 11:47:42 +08:00
|
|
|
{
|
2019-11-08 12:14:23 +08:00
|
|
|
/// <summary>
|
2019-11-12 09:18:25 +08:00
|
|
|
/// Creates a new <see cref="TernaryStateMenuItem"/>.
|
2019-11-08 12:14:23 +08:00
|
|
|
/// </summary>
|
|
|
|
/// <param name="text">The text to display.</param>
|
2021-05-20 18:34:53 +08:00
|
|
|
/// <param name="nextStateFunction">A function to inform what the next state should be when this item is clicked.</param>
|
2019-11-12 09:18:25 +08:00
|
|
|
/// <param name="type">The type of action which this <see cref="TernaryStateMenuItem"/> performs.</param>
|
|
|
|
/// <param name="action">A delegate to be invoked when this <see cref="TernaryStateMenuItem"/> is pressed.</param>
|
2021-05-20 18:34:53 +08:00
|
|
|
protected TernaryStateMenuItem(string text, Func<TernaryState, TernaryState> nextStateFunction, MenuItemType type = MenuItemType.Standard, Action<TernaryState> action = null)
|
|
|
|
: base(text, nextStateFunction, type, action)
|
2019-11-08 11:47:42 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-11-11 17:56:18 +08:00
|
|
|
public override IconUsage? GetIconForState(TernaryState state)
|
2019-11-08 11:47:42 +08:00
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
2019-11-11 17:56:18 +08:00
|
|
|
case TernaryState.Indeterminate:
|
|
|
|
return FontAwesome.Solid.DotCircle;
|
2019-11-08 11:47:42 +08:00
|
|
|
|
2019-11-11 17:56:18 +08:00
|
|
|
case TernaryState.True:
|
2019-11-08 11:47:42 +08:00
|
|
|
return FontAwesome.Solid.Check;
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|