1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 01:27:35 +08:00
osu-lazer/osu.Game/Graphics/UserInterface/ThreeStateMenuItem.cs

60 lines
1.5 KiB
C#
Raw Normal View History

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.
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
{
public class ThreeStateMenuItem : StatefulMenuItem<ThreeStates>
{
public ThreeStateMenuItem(string text, MenuItemType type = MenuItemType.Standard)
2019-11-08 11:55:22 +08:00
: this(text, type, null)
{
}
public ThreeStateMenuItem(string text, MenuItemType type, Action<ThreeStates> action)
: base(text, getNextState, type, action)
2019-11-08 11:47:42 +08:00
{
}
public override IconUsage? GetIconForState(ThreeStates state)
{
switch (state)
{
case ThreeStates.Indeterminate:
return FontAwesome.Regular.Circle;
case ThreeStates.Enabled:
return FontAwesome.Solid.Check;
}
return null;
}
private static ThreeStates getNextState(ThreeStates state)
{
switch (state)
{
case ThreeStates.Disabled:
return ThreeStates.Enabled;
case ThreeStates.Indeterminate:
return ThreeStates.Enabled;
case ThreeStates.Enabled:
return ThreeStates.Disabled;
}
return ThreeStates.Disabled;
}
}
public enum ThreeStates
{
Disabled,
Indeterminate,
Enabled
}
}