1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Merge pull request #2064 from peppy/drag-lenience

Fix drag handling in line with framework changes
This commit is contained in:
Dan Balasescu 2018-02-13 22:19:20 +09:00 committed by GitHub
commit 44c9d14142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 6 deletions

@ -1 +1 @@
Subproject commit eba12eb4a0fa6238873dd266deb35bfdece21a6a
Subproject commit 63c9440bfbd2bfb36f14c9ee0a521a6c46849cec

View File

@ -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

View File

@ -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;