2020-11-03 07:01:14 +00:00
|
|
|
// 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.Collections.Generic;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics.UserInterface;
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Edit
|
|
|
|
{
|
2021-04-21 09:05:26 +00:00
|
|
|
internal class WaveformOpacityMenuItem : MenuItem
|
2020-11-03 07:01:14 +00:00
|
|
|
{
|
|
|
|
private readonly Bindable<float> waveformOpacity;
|
|
|
|
|
|
|
|
private readonly Dictionary<float, ToggleMenuItem> menuItemLookup = new Dictionary<float, ToggleMenuItem>();
|
|
|
|
|
2021-04-21 09:05:26 +00:00
|
|
|
public WaveformOpacityMenuItem(Bindable<float> waveformOpacity)
|
2020-11-03 07:01:14 +00:00
|
|
|
: base("Waveform opacity")
|
|
|
|
{
|
|
|
|
Items = new[]
|
|
|
|
{
|
|
|
|
createMenuItem(0.25f),
|
|
|
|
createMenuItem(0.5f),
|
|
|
|
createMenuItem(0.75f),
|
|
|
|
createMenuItem(1f),
|
|
|
|
};
|
|
|
|
|
2021-04-21 09:05:26 +00:00
|
|
|
this.waveformOpacity = waveformOpacity;
|
2020-11-03 07:01:14 +00:00
|
|
|
waveformOpacity.BindValueChanged(opacity =>
|
|
|
|
{
|
|
|
|
foreach (var kvp in menuItemLookup)
|
|
|
|
kvp.Value.State.Value = kvp.Key == opacity.NewValue;
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
private ToggleMenuItem createMenuItem(float opacity)
|
|
|
|
{
|
|
|
|
var item = new ToggleMenuItem($"{opacity * 100}%", MenuItemType.Standard, _ => updateOpacity(opacity));
|
|
|
|
menuItemLookup[opacity] = item;
|
|
|
|
return item;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updateOpacity(float opacity) => waveformOpacity.Value = opacity;
|
|
|
|
}
|
|
|
|
}
|