1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 12:23:21 +08:00

Make toolbar handle mouse events instead

This commit is contained in:
Joseph Madamba 2021-08-30 20:53:43 -07:00
parent 7bb2269eba
commit 570d36fde7
3 changed files with 7 additions and 7 deletions

View File

@ -345,7 +345,9 @@ namespace osu.Game.Tests.Visual.Navigation
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));
AddStep("move cursor to toolbar", () => InputManager.MoveMouseTo(Game.Toolbar.ScreenSpaceDrawQuad.Centre));
AddStep("release left mouse button", () => InputManager.ReleaseButton(MouseButton.Left));
AddAssert("now playing is still visible", () => nowPlayingOverlay.State.Value == Visibility.Visible);
AddAssert("now playing is hidden", () => nowPlayingOverlay.State.Value == Visibility.Hidden);
AddStep("press now playing hotkey", () => InputManager.Key(Key.F6));
// toolbar -> background
AddStep("press left mouse button", () => InputManager.PressButton(MouseButton.Left));

View File

@ -75,14 +75,14 @@ namespace osu.Game.Graphics.Containers
protected override bool OnMouseDown(MouseDownEvent e)
{
closeOnMouseUp = !base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition) && (game?.Toolbar.IsHovered == false);
closeOnMouseUp = !base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition);
return base.OnMouseDown(e);
}
protected override void OnMouseUp(MouseUpEvent e)
{
if (closeOnMouseUp && !base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition) && (game?.Toolbar.IsHovered == false))
if (closeOnMouseUp && !base.ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
Hide();
base.OnMouseUp(e);

View File

@ -41,8 +41,7 @@ namespace osu.Game.Overlays.Toolbar
// Toolbar and its components need keyboard input even when hidden.
public override bool PropagateNonPositionalInputSubTree => true;
// IsHovered is used
public override bool HandlePositionalInput => true;
protected override bool Handle(UIEvent e) => e is MouseEvent;
public Toolbar()
{
@ -143,13 +142,12 @@ namespace osu.Game.Overlays.Toolbar
protected override bool OnHover(HoverEvent e)
{
gradientBackground.FadeIn(transition_time, Easing.OutQuint);
return base.OnHover(e);
return true;
}
protected override void OnHoverLost(HoverLostEvent e)
{
gradientBackground.FadeOut(transition_time, Easing.OutQuint);
base.OnHoverLost(e);
}
}