mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Move drag box drag handling to BlueprintContainer
This commit is contained in:
@ -23,6 +23,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
public event Action<IEnumerable<HitObject>> SelectionChanged;
|
public event Action<IEnumerable<HitObject>> SelectionChanged;
|
||||||
|
|
||||||
|
private DragBox dragBox;
|
||||||
private SelectionBlueprintContainer selectionBlueprints;
|
private SelectionBlueprintContainer selectionBlueprints;
|
||||||
private Container<PlacementBlueprint> placementBlueprintContainer;
|
private Container<PlacementBlueprint> placementBlueprintContainer;
|
||||||
private PlacementBlueprint currentPlacement;
|
private PlacementBlueprint currentPlacement;
|
||||||
@ -46,12 +47,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
selectionHandler = composer.CreateSelectionHandler();
|
selectionHandler = composer.CreateSelectionHandler();
|
||||||
selectionHandler.DeselectAll = deselectAll;
|
selectionHandler.DeselectAll = deselectAll;
|
||||||
|
|
||||||
var dragBox = new DragBox(select);
|
|
||||||
dragBox.DragEnd += () => selectionHandler.UpdateVisibility();
|
|
||||||
|
|
||||||
InternalChildren = new[]
|
InternalChildren = new[]
|
||||||
{
|
{
|
||||||
dragBox,
|
dragBox = new DragBox(select),
|
||||||
selectionHandler,
|
selectionHandler,
|
||||||
selectionBlueprints = new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both },
|
selectionBlueprints = new SelectionBlueprintContainer { RelativeSizeAxes = Axes.Both },
|
||||||
placementBlueprintContainer = new Container<PlacementBlueprint> { RelativeSizeAxes = Axes.Both },
|
placementBlueprintContainer = new Container<PlacementBlueprint> { RelativeSizeAxes = Axes.Both },
|
||||||
@ -229,6 +227,28 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
|
|
||||||
private void onSelectionRequested(SelectionBlueprint blueprint, InputState state) => selectionHandler.HandleSelectionRequested(blueprint, state);
|
private void onSelectionRequested(SelectionBlueprint blueprint, InputState state) => selectionHandler.HandleSelectionRequested(blueprint, state);
|
||||||
|
|
||||||
|
protected override bool OnDragStart(DragStartEvent e)
|
||||||
|
{
|
||||||
|
if (!selectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
|
||||||
|
dragBox.FadeIn(250, Easing.OutQuint);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnDrag(DragEvent e)
|
||||||
|
{
|
||||||
|
dragBox.UpdateDrag(e);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override bool OnDragEnd(DragEndEvent e)
|
||||||
|
{
|
||||||
|
dragBox.FadeOut(250, Easing.OutQuint);
|
||||||
|
selectionHandler.UpdateVisibility();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent)
|
private void onDragRequested(SelectionBlueprint blueprint, DragEvent dragEvent)
|
||||||
{
|
{
|
||||||
HitObject draggedObject = blueprint.DrawableObject.HitObject;
|
HitObject draggedObject = blueprint.DrawableObject.HitObject;
|
||||||
|
@ -19,11 +19,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
{
|
{
|
||||||
private readonly Action<RectangleF> performSelection;
|
private readonly Action<RectangleF> performSelection;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Invoked when the drag selection has finished.
|
|
||||||
/// </summary>
|
|
||||||
public event Action DragEnd;
|
|
||||||
|
|
||||||
private Drawable box;
|
private Drawable box;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -55,13 +50,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnDragStart(DragStartEvent e)
|
public void UpdateDrag(DragEvent e)
|
||||||
{
|
|
||||||
this.FadeIn(250, Easing.OutQuint);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnDrag(DragEvent e)
|
|
||||||
{
|
{
|
||||||
var dragPosition = e.ScreenSpaceMousePosition;
|
var dragPosition = e.ScreenSpaceMousePosition;
|
||||||
var dragStartPosition = e.ScreenSpaceMouseDownPosition;
|
var dragStartPosition = e.ScreenSpaceMouseDownPosition;
|
||||||
@ -78,14 +67,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
box.Size = bottomRight - topLeft;
|
box.Size = bottomRight - topLeft;
|
||||||
|
|
||||||
performSelection?.Invoke(dragRectangle);
|
performSelection?.Invoke(dragRectangle);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override bool OnDragEnd(DragEndEvent e)
|
|
||||||
{
|
|
||||||
this.FadeOut(250, Easing.OutQuint);
|
|
||||||
DragEnd?.Invoke();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user