Merge pull request #12768 from frenzibyte/fix-two-hovered-handles

Fix rotation handle visibility logic not handling two handles hovered at one point
This commit is contained in:
Dean Herbert 2021-05-13 20:57:47 +09:00 committed by GitHub
commit ee67c0ddc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -167,5 +167,21 @@ namespace osu.Game.Tests.Visual.Editing
AddStep("move mouse away", () => InputManager.MoveMouseTo(selectionBox, new Vector2(20))); AddStep("move mouse away", () => InputManager.MoveMouseTo(selectionBox, new Vector2(20)));
AddUntilStep("rotation handle hidden", () => rotationHandle.Alpha == 0); AddUntilStep("rotation handle hidden", () => rotationHandle.Alpha == 0);
} }
/// <summary>
/// Tests that hovering over two handles instantaneously from one to another does not crash or cause issues to the visibility state.
/// </summary>
[Test]
public void TestHoverOverTwoHandlesInstantaneously()
{
AddStep("hover over top-left scale handle", () =>
InputManager.MoveMouseTo(this.ChildrenOfType<SelectionBoxScaleHandle>().Single(s => s.Anchor == Anchor.TopLeft)));
AddStep("hover over top-right scale handle", () =>
InputManager.MoveMouseTo(this.ChildrenOfType<SelectionBoxScaleHandle>().Single(s => s.Anchor == Anchor.TopRight)));
AddUntilStep("top-left rotation handle hidden", () =>
this.ChildrenOfType<SelectionBoxRotationHandle>().Single(r => r.Anchor == Anchor.TopLeft).Alpha == 0);
AddUntilStep("top-right rotation handle shown", () =>
this.ChildrenOfType<SelectionBoxRotationHandle>().Single(r => r.Anchor == Anchor.TopRight).Alpha == 1);
}
} }
} }

View File

@ -84,8 +84,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (activeHandle?.IsHeld == true) if (activeHandle?.IsHeld == true)
return; return;
activeHandle = rotationHandles.SingleOrDefault(h => h.IsHeld || h.IsHovered); activeHandle = rotationHandles.FirstOrDefault(h => h.IsHeld || h.IsHovered);
activeHandle ??= allDragHandles.SingleOrDefault(h => h.IsHovered); activeHandle ??= allDragHandles.FirstOrDefault(h => h.IsHovered);
if (activeHandle != null) if (activeHandle != null)
{ {