1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 18:47:27 +08:00

Check X/Y sizing available separately to fix weird edge cases

This commit is contained in:
Dean Herbert 2023-11-10 17:53:56 +09:00
parent 46a219e010
commit f25489cc7b
No known key found for this signature in database

View File

@ -32,11 +32,11 @@ namespace osu.Game.Overlays.SkinEditor
UpdatePosition = updateDrawablePosition UpdatePosition = updateDrawablePosition
}; };
private bool allSelectedSupportManualSizing => SelectedItems.All(b => (b as CompositeDrawable)?.AutoSizeAxes == Axes.None); private bool allSelectedSupportManualSizing(Axes axis) => SelectedItems.All(b => (b as CompositeDrawable)?.AutoSizeAxes.HasFlagFast(axis) == false);
public override bool HandleScale(Vector2 scale, Anchor anchor) public override bool HandleScale(Vector2 scale, Anchor anchor)
{ {
bool adjustSize; Axes adjustAxis;
switch (anchor) switch (anchor)
{ {
@ -45,19 +45,25 @@ namespace osu.Game.Overlays.SkinEditor
case Anchor.TopRight: case Anchor.TopRight:
case Anchor.BottomLeft: case Anchor.BottomLeft:
case Anchor.BottomRight: case Anchor.BottomRight:
adjustSize = false; adjustAxis = Axes.Both;
break; break;
// for edges, adjust size. // for edges, adjust size.
// autosize elements can't be easily handled so just disable sizing for now.
case Anchor.TopCentre: case Anchor.TopCentre:
case Anchor.CentreLeft:
case Anchor.CentreRight:
case Anchor.BottomCentre: case Anchor.BottomCentre:
// autosize elements can't be easily handled so just disable sizing for now. if (!allSelectedSupportManualSizing(Axes.Y))
if (!allSelectedSupportManualSizing)
return false; return false;
adjustSize = true; adjustAxis = Axes.Y;
break;
case Anchor.CentreLeft:
case Anchor.CentreRight:
if (!allSelectedSupportManualSizing(Axes.X))
return false;
adjustAxis = Axes.X;
break; break;
default: default:
@ -151,10 +157,20 @@ namespace osu.Game.Overlays.SkinEditor
if (Precision.AlmostEquals(MathF.Abs(drawableItem.Rotation) % 180, 90)) if (Precision.AlmostEquals(MathF.Abs(drawableItem.Rotation) % 180, 90))
currentScaledDelta = new Vector2(scaledDelta.Y, scaledDelta.X); currentScaledDelta = new Vector2(scaledDelta.Y, scaledDelta.X);
if (adjustSize) switch (adjustAxis)
drawableItem.Size *= currentScaledDelta; {
else case Axes.X:
drawableItem.Scale *= currentScaledDelta; drawableItem.Width *= currentScaledDelta.X;
break;
case Axes.Y:
drawableItem.Height *= currentScaledDelta.Y;
break;
case Axes.Both:
drawableItem.Scale *= currentScaledDelta;
break;
}
} }
return true; return true;
@ -203,7 +219,8 @@ namespace osu.Game.Overlays.SkinEditor
{ {
base.OnSelectionChanged(); base.OnSelectionChanged();
SelectionBox.CanScaleX = SelectionBox.CanScaleY = allSelectedSupportManualSizing; SelectionBox.CanScaleX = allSelectedSupportManualSizing(Axes.X);
SelectionBox.CanScaleY = allSelectedSupportManualSizing(Axes.Y);
SelectionBox.CanScaleProportionally = true; SelectionBox.CanScaleProportionally = true;
SelectionBox.CanFlipX = true; SelectionBox.CanFlipX = true;
SelectionBox.CanFlipY = true; SelectionBox.CanFlipY = true;