1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-13 15:43:21 +08:00

Change control point piece selection logic to allow dragging multiple

This commit is contained in:
Bartłomiej Dach 2021-12-20 21:18:38 +01:00
parent fbba8293c7
commit a9408485cc
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -135,6 +135,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
updateMarkerDisplay();
}
// Used to pair up mouse down events which caused this piece to be selected
// with their corresponding mouse up events.
private bool selectionPerformed;
protected override bool OnMouseDown(MouseDownEvent e)
{
if (RequestSelection == null)
@ -143,7 +147,12 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
switch (e.Button)
{
case MouseButton.Left:
RequestSelection.Invoke(this, e);
if (!IsSelected.Value)
{
RequestSelection.Invoke(this, e);
selectionPerformed = true;
}
return true;
case MouseButton.Right:
@ -155,6 +164,18 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
return false;
}
protected override void OnMouseUp(MouseUpEvent e)
{
base.OnMouseUp(e);
// ctrl+click deselects this piece, but only if this event
// wasn't immediately preceded by a matching mouse down.
if (IsSelected.Value && e.ControlPressed && !selectionPerformed)
IsSelected.Value = false;
selectionPerformed = false;
}
protected override bool OnClick(ClickEvent e) => RequestSelection != null;
protected override bool OnDragStart(DragStartEvent e)