mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Combine scale operations and tidy up scale drag handle construction
This commit is contained in:
@ -17,8 +17,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
public class ComposeSelectionBox : CompositeDrawable
|
||||
{
|
||||
public Action<DragEvent> OnRotation;
|
||||
public Action<DragEvent, Anchor> OnScaleX;
|
||||
public Action<DragEvent, Anchor> OnScaleY;
|
||||
public Action<DragEvent, Anchor> OnScale;
|
||||
|
||||
public Action OperationStarted;
|
||||
public Action OperationEnded;
|
||||
@ -128,20 +127,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
AddRangeInternal(new[]
|
||||
{
|
||||
new DragHandle
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
HandleDrag = e => OnScaleY?.Invoke(e, Anchor.TopCentre),
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
},
|
||||
new DragHandle
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
HandleDrag = e => OnScaleY?.Invoke(e, Anchor.BottomCentre),
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
},
|
||||
createDragHandle(Anchor.TopCentre),
|
||||
createDragHandle(Anchor.BottomCentre),
|
||||
});
|
||||
}
|
||||
|
||||
@ -149,20 +136,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
AddRangeInternal(new[]
|
||||
{
|
||||
new DragHandle
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
HandleDrag = e => OnScaleX?.Invoke(e, Anchor.CentreLeft),
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
},
|
||||
new DragHandle
|
||||
{
|
||||
Anchor = Anchor.CentreRight,
|
||||
HandleDrag = e => OnScaleX?.Invoke(e, Anchor.CentreRight),
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
},
|
||||
createDragHandle(Anchor.CentreLeft),
|
||||
createDragHandle(Anchor.CentreRight),
|
||||
});
|
||||
}
|
||||
|
||||
@ -170,52 +145,20 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
AddRangeInternal(new[]
|
||||
{
|
||||
new DragHandle
|
||||
{
|
||||
Anchor = Anchor.TopLeft,
|
||||
HandleDrag = e =>
|
||||
{
|
||||
OnScaleX?.Invoke(e, Anchor.TopLeft);
|
||||
OnScaleY?.Invoke(e, Anchor.TopLeft);
|
||||
},
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
},
|
||||
new DragHandle
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
HandleDrag = e =>
|
||||
{
|
||||
OnScaleX?.Invoke(e, Anchor.TopRight);
|
||||
OnScaleY?.Invoke(e, Anchor.TopRight);
|
||||
},
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
},
|
||||
new DragHandle
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
HandleDrag = e =>
|
||||
{
|
||||
OnScaleX?.Invoke(e, Anchor.BottomLeft);
|
||||
OnScaleY?.Invoke(e, Anchor.BottomLeft);
|
||||
},
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
},
|
||||
new DragHandle
|
||||
{
|
||||
Anchor = Anchor.BottomRight,
|
||||
HandleDrag = e =>
|
||||
{
|
||||
OnScaleX?.Invoke(e, Anchor.BottomRight);
|
||||
OnScaleY?.Invoke(e, Anchor.BottomRight);
|
||||
},
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
},
|
||||
createDragHandle(Anchor.TopLeft),
|
||||
createDragHandle(Anchor.TopRight),
|
||||
createDragHandle(Anchor.BottomLeft),
|
||||
createDragHandle(Anchor.BottomRight),
|
||||
});
|
||||
}
|
||||
|
||||
ScaleDragHandle createDragHandle(Anchor anchor) =>
|
||||
new ScaleDragHandle(anchor)
|
||||
{
|
||||
HandleDrag = e => OnScale?.Invoke(e, anchor),
|
||||
OperationStarted = operationStarted,
|
||||
OperationEnded = operationEnded
|
||||
};
|
||||
}
|
||||
|
||||
private int activeOperations;
|
||||
@ -232,6 +175,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
OperationStarted?.Invoke();
|
||||
}
|
||||
|
||||
private class ScaleDragHandle : DragHandle
|
||||
{
|
||||
public ScaleDragHandle(Anchor anchor)
|
||||
{
|
||||
Anchor = anchor;
|
||||
}
|
||||
}
|
||||
|
||||
private class RotationDragHandle : DragHandle
|
||||
{
|
||||
private SpriteIcon icon;
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// copyright (c) ppy pty ltd <contact@ppy.sh>. licensed under the mit licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
@ -101,8 +101,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
OperationEnded = OnDragOperationEnded,
|
||||
|
||||
OnRotation = e => HandleRotation(e.Delta.X),
|
||||
OnScaleX = (e, anchor) => HandleScaleX(e.Delta.X, anchor),
|
||||
OnScaleY = (e, anchor) => HandleScaleY(e.Delta.Y, anchor),
|
||||
OnScale = (e, anchor) => HandleScale(e.Delta, anchor),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
@ -145,20 +144,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
public virtual bool HandleRotation(float angle) => false;
|
||||
|
||||
/// <summary>
|
||||
/// Handles the selected <see cref="DrawableHitObject"/>s being scaled in a vertical direction.
|
||||
/// Handles the selected <see cref="DrawableHitObject"/>s being scaled.
|
||||
/// </summary>
|
||||
/// <param name="scale">The delta scale to apply.</param>
|
||||
/// <param name="scale">The delta scale to apply, in playfield local coordinates.</param>
|
||||
/// <param name="anchor">The point of reference where the scale is originating from.</param>
|
||||
/// <returns>Whether any <see cref="DrawableHitObject"/>s could be moved.</returns>
|
||||
public virtual bool HandleScaleY(in float scale, Anchor anchor) => false;
|
||||
|
||||
/// <summary>
|
||||
/// Handles the selected <see cref="DrawableHitObject"/>s being scaled in a horizontal direction.
|
||||
/// </summary>
|
||||
/// <param name="scale">The delta scale to apply.</param>
|
||||
/// <param name="anchor">The point of reference where the scale is originating from.</param>
|
||||
/// <returns>Whether any <see cref="DrawableHitObject"/>s could be moved.</returns>
|
||||
public virtual bool HandleScaleX(in float scale, Anchor anchor) => false;
|
||||
public virtual bool HandleScale(Vector2 scale, Anchor anchor) => false;
|
||||
|
||||
public bool OnPressed(PlatformAction action)
|
||||
{
|
||||
|
Reference in New Issue
Block a user