mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Avoid using guesses to determine whether inputs blocked
This commit is contained in:
@ -110,9 +110,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
bool selectionPerformed = performMouseDownActions(e);
|
||||
|
||||
// even if a selection didn't occur, a drag event may still move the selection.
|
||||
prepareSelectionMovement();
|
||||
bool movementPossible = prepareSelectionMovement();
|
||||
|
||||
return selectionPerformed || e.Button == MouseButton.Left;
|
||||
return selectionPerformed || movementPossible;
|
||||
}
|
||||
|
||||
protected SelectionBlueprint<T> ClickedBlueprint { get; private set; }
|
||||
@ -427,19 +427,21 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <summary>
|
||||
/// Attempts to begin the movement of any selected blueprints.
|
||||
/// </summary>
|
||||
private void prepareSelectionMovement()
|
||||
/// <returns>Whether a movement is possible.</returns>
|
||||
private bool prepareSelectionMovement()
|
||||
{
|
||||
if (!SelectionHandler.SelectedBlueprints.Any())
|
||||
return;
|
||||
return false;
|
||||
|
||||
// Any selected blueprint that is hovered can begin the movement of the group, however only the first item (according to SortForMovement) is used for movement.
|
||||
// A special case is added for when a click selection occurred before the drag
|
||||
if (!clickSelectionBegan && !SelectionHandler.SelectedBlueprints.Any(b => b.IsHovered))
|
||||
return;
|
||||
return false;
|
||||
|
||||
// Movement is tracked from the blueprint of the earliest item, since it only makes sense to distance snap from that item
|
||||
movementBlueprints = SortForMovement(SelectionHandler.SelectedBlueprints).ToArray();
|
||||
movementBlueprintOriginalPositions = movementBlueprints.Select(m => m.ScreenSpaceSelectionPoint).ToArray();
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -35,15 +35,10 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private Bindable<HitObject> placement;
|
||||
private SelectionBlueprint<HitObject> placementBlueprint;
|
||||
|
||||
// We want children to be able to be clicked and dragged
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
private SelectableAreaBackground backgroundBox;
|
||||
|
||||
// This drawable itself should still check whether the mouse is over it
|
||||
private bool shouldHandleInputAt(Vector2 screenSpacePos)
|
||||
{
|
||||
float localY = ToLocalSpace(screenSpacePos).Y;
|
||||
return DrawRectangle.Top <= localY && DrawRectangle.Bottom >= localY;
|
||||
}
|
||||
// We want children to be able to be clicked and dragged, regardless of this drawable's size
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||
|
||||
public TimelineBlueprintContainer(HitObjectComposer composer)
|
||||
: base(composer)
|
||||
@ -58,7 +53,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(new SelectableAreaBackground
|
||||
AddInternal(backgroundBox = new SelectableAreaBackground
|
||||
{
|
||||
Colour = Color4.Black,
|
||||
Depth = float.MaxValue,
|
||||
@ -97,25 +92,13 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
|
||||
protected override Container<SelectionBlueprint<HitObject>> CreateSelectionBlueprintContainer() => new TimelineSelectionBlueprintContainer { RelativeSizeAxes = Axes.Both };
|
||||
|
||||
protected override bool OnMouseDown(MouseDownEvent e)
|
||||
{
|
||||
int selectionCount = SelectedItems.Count;
|
||||
|
||||
// We let BlueprintContainer attempt a HitObject selection
|
||||
// If it fails, we'll pass it this input back to the timeline so it can be dragged
|
||||
// We know it failed if the selection count is unchanged after the selection attempt
|
||||
if (base.OnMouseDown(e) && selectionCount != SelectedItems.Count)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override bool OnDragStart(DragStartEvent e)
|
||||
{
|
||||
if (!shouldHandleInputAt(e.ScreenSpaceMouseDownPosition))
|
||||
return false;
|
||||
// We should only allow BlueprintContainer to create a drag box if the mouse is within selection bounds
|
||||
if (backgroundBox.ReceivePositionalInputAt(e.ScreenSpaceMouseDownPosition))
|
||||
return base.OnDragStart(e);
|
||||
|
||||
return base.OnDragStart(e);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected override void OnDrag(DragEvent e)
|
||||
|
Reference in New Issue
Block a user