mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Add ternary toggle buttons to editor toolbox selection
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
// 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;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Components.TernaryButtons
|
||||
{
|
||||
public class TernaryButton
|
||||
{
|
||||
public readonly Bindable<TernaryState> Bindable;
|
||||
|
||||
public readonly string Description;
|
||||
|
||||
/// <summary>
|
||||
/// A function which creates a drawable icon to represent this item. If null, a sane default should be used.
|
||||
/// </summary>
|
||||
public readonly Func<Drawable> CreateIcon;
|
||||
|
||||
public TernaryButton(Bindable<TernaryState> bindable, string description, Func<Drawable> createIcon = null)
|
||||
{
|
||||
Bindable = bindable;
|
||||
Description = description;
|
||||
CreateIcon = createIcon;
|
||||
}
|
||||
|
||||
public void Toggle()
|
||||
{
|
||||
switch (Bindable.Value)
|
||||
{
|
||||
case TernaryState.False:
|
||||
case TernaryState.Indeterminate:
|
||||
Bindable.Value = TernaryState.True;
|
||||
break;
|
||||
|
||||
case TernaryState.True:
|
||||
Bindable.Value = TernaryState.False;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user