1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 01:33:21 +08:00
osu-lazer/osu.Game/Graphics/UserInterface/ToggleMenuItem.cs

40 lines
1.5 KiB
C#
Raw Normal View History

// 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
using System;
using osu.Framework.Graphics.Sprites;
namespace osu.Game.Graphics.UserInterface
{
2019-11-08 12:14:23 +08:00
/// <summary>
/// An <see cref="OsuMenuItem"/> which displays an enabled or disabled state.
/// </summary>
public class ToggleMenuItem : StatefulMenuItem<bool>
{
2019-11-08 12:14:23 +08: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>
public ToggleMenuItem(string text, MenuItemType type = MenuItemType.Standard)
: this(text, type, null)
{
}
2019-11-08 12:14:23 +08: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>
public ToggleMenuItem(string text, MenuItemType type, Action<bool> action)
2019-11-08 11:55:22 +08:00
: base(text, value => !value, type, action)
{
}
2022-06-24 13:48:43 +08:00
public override IconUsage? GetIconForState(bool state) => state ? FontAwesome.Solid.Check : null;
}
}