From 73d1ed29d099cbe4827c14e717840a4212ca5b3c Mon Sep 17 00:00:00 2001 From: Paul Hirch Date: Tue, 29 Oct 2024 04:37:50 +0100 Subject: [PATCH] Fix MouseScroll --- AltUI/Controls/DarkScrollBar.cs | 11 ++++------- AltUI/Controls/DarkScrollBase.cs | 11 +++++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/AltUI/Controls/DarkScrollBar.cs b/AltUI/Controls/DarkScrollBar.cs index cac3b72..447eaff 100644 --- a/AltUI/Controls/DarkScrollBar.cs +++ b/AltUI/Controls/DarkScrollBar.cs @@ -75,6 +75,9 @@ public int Value value = Minimum; var maximumValue = Maximum - ViewSize; + if (maximumValue < Minimum) + maximumValue = Minimum; + if (value > maximumValue) value = maximumValue; @@ -376,13 +379,7 @@ public void ScrollBy(int offset) public void ScrollByPhysical(int offsetInPixels) { - var isVert = _scrollOrientation == DarkScrollOrientation.Vertical; - - var thumbPos = isVert ? (_thumbArea.Top - _trackArea.Top) : (_thumbArea.Left - _trackArea.Left); - - var newPosition = thumbPos - offsetInPixels; - - ScrollToPhysical(newPosition); + Value += offsetInPixels; } public void UpdateScrollBar() diff --git a/AltUI/Controls/DarkScrollBase.cs b/AltUI/Controls/DarkScrollBase.cs index cb14780..a68c8f4 100644 --- a/AltUI/Controls/DarkScrollBase.cs +++ b/AltUI/Controls/DarkScrollBase.cs @@ -36,6 +36,9 @@ public abstract class DarkScrollBase : Control #region Property Region + [Browsable(false)] + [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + public int MouseScrollPixelStep { get; set; } = 20; [Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] @@ -323,16 +326,16 @@ protected override void OnMouseWheel(MouseEventArgs e) if (!horizontal) { if (e.Delta > 0) - _vScrollBar.ScrollByPhysical(3); + _vScrollBar.ScrollByPhysical(-MouseScrollPixelStep); else if (e.Delta < 0) - _vScrollBar.ScrollByPhysical(-3); + _vScrollBar.ScrollByPhysical(MouseScrollPixelStep); } else { if (e.Delta > 0) - _hScrollBar.ScrollByPhysical(3); + _hScrollBar.ScrollByPhysical(-MouseScrollPixelStep); else if (e.Delta < 0) - _hScrollBar.ScrollByPhysical(-3); + _hScrollBar.ScrollByPhysical(MouseScrollPixelStep); } }