1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-28 10:17:19 +08:00

Rewrite selection box computation logic with RectangleF's helper methods

This commit is contained in:
Salman Ahmed 2021-05-02 02:51:06 +03:00
parent 07fe99025f
commit 0aa17e7c95

View File

@ -328,21 +328,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
return; return;
// Move the rectangle to cover the items // Move the rectangle to cover the items
var topLeft = new Vector2(float.MaxValue, float.MaxValue); RectangleF selectionRect = ToLocalSpace(selectedBlueprints.First().SelectionQuad).AABBFloat;
var bottomRight = new Vector2(float.MinValue, float.MinValue);
foreach (var blueprint in selectedBlueprints) foreach (var blueprint in selectedBlueprints.Skip(1))
{ selectionRect = RectangleF.Union(selectionRect, ToLocalSpace(blueprint.SelectionQuad).AABBFloat);
var blueprintRect = blueprint.SelectionQuad.AABBFloat;
topLeft = Vector2.ComponentMin(topLeft, ToLocalSpace(blueprintRect.TopLeft));
bottomRight = Vector2.ComponentMax(bottomRight, ToLocalSpace(blueprintRect.BottomRight));
}
topLeft -= new Vector2(5); selectionRect = selectionRect.Inflate(5f);
bottomRight += new Vector2(5);
content.Size = bottomRight - topLeft; content.Position = selectionRect.Location;
content.Position = topLeft; content.Size = selectionRect.Size;
} }
#endregion #endregion