mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Remove drag from class/method namings + refactor
This commit is contained in:
@ -222,7 +222,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
// Todo: Snap dragPosition
|
||||
|
||||
selectionHandler.HandleDrag(blueprint, new SelectionDragEvent(blueprint, blueprint.ScreenSpaceDragStartPosition, dragPosition));
|
||||
selectionHandler.HandleMovement(new MoveSelectionEvent(blueprint, blueprint.ScreenSpaceDragStartPosition, dragPosition));
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -0,0 +1,53 @@
|
||||
// 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 osu.Game.Rulesets.Edit;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// An event which occurs when a <see cref="SelectionBlueprint"/> is moved.
|
||||
/// </summary>
|
||||
public class MoveSelectionEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="SelectionBlueprint"/> that triggered this <see cref="MoveSelectionEvent"/>.
|
||||
/// </summary>
|
||||
public readonly SelectionBlueprint Blueprint;
|
||||
|
||||
/// <summary>
|
||||
/// The starting screen-space position of the hitobject.
|
||||
/// </summary>
|
||||
public readonly Vector2 ScreenSpaceStartPosition;
|
||||
|
||||
/// <summary>
|
||||
/// The expected screen-space position of the hitobject at the current cursor position.
|
||||
/// </summary>
|
||||
public readonly Vector2 ScreenSpacePosition;
|
||||
|
||||
/// <summary>
|
||||
/// The distance between <see cref="ScreenSpacePosition"/> and the hitobject's current position, in the coordinate-space of the hitobject's parent.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This does not use <see cref="ScreenSpaceStartPosition"/> and does not represent the cumulative movement distance.
|
||||
/// </remarks>
|
||||
public readonly Vector2 InstantDelta;
|
||||
|
||||
public MoveSelectionEvent(SelectionBlueprint blueprint, Vector2 screenSpaceStartPosition, Vector2 screenSpacePosition)
|
||||
{
|
||||
Blueprint = blueprint;
|
||||
ScreenSpaceStartPosition = screenSpaceStartPosition;
|
||||
ScreenSpacePosition = screenSpacePosition;
|
||||
|
||||
InstantDelta = toLocalSpace(ScreenSpacePosition) - Blueprint.HitObject.Position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a screen-space position into the coordinate space of the hitobject's parents.
|
||||
/// </summary>
|
||||
/// <param name="screenSpacePosition">The screen-space position.</param>
|
||||
/// <returns>The position in the coordinate space of the hitobject's parent.</returns>
|
||||
private Vector2 toLocalSpace(Vector2 screenSpacePosition) => Blueprint.HitObject.Parent.ToLocalSpace(screenSpacePosition);
|
||||
}
|
||||
}
|
@ -1,53 +0,0 @@
|
||||
// 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 osu.Game.Rulesets.Edit;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
/// <summary>
|
||||
/// An event which occurs when a <see cref="SelectionBlueprint"/> is dragged.
|
||||
/// </summary>
|
||||
public class SelectionDragEvent
|
||||
{
|
||||
/// <summary>
|
||||
/// The dragged <see cref="SelectionBlueprint"/>.
|
||||
/// </summary>
|
||||
public readonly SelectionBlueprint DraggedBlueprint;
|
||||
|
||||
/// <summary>
|
||||
/// The screen-space position of the hitobject at the start of the drag.
|
||||
/// </summary>
|
||||
public readonly Vector2 ScreenSpaceDragStartPosition;
|
||||
|
||||
/// <summary>
|
||||
/// The new screen-space position of the hitobject at the current drag point.
|
||||
/// </summary>
|
||||
public readonly Vector2 ScreenSpaceDragPosition;
|
||||
|
||||
/// <summary>
|
||||
/// The distance between <see cref="ScreenSpaceDragPosition"/> and the hitobject's current position, in the coordinate-space of the hitobject's parent.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This does not use <see cref="ScreenSpaceDragStartPosition"/> and does not represent the cumulative drag distance.
|
||||
/// </remarks>
|
||||
public readonly Vector2 InstantDragDelta;
|
||||
|
||||
public SelectionDragEvent(SelectionBlueprint blueprint, Vector2 screenSpaceDragStartPosition, Vector2 screenSpaceDragPosition)
|
||||
{
|
||||
DraggedBlueprint = blueprint;
|
||||
ScreenSpaceDragStartPosition = screenSpaceDragStartPosition;
|
||||
ScreenSpaceDragPosition = screenSpaceDragPosition;
|
||||
|
||||
InstantDragDelta = toLocalSpace(ScreenSpaceDragPosition) - DraggedBlueprint.HitObject.Position;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a screen-space position into the coordinate space of the hitobject's parents.
|
||||
/// </summary>
|
||||
/// <param name="screenSpacePosition">The screen-space position.</param>
|
||||
/// <returns>The position in the coordinate space of the hitobject's parent.</returns>
|
||||
private Vector2 toLocalSpace(Vector2 screenSpacePosition) => DraggedBlueprint.HitObject.Parent.ToLocalSpace(screenSpacePosition);
|
||||
}
|
||||
}
|
@ -65,11 +65,10 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
#region User Input Handling
|
||||
|
||||
/// <summary>
|
||||
/// Handles the selected <see cref="DrawableHitObject"/>s being dragged.
|
||||
/// Handles the selected <see cref="DrawableHitObject"/>s being moved.
|
||||
/// </summary>
|
||||
/// <param name="blueprint">The <see cref="SelectionBlueprint"/> that received the drag event.</param>
|
||||
/// <param name="dragEvent">The drag event.</param>
|
||||
public virtual void HandleDrag(SelectionBlueprint blueprint, SelectionDragEvent dragEvent)
|
||||
/// <param name="moveEvent">The move event.</param>
|
||||
public virtual void HandleMovement(MoveSelectionEvent moveEvent)
|
||||
{
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user