From 9e7d559f55307930b24bd3de270ac3c6360248fb Mon Sep 17 00:00:00 2001 From: Jason Won Date: Thu, 4 Nov 2021 17:10:41 -0400 Subject: [PATCH] fix aspect locked scaling of skin components --- .../Skinning/Editor/SkinSelectionHandler.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/osu.Game/Skinning/Editor/SkinSelectionHandler.cs b/osu.Game/Skinning/Editor/SkinSelectionHandler.cs index 0790faad34..01bd5e8196 100644 --- a/osu.Game/Skinning/Editor/SkinSelectionHandler.cs +++ b/osu.Game/Skinning/Editor/SkinSelectionHandler.cs @@ -70,14 +70,16 @@ namespace osu.Game.Skinning.Editor if (anchor.HasFlagFast(Anchor.x1)) scale.X = 0; if (anchor.HasFlagFast(Anchor.y1)) scale.Y = 0; - bool shouldAspectLock = - // for now aspect lock scale adjustments that occur at corners.. - (!anchor.HasFlagFast(Anchor.x1) && !anchor.HasFlagFast(Anchor.y1)) - // ..or if any of the selection have been rotated. - // this is to avoid requiring skew logic (which would likely not be the user's expected transform anyway). - || SelectedBlueprints.Any(b => !Precision.AlmostEquals(((Drawable)b.Item).Rotation, 0)); - - if (shouldAspectLock) + // for now aspect lock scale adjustments that occur at corners.. + if (!anchor.HasFlagFast(Anchor.x1) && !anchor.HasFlagFast(Anchor.y1)) + { + // project scale vector along diagonal + Vector2 diag = (selectionRect.TopLeft - selectionRect.BottomRight).Normalized(); + scale = Vector2.Dot(scale, diag) * diag; + } + // ..or if any of the selection have been rotated. + // this is to avoid requiring skew logic (which would likely not be the user's expected transform anyway). + else if (SelectedBlueprints.Any(b => !Precision.AlmostEquals(((Drawable)b.Item).Rotation, 0))) { if (anchor.HasFlagFast(Anchor.x1)) // if dragging from the horizontal centre, only a vertical component is available.