diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs b/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs
index 423927481c..5d1bcd1ef7 100644
--- a/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs
+++ b/osu.Game/Rulesets/Edit/Layers/Selection/CaptureBox.cs
@@ -15,17 +15,26 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
///
/// A box which encapsulates captured s.
///
- public class CaptureBox : VisibilityContainer
+ public abstract class CaptureBox : VisibilityContainer
{
+ ///
+ /// Top-left corner of the rectangle that encloses the s.
+ ///
+ protected Vector2 FinalPosition { get; private set; }
+
+ ///
+ /// Size of the rectangle that encloses the s.
+ ///
+ protected Vector2 FinalSize { get; private set; }
+
private readonly IDrawable captureArea;
private readonly IReadOnlyList capturedObjects;
- public CaptureBox(IDrawable captureArea, IReadOnlyList capturedObjects)
+ protected CaptureBox(IDrawable captureArea, IReadOnlyList capturedObjects)
{
this.captureArea = captureArea;
this.capturedObjects = capturedObjects;
- Origin = Anchor.Centre;
Masking = true;
BorderThickness = 3;
@@ -57,13 +66,47 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
topLeft -= new Vector2(5);
bottomRight += new Vector2(5);
- Size = bottomRight - topLeft;
- Position = topLeft + Size / 2f;
+ FinalSize = bottomRight - topLeft;
+ FinalPosition = topLeft;
}
- protected override void PopIn() => this.ScaleTo(1.1f)
- .Then()
- .ScaleTo(1f, 300, Easing.OutQuint).FadeIn(300, Easing.OutQuint);
+ protected override void PopIn() => this.MoveTo(FinalPosition).ResizeTo(FinalSize).FadeIn();
+ protected override void PopOut() => this.FadeOut();
+ }
+
+ ///
+ /// A which fully encloses the s from the start.
+ ///
+ public class InstantCaptureBox : CaptureBox
+ {
+ public InstantCaptureBox(IDrawable captureArea, IReadOnlyList capturedObjects)
+ : base(captureArea, capturedObjects)
+ {
+ Origin = Anchor.Centre;
+ }
+
+ protected override void PopIn()
+ => this.MoveTo(FinalPosition + FinalSize / 2f).ResizeTo(FinalSize).ScaleTo(1.1f)
+ .Then()
+ .ScaleTo(1f, 300, Easing.OutQuint).FadeIn(300, Easing.OutQuint);
+
+ protected override void PopOut() => this.FadeOut(300, Easing.OutQuint);
+ }
+
+ ///
+ /// A which moves from an initial position + size to enclose s.
+ ///
+ public class DragCaptureBox : CaptureBox
+ {
+ public DragCaptureBox(IDrawable captureArea, IReadOnlyList capturedObjects, Vector2 initialPosition, Vector2 initialSize)
+ : base(captureArea, capturedObjects)
+ {
+ Position = initialPosition;
+ Size = initialSize;
+ }
+
+ protected override void PopIn()
+ => this.MoveTo(FinalPosition, 300, Easing.OutQuint).ResizeTo(FinalSize, 300, Easing.OutQuint).FadeIn(300, Easing.OutQuint);
protected override void PopOut() => this.FadeOut(300, Easing.OutQuint);
}
diff --git a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs
index e7a46569f1..e1fc0d179a 100644
--- a/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs
+++ b/osu.Game/Rulesets/Edit/Layers/Selection/SelectionLayer.cs
@@ -58,7 +58,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
protected override bool OnDragEnd(InputState state)
{
selectionBox.Hide();
- finishCapture();
+ finishCapture(true);
return true;
}
@@ -66,7 +66,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
protected override bool OnClick(InputState state)
{
capturePoint(state.Mouse.NativeState.Position);
- finishCapture();
+ finishCapture(false);
return true;
}
@@ -94,7 +94,7 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
capturedHitObjects.Add(captured);
}
- private void finishCapture()
+ private void finishCapture(bool fromDrag)
{
if (capturedHitObjects.Count == 0)
return;
@@ -102,7 +102,11 @@ namespace osu.Game.Rulesets.Edit.Layers.Selection
// Due to https://github.com/ppy/osu-framework/issues/1382, we may get here through both
// OnDragEnd and OnClick methods within a single frame, OnMouseDown doesn't help us here
captureBox?.Hide();
- AddInternal(captureBox = new CaptureBox(this, capturedHitObjects.ToList()));
+
+ if (fromDrag)
+ AddInternal(captureBox = new DragCaptureBox(this, capturedHitObjects.ToList(), selectionBox.Position, selectionBox.Size));
+ else
+ AddInternal(captureBox = new InstantCaptureBox(this, capturedHitObjects.ToList()));
}
}
}