1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 08:27:49 +08:00

Merge pull request #25833 from peppy/fix-song-select-position-reset

Fix song select's carousel scroll position getting reset on background processing
This commit is contained in:
Bartłomiej Dach 2023-12-18 12:27:48 +01:00 committed by GitHub
commit 41f5a6e292
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -44,9 +44,6 @@ namespace osu.Game.Graphics.Containers
private bool shouldPerformRightMouseScroll(MouseButtonEvent e) => RightMouseScrollbar && e.Button == MouseButton.Right;
private void scrollFromMouseEvent(MouseEvent e) =>
ScrollTo(Clamp(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim] / DrawSize[ScrollDim]) * Content.DrawSize[ScrollDim], true, DistanceDecayOnRightMouseScrollbar);
private bool rightMouseDragging;
protected override bool IsDragging => base.IsDragging || rightMouseDragging;
@ -80,7 +77,7 @@ namespace osu.Game.Graphics.Containers
{
if (shouldPerformRightMouseScroll(e))
{
scrollFromMouseEvent(e);
ScrollFromMouseEvent(e);
return true;
}
@ -91,7 +88,7 @@ namespace osu.Game.Graphics.Containers
{
if (rightMouseDragging)
{
scrollFromMouseEvent(e);
ScrollFromMouseEvent(e);
return;
}
@ -129,6 +126,9 @@ namespace osu.Game.Graphics.Containers
return base.OnScroll(e);
}
protected virtual void ScrollFromMouseEvent(MouseEvent e) =>
ScrollTo(Clamp(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim] / DrawSize[ScrollDim]) * Content.DrawSize[ScrollDim], true, DistanceDecayOnRightMouseScrollbar);
protected override ScrollbarContainer CreateScrollbar(Direction direction) => new OsuScrollbar(direction);
protected partial class OsuScrollbar : ScrollbarContainer

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
namespace osu.Game.Graphics.Containers
{
@ -46,6 +47,12 @@ namespace osu.Game.Graphics.Containers
base.ScrollIntoView(target, animated);
}
protected override void ScrollFromMouseEvent(MouseEvent e)
{
UserScrolling = true;
base.ScrollFromMouseEvent(e);
}
public new void ScrollTo(float value, bool animated = true, double? distanceDecay = null)
{
UserScrolling = false;