mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add flip event flow and stop passing raw input events to handle methods
This commit is contained in:
@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Events;
|
|
||||||
using osu.Game.Screens.Edit.Compose.Components;
|
using osu.Game.Screens.Edit.Compose.Components;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -20,7 +19,7 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddStep("create box", () =>
|
AddStep("create box", () =>
|
||||||
Child = selectionArea = new Container
|
Child = selectionArea = new Container
|
||||||
{
|
{
|
||||||
Size = new Vector2(300),
|
Size = new Vector2(400),
|
||||||
Position = -new Vector2(150),
|
Position = -new Vector2(150),
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
@ -42,29 +41,29 @@ namespace osu.Game.Tests.Visual.Editing
|
|||||||
AddToggleStep("toggle y", state => selectionBox.CanScaleY = state);
|
AddToggleStep("toggle y", state => selectionBox.CanScaleY = state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleScale(DragEvent e, Anchor reference)
|
private void handleScale(Vector2 amount, Anchor reference)
|
||||||
{
|
{
|
||||||
if ((reference & Anchor.y1) == 0)
|
if ((reference & Anchor.y1) == 0)
|
||||||
{
|
{
|
||||||
int directionY = (reference & Anchor.y0) > 0 ? -1 : 1;
|
int directionY = (reference & Anchor.y0) > 0 ? -1 : 1;
|
||||||
if (directionY < 0)
|
if (directionY < 0)
|
||||||
selectionArea.Y += e.Delta.Y;
|
selectionArea.Y += amount.Y;
|
||||||
selectionArea.Height += directionY * e.Delta.Y;
|
selectionArea.Height += directionY * amount.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((reference & Anchor.x1) == 0)
|
if ((reference & Anchor.x1) == 0)
|
||||||
{
|
{
|
||||||
int directionX = (reference & Anchor.x0) > 0 ? -1 : 1;
|
int directionX = (reference & Anchor.x0) > 0 ? -1 : 1;
|
||||||
if (directionX < 0)
|
if (directionX < 0)
|
||||||
selectionArea.X += e.Delta.X;
|
selectionArea.X += amount.X;
|
||||||
selectionArea.Width += directionX * e.Delta.X;
|
selectionArea.Width += directionX * amount.X;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleRotation(DragEvent e)
|
private void handleRotation(float angle)
|
||||||
{
|
{
|
||||||
// kinda silly and wrong, but just showing that the drag handles work.
|
// kinda silly and wrong, but just showing that the drag handles work.
|
||||||
selectionArea.Rotation += e.Delta.X;
|
selectionArea.Rotation += angle;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,8 +16,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
public class ComposeSelectionBox : CompositeDrawable
|
public class ComposeSelectionBox : CompositeDrawable
|
||||||
{
|
{
|
||||||
public Action<DragEvent> OnRotation;
|
public Action<float> OnRotation;
|
||||||
public Action<DragEvent, Anchor> OnScale;
|
public Action<Vector2, Anchor> OnScale;
|
||||||
|
public Action<Direction> OnFlip;
|
||||||
|
|
||||||
public Action OperationStarted;
|
public Action OperationStarted;
|
||||||
public Action OperationEnded;
|
public Action OperationEnded;
|
||||||
|
@ -100,8 +100,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
OperationStarted = OnOperationBegan,
|
OperationStarted = OnOperationBegan,
|
||||||
OperationEnded = OnOperationEnded,
|
OperationEnded = OnOperationEnded,
|
||||||
|
|
||||||
OnRotation = e => HandleRotation(e.Delta.X),
|
OnRotation = angle => HandleRotation(angle),
|
||||||
OnScale = (e, anchor) => HandleScale(e.Delta, anchor),
|
OnScale = (amount, anchor) => HandleScale(amount, anchor),
|
||||||
|
OnFlip = direction => HandleFlip(direction),
|
||||||
};
|
};
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -151,6 +152,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <returns>Whether any <see cref="DrawableHitObject"/>s could be moved.</returns>
|
/// <returns>Whether any <see cref="DrawableHitObject"/>s could be moved.</returns>
|
||||||
public virtual bool HandleScale(Vector2 scale, Anchor anchor) => false;
|
public virtual bool HandleScale(Vector2 scale, Anchor anchor) => false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handled the selected <see cref="DrawableHitObject"/>s being flipped.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="direction">The direction to flip</param>
|
||||||
|
/// <returns>Whether any <see cref="DrawableHitObject"/>s could be moved.</returns>
|
||||||
|
public virtual bool HandleFlip(Direction direction) => false;
|
||||||
|
|
||||||
public bool OnPressed(PlatformAction action)
|
public bool OnPressed(PlatformAction action)
|
||||||
{
|
{
|
||||||
switch (action.ActionMethod)
|
switch (action.ActionMethod)
|
||||||
|
Reference in New Issue
Block a user