mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Move drag box drag handling to BlueprintContainer
This commit is contained in:
parent
02efd0e943
commit
cef2318cf5
@ -23,6 +23,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
public event Action<IEnumerable<HitObject>> SelectionChanged;
|
||||
|
||||
private DragBox dragBox;
|
||||
private SelectionBlueprintContainer selectionBlueprints;
|
||||
private Container<PlacementBlueprint> placementBlueprintContainer;
|
||||
private PlacementBlueprint currentPlacement;
|
||||
@ -46,12 +47,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
selectionHandler = composer.CreateSelectionHandler();
|
||||
selectionHandler.DeselectAll = deselectAll;
|
||||
|
||||
var dragBox = new DragBox(select);
|
||||
dragBox.DragEnd += () => selectionHandler.UpdateVisibility();
|
||||
|
||||
InternalChildren = new[]
|
||||
{
|
||||
dragBox,
|
||||
dragBox = new DragBox(select),
|
||||
selectionHandler,
|
||||
selectionBlueprints = new SelectionBlueprintContainer { 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);
|
||||
|
||||
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)
|
||||
{
|
||||
HitObject draggedObject = blueprint.DrawableObject.HitObject;
|
||||
|
@ -19,11 +19,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
private readonly Action<RectangleF> performSelection;
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the drag selection has finished.
|
||||
/// </summary>
|
||||
public event Action DragEnd;
|
||||
|
||||
private Drawable box;
|
||||
|
||||
/// <summary>
|
||||
@ -55,13 +50,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
};
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e)
|
||||
{
|
||||
this.FadeIn(250, Easing.OutQuint);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDrag(DragEvent e)
|
||||
public void UpdateDrag(DragEvent e)
|
||||
{
|
||||
var dragPosition = e.ScreenSpaceMousePosition;
|
||||
var dragStartPosition = e.ScreenSpaceMouseDownPosition;
|
||||
@ -78,14 +67,6 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
box.Size = bottomRight - topLeft;
|
||||
|
||||
performSelection?.Invoke(dragRectangle);
|
||||
return true;
|
||||
}
|
||||
|
||||
protected override bool OnDragEnd(DragEndEvent e)
|
||||
{
|
||||
this.FadeOut(250, Easing.OutQuint);
|
||||
DragEnd?.Invoke();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user