Merge pull request #30757 from peppy/fix-scroll-absolute-pos

Fix right click scroll at song select not quite matching scrollbar position
This commit is contained in:
Bartłomiej Dach 2024-11-19 10:40:00 +01:00 committed by GitHub
commit 273095fd82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 6 deletions

View File

@ -42,8 +42,6 @@ public partial class OsuScrollContainer<T> : ScrollContainer<T> where T : Drawab
/// </summary>
public double DistanceDecayOnRightMouseScrollbar = 0.02;
private bool shouldPerformRightMouseScroll(MouseButtonEvent e) => RightMouseScrollbar && e.Button == MouseButton.Right;
private bool rightMouseDragging;
protected override bool IsDragging => base.IsDragging || rightMouseDragging;
@ -126,8 +124,15 @@ protected override bool OnScroll(ScrollEvent e)
return base.OnScroll(e);
}
protected virtual void ScrollFromMouseEvent(MouseEvent e) =>
ScrollTo(Clamp(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim] / DrawSize[ScrollDim] * Content.DrawSize[ScrollDim]), true, DistanceDecayOnRightMouseScrollbar);
protected virtual void ScrollFromMouseEvent(MouseEvent e)
{
float fromScrollbarPosition = FromScrollbarPosition(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim]);
float scrollbarCentreOffset = FromScrollbarPosition(Scrollbar.DrawHeight) * 0.5f;
ScrollTo(Clamp(fromScrollbarPosition - scrollbarCentreOffset), true, DistanceDecayOnRightMouseScrollbar);
}
private bool shouldPerformRightMouseScroll(MouseButtonEvent e) => RightMouseScrollbar && e.Button == MouseButton.Right;
protected override ScrollbarContainer CreateScrollbar(Direction direction) => new OsuScrollbar(direction);

View File

@ -245,8 +245,7 @@ private void load(OsuConfigManager config, AudioManager audio, CancellationToken
config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm);
config.BindWith(OsuSetting.SongSelectRightMouseScroll, RightClickScrollingEnabled);
RightClickScrollingEnabled.ValueChanged += enabled => Scroll.RightMouseScrollbar = enabled.NewValue;
RightClickScrollingEnabled.TriggerChange();
RightClickScrollingEnabled.BindValueChanged(enabled => Scroll.RightMouseScrollbar = enabled.NewValue, true);
if (detachedBeatmapStore != null && detachedBeatmapSets == null)
{