1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-14 02:43:02 +08:00

let SelectionBox perform flip with scale handles

This commit is contained in:
Wleter 2023-09-01 13:01:51 +02:00
parent f277909470
commit fc4069f794
2 changed files with 23 additions and 11 deletions

View File

@ -81,18 +81,12 @@ namespace osu.Game.Overlays.SkinEditor
if (adjustedRect.Width <= 0 || adjustedRect.Height <= 0) if (adjustedRect.Width <= 0 || adjustedRect.Height <= 0)
{ {
if (adjustedRect.Width <= 0) Axes toFlip = Axes.None;
{
SelectionBox.FlipScaleHandles(Direction.Horizontal);
HandleFlip(Direction.Horizontal, false);
}
if (adjustedRect.Height <= 0) if (adjustedRect.Width <= 0) toFlip |= Axes.X;
{ if (adjustedRect.Height <= 0) toFlip |= Axes.Y;
SelectionBox.FlipScaleHandles(Direction.Vertical);
HandleFlip(Direction.Vertical, false);
}
SelectionBox.PerformFlipFromScaleHandles(toFlip);
return true; return true;
} }

View File

@ -4,6 +4,7 @@
using System; using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions.EnumExtensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -307,7 +308,24 @@ namespace osu.Game.Screens.Edit.Compose.Components
return button; return button;
} }
public void FlipScaleHandles(Direction direction) => dragHandles.FlipScaleHandles(direction); /// <remarks>
/// This method should be called when a selection needs to be flipped
/// because of an ongoing scale handle drag that would otherwise cause width or height to go negative.
/// </remarks>
public void PerformFlipFromScaleHandles(Axes axes)
{
if (axes.HasFlagFast(Axes.X))
{
dragHandles.FlipScaleHandles(Direction.Horizontal);
OnFlip?.Invoke(Direction.Horizontal, false);
}
if (axes.HasFlagFast(Axes.Y))
{
dragHandles.FlipScaleHandles(Direction.Vertical);
OnFlip?.Invoke(Direction.Vertical, false);
}
}
private void addScaleHandle(Anchor anchor) private void addScaleHandle(Anchor anchor)
{ {