2019-11-07 13:26:35 +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.
|
|
|
|
|
|
|
|
using System;
|
2019-11-08 02:15:03 +00:00
|
|
|
using osu.Framework.Graphics.Sprites;
|
2019-11-07 13:26:35 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Graphics.UserInterface
|
|
|
|
{
|
2019-11-08 04:14:23 +00:00
|
|
|
/// <summary>
|
|
|
|
/// An <see cref="OsuMenuItem"/> which displays an enabled or disabled state.
|
|
|
|
/// </summary>
|
2019-11-08 02:15:03 +00:00
|
|
|
public class ToggleMenuItem : StatefulMenuItem<bool>
|
2019-11-07 13:26:35 +00:00
|
|
|
{
|
2019-11-08 04:14:23 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new <see cref="ToggleMenuItem"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="text">The text to display.</param>
|
|
|
|
/// <param name="type">The type of action which this <see cref="ToggleMenuItem"/> performs.</param>
|
2019-11-07 13:26:35 +00:00
|
|
|
public ToggleMenuItem(string text, MenuItemType type = MenuItemType.Standard)
|
|
|
|
: this(text, type, null)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-11-08 04:14:23 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Creates a new <see cref="ToggleMenuItem"/>.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="text">The text to display.</param>
|
|
|
|
/// <param name="type">The type of action which this <see cref="ToggleMenuItem"/> performs.</param>
|
|
|
|
/// <param name="action">A delegate to be invoked when this <see cref="ToggleMenuItem"/> is pressed.</param>
|
2019-11-07 13:26:35 +00:00
|
|
|
public ToggleMenuItem(string text, MenuItemType type, Action<bool> action)
|
2019-11-08 03:55:22 +00:00
|
|
|
: base(text, value => !value, type, action)
|
2019-11-07 13:26:35 +00:00
|
|
|
{
|
|
|
|
}
|
2019-11-08 02:15:03 +00:00
|
|
|
|
|
|
|
public override IconUsage? GetIconForState(bool state) => state ? (IconUsage?)FontAwesome.Solid.Check : null;
|
2019-11-07 13:26:35 +00:00
|
|
|
}
|
|
|
|
}
|