1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Add special cases for click-selection

This commit is contained in:
smoogipoo 2019-10-24 16:14:29 +09:00
parent 8e4a21bee7
commit 45bd91f63f

View File

@ -11,7 +11,6 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Primitives;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.Input.Events; using osu.Framework.Input.Events;
using osu.Framework.Input.States;
using osu.Game.Rulesets.Edit; using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Edit.Tools; using osu.Game.Rulesets.Edit.Tools;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
@ -135,9 +134,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnClick(ClickEvent e) 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 // Deselection should only occur if no selected blueprints are hovered
// otherwise, deselection should only occur if the click event did not occur on top of a selected blueprint // 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 (clickSelectionBegan || selectionHandler.SelectedBlueprints.Any(b => b.IsHovered)) if (endClickSelection() || selectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
return true; return true;
deselectAll(); deselectAll();
@ -146,7 +145,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override bool OnMouseUp(MouseUpEvent e) protected override bool OnMouseUp(MouseUpEvent e)
{ {
endClickSelection(); // Special case for when a drag happened instead of a click
Schedule(() => endClickSelection());
return true; return true;
} }
@ -257,9 +257,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary> /// <summary>
/// Finishes the current blueprint selection. /// Finishes the current blueprint selection.
/// </summary> /// </summary>
private void endClickSelection() /// <returns>Whether a click selection was active.</returns>
private bool endClickSelection()
{ {
if (!clickSelectionBegan)
return false;
clickSelectionBegan = false; clickSelectionBegan = false;
return true;
} }
/// <summary> /// <summary>
@ -313,8 +318,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
Debug.Assert(movementBlueprint == null); Debug.Assert(movementBlueprint == null);
// Any selected blueprints can begin the movement of the group, however only the earliest hitobject is used for movement // Any selected blueprint that is hovered can begin the movement of the group, however only the earliest hitobject is used for movement
if (!selectionHandler.SelectedBlueprints.Any(b => b.IsHovered)) // A special case is added for when a click selection occurred before the drag
if (!clickSelectionBegan && !selectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
return false; return false;
// Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject // Movement is tracked from the blueprint of the earliest hitobject, since it only makes sense to distance snap from that hitobject