mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Add test coverage and fix fail case where a drag selection ends incorrectly with cyclic selection
This commit is contained in:
parent
3c4e2d8700
commit
1cf870d956
@ -83,6 +83,14 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
});
|
||||
});
|
||||
|
||||
// This step is specifically added to reproduce an edge case which was found during cyclic selection development.
|
||||
// If everything is working as expected it should not affect the subsequent drag selections.
|
||||
AddRepeatStep("Select top left", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.TopLeft + new Vector2(box1.ScreenSpaceDrawQuad.Width / 8));
|
||||
InputManager.Click(MouseButton.Left);
|
||||
}, 2);
|
||||
|
||||
AddStep("Begin drag top left", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(box1.ScreenSpaceDrawQuad.TopLeft - new Vector2(box1.ScreenSpaceDrawQuad.Width / 4));
|
||||
@ -91,7 +99,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
AddStep("Drag to bottom right", () =>
|
||||
{
|
||||
InputManager.MoveMouseTo(box2.ScreenSpaceDrawQuad.Centre + new Vector2(box2.ScreenSpaceDrawQuad.Width / 4));
|
||||
InputManager.MoveMouseTo(box3.ScreenSpaceDrawQuad.TopRight + new Vector2(-box3.ScreenSpaceDrawQuad.Width / 8, box3.ScreenSpaceDrawQuad.Height / 4));
|
||||
});
|
||||
|
||||
AddStep("Release button", () =>
|
||||
|
@ -178,6 +178,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
endClickSelection(e);
|
||||
clickSelectionHandled = false;
|
||||
isDraggingBlueprint = false;
|
||||
wasDragStarted = false;
|
||||
});
|
||||
|
||||
finishSelectionMovement();
|
||||
@ -191,6 +192,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
return false;
|
||||
|
||||
lastDragEvent = e;
|
||||
wasDragStarted = true;
|
||||
|
||||
if (movementBlueprints != null)
|
||||
{
|
||||
@ -399,7 +401,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
if (selectedBlueprintAlreadySelectedOnMouseDown && AllowCyclicSelection)
|
||||
if (!wasDragStarted && selectedBlueprintAlreadySelectedOnMouseDown && AllowCyclicSelection)
|
||||
{
|
||||
// If a click occurred and was handled by the currently selected blueprint but didn't result in a drag,
|
||||
// cycle between other blueprints which are also under the cursor.
|
||||
@ -485,6 +487,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
private bool isDraggingBlueprint;
|
||||
|
||||
/// <summary>
|
||||
/// Whether a drag operation was started at all.
|
||||
/// </summary>
|
||||
private bool wasDragStarted;
|
||||
|
||||
/// <summary>
|
||||
/// Attempts to begin the movement of any selected blueprints.
|
||||
/// </summary>
|
||||
|
Loading…
Reference in New Issue
Block a user