mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
fix adjust axes detection
This commit is contained in:
parent
1596776a81
commit
9b9485f656
@ -7,6 +7,7 @@ using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
@ -82,7 +83,7 @@ namespace osu.Game.Rulesets.Osu.Edit
|
||||
obj => obj.Path.ControlPoints.Select(p => p.Type).ToArray());
|
||||
}
|
||||
|
||||
public override void Update(Vector2 scale, Vector2? origin = null)
|
||||
public override void Update(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both)
|
||||
{
|
||||
if (objectsInScale == null)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Update)} a scale operation without calling {nameof(Begin)} first!");
|
||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
isFlippedY = false;
|
||||
}
|
||||
|
||||
public override void Update(Vector2 scale, Vector2? origin = null)
|
||||
public override void Update(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both)
|
||||
{
|
||||
if (objectsInScale == null)
|
||||
throw new InvalidOperationException($"Cannot {nameof(Update)} a scale operation without calling {nameof(Begin)} first!");
|
||||
@ -91,7 +91,6 @@ namespace osu.Game.Overlays.SkinEditor
|
||||
Debug.Assert(originalWidths != null && originalHeights != null && originalScales != null && originalPositions != null && defaultOrigin != null && OriginalSurroundingQuad != null);
|
||||
|
||||
var actualOrigin = origin ?? defaultOrigin.Value;
|
||||
Axes adjustAxis = scale.X == 1 ? Axes.Y : scale.Y == 1 ? Axes.X : Axes.Both;
|
||||
|
||||
if ((adjustAxis == Axes.Y && !allSelectedSupportManualSizing(Axes.Y)) ||
|
||||
(adjustAxis == Axes.X && !allSelectedSupportManualSizing(Axes.X)))
|
||||
|
@ -38,20 +38,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
private Vector2 getOriginPosition()
|
||||
{
|
||||
var quad = scaleHandler!.OriginalSurroundingQuad!.Value;
|
||||
Vector2 origin = quad.TopLeft;
|
||||
|
||||
if ((originalAnchor & Anchor.x0) > 0)
|
||||
origin.X += quad.Width;
|
||||
|
||||
if ((originalAnchor & Anchor.y0) > 0)
|
||||
origin.Y += quad.Height;
|
||||
|
||||
return origin;
|
||||
}
|
||||
|
||||
private Vector2 rawScale;
|
||||
|
||||
protected override void OnDrag(DragEvent e)
|
||||
@ -113,7 +99,38 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
? new Vector2((rawScale.X + rawScale.Y) * 0.5f)
|
||||
: rawScale;
|
||||
|
||||
scaleHandler!.Update(newScale, getOriginPosition());
|
||||
scaleHandler!.Update(newScale, getOriginPosition(), getAdjustAxis());
|
||||
}
|
||||
|
||||
private Vector2 getOriginPosition()
|
||||
{
|
||||
var quad = scaleHandler!.OriginalSurroundingQuad!.Value;
|
||||
Vector2 origin = quad.TopLeft;
|
||||
|
||||
if ((originalAnchor & Anchor.x0) > 0)
|
||||
origin.X += quad.Width;
|
||||
|
||||
if ((originalAnchor & Anchor.y0) > 0)
|
||||
origin.Y += quad.Height;
|
||||
|
||||
return origin;
|
||||
}
|
||||
|
||||
private Axes getAdjustAxis()
|
||||
{
|
||||
switch (originalAnchor)
|
||||
{
|
||||
case Anchor.TopCentre:
|
||||
case Anchor.BottomCentre:
|
||||
return Axes.Y;
|
||||
|
||||
case Anchor.CentreLeft:
|
||||
case Anchor.CentreRight:
|
||||
return Axes.X;
|
||||
|
||||
default:
|
||||
return Axes.Both;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,10 +46,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// The origin point to scale from.
|
||||
/// If the default <see langword="null"/> value is supplied, a sane implementation-defined default will be used.
|
||||
/// </param>
|
||||
public void ScaleSelection(Vector2 scale, Vector2? origin = null)
|
||||
/// <param name="adjustAxis">The axes to adjust the scale in.</param>
|
||||
public void ScaleSelection(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both)
|
||||
{
|
||||
Begin();
|
||||
Update(scale, origin);
|
||||
Update(scale, origin, adjustAxis);
|
||||
Commit();
|
||||
}
|
||||
|
||||
@ -83,7 +84,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// The origin point to scale from.
|
||||
/// If the default <see langword="null"/> value is supplied, a sane implementation-defined default will be used.
|
||||
/// </param>
|
||||
public virtual void Update(Vector2 scale, Vector2? origin = null)
|
||||
/// <param name="adjustAxis">The axes to adjust the scale in.</param>
|
||||
public virtual void Update(Vector2 scale, Vector2? origin = null, Axes adjustAxis = Axes.Both)
|
||||
{
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user