1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 20:07:29 +08:00

Split out common selection quad logic

This commit is contained in:
Dean Herbert 2021-05-20 18:24:25 +09:00
parent 27e81d6504
commit 95c78b9185

View File

@ -7,6 +7,7 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Extensions.EnumExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Primitives;
using osu.Framework.Graphics.UserInterface;
using osu.Game.Extensions;
using osu.Game.Graphics.UserInterface;
@ -38,8 +39,7 @@ namespace osu.Game.Skinning.Editor
}
else
{
var selectionQuad = GetSurroundingQuad(SelectedBlueprints.SelectMany(b =>
b.Item.ScreenSpaceDrawQuad.GetVertices().ToArray()));
var selectionQuad = getSelectionQuad();
referenceOrigin ??= selectionQuad.Centre;
@ -63,8 +63,7 @@ namespace osu.Game.Skinning.Editor
adjustScaleFromAnchor(ref scale, anchor);
var selectionQuad = GetSurroundingQuad(SelectedBlueprints.SelectMany(b =>
b.Item.ScreenSpaceDrawQuad.GetVertices().ToArray()));
var selectionQuad = getSelectionQuad();
// the selection quad is always upright, so use a rect to make mutating the values easier.
var adjustedRect = selectionQuad.AABBFloat;
@ -220,6 +219,13 @@ namespace osu.Game.Skinning.Editor
}
}
/// <summary>
/// A screen-space quad surrounding all selected drawables, accounting for their full displayed size.
/// </summary>
/// <returns></returns>
private Quad getSelectionQuad() =>
GetSurroundingQuad(SelectedBlueprints.SelectMany(b => b.Item.ScreenSpaceDrawQuad.GetVertices().ToArray()));
private void applyAnchor(Anchor anchor)
{
foreach (var item in SelectedItems)