osu/osu.Game/Graphics/UserInterface/TernaryStateMenuItem.cs

41 lines
1.6 KiB
C#
Raw Normal View History

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