mirror of
https://github.com/ppy/osu
synced 2025-02-08 06:07:14 +00:00
Add keyboard adjustment support
This commit is contained in:
parent
3df9d7c9e1
commit
873806c2ea
@ -148,7 +148,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVolumeControlViaMusicButton()
|
||||
public void TestVolumeControlViaMusicButtonScroll()
|
||||
{
|
||||
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
|
||||
|
||||
@ -160,6 +160,19 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
AddAssert("volume raised up", () => Audio.Volume.Value == 1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestVolumeControlViaMusicButtonArrowKeys()
|
||||
{
|
||||
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
|
||||
|
||||
AddStep("reset volume", () => Audio.Volume.Value = 1);
|
||||
|
||||
AddRepeatStep("arrow down", () => InputManager.Key(Key.Down), 5);
|
||||
AddAssert("volume lowered down", () => Audio.Volume.Value < 1);
|
||||
AddRepeatStep("arrow up", () => InputManager.Key(Key.Up), 5);
|
||||
AddAssert("volume raised up", () => Audio.Volume.Value == 1);
|
||||
}
|
||||
|
||||
public class TestToolbar : Toolbar
|
||||
{
|
||||
public new Bindable<OverlayActivation> OverlayActivationMode => base.OverlayActivationMode as Bindable<OverlayActivation>;
|
||||
|
@ -13,6 +13,7 @@ using osu.Framework.Input.Events;
|
||||
using osu.Framework.Threading;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osuTK.Graphics;
|
||||
using osuTK.Input;
|
||||
|
||||
namespace osu.Game.Overlays.Toolbar
|
||||
{
|
||||
@ -78,6 +79,24 @@ namespace osu.Game.Overlays.Toolbar
|
||||
globalVolume.BindValueChanged(v => volumeBar.ResizeHeightTo((float)v.NewValue, 200, Easing.OutQuint), true);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(KeyDownEvent e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Up:
|
||||
focusForAdjustment();
|
||||
volume?.Adjust(GlobalAction.IncreaseVolume);
|
||||
return true;
|
||||
|
||||
case Key.Down:
|
||||
focusForAdjustment();
|
||||
volume?.Adjust(GlobalAction.IncreaseVolume, -1);
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnKeyDown(e);
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
focusForAdjustment();
|
||||
|
Loading…
Reference in New Issue
Block a user