1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 11:42:54 +08:00

Merge pull request #29541 from frenzibyte/fix-mod-customisation-dragging-outside

Keep mod customisation panel open when dragging outside
This commit is contained in:
Dean Herbert 2024-08-22 15:28:32 +09:00 committed by GitHub
commit 7e483bbee3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 38 additions and 5 deletions

View File

@ -7,6 +7,8 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using osu.Game.Overlays.Mods;
using osu.Game.Rulesets.Mods;
@ -157,6 +159,27 @@ namespace osu.Game.Tests.Visual.UserInterface
checkExpanded(false);
}
[Test]
public void TestDraggingKeepsPanelExpanded()
{
AddStep("add customisable mod", () =>
{
SelectedMods.Value = new[] { new OsuModDoubleTime() };
panel.Enabled.Value = true;
});
AddStep("hover header", () => InputManager.MoveMouseTo(header));
checkExpanded(true);
AddStep("hover slider bar nub", () => InputManager.MoveMouseTo(panel.ChildrenOfType<OsuSliderBar<double>>().First().ChildrenOfType<Nub>().Single()));
AddStep("hold", () => InputManager.PressButton(MouseButton.Left));
AddStep("drag outside", () => InputManager.MoveMouseTo(Vector2.Zero));
checkExpanded(true);
AddStep("release", () => InputManager.ReleaseButton(MouseButton.Left));
checkExpanded(false);
}
private void checkExpanded(bool expanded)
{
AddUntilStep(expanded ? "is expanded" : "not expanded", () => panel.ExpandedState.Value,

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Effects;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Configuration;
@ -214,15 +215,24 @@ namespace osu.Game.Overlays.Mods
this.panel = panel;
}
protected override void OnHoverLost(HoverLostEvent e)
private InputManager inputManager = null!;
protected override void LoadComplete()
{
if (ExpandedState.Value is ModCustomisationPanelState.ExpandedByHover
&& !ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
base.LoadComplete();
inputManager = GetContainingInputManager()!;
}
protected override void Update()
{
base.Update();
if (ExpandedState.Value == ModCustomisationPanelState.ExpandedByHover
&& !ReceivePositionalInputAt(inputManager.CurrentState.Mouse.Position)
&& inputManager.DraggedDrawable == null)
{
ExpandedState.Value = ModCustomisationPanelState.Collapsed;
}
base.OnHoverLost(e);
}
}