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:
parent
07fe99025f
commit
0aa17e7c95
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user