1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 15:17:44 +08:00

Scale around center when pressing alt while dragging selection box scale handle

This commit is contained in:
Marvin Schürz 2024-09-21 13:37:41 +02:00
parent ccf1acce56
commit 2dbbbe270d

View File

@ -50,14 +50,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
rawScale = convertDragEventToScaleMultiplier(e);
applyScale(shouldLockAspectRatio: isCornerAnchor(originalAnchor) && e.ShiftPressed);
applyScale(shouldLockAspectRatio: isCornerAnchor(originalAnchor) && e.ShiftPressed, ignoreAnchor: e.AltPressed);
}
protected override bool OnKeyDown(KeyDownEvent e)
{
if (IsDragged)
{
applyScale(shouldLockAspectRatio: isCornerAnchor(originalAnchor) && e.ShiftPressed);
applyScale(shouldLockAspectRatio: isCornerAnchor(originalAnchor) && e.ShiftPressed, ignoreAnchor: e.AltPressed);
return true;
}
@ -69,7 +69,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
base.OnKeyUp(e);
if (IsDragged)
applyScale(shouldLockAspectRatio: isCornerAnchor(originalAnchor) && e.ShiftPressed);
applyScale(shouldLockAspectRatio: isCornerAnchor(originalAnchor) && e.ShiftPressed, ignoreAnchor: e.AltPressed);
}
protected override void OnDragEnd(DragEndEvent e)
@ -100,13 +100,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
if ((originalAnchor & Anchor.y0) > 0) scale.Y = -scale.Y;
}
private void applyScale(bool shouldLockAspectRatio)
private void applyScale(bool shouldLockAspectRatio, bool ignoreAnchor = false)
{
var newScale = shouldLockAspectRatio
? new Vector2((rawScale.X + rawScale.Y) * 0.5f)
: rawScale;
var scaleOrigin = originalAnchor.Opposite().PositionOnQuad(scaleHandler!.OriginalSurroundingQuad!.Value);
Vector2? scaleOrigin = ignoreAnchor ? null : originalAnchor.Opposite().PositionOnQuad(scaleHandler!.OriginalSurroundingQuad!.Value);
scaleHandler!.Update(newScale, scaleOrigin, getAdjustAxis());
}