mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 16:02:55 +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:
commit
7e483bbee3
@ -7,6 +7,8 @@ using NUnit.Framework;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -157,6 +159,27 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
checkExpanded(false);
|
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)
|
private void checkExpanded(bool expanded)
|
||||||
{
|
{
|
||||||
AddUntilStep(expanded ? "is expanded" : "not expanded", () => panel.ExpandedState.Value,
|
AddUntilStep(expanded ? "is expanded" : "not expanded", () => panel.ExpandedState.Value,
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
@ -214,15 +215,24 @@ namespace osu.Game.Overlays.Mods
|
|||||||
this.panel = panel;
|
this.panel = panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(HoverLostEvent e)
|
private InputManager inputManager = null!;
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
if (ExpandedState.Value is ModCustomisationPanelState.ExpandedByHover
|
base.LoadComplete();
|
||||||
&& !ReceivePositionalInputAt(e.ScreenSpaceMousePosition))
|
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;
|
ExpandedState.Value = ModCustomisationPanelState.Collapsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnHoverLost(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user