From 45bd91f63fd10fd9c617fb6082f64166f90db160 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 24 Oct 2019 16:14:29 +0900 Subject: [PATCH] Add special cases for click-selection --- .../Compose/Components/BlueprintContainer.cs | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index 123fdc78e6..8d87af6931 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Input; using osu.Framework.Input.Events; -using osu.Framework.Input.States; using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Objects; @@ -135,9 +134,9 @@ namespace osu.Game.Screens.Edit.Compose.Components protected override bool OnClick(ClickEvent e) { - // clickSelectionBegan will be true if a mouse down occurred on the blueprint but the click event was received outside of the blueprint - // otherwise, deselection should only occur if the click event did not occur on top of a selected blueprint - if (clickSelectionBegan || selectionHandler.SelectedBlueprints.Any(b => b.IsHovered)) + // Deselection should only occur if no selected blueprints are hovered + // A special case for when a blueprint was selected via this click is added since OnClick() may occur outside the hitobject and should not trigger deselection + if (endClickSelection() || selectionHandler.SelectedBlueprints.Any(b => b.IsHovered)) return true; deselectAll(); @@ -146,7 +145,8 @@ namespace osu.Game.Screens.Edit.Compose.Components protected override bool OnMouseUp(MouseUpEvent e) { - endClickSelection(); + // Special case for when a drag happened instead of a click + Schedule(() => endClickSelection()); return true; } @@ -257,9 +257,14 @@ namespace osu.Game.Screens.Edit.Compose.Components /// /// Finishes the current blueprint selection. /// - private void endClickSelection() + /// Whether a click selection was active. + private bool endClickSelection() { + if (!clickSelectionBegan) + return false; + clickSelectionBegan = false; + return true; } /// @@ -313,8 +318,9 @@ namespace osu.Game.Screens.Edit.Compose.Components { Debug.Assert(movementBlueprint == null); - // Any selected blueprints can begin the movement of the group, however only the earliest hitobject is used for movement - if (!selectionHandler.SelectedBlueprints.Any(b => b.IsHovered)) + // Any selected blueprint that is hovered can begin the movement of the group, however only the earliest hitobject is used for movement + // A special case is added for when a click selection occurred before the drag + if (!clickSelectionBegan && !selectionHandler.SelectedBlueprints.Any(b => b.IsHovered)) return false; // Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject