mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 22:12:53 +08: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]
|
[Test]
|
||||||
public void TestVolumeControlViaMusicButton()
|
public void TestVolumeControlViaMusicButtonScroll()
|
||||||
{
|
{
|
||||||
AddStep("hover toolbar music button", () => InputManager.MoveMouseTo(this.ChildrenOfType<ToolbarMusicButton>().Single()));
|
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);
|
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 class TestToolbar : Toolbar
|
||||||
{
|
{
|
||||||
public new Bindable<OverlayActivation> OverlayActivationMode => base.OverlayActivationMode as Bindable<OverlayActivation>;
|
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.Framework.Threading;
|
||||||
using osu.Game.Input.Bindings;
|
using osu.Game.Input.Bindings;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
using osuTK.Input;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Toolbar
|
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);
|
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)
|
protected override bool OnScroll(ScrollEvent e)
|
||||||
{
|
{
|
||||||
focusForAdjustment();
|
focusForAdjustment();
|
||||||
|
Loading…
Reference in New Issue
Block a user