mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:12:56 +08:00
Merge pull request #2064 from peppy/drag-lenience
Fix drag handling in line with framework changes
This commit is contained in:
commit
44c9d14142
@ -1 +1 @@
|
||||
Subproject commit eba12eb4a0fa6238873dd266deb35bfdece21a6a
|
||||
Subproject commit 63c9440bfbd2bfb36f14c9ee0a521a6c46849cec
|
@ -34,7 +34,19 @@ namespace osu.Game.Overlays.Music
|
||||
|
||||
public Action<BeatmapSetInfo> OnSelect;
|
||||
|
||||
public bool IsDraggable => handle.IsHovered;
|
||||
public bool IsDraggable { get; private set; }
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
IsDraggable = handle.IsHovered;
|
||||
return base.OnMouseDown(state, args);
|
||||
}
|
||||
|
||||
protected override bool OnMouseUp(InputState state, MouseUpEventArgs args)
|
||||
{
|
||||
IsDraggable = false;
|
||||
return base.OnMouseUp(state, args);
|
||||
}
|
||||
|
||||
private bool selected;
|
||||
public bool Selected
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Allocation;
|
||||
@ -65,9 +64,12 @@ namespace osu.Game.Overlays
|
||||
AlwaysPresent = true;
|
||||
}
|
||||
|
||||
private Vector2 dragStart;
|
||||
|
||||
protected override bool OnDragStart(InputState state)
|
||||
{
|
||||
base.OnDragStart(state);
|
||||
dragStart = state.Mouse.Position;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -75,9 +77,7 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
if (base.OnDrag(state)) return true;
|
||||
|
||||
Trace.Assert(state.Mouse.PositionMouseDown != null, "state.Mouse.PositionMouseDown != null");
|
||||
|
||||
Vector2 change = state.Mouse.Position - state.Mouse.PositionMouseDown.Value;
|
||||
Vector2 change = state.Mouse.Position - dragStart;
|
||||
|
||||
// Diminish the drag distance as we go further to simulate "rubber band" feeling.
|
||||
change *= change.Length <= 0 ? 0 : (float)Math.Pow(change.Length, 0.7f) / change.Length;
|
||||
|
Loading…
Reference in New Issue
Block a user