1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 13:27:25 +08:00

Add to existing selection when dragging with control pressed

Closes https://github.com/ppy/osu/issues/29023.
This commit is contained in:
Bartłomiej Dach 2024-09-18 15:02:04 +02:00
parent 2d3b027f85
commit f6195c5515
No known key found for this signature in database
2 changed files with 15 additions and 4 deletions

View File

@ -196,6 +196,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
DragBox.HandleDrag(e);
DragBox.Show();
selectionBeforeDrag.Clear();
if (e.ControlPressed)
selectionBeforeDrag.UnionWith(SelectedItems);
return true;
}
@ -217,6 +222,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
}
DragBox.Hide();
selectionBeforeDrag.Clear();
}
protected override void Update()
@ -227,7 +233,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
lastDragEvent.Target = this;
DragBox.HandleDrag(lastDragEvent);
UpdateSelectionFromDragBox();
UpdateSelectionFromDragBox(selectionBeforeDrag);
}
}
@ -472,7 +478,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// <summary>
/// Select all blueprints in a selection area specified by <see cref="DragBox"/>.
/// </summary>
protected virtual void UpdateSelectionFromDragBox()
protected virtual void UpdateSelectionFromDragBox(HashSet<T> selectionBeforeDrag)
{
var quad = DragBox.Box.ScreenSpaceDrawQuad;
@ -482,7 +488,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
{
case SelectionState.Selected:
// Selection is preserved even after blueprint becomes dead.
if (!quad.Contains(blueprint.ScreenSpaceSelectionPoint))
if (!quad.Contains(blueprint.ScreenSpaceSelectionPoint) && !selectionBeforeDrag.Contains(blueprint.Item))
blueprint.Deselect();
break;
@ -535,6 +541,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
/// </summary>
private bool wasDragStarted;
private readonly HashSet<T> selectionBeforeDrag = new HashSet<T>();
/// <summary>
/// Attempts to begin the movement of any selected blueprints.
/// </summary>

View File

@ -173,7 +173,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
protected sealed override DragBox CreateDragBox() => new TimelineDragBox();
protected override void UpdateSelectionFromDragBox()
protected override void UpdateSelectionFromDragBox(HashSet<HitObject> selectionBeforeDrag)
{
Composer.BlueprintContainer.CommitIfPlacementActive();
@ -191,6 +191,9 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
bool shouldBeSelected(HitObject hitObject)
{
if (selectionBeforeDrag.Contains(hitObject))
return true;
double midTime = (hitObject.StartTime + hitObject.GetEndTime()) / 2;
return minTime <= midTime && midTime <= maxTime;
}