From 92c9d1dbf33ee369672e932a6134a79a2d6cb803 Mon Sep 17 00:00:00 2001 From: Benedikt Schroeder Date: Wed, 5 Jun 2019 14:58:48 +0200 Subject: [PATCH 1/4] Use star sized row instead of auto row --- samples/ControlCatalog/Pages/DataGridPage.xaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/ControlCatalog/Pages/DataGridPage.xaml b/samples/ControlCatalog/Pages/DataGridPage.xaml index 268b06f756..d1742c12b7 100644 --- a/samples/ControlCatalog/Pages/DataGridPage.xaml +++ b/samples/ControlCatalog/Pages/DataGridPage.xaml @@ -11,7 +11,7 @@ - + DataGrid A control for displaying and interacting with a data source. @@ -52,4 +52,4 @@ - \ No newline at end of file + From 85a5288fdd835481764ffc6c10dfb77c90708c3a Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Thu, 6 Jun 2019 12:47:05 +0300 Subject: [PATCH 2/4] Propagate mouse pointer capture to Win32 API --- src/Avalonia.Input/MouseDevice.cs | 9 ++++-- src/Avalonia.Input/Pointer.cs | 6 ++++ .../Wpf/WpfMouseDevice.cs | 28 +++++++++++++------ .../Input/WindowsMouseDevice.cs | 26 ++++++++++++----- src/Windows/Avalonia.Win32/WindowImpl.cs | 2 ++ 5 files changed, 53 insertions(+), 18 deletions(-) diff --git a/src/Avalonia.Input/MouseDevice.cs b/src/Avalonia.Input/MouseDevice.cs index 4c4d679087..ee7d0c9501 100644 --- a/src/Avalonia.Input/MouseDevice.cs +++ b/src/Avalonia.Input/MouseDevice.cs @@ -20,8 +20,13 @@ namespace Avalonia.Input private Rect _lastClickRect; private ulong _lastClickTime; - private readonly Pointer _pointer = new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true); + private readonly Pointer _pointer; + public MouseDevice(Pointer pointer = null) + { + _pointer = pointer ?? new Pointer(Pointer.GetNextFreeId(), PointerType.Mouse, true); + } + /// /// Gets the control that is currently capturing by the mouse, if any. /// @@ -51,7 +56,7 @@ namespace Avalonia.Input /// within the control's bounds or not. The current mouse capture control is exposed /// by the property. /// - public virtual void Capture(IInputElement control) + public void Capture(IInputElement control) { _pointer.Capture(control); } diff --git a/src/Avalonia.Input/Pointer.cs b/src/Avalonia.Input/Pointer.cs index 890ad57024..80d803abb1 100644 --- a/src/Avalonia.Input/Pointer.cs +++ b/src/Avalonia.Input/Pointer.cs @@ -27,6 +27,11 @@ namespace Avalonia.Input var seen = new HashSet(control1.GetSelfAndVisualAncestors().OfType()); return control2.GetSelfAndVisualAncestors().OfType().FirstOrDefault(seen.Contains); } + + protected virtual void PlatformCapture(IInputElement element) + { + + } public void Capture(IInputElement control) { @@ -34,6 +39,7 @@ namespace Avalonia.Input Captured.DetachedFromVisualTree -= OnCaptureDetached; var oldCapture = control; Captured = control; + PlatformCapture(control); if (oldCapture != null) { var commonParent = FindCommonParent(control, oldCapture); diff --git a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfMouseDevice.cs b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfMouseDevice.cs index 0d93115714..ebfe8cde47 100644 --- a/src/Windows/Avalonia.Win32.Interop/Wpf/WpfMouseDevice.cs +++ b/src/Windows/Avalonia.Win32.Interop/Wpf/WpfMouseDevice.cs @@ -9,22 +9,32 @@ namespace Avalonia.Win32.Interop.Wpf { private readonly WpfTopLevelImpl _impl; - public WpfMouseDevice(WpfTopLevelImpl impl) + public WpfMouseDevice(WpfTopLevelImpl impl) : base(new WpfMousePointer(impl)) { _impl = impl; } - public override void Capture(IInputElement control) + class WpfMousePointer : Pointer { - if (control == null) + private readonly WpfTopLevelImpl _impl; + + public WpfMousePointer(WpfTopLevelImpl impl) : base(Pointer.GetNextFreeId(), PointerType.Mouse, true) + { + _impl = impl; + } + + protected override void PlatformCapture(IInputElement control) { - System.Windows.Input.Mouse.Capture(null); + if (control == null) + { + System.Windows.Input.Mouse.Capture(null); + } + else if ((control.GetVisualRoot() as EmbeddableControlRoot)?.PlatformImpl != _impl) + throw new ArgumentException("Visual belongs to unknown toplevel"); + else + System.Windows.Input.Mouse.Capture(_impl); } - else if ((control.GetVisualRoot() as EmbeddableControlRoot)?.PlatformImpl != _impl) - throw new ArgumentException("Visual belongs to unknown toplevel"); - else - System.Windows.Input.Mouse.Capture(_impl); - base.Capture(control); } + } } diff --git a/src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs b/src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs index 2b4105efee..e7c379ad89 100644 --- a/src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs +++ b/src/Windows/Avalonia.Win32/Input/WindowsMouseDevice.cs @@ -1,7 +1,10 @@ // Copyright (c) The Avalonia Project. All rights reserved. // Licensed under the MIT license. See licence.md file in the project root for full license information. +using System; +using Avalonia.Controls; using Avalonia.Input; +using Avalonia.VisualTree; using Avalonia.Win32.Interop; namespace Avalonia.Win32.Input @@ -10,23 +13,32 @@ namespace Avalonia.Win32.Input { public static WindowsMouseDevice Instance { get; } = new WindowsMouseDevice(); + public WindowsMouseDevice() : base(new WindowsMousePointer()) + { + + } + public WindowImpl CurrentWindow { get; set; } - public override void Capture(IInputElement control) + class WindowsMousePointer : Pointer { - base.Capture(control); - - if (control != null) + public WindowsMousePointer() : base(Pointer.GetNextFreeId(),PointerType.Mouse, true) { - UnmanagedMethods.SetCapture(CurrentWindow.Handle.Handle); } - else + + protected override void PlatformCapture(IInputElement element) { - UnmanagedMethods.ReleaseCapture(); + var hwnd = ((element?.GetVisualRoot() as TopLevel)?.PlatformImpl as WindowImpl) + ?.Handle.Handle; + + if (hwnd.HasValue && hwnd != IntPtr.Zero) + UnmanagedMethods.SetCapture(hwnd.Value); + else + UnmanagedMethods.ReleaseCapture(); } } } diff --git a/src/Windows/Avalonia.Win32/WindowImpl.cs b/src/Windows/Avalonia.Win32/WindowImpl.cs index 9e8b2d58a6..5cc148fa0d 100644 --- a/src/Windows/Avalonia.Win32/WindowImpl.cs +++ b/src/Windows/Avalonia.Win32/WindowImpl.cs @@ -336,6 +336,7 @@ namespace Avalonia.Win32 public void BeginMoveDrag() { + WindowsMouseDevice.Instance.Capture(null); UnmanagedMethods.DefWindowProc(_hwnd, (int)UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN, new IntPtr((int)UnmanagedMethods.HitTestValues.HTCAPTION), IntPtr.Zero); } @@ -357,6 +358,7 @@ namespace Avalonia.Win32 #if USE_MANAGED_DRAG _managedDrag.BeginResizeDrag(edge, ScreenToClient(MouseDevice.Position)); #else + WindowsMouseDevice.Instance.Capture(null); UnmanagedMethods.DefWindowProc(_hwnd, (int)UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN, new IntPtr((int)EdgeDic[edge]), IntPtr.Zero); #endif From 39b19e8ff30a9154535fbd207961de9e6d838332 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Pedro?= Date: Fri, 7 Jun 2019 23:41:06 +0100 Subject: [PATCH 3/4] XML comment fixes. --- src/Avalonia.Base/Utilities/MathUtilities.cs | 5 ++++- src/Avalonia.Controls/Grid.cs | 8 ++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Avalonia.Base/Utilities/MathUtilities.cs b/src/Avalonia.Base/Utilities/MathUtilities.cs index 546133bb03..41b57b6e70 100644 --- a/src/Avalonia.Base/Utilities/MathUtilities.cs +++ b/src/Avalonia.Base/Utilities/MathUtilities.cs @@ -30,6 +30,7 @@ namespace Avalonia.Utilities /// LessThan - Returns whether or not the first double is less than the second double. /// That is, whether or not the first is strictly less than *and* not within epsilon of /// the other number. + /// /// The first double to compare. /// The second double to compare. public static bool LessThan(double value1, double value2) @@ -41,6 +42,7 @@ namespace Avalonia.Utilities /// GreaterThan - Returns whether or not the first double is greater than the second double. /// That is, whether or not the first is strictly greater than *and* not within epsilon of /// the other number. + /// /// The first double to compare. /// The second double to compare. public static bool GreaterThan(double value1, double value2) @@ -52,6 +54,7 @@ namespace Avalonia.Utilities /// LessThanOrClose - Returns whether or not the first double is less than or close to /// the second double. That is, whether or not the first is strictly less than or within /// epsilon of the other number. + /// /// The first double to compare. /// The second double to compare. public static bool LessThanOrClose(double value1, double value2) @@ -170,4 +173,4 @@ namespace Avalonia.Utilities } } } -} \ No newline at end of file +} diff --git a/src/Avalonia.Controls/Grid.cs b/src/Avalonia.Controls/Grid.cs index fc61c409f0..6d3b9f37cf 100644 --- a/src/Avalonia.Controls/Grid.cs +++ b/src/Avalonia.Controls/Grid.cs @@ -1969,7 +1969,7 @@ namespace Avalonia.Controls /// /// Array of definitions to process. /// Final size to lay out to. - /// True if sizing row definitions, false for columns + /// True if sizing column definitions, false for rows private void SetFinalSize( IReadOnlyList definitions, double finalSize, @@ -2694,9 +2694,9 @@ namespace Avalonia.Controls /// if the max constraint has higher discrepancy /// null if proportion doesn't fail a min or max constraint /// The discrepancy is the ratio of the proportion to the max- or min-ratio. - /// When both ratios hit the constraint, minRatio < proportion < maxRatio, + /// When both ratios hit the constraint, minRatio < proportion > maxRatio, /// and the minRatio has higher discrepancy if - /// (proportion / minRatio) > (maxRatio / proportion) + /// (proportion / minRatio) > (maxRatio / proportion) /// private static bool? Choose(double minRatio, double maxRatio, double proportion) { @@ -4063,4 +4063,4 @@ namespace Avalonia.Controls private static readonly Pen _evenDashPen; // second pen to draw dash } } -} \ No newline at end of file +} From fedbe118be3ef7b1c8cf59172c0ec84fbfe2a99a Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Sat, 8 Jun 2019 17:48:12 +0300 Subject: [PATCH 4/4] Update readme.md --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 12f683bd55..cf995f10fb 100644 --- a/readme.md +++ b/readme.md @@ -8,9 +8,9 @@ ## About -Avalonia is a WPF-inspired cross-platform XAML-based UI framework providing a flexible styling system and supporting a wide range of OSs: Windows (.NET Framework, .NET Core), Linux (GTK), MacOS, Android and iOS. +Avalonia is a WPF/UWP-inspired cross-platform XAML-based UI framework providing a flexible styling system and supporting a wide range of OSs: Windows (.NET Framework, .NET Core), Linux (libX11), MacOS, Android (experimental) and iOS (exprerimental). -**Avalonia is currently in beta** which means that the framework is generally usable for writing applications, but there may be some bugs and breaking changes as we continue development. +**Avalonia is currently in beta** which means that the framework is generally usable for writing applications, but there may be some bugs and breaking changes as we continue development, for more details about the status see https://github.com/AvaloniaUI/Avalonia/issues/2239 | Control catalog | Desktop platforms | Mobile platforms | |---|---|---|