From ee383659e25fb538511b9bbcfd545ef3060ec28d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dariusz=20Komosi=C5=84ski?= Date: Mon, 12 Apr 2021 23:30:54 +0200 Subject: [PATCH 1/7] Restore missing DPI correction for GridSplitter behavior. --- src/Avalonia.Controls/GridSplitter.cs | 18 ++++++++++++++---- .../Presenters/ContentPresenter.cs | 14 +------------- src/Avalonia.Layout/LayoutHelper.cs | 19 +++++++++++++++++++ src/Avalonia.Layout/Layoutable.cs | 16 ++-------------- 4 files changed, 36 insertions(+), 31 deletions(-) diff --git a/src/Avalonia.Controls/GridSplitter.cs b/src/Avalonia.Controls/GridSplitter.cs index a2d53f4f06..a38ee739bc 100644 --- a/src/Avalonia.Controls/GridSplitter.cs +++ b/src/Avalonia.Controls/GridSplitter.cs @@ -609,10 +609,20 @@ namespace Avalonia.Controls private void MoveSplitter(double horizontalChange, double verticalChange) { Debug.Assert(_resizeData != null, "_resizeData should not be null when calling MoveSplitter"); - - // Calculate the offset to adjust the splitter. - var delta = _resizeData.ResizeDirection == GridResizeDirection.Columns ? horizontalChange : verticalChange; - + + // Calculate the offset to adjust the splitter. If layout rounding is enabled, we + // need to round to an integer physical pixel value to avoid round-ups of children that + // expand the bounds of the Grid. In practice this only happens in high dpi because + // horizontal/vertical offsets here are never fractional (they correspond to mouse movement + // across logical pixels). Rounding error only creeps in when converting to a physical + // display with something other than the logical 96 dpi. + double delta = _resizeData.ResizeDirection == GridResizeDirection.Columns ? horizontalChange : verticalChange; + + if (UseLayoutRounding) + { + delta = LayoutHelper.RoundLayoutValue(delta, LayoutHelper.GetLayoutScale(this)); + } + DefinitionBase definition1 = _resizeData.Definition1; DefinitionBase definition2 = _resizeData.Definition2; diff --git a/src/Avalonia.Controls/Presenters/ContentPresenter.cs b/src/Avalonia.Controls/Presenters/ContentPresenter.cs index b28927c969..472727823a 100644 --- a/src/Avalonia.Controls/Presenters/ContentPresenter.cs +++ b/src/Avalonia.Controls/Presenters/ContentPresenter.cs @@ -378,7 +378,7 @@ namespace Avalonia.Controls.Presenters var useLayoutRounding = UseLayoutRounding; var availableSize = finalSize; var sizeForChild = availableSize; - var scale = GetLayoutScale(); + var scale = LayoutHelper.GetLayoutScale(this); var originX = offset.X; var originY = offset.Y; @@ -462,18 +462,6 @@ namespace Avalonia.Controls.Presenters PseudoClasses.Set(":empty", Content is null); } - private double GetLayoutScale() - { - var result = (VisualRoot as ILayoutRoot)?.LayoutScaling ?? 1.0; - - if (result == 0 || double.IsNaN(result) || double.IsInfinity(result)) - { - throw new Exception($"Invalid LayoutScaling returned from {VisualRoot.GetType()}"); - } - - return result; - } - private void TemplatedParentChanged(AvaloniaPropertyChangedEventArgs e) { var host = e.NewValue as IContentPresenterHost; diff --git a/src/Avalonia.Layout/LayoutHelper.cs b/src/Avalonia.Layout/LayoutHelper.cs index 3708748ad1..8ad972059f 100644 --- a/src/Avalonia.Layout/LayoutHelper.cs +++ b/src/Avalonia.Layout/LayoutHelper.cs @@ -82,6 +82,25 @@ namespace Avalonia.Layout InnerInvalidateMeasure(control); } + /// + /// Obtains layout scale of the given control. + /// + /// The control. + /// Thrown when control has no root or returned layout scaling is invalid. + public static double GetLayoutScale(ILayoutable control) + { + var visualRoot = control.VisualRoot; + + var result = (visualRoot as ILayoutRoot)?.LayoutScaling ?? 1.0; + + if (result == 0 || double.IsNaN(result) || double.IsInfinity(result)) + { + throw new Exception($"Invalid LayoutScaling returned from {visualRoot.GetType()}"); + } + + return result; + } + /// /// Rounds a size to integer values for layout purposes, compensating for high DPI screen /// coordinates. diff --git a/src/Avalonia.Layout/Layoutable.cs b/src/Avalonia.Layout/Layoutable.cs index aca2965ea6..a1d00017ed 100644 --- a/src/Avalonia.Layout/Layoutable.cs +++ b/src/Avalonia.Layout/Layoutable.cs @@ -590,7 +590,7 @@ namespace Avalonia.Layout if (UseLayoutRounding) { - var scale = GetLayoutScale(); + var scale = LayoutHelper.GetLayoutScale(this); width = LayoutHelper.RoundLayoutValue(width, scale); height = LayoutHelper.RoundLayoutValue(height, scale); } @@ -652,7 +652,7 @@ namespace Avalonia.Layout var horizontalAlignment = HorizontalAlignment; var verticalAlignment = VerticalAlignment; var size = availableSizeMinusMargins; - var scale = GetLayoutScale(); + var scale = LayoutHelper.GetLayoutScale(this); var useLayoutRounding = UseLayoutRounding; if (horizontalAlignment != HorizontalAlignment.Stretch) @@ -833,17 +833,5 @@ namespace Avalonia.Layout { return new Size(Math.Max(size.Width, 0), Math.Max(size.Height, 0)); } - - private double GetLayoutScale() - { - var result = (VisualRoot as ILayoutRoot)?.LayoutScaling ?? 1.0; - - if (result == 0 || double.IsNaN(result) || double.IsInfinity(result)) - { - throw new Exception($"Invalid LayoutScaling returned from {VisualRoot.GetType()}"); - } - - return result; - } } } From 57ec11d9d35ae1df091e271fc3b7666c17c6a77f Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Thu, 15 Apr 2021 13:57:19 +0100 Subject: [PATCH 2/7] upstream relativepanel fixes from https://github.com/HandyOrg/HandyControl/commit/f4d4bdde1036ab3e160e805a40dea127d72616a5 --- src/Avalonia.Controls/RelativePanel.cs | 46 ++++++++++++++------------ 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/Avalonia.Controls/RelativePanel.cs b/src/Avalonia.Controls/RelativePanel.cs index 27f13a3f57..8fe56d1fb2 100644 --- a/src/Avalonia.Controls/RelativePanel.cs +++ b/src/Avalonia.Controls/RelativePanel.cs @@ -55,7 +55,7 @@ namespace Avalonia.Controls _childGraph.Measure(availableSize); _childGraph.Reset(false); - var boundingSize = _childGraph.GetBoundingSize(Width.IsNaN(), Height.IsNaN()); + var boundingSize = _childGraph.GetBoundingSize(Width.IsNaN(), Height.IsNaN(), availableSize); _childGraph.Reset(); _childGraph.Measure(boundingSize); return boundingSize; @@ -286,6 +286,8 @@ namespace Avalonia.Controls private void MeasureChild(GraphNode node) { + var availableSize = AvailableSize; + var child = node.Element; child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); node.OriginDesiredSize = child.DesiredSize; @@ -328,10 +330,10 @@ namespace Avalonia.Controls : node.AlignBottomWithNode.Bottom * 0.5; } - var availableHeight = AvailableSize.Height - node.Top - node.Bottom; + var availableHeight = availableSize.Height - node.Top - node.Bottom; if (availableHeight.IsNaN()) { - availableHeight = AvailableSize.Height; + availableHeight = availableSize.Height; if (!node.Top.IsNaN() && node.Bottom.IsNaN()) { @@ -343,10 +345,10 @@ namespace Avalonia.Controls } } - var availableWidth = AvailableSize.Width - node.Left - node.Right; + var availableWidth = availableSize.Width - node.Left - node.Right; if (availableWidth.IsNaN()) { - availableWidth = AvailableSize.Width; + availableWidth = availableSize.Width; if (!node.Left.IsNaN() && node.Right.IsNaN()) { @@ -380,7 +382,7 @@ namespace Avalonia.Controls if (node.Left.IsNaN()) { - node.Left = AvailableSize.Width - node.RightOfNode.Right; + node.Left = availableSize.Width - node.RightOfNode.Right; } } @@ -393,14 +395,14 @@ namespace Avalonia.Controls if (node.Top.IsNaN()) { - node.Top = AvailableSize.Height - node.BelowNode.Bottom; + node.Top = availableSize.Height - node.BelowNode.Bottom; } } if (node.AlignHorizontalCenterWith != null) { - var halfWidthLeft = (AvailableSize.Width + node.AlignHorizontalCenterWith.Left - node.AlignHorizontalCenterWith.Right - childSize.Width) * 0.5; - var halfWidthRight = (AvailableSize.Width - node.AlignHorizontalCenterWith.Left + node.AlignHorizontalCenterWith.Right - childSize.Width) * 0.5; + var halfWidthLeft = (availableSize.Width + node.AlignHorizontalCenterWith.Left - node.AlignHorizontalCenterWith.Right - childSize.Width) * 0.5; + var halfWidthRight = (availableSize.Width - node.AlignHorizontalCenterWith.Left + node.AlignHorizontalCenterWith.Right - childSize.Width) * 0.5; if (node.Left.IsNaN()) node.Left = halfWidthLeft; @@ -415,8 +417,8 @@ namespace Avalonia.Controls if (node.AlignVerticalCenterWith != null) { - var halfHeightTop = (AvailableSize.Height + node.AlignVerticalCenterWith.Top - node.AlignVerticalCenterWith.Bottom - childSize.Height) * 0.5; - var halfHeightBottom = (AvailableSize.Height - node.AlignVerticalCenterWith.Top + node.AlignVerticalCenterWith.Bottom - childSize.Height) * 0.5; + var halfHeightTop = (availableSize.Height + node.AlignVerticalCenterWith.Top - node.AlignVerticalCenterWith.Bottom - childSize.Height) * 0.5; + var halfHeightBottom = (availableSize.Height - node.AlignVerticalCenterWith.Top + node.AlignVerticalCenterWith.Bottom - childSize.Height) * 0.5; if (node.Top.IsNaN()) node.Top = halfHeightTop; @@ -431,7 +433,7 @@ namespace Avalonia.Controls if (GetAlignHorizontalCenterWithPanel(child)) { - var halfSubWidth = (AvailableSize.Width - childSize.Width) * 0.5; + var halfSubWidth = (availableSize.Width - childSize.Width) * 0.5; if (node.Left.IsNaN()) node.Left = halfSubWidth; @@ -446,7 +448,7 @@ namespace Avalonia.Controls if (GetAlignVerticalCenterWithPanel(child)) { - var halfSubHeight = (AvailableSize.Height - childSize.Height) * 0.5; + var halfSubHeight = (availableSize.Height - childSize.Height) * 0.5; if (node.Top.IsNaN()) node.Top = halfSubHeight; @@ -462,37 +464,37 @@ namespace Avalonia.Controls if (node.Left.IsNaN()) { if (!node.Right.IsNaN()) - node.Left = AvailableSize.Width - node.Right - childSize.Width; + node.Left = availableSize.Width - node.Right - childSize.Width; else { node.Left = 0; - node.Right = AvailableSize.Width - childSize.Width; + node.Right = availableSize.Width - childSize.Width; } } else if (!node.Left.IsNaN() && node.Right.IsNaN()) { - node.Right = AvailableSize.Width - node.Left - childSize.Width; + node.Right = availableSize.Width - node.Left - childSize.Width; } if (node.Top.IsNaN()) { if (!node.Bottom.IsNaN()) - node.Top = AvailableSize.Height - node.Bottom - childSize.Height; + node.Top = availableSize.Height - node.Bottom - childSize.Height; else { node.Top = 0; - node.Bottom = AvailableSize.Height - childSize.Height; + node.Bottom = availableSize.Height - childSize.Height; } } else if (!node.Top.IsNaN() && node.Bottom.IsNaN()) { - node.Bottom = AvailableSize.Height - node.Top - childSize.Height; + node.Bottom = availableSize.Height - node.Top - childSize.Height; } node.Measured = true; } - public Size GetBoundingSize(bool calcWidth, bool calcHeight) + public Size GetBoundingSize(bool calcWidth, bool calcHeight, Size availableSize) { var boundingSize = new Size(); @@ -503,8 +505,8 @@ namespace Avalonia.Controls boundingSize = boundingSize.WithHeight(Math.Max(boundingSize.Height, size.Height)); } - boundingSize = boundingSize.WithWidth(calcWidth ? boundingSize.Width : AvailableSize.Width); - boundingSize = boundingSize.WithHeight(calcHeight ? boundingSize.Height : AvailableSize.Height); + boundingSize = boundingSize.WithWidth(calcWidth ? Math.Max(availableSize.Width, boundingSize.Width) : availableSize.Width); + boundingSize = boundingSize.WithHeight(calcHeight ? Math.Max(availableSize.Height, boundingSize.Height) : availableSize.Height); return boundingSize; } } From 3ac615c4e31e2cc96ff76c67f0d06b6daaf285d3 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Sun, 18 Apr 2021 17:06:12 +0200 Subject: [PATCH 3/7] Make GritSplitter calculations match the ones in WPF. --- src/Avalonia.Base/Utilities/MathUtilities.cs | 15 +++++++++++++++ src/Avalonia.Controls/GridSplitter.cs | 4 ++-- src/Avalonia.Layout/LayoutHelper.cs | 6 ++++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/src/Avalonia.Base/Utilities/MathUtilities.cs b/src/Avalonia.Base/Utilities/MathUtilities.cs index 446b366dc8..1ea369954a 100644 --- a/src/Avalonia.Base/Utilities/MathUtilities.cs +++ b/src/Avalonia.Base/Utilities/MathUtilities.cs @@ -30,6 +30,21 @@ namespace Avalonia.Utilities return (-eps < delta) && (eps > delta); } + /// + /// AreClose - Returns whether or not two doubles are "close". That is, whether or + /// not they are within epsilon of each other. + /// + /// The first double to compare. + /// The second double to compare. + /// The fixed epsilon value used to compare. + public static bool AreClose(double value1, double value2, double eps) + { + //in case they are Infinities (then epsilon check does not work) + if (value1 == value2) return true; + double delta = value1 - value2; + return (-eps < delta) && (eps > delta); + } + /// /// AreClose - Returns whether or not two floats are "close". That is, whether or /// not they are within epsilon of each other. diff --git a/src/Avalonia.Controls/GridSplitter.cs b/src/Avalonia.Controls/GridSplitter.cs index a38ee739bc..26c8464576 100644 --- a/src/Avalonia.Controls/GridSplitter.cs +++ b/src/Avalonia.Controls/GridSplitter.cs @@ -632,11 +632,11 @@ namespace Avalonia.Controls double actualLength2 = GetActualLength(definition2); // When splitting, Check to see if the total pixels spanned by the definitions - // is the same asbefore starting resize. If not cancel the drag + // is the same as before starting resize. If not cancel the drag. if (_resizeData.SplitBehavior == SplitBehavior.Split && !MathUtilities.AreClose( actualLength1 + actualLength2, - _resizeData.OriginalDefinition1ActualLength + _resizeData.OriginalDefinition2ActualLength)) + _resizeData.OriginalDefinition1ActualLength + _resizeData.OriginalDefinition2ActualLength, LayoutHelper.LayoutEpsilon)) { CancelResize(); diff --git a/src/Avalonia.Layout/LayoutHelper.cs b/src/Avalonia.Layout/LayoutHelper.cs index 8ad972059f..35eae0f54c 100644 --- a/src/Avalonia.Layout/LayoutHelper.cs +++ b/src/Avalonia.Layout/LayoutHelper.cs @@ -9,6 +9,12 @@ namespace Avalonia.Layout /// public static class LayoutHelper { + /// + /// Epsilon value used for certain layout calculations. + /// Based on the value in WPF LayoutDoubleUtil. + /// + public const double LayoutEpsilon = 0.00000153; + /// /// Calculates a control's size based on its , /// , , From c2790472b5d8c4f7b753e65c4e2c1c2b1d268477 Mon Sep 17 00:00:00 2001 From: Dariusz Komosinski Date: Mon, 19 Apr 2021 11:24:30 +0200 Subject: [PATCH 4/7] Made LayoutEpsilon a property. --- src/Avalonia.Layout/LayoutHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Layout/LayoutHelper.cs b/src/Avalonia.Layout/LayoutHelper.cs index 35eae0f54c..2fe59b49ca 100644 --- a/src/Avalonia.Layout/LayoutHelper.cs +++ b/src/Avalonia.Layout/LayoutHelper.cs @@ -13,7 +13,7 @@ namespace Avalonia.Layout /// Epsilon value used for certain layout calculations. /// Based on the value in WPF LayoutDoubleUtil. /// - public const double LayoutEpsilon = 0.00000153; + public static double LayoutEpsilon { get; } = 0.00000153; /// /// Calculates a control's size based on its , From 84bc8b682cd491ccd8e606699c29f495c4cf2fd3 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 19 Apr 2021 19:33:10 +0100 Subject: [PATCH 5/7] upstream fix https://github.com/HandyOrg/HandyControl/commit/916d3d12b2f04ea5115cc0088589741a64b62a0e --- src/Avalonia.Controls/RelativePanel.cs | 49 +++++++++++++------------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/src/Avalonia.Controls/RelativePanel.cs b/src/Avalonia.Controls/RelativePanel.cs index 8fe56d1fb2..2305d8fb9e 100644 --- a/src/Avalonia.Controls/RelativePanel.cs +++ b/src/Avalonia.Controls/RelativePanel.cs @@ -55,7 +55,10 @@ namespace Avalonia.Controls _childGraph.Measure(availableSize); _childGraph.Reset(false); - var boundingSize = _childGraph.GetBoundingSize(Width.IsNaN(), Height.IsNaN(), availableSize); + var calcWidth = Width.IsNaN() && HorizontalAlignment != HorizontalAlignment.Stretch; + var calcHeight = Height.IsNaN() && VerticalAlignment != VerticalAlignment.Stretch; + + var boundingSize = _childGraph.GetBoundingSize(calcWidth, calcHeight); _childGraph.Reset(); _childGraph.Measure(boundingSize); return boundingSize; @@ -286,8 +289,6 @@ namespace Avalonia.Controls private void MeasureChild(GraphNode node) { - var availableSize = AvailableSize; - var child = node.Element; child.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); node.OriginDesiredSize = child.DesiredSize; @@ -330,10 +331,10 @@ namespace Avalonia.Controls : node.AlignBottomWithNode.Bottom * 0.5; } - var availableHeight = availableSize.Height - node.Top - node.Bottom; + var availableHeight = AvailableSize.Height - node.Top - node.Bottom; if (availableHeight.IsNaN()) { - availableHeight = availableSize.Height; + availableHeight = AvailableSize.Height; if (!node.Top.IsNaN() && node.Bottom.IsNaN()) { @@ -345,10 +346,10 @@ namespace Avalonia.Controls } } - var availableWidth = availableSize.Width - node.Left - node.Right; + var availableWidth = AvailableSize.Width - node.Left - node.Right; if (availableWidth.IsNaN()) { - availableWidth = availableSize.Width; + availableWidth = AvailableSize.Width; if (!node.Left.IsNaN() && node.Right.IsNaN()) { @@ -382,7 +383,7 @@ namespace Avalonia.Controls if (node.Left.IsNaN()) { - node.Left = availableSize.Width - node.RightOfNode.Right; + node.Left = AvailableSize.Width - node.RightOfNode.Right; } } @@ -395,14 +396,14 @@ namespace Avalonia.Controls if (node.Top.IsNaN()) { - node.Top = availableSize.Height - node.BelowNode.Bottom; + node.Top = AvailableSize.Height - node.BelowNode.Bottom; } } if (node.AlignHorizontalCenterWith != null) { - var halfWidthLeft = (availableSize.Width + node.AlignHorizontalCenterWith.Left - node.AlignHorizontalCenterWith.Right - childSize.Width) * 0.5; - var halfWidthRight = (availableSize.Width - node.AlignHorizontalCenterWith.Left + node.AlignHorizontalCenterWith.Right - childSize.Width) * 0.5; + var halfWidthLeft = (AvailableSize.Width + node.AlignHorizontalCenterWith.Left - node.AlignHorizontalCenterWith.Right - childSize.Width) * 0.5; + var halfWidthRight = (AvailableSize.Width - node.AlignHorizontalCenterWith.Left + node.AlignHorizontalCenterWith.Right - childSize.Width) * 0.5; if (node.Left.IsNaN()) node.Left = halfWidthLeft; @@ -417,8 +418,8 @@ namespace Avalonia.Controls if (node.AlignVerticalCenterWith != null) { - var halfHeightTop = (availableSize.Height + node.AlignVerticalCenterWith.Top - node.AlignVerticalCenterWith.Bottom - childSize.Height) * 0.5; - var halfHeightBottom = (availableSize.Height - node.AlignVerticalCenterWith.Top + node.AlignVerticalCenterWith.Bottom - childSize.Height) * 0.5; + var halfHeightTop = (AvailableSize.Height + node.AlignVerticalCenterWith.Top - node.AlignVerticalCenterWith.Bottom - childSize.Height) * 0.5; + var halfHeightBottom = (AvailableSize.Height - node.AlignVerticalCenterWith.Top + node.AlignVerticalCenterWith.Bottom - childSize.Height) * 0.5; if (node.Top.IsNaN()) node.Top = halfHeightTop; @@ -433,7 +434,7 @@ namespace Avalonia.Controls if (GetAlignHorizontalCenterWithPanel(child)) { - var halfSubWidth = (availableSize.Width - childSize.Width) * 0.5; + var halfSubWidth = (AvailableSize.Width - childSize.Width) * 0.5; if (node.Left.IsNaN()) node.Left = halfSubWidth; @@ -448,7 +449,7 @@ namespace Avalonia.Controls if (GetAlignVerticalCenterWithPanel(child)) { - var halfSubHeight = (availableSize.Height - childSize.Height) * 0.5; + var halfSubHeight = (AvailableSize.Height - childSize.Height) * 0.5; if (node.Top.IsNaN()) node.Top = halfSubHeight; @@ -464,37 +465,37 @@ namespace Avalonia.Controls if (node.Left.IsNaN()) { if (!node.Right.IsNaN()) - node.Left = availableSize.Width - node.Right - childSize.Width; + node.Left = AvailableSize.Width - node.Right - childSize.Width; else { node.Left = 0; - node.Right = availableSize.Width - childSize.Width; + node.Right = AvailableSize.Width - childSize.Width; } } else if (!node.Left.IsNaN() && node.Right.IsNaN()) { - node.Right = availableSize.Width - node.Left - childSize.Width; + node.Right = AvailableSize.Width - node.Left - childSize.Width; } if (node.Top.IsNaN()) { if (!node.Bottom.IsNaN()) - node.Top = availableSize.Height - node.Bottom - childSize.Height; + node.Top = AvailableSize.Height - node.Bottom - childSize.Height; else { node.Top = 0; - node.Bottom = availableSize.Height - childSize.Height; + node.Bottom = AvailableSize.Height - childSize.Height; } } else if (!node.Top.IsNaN() && node.Bottom.IsNaN()) { - node.Bottom = availableSize.Height - node.Top - childSize.Height; + node.Bottom = AvailableSize.Height - node.Top - childSize.Height; } node.Measured = true; } - public Size GetBoundingSize(bool calcWidth, bool calcHeight, Size availableSize) + public Size GetBoundingSize(bool calcWidth, bool calcHeight) { var boundingSize = new Size(); @@ -505,8 +506,8 @@ namespace Avalonia.Controls boundingSize = boundingSize.WithHeight(Math.Max(boundingSize.Height, size.Height)); } - boundingSize = boundingSize.WithWidth(calcWidth ? Math.Max(availableSize.Width, boundingSize.Width) : availableSize.Width); - boundingSize = boundingSize.WithHeight(calcHeight ? Math.Max(availableSize.Height, boundingSize.Height) : availableSize.Height); + boundingSize = boundingSize.WithWidth(calcWidth ? boundingSize.Width : AvailableSize.Width); + boundingSize = boundingSize.WithHeight(calcHeight ? boundingSize.Height : AvailableSize.Height); return boundingSize; } } From c39fa50efc30769073ec8d37725c7dab53fd4b6c Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Mon, 19 Apr 2021 20:03:35 +0100 Subject: [PATCH 6/7] [osx] if app only has an app menu and no window menu, ensure its applied when window is first shown. --- native/Avalonia.Native/src/OSX/window.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/native/Avalonia.Native/src/OSX/window.mm b/native/Avalonia.Native/src/OSX/window.mm index b46655c7df..d7afbdaa3a 100644 --- a/native/Avalonia.Native/src/OSX/window.mm +++ b/native/Avalonia.Native/src/OSX/window.mm @@ -1936,6 +1936,10 @@ NSArray* AllLoopModes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEvent [NSApp setMenu:_menu]; } + else + { + [self showAppMenuOnly]; + } } -(void) showAppMenuOnly From ccfcf0e343cc75624f35f8c7d78592b222ef5772 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 21 Apr 2021 11:10:16 +0300 Subject: [PATCH 7/7] NativeControlHost: fixed absolute bounds calculation --- src/Avalonia.Controls/NativeControlHost.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/NativeControlHost.cs b/src/Avalonia.Controls/NativeControlHost.cs index c2fe1bb691..e18b7a5ba2 100644 --- a/src/Avalonia.Controls/NativeControlHost.cs +++ b/src/Avalonia.Controls/NativeControlHost.cs @@ -120,7 +120,7 @@ namespace Avalonia.Controls private Rect? GetAbsoluteBounds() { var bounds = Bounds; - var position = this.TranslatePoint(bounds.Position, _currentRoot); + var position = this.TranslatePoint(default, _currentRoot); if (position == null) return null; return new Rect(position.Value, bounds.Size);