1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:12:57 +08:00

Merge pull request #13960 from ekrctb/selection-box-can-flip

Allow specifying different value of scaling and flipping support for a selection box
This commit is contained in:
Dean Herbert 2021-07-21 18:05:18 +09:00 committed by GitHub
commit a261f1ef8f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 10 deletions

View File

@ -35,8 +35,8 @@ namespace osu.Game.Rulesets.Osu.Edit
Quad quad = selectedMovableObjects.Length > 0 ? getSurroundingQuad(selectedMovableObjects) : new Quad(); Quad quad = selectedMovableObjects.Length > 0 ? getSurroundingQuad(selectedMovableObjects) : new Quad();
SelectionBox.CanRotate = quad.Width > 0 || quad.Height > 0; SelectionBox.CanRotate = quad.Width > 0 || quad.Height > 0;
SelectionBox.CanScaleX = quad.Width > 0; SelectionBox.CanFlipX = SelectionBox.CanScaleX = quad.Width > 0;
SelectionBox.CanScaleY = quad.Height > 0; SelectionBox.CanFlipY = SelectionBox.CanScaleY = quad.Height > 0;
SelectionBox.CanReverse = EditorBeatmap.SelectedHitObjects.Count > 1 || EditorBeatmap.SelectedHitObjects.Any(s => s is Slider); SelectionBox.CanReverse = EditorBeatmap.SelectedHitObjects.Count > 1 || EditorBeatmap.SelectedHitObjects.Any(s => s is Slider);
} }

View File

@ -35,6 +35,8 @@ namespace osu.Game.Tests.Visual.Editing
CanRotate = true, CanRotate = true,
CanScaleX = true, CanScaleX = true,
CanScaleY = true, CanScaleY = true,
CanFlipX = true,
CanFlipY = true,
OnRotation = handleRotation, OnRotation = handleRotation,
OnScale = handleScale OnScale = handleScale

View File

@ -64,7 +64,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
private bool canScaleX; private bool canScaleX;
/// <summary> /// <summary>
/// Whether vertical scale support should be enabled. /// Whether horizontal scaling support should be enabled.
/// </summary> /// </summary>
public bool CanScaleX public bool CanScaleX
{ {
@ -81,7 +81,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
private bool canScaleY; private bool canScaleY;
/// <summary> /// <summary>
/// Whether horizontal scale support should be enabled. /// Whether vertical scaling support should be enabled.
/// </summary> /// </summary>
public bool CanScaleY public bool CanScaleY
{ {
@ -95,6 +95,40 @@ namespace osu.Game.Screens.Edit.Compose.Components
} }
} }
private bool canFlipX;
/// <summary>
/// Whether horizontal flipping support should be enabled.
/// </summary>
public bool CanFlipX
{
get => canFlipX;
set
{
if (canFlipX == value) return;
canFlipX = value;
recreate();
}
}
private bool canFlipY;
/// <summary>
/// Whether vertical flipping support should be enabled.
/// </summary>
public bool CanFlipY
{
get => canFlipY;
set
{
if (canFlipY == value) return;
canFlipY = value;
recreate();
}
}
private string text; private string text;
public string Text public string Text
@ -142,10 +176,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
return CanReverse && runOperationFromHotkey(OnReverse); return CanReverse && runOperationFromHotkey(OnReverse);
case Key.H: case Key.H:
return CanScaleX && runOperationFromHotkey(() => OnFlip?.Invoke(Direction.Horizontal) ?? false); return CanFlipX && runOperationFromHotkey(() => OnFlip?.Invoke(Direction.Horizontal) ?? false);
case Key.J: case Key.J:
return CanScaleY && runOperationFromHotkey(() => OnFlip?.Invoke(Direction.Vertical) ?? false); return CanFlipY && runOperationFromHotkey(() => OnFlip?.Invoke(Direction.Vertical) ?? false);
} }
return base.OnKeyDown(e); return base.OnKeyDown(e);
@ -214,6 +248,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
if (CanScaleX) addXScaleComponents(); if (CanScaleX) addXScaleComponents();
if (CanScaleX && CanScaleY) addFullScaleComponents(); if (CanScaleX && CanScaleY) addFullScaleComponents();
if (CanScaleY) addYScaleComponents(); if (CanScaleY) addYScaleComponents();
if (CanFlipX) addXFlipComponents();
if (CanFlipY) addYFlipComponents();
if (CanRotate) addRotationComponents(); if (CanRotate) addRotationComponents();
if (CanReverse) addButton(FontAwesome.Solid.Backward, "Reverse pattern (Ctrl-G)", () => OnReverse?.Invoke()); if (CanReverse) addButton(FontAwesome.Solid.Backward, "Reverse pattern (Ctrl-G)", () => OnReverse?.Invoke());
} }
@ -231,8 +267,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void addYScaleComponents() private void addYScaleComponents()
{ {
addButton(FontAwesome.Solid.ArrowsAltV, "Flip vertically (Ctrl-J)", () => OnFlip?.Invoke(Direction.Vertical));
addScaleHandle(Anchor.TopCentre); addScaleHandle(Anchor.TopCentre);
addScaleHandle(Anchor.BottomCentre); addScaleHandle(Anchor.BottomCentre);
} }
@ -247,12 +281,20 @@ namespace osu.Game.Screens.Edit.Compose.Components
private void addXScaleComponents() private void addXScaleComponents()
{ {
addButton(FontAwesome.Solid.ArrowsAltH, "Flip horizontally (Ctrl-H)", () => OnFlip?.Invoke(Direction.Horizontal));
addScaleHandle(Anchor.CentreLeft); addScaleHandle(Anchor.CentreLeft);
addScaleHandle(Anchor.CentreRight); addScaleHandle(Anchor.CentreRight);
} }
private void addXFlipComponents()
{
addButton(FontAwesome.Solid.ArrowsAltH, "Flip horizontally (Ctrl-H)", () => OnFlip?.Invoke(Direction.Horizontal));
}
private void addYFlipComponents()
{
addButton(FontAwesome.Solid.ArrowsAltV, "Flip vertically (Ctrl-J)", () => OnFlip?.Invoke(Direction.Vertical));
}
private void addButton(IconUsage icon, string tooltip, Action action) private void addButton(IconUsage icon, string tooltip, Action action)
{ {
var button = new SelectionBoxButton(icon, tooltip) var button = new SelectionBoxButton(icon, tooltip)

View File

@ -170,6 +170,8 @@ namespace osu.Game.Skinning.Editor
SelectionBox.CanRotate = true; SelectionBox.CanRotate = true;
SelectionBox.CanScaleX = true; SelectionBox.CanScaleX = true;
SelectionBox.CanScaleY = true; SelectionBox.CanScaleY = true;
SelectionBox.CanFlipX = true;
SelectionBox.CanFlipY = true;
SelectionBox.CanReverse = false; SelectionBox.CanReverse = false;
} }