From 4384adc357942fc26d43fed08a36b802e973257a Mon Sep 17 00:00:00 2001 From: donandren Date: Sat, 18 Jun 2016 14:40:44 +0300 Subject: [PATCH 1/2] handle horizontal wheel events --- src/Windows/Avalonia.Win32/WindowImpl.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 483de0d000..93e2b172f0 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -499,6 +499,14 @@ namespace Avalonia.Win32 ScreenToClient(DipFromLParam(lParam)), new Vector(0, ((int)wParam >> 16) / wheelDelta), GetMouseModifiers(wParam)); break; + case UnmanagedMethods.WindowsMessage.WM_MOUSEHWHEEL: + e = new RawMouseWheelEventArgs( + WindowsMouseDevice.Instance, + timestamp, + _owner, + ScreenToClient(DipFromLParam(lParam)), + new Vector(-((int)wParam >> 16) / wheelDelta,0), GetMouseModifiers(wParam)); + break; case UnmanagedMethods.WindowsMessage.WM_MOUSELEAVE: _trackingMouse = false; From b9ad9b82ce72f1d4a68894414a9ceca06674df9e Mon Sep 17 00:00:00 2001 From: donandren Date: Sat, 18 Jun 2016 14:43:19 +0300 Subject: [PATCH 2/2] process scroll events in ScrollContentPresenter in more generic way (support also horizontal scroll) and horizontal scroll support in VirtualizationMode --- .../Presenters/ItemsPresenter.cs | 2 +- .../Presenters/ScrollContentPresenter.cs | 32 +++++++++++-------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Avalonia.Controls/Presenters/ItemsPresenter.cs b/src/Avalonia.Controls/Presenters/ItemsPresenter.cs index 4547c8fd45..ffc2680c83 100644 --- a/src/Avalonia.Controls/Presenters/ItemsPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ItemsPresenter.cs @@ -69,7 +69,7 @@ namespace Avalonia.Controls.Presenters Action ILogicalScrollable.InvalidateScroll { get; set; } /// - Size ILogicalScrollable.ScrollSize => new Size(0, 1); + Size ILogicalScrollable.ScrollSize => new Size(1, 1); /// Size ILogicalScrollable.PageScrollSize => new Size(0, 1); diff --git a/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs b/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs index e0061ed386..d9f0260e39 100644 --- a/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ScrollContentPresenter.cs @@ -231,26 +231,32 @@ namespace Avalonia.Controls.Presenters /// protected override void OnPointerWheelChanged(PointerWheelEventArgs e) { - if (Extent.Height > Viewport.Height) + if (Extent.Height > Viewport.Height || Extent.Width > Viewport.Width) { var scrollable = Child as ILogicalScrollable; + bool isLogical = scrollable?.IsLogicalScrollEnabled == true; - if (scrollable?.IsLogicalScrollEnabled == true) - { - var y = Offset.Y + (-e.Delta.Y * scrollable.ScrollSize.Height); + double x = Offset.X; + double y = Offset.Y; + + if (Extent.Height > Viewport.Height) + { + double height = isLogical ? scrollable.ScrollSize.Height : 50; + y += -e.Delta.Y * height; y = Math.Max(y, 0); y = Math.Min(y, Extent.Height - Viewport.Height); - Offset = new Vector(Offset.X, y); - e.Handled = true; } - else + + if (Extent.Width > Viewport.Width) { - var y = Offset.Y + (-e.Delta.Y * 50); - y = Math.Max(y, 0); - y = Math.Min(y, Extent.Height - Viewport.Height); - Offset = new Vector(Offset.X, y); - e.Handled = true; + double width = isLogical ? scrollable.ScrollSize.Width : 50; + x += -e.Delta.X * width; + x = Math.Max(x, 0); + x = Math.Min(x, Extent.Width - Viewport.Width); } + + Offset = new Vector(x, y); + e.Handled = true; } } @@ -308,4 +314,4 @@ namespace Avalonia.Controls.Presenters } } } -} +} \ No newline at end of file