Adjust tick-based wheel control to be more correct

This commit is contained in:
Dean Herbert
2018-11-22 20:13:40 +09:00
parent a48c26d999
commit 10047e6815
2 changed files with 21 additions and 13 deletions

View File

@ -187,15 +187,19 @@ namespace osu.Game.Screens.Edit
protected override bool OnScroll(ScrollEvent e)
{
scrollAccumulation += e.ScrollDelta.X + e.ScrollDelta.Y * (e.IsPrecise ? 0.1 : 1);
if (Math.Abs(scrollAccumulation) < 1)
return true;
if (scrollAccumulation > 0)
clock.SeekBackward(!clock.IsRunning);
else
clock.SeekForward(!clock.IsRunning);
const int precision = 1;
while (Math.Abs(scrollAccumulation) > precision)
{
if (scrollAccumulation > 0)
clock.SeekBackward(!clock.IsRunning);
else
clock.SeekForward(!clock.IsRunning);
scrollAccumulation = scrollAccumulation < 0 ? Math.Min(0, scrollAccumulation + precision) : Math.Max(0, scrollAccumulation - precision);
}
scrollAccumulation = 0;
return true;
}