mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Move a lot of the implementation to base SelectionHandler
This commit is contained in:
@ -43,6 +43,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
private OsuSpriteText selectionDetailsText;
|
||||
|
||||
protected ComposeSelectionBox SelectionBox { get; private set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
protected EditorBeatmap EditorBeatmap { get; private set; }
|
||||
|
||||
@ -87,12 +89,37 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
}
|
||||
}
|
||||
},
|
||||
CreateSelectionBox(),
|
||||
SelectionBox = CreateSelectionBox(),
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public virtual ComposeSelectionBox CreateSelectionBox() => new ComposeSelectionBox();
|
||||
public ComposeSelectionBox CreateSelectionBox()
|
||||
=> new ComposeSelectionBox
|
||||
{
|
||||
OperationStarted = OnDragOperationBegan,
|
||||
OperationEnded = OnDragOperationEnded,
|
||||
|
||||
OnRotation = e => HandleRotation(e.Delta.X),
|
||||
OnScaleX = (e, anchor) => HandleScaleX(e.Delta.X, anchor),
|
||||
OnScaleY = (e, anchor) => HandleScaleY(e.Delta.Y, anchor),
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Fired when a drag operation ends from the selection box.
|
||||
/// </summary>
|
||||
protected virtual void OnDragOperationBegan()
|
||||
{
|
||||
ChangeHandler.BeginChange();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fired when a drag operation begins from the selection box.
|
||||
/// </summary>
|
||||
protected virtual void OnDragOperationEnded()
|
||||
{
|
||||
ChangeHandler.EndChange();
|
||||
}
|
||||
|
||||
#region User Input Handling
|
||||
|
||||
@ -108,7 +135,30 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// Whether any <see cref="DrawableHitObject"/>s could be moved.
|
||||
/// Returning true will also propagate StartTime changes provided by the closest <see cref="IPositionSnapProvider.SnapScreenSpacePositionToValidTime"/>.
|
||||
/// </returns>
|
||||
public virtual bool HandleMovement(MoveSelectionEvent moveEvent) => true;
|
||||
public virtual bool HandleMovement(MoveSelectionEvent moveEvent) => false;
|
||||
|
||||
/// <summary>
|
||||
/// Handles the selected <see cref="DrawableHitObject"/>s being rotated.
|
||||
/// </summary>
|
||||
/// <param name="angle">The delta angle to apply to the selection.</param>
|
||||
/// <returns>Whether any <see cref="DrawableHitObject"/>s could be moved.</returns>
|
||||
public virtual bool HandleRotation(float angle) => false;
|
||||
|
||||
/// <summary>
|
||||
/// Handles the selected <see cref="DrawableHitObject"/>s being scaled in a vertical 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 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 bool OnPressed(PlatformAction action)
|
||||
{
|
||||
@ -211,11 +261,22 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
selectionDetailsText.Text = count > 0 ? count.ToString() : string.Empty;
|
||||
|
||||
if (count > 0)
|
||||
{
|
||||
Show();
|
||||
OnSelectionChanged();
|
||||
}
|
||||
else
|
||||
Hide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered whenever more than one object is selected, on each change.
|
||||
/// Should update the selection box's state to match supported operations.
|
||||
/// </summary>
|
||||
protected virtual void OnSelectionChanged()
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
Reference in New Issue
Block a user