Refactor blueprint container drag code

This commit is contained in:
ekrctb
2022-10-11 22:39:53 +09:00
parent 1a24762f9b
commit fcb9e2cc00
4 changed files with 38 additions and 66 deletions

View File

@ -170,11 +170,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
finishSelectionMovement();
}
private MouseButtonEvent lastDragEvent;
protected override bool OnDragStart(DragStartEvent e)
{
if (e.Button == MouseButton.Right)
return false;
lastDragEvent = e;
if (movementBlueprints != null)
{
isDraggingBlueprint = true;
@ -189,22 +193,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected override void OnDrag(DragEvent e)
{
if (e.Button == MouseButton.Right)
return;
if (DragBox.State == Visibility.Visible)
{
DragBox.HandleDrag(e);
UpdateSelectionFromDragBox();
}
lastDragEvent = e;
moveCurrentSelection(e);
}
protected override void OnDragEnd(DragEndEvent e)
{
if (e.Button == MouseButton.Right)
return;
lastDragEvent = null;
if (isDraggingBlueprint)
{
@ -215,6 +211,18 @@ namespace osu.Game.Screens.Edit.Compose.Components
DragBox.Hide();
}
protected override void Update()
{
base.Update();
if (lastDragEvent != null && DragBox.State == Visibility.Visible)
{
lastDragEvent.Target = this;
DragBox.HandleDrag(lastDragEvent);
UpdateSelectionFromDragBox();
}
}
/// <summary>
/// Called whenever a drag operation completes, before any change transaction is committed.
/// </summary>