Fix using right mouse button to drag at song select seeking incorrectly with many beatmaps loaded

Closes #5195
This commit is contained in:
Dean Herbert 2019-07-30 07:03:59 +09:00
parent 5fa820cdd4
commit cec26a270e
1 changed files with 10 additions and 9 deletions

View File

@ -27,11 +27,12 @@ public class OsuScrollContainer : ScrollContainer<Drawable>
private bool shouldPerformRightMouseScroll(MouseButtonEvent e) => RightMouseScrollbar && e.Button == MouseButton.Right;
private void scrollToRelative(float value) => ScrollTo(Clamp((value - Scrollbar.DrawSize[ScrollDim] / 2) / Scrollbar.Size[ScrollDim]), true, DistanceDecayOnRightMouseScrollbar);
private void scrollFromMouseEvent(MouseEvent e) =>
ScrollTo(Clamp(ToLocalSpace(e.ScreenSpaceMousePosition)[ScrollDim] / DrawSize[ScrollDim]) * Content.DrawSize[ScrollDim], true, DistanceDecayOnRightMouseScrollbar);
private bool mouseScrollBarDragging;
private bool rightMouseDragging;
protected override bool IsDragging => base.IsDragging || mouseScrollBarDragging;
protected override bool IsDragging => base.IsDragging || rightMouseDragging;
public OsuScrollContainer(Direction scrollDirection = Direction.Vertical)
: base(scrollDirection)
@ -42,7 +43,7 @@ protected override bool OnMouseDown(MouseDownEvent e)
{
if (shouldPerformRightMouseScroll(e))
{
scrollToRelative(e.MousePosition[ScrollDim]);
scrollFromMouseEvent(e);
return true;
}
@ -51,9 +52,9 @@ protected override bool OnMouseDown(MouseDownEvent e)
protected override bool OnDrag(DragEvent e)
{
if (mouseScrollBarDragging)
if (rightMouseDragging)
{
scrollToRelative(e.MousePosition[ScrollDim]);
scrollFromMouseEvent(e);
return true;
}
@ -64,7 +65,7 @@ protected override bool OnDragStart(DragStartEvent e)
{
if (shouldPerformRightMouseScroll(e))
{
mouseScrollBarDragging = true;
rightMouseDragging = true;
return true;
}
@ -73,9 +74,9 @@ protected override bool OnDragStart(DragStartEvent e)
protected override bool OnDragEnd(DragEndEvent e)
{
if (mouseScrollBarDragging)
if (rightMouseDragging)
{
mouseScrollBarDragging = false;
rightMouseDragging = false;
return true;
}