1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 20:47:26 +08:00

Add tolerance when drag-scrolling editor timeline

Closes https://github.com/ppy/osu/issues/28983.

While the direct cause of this is most likely mouse confine in
full-screen, it shouldn't/can't really be disabled just for this,
and I also get this on linux in *windowed* mode.

In checking other apps, adding some tolerance to this sort of
drag-scroll behaviour seems like a sane UX improvement anyways.
This commit is contained in:
Bartłomiej Dach 2024-07-23 11:05:53 +02:00
parent 5911c42116
commit 38fc6f70f6
No known key found for this signature in database

View File

@ -198,11 +198,20 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
var timelineQuad = timeline.ScreenSpaceDrawQuad;
float mouseX = InputManager.CurrentState.Mouse.Position.X;
// for better UX do not require the user to drag all the way to the edge and beyond to initiate a drag-scroll.
// this is especially important in scenarios like fullscreen, where mouse confine will usually be on
// and the user physically *won't be able to* drag beyond the edge of the timeline
// (since its left edge is co-incident with the window edge).
const float scroll_tolerance = 20;
float leftBound = timelineQuad.TopLeft.X + scroll_tolerance;
float rightBound = timelineQuad.TopRight.X - scroll_tolerance;
// scroll if in a drag and dragging outside visible extents
if (mouseX > timelineQuad.TopRight.X)
timeline.ScrollBy((float)((mouseX - timelineQuad.TopRight.X) / 10 * Clock.ElapsedFrameTime));
else if (mouseX < timelineQuad.TopLeft.X)
timeline.ScrollBy((float)((mouseX - timelineQuad.TopLeft.X) / 10 * Clock.ElapsedFrameTime));
if (mouseX > rightBound)
timeline.ScrollBy((float)((mouseX - rightBound) / 10 * Clock.ElapsedFrameTime));
else if (mouseX < leftBound)
timeline.ScrollBy((float)((mouseX - leftBound) / 10 * Clock.ElapsedFrameTime));
}
private partial class SelectableAreaBackground : CompositeDrawable