// 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; namespace osu.Game.Screens.Edit.Components.RadioButtons { public class RadioButton { /// /// Whether this is selected. /// public readonly BindableBool Selected; /// /// The item related to this button. /// public string Item; /// /// 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 item, Action action, Func createIcon = null) { Item = item; 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; } }