mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 17:43:05 +08:00
Merge pull request #3759 from peppy/fix-editor-precise-scroll
Fix precision scroll events being handled incorrectly by editor
This commit is contained in:
commit
91b484a643
@ -228,15 +228,19 @@ namespace osu.Game.Overlays.Volume
|
||||
public void Decrease(double amount = 1, bool isPrecise = false) => adjust(-amount, isPrecise);
|
||||
|
||||
// because volume precision is set to 0.01, this local is required to keep track of more precise adjustments and only apply when possible.
|
||||
private double adjustAccumulator;
|
||||
private double scrollAccumulation;
|
||||
|
||||
private void adjust(double delta, bool isPrecise)
|
||||
{
|
||||
adjustAccumulator += delta * adjust_step * (isPrecise ? 0.1 : 1);
|
||||
if (Math.Abs(adjustAccumulator) < Bindable.Precision)
|
||||
return;
|
||||
Volume += adjustAccumulator;
|
||||
adjustAccumulator = 0;
|
||||
scrollAccumulation += delta * adjust_step * (isPrecise ? 0.1 : 1);
|
||||
|
||||
var precision = Bindable.Precision;
|
||||
|
||||
while (Math.Abs(scrollAccumulation) > precision)
|
||||
{
|
||||
Volume += Math.Sign(scrollAccumulation) * precision;
|
||||
scrollAccumulation = scrollAccumulation < 0 ? Math.Min(0, scrollAccumulation + precision) : Math.Max(0, scrollAccumulation - precision);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osuTK.Graphics;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Screens.Backgrounds;
|
||||
@ -181,12 +182,24 @@ namespace osu.Game.Screens.Edit
|
||||
LoadComponentAsync(currentScreen, screenContainer.Add);
|
||||
}
|
||||
|
||||
private double scrollAccumulation;
|
||||
|
||||
protected override bool OnScroll(ScrollEvent e)
|
||||
{
|
||||
if (e.ScrollDelta.X + e.ScrollDelta.Y > 0)
|
||||
clock.SeekBackward(!clock.IsRunning);
|
||||
else
|
||||
clock.SeekForward(!clock.IsRunning);
|
||||
scrollAccumulation += (e.ScrollDelta.X + e.ScrollDelta.Y) * (e.IsPrecise ? 0.1 : 1);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user