// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using System; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Localisation; namespace osu.Game.Screens.Edit.Components.RadioButtons { public class RadioButton { /// /// Whether this is selected. /// Disable this bindable to disable the button. /// public readonly BindableBool Selected; /// /// The item related to this button. /// public string Label; /// /// A function which creates a drawable icon to represent this item. If null, a sane default should be used. /// public readonly Func? CreateIcon; private readonly Action? action; public RadioButton(string label, Action? action, Func? createIcon = null) { Label = label; CreateIcon = createIcon; this.action = action; Selected = new BindableBool(); } /// /// Selects this . /// public void Select() { if (!Selected.Value) { Selected.Value = true; action?.Invoke(); } } /// /// Deselects this . /// public void Deselect() => Selected.Value = false; // Tooltip text that will be shown when hovered over public LocalisableString TooltipText { get; set; } = string.Empty; } }