// 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 object 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(object item, Action action, Func createIcon = null) { Item = item; CreateIcon = createIcon; this.action = action; Selected = new BindableBool(); } public RadioButton(string item) : this(item, null) { Item = item; action = null; } /// /// Selects this . /// public void Select() { if (!Selected.Value) { Selected.Value = true; action?.Invoke(); } } /// /// Deselects this . /// public void Deselect() => Selected.Value = false; } }