diff --git a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs
index aaf3517c9c..8cb86bc108 100644
--- a/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs
+++ b/osu.Game.Rulesets.Osu/Edit/OsuSelectionHandler.cs
@@ -225,26 +225,10 @@ namespace osu.Game.Rulesets.Osu.Edit
private void scaleHitObjects(OsuHitObject[] hitObjects, Anchor reference, Vector2 scale)
{
scale = getClampedScale(hitObjects, reference, scale);
-
- // move the selection before scaling if dragging from top or left anchors.
- float xOffset = ((reference & Anchor.x0) > 0) ? -scale.X : 0;
- float yOffset = ((reference & Anchor.y0) > 0) ? -scale.Y : 0;
-
Quad selectionQuad = getSurroundingQuad(hitObjects);
foreach (var h in hitObjects)
- {
- var newPosition = h.Position;
-
- // guard against no-ops and NaN.
- if (scale.X != 0 && selectionQuad.Width > 0)
- newPosition.X = selectionQuad.TopLeft.X + xOffset + (h.X - selectionQuad.TopLeft.X) / selectionQuad.Width * (selectionQuad.Width + scale.X);
-
- if (scale.Y != 0 && selectionQuad.Height > 0)
- newPosition.Y = selectionQuad.TopLeft.Y + yOffset + (h.Y - selectionQuad.TopLeft.Y) / selectionQuad.Height * (selectionQuad.Height + scale.Y);
-
- h.Position = newPosition;
- }
+ h.Position = GetScaledPosition(reference, scale, selectionQuad, h.Position);
}
private (bool X, bool Y) isQuadInBounds(Quad quad)
diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
index bfd5ab7afa..26328b4dc7 100644
--- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
+++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs
@@ -375,6 +375,26 @@ namespace osu.Game.Screens.Edit.Compose.Components
return position;
}
+ ///
+ /// Given a scale vector, a surrounding quad for all selected objects, and a position,
+ /// will return the scaled position in screen space coordinates.
+ ///
+ protected static Vector2 GetScaledPosition(Anchor reference, Vector2 scale, Quad selectionQuad, Vector2 position)
+ {
+ // adjust the direction of scale depending on which side the user is dragging.
+ float xOffset = ((reference & Anchor.x0) > 0) ? -scale.X : 0;
+ float yOffset = ((reference & Anchor.y0) > 0) ? -scale.Y : 0;
+
+ // guard against no-ops and NaN.
+ if (scale.X != 0 && selectionQuad.Width > 0)
+ position.X = selectionQuad.TopLeft.X + xOffset + (position.X - selectionQuad.TopLeft.X) / selectionQuad.Width * (selectionQuad.Width + scale.X);
+
+ if (scale.Y != 0 && selectionQuad.Height > 0)
+ position.Y = selectionQuad.TopLeft.Y + yOffset + (position.Y - selectionQuad.TopLeft.Y) / selectionQuad.Height * (selectionQuad.Height + scale.Y);
+
+ return position;
+ }
+
///
/// Returns a quad surrounding the provided points.
///