1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 08:22:56 +08:00

Align the drag circles on the selction box in the editor to be on the center of the border

This commit is contained in:
Graham Johnson 2020-12-17 19:34:16 -05:00
parent bb586f3175
commit a01ed1827a

View File

@ -235,6 +235,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void addDragHandle(Anchor anchor) => AddInternal(new SelectionBoxDragHandle
{
Anchor = anchor,
Y = getAdjustmentToCenterCircleOnBorder(anchor).Y,
X = getAdjustmentToCenterCircleOnBorder(anchor).X,
HandleDrag = e => OnScale?.Invoke(e.Delta, anchor),
OperationStarted = operationStarted,
OperationEnded = operationEnded
@ -251,6 +253,45 @@ namespace osu.Game.Screens.Edit.Compose.Components
return (endAngle - startAngle) * 180 / MathF.PI;
}
/// <summary>
/// Adjust Drag circle to be centered on the center of the border instead of on the edge.
/// </summary>
/// <param name="anchor">The part of the rectangle to be adjusted.</param>
private Vector2 getAdjustmentToCenterCircleOnBorder(Anchor anchor)
{
Vector2 adjustment = Vector2.Zero;
switch (anchor)
{
case Anchor.TopLeft:
case Anchor.CentreLeft:
case Anchor.BottomLeft:
adjustment.X = BORDER_RADIUS / 2;
break;
case Anchor.TopRight:
case Anchor.CentreRight:
case Anchor.BottomRight:
adjustment.X = -BORDER_RADIUS / 2;
break;
}
switch (anchor)
{
case Anchor.TopLeft:
case Anchor.TopCentre:
case Anchor.TopRight:
adjustment.Y = BORDER_RADIUS / 2;
break;
case Anchor.BottomLeft:
case Anchor.BottomCentre:
case Anchor.BottomRight:
adjustment.Y = -BORDER_RADIUS / 2;
break;
}
return adjustment;
}
private void operationEnded()
{
if (--activeOperations == 0)