|
|
@@ -3,6 +3,7 @@
|
|
|
|
|
|
using System;
|
|
|
using System.Linq;
|
|
|
+using Perspex.Platform;
|
|
|
using Perspex.VisualTree;
|
|
|
using Serilog;
|
|
|
using Serilog.Core.Enrichers;
|
|
|
@@ -466,6 +467,7 @@ namespace Perspex.Layout
|
|
|
.Deflate(margin);
|
|
|
|
|
|
var measured = MeasureOverride(constrained);
|
|
|
+
|
|
|
var width = measured.Width;
|
|
|
var height = measured.Height;
|
|
|
|
|
|
@@ -485,6 +487,13 @@ namespace Perspex.Layout
|
|
|
height = Math.Min(height, MaxHeight);
|
|
|
height = Math.Max(height, MinHeight);
|
|
|
|
|
|
+ if (UseLayoutRounding)
|
|
|
+ {
|
|
|
+ var scale = GetLayoutScale();
|
|
|
+ width = Math.Ceiling(width * scale) / scale;
|
|
|
+ height = Math.Ceiling(height * scale) / scale;
|
|
|
+ }
|
|
|
+
|
|
|
return NonNegative(new Size(width, height).Inflate(margin));
|
|
|
}
|
|
|
else
|
|
|
@@ -510,12 +519,6 @@ namespace Perspex.Layout
|
|
|
height = Math.Max(height, child.DesiredSize.Height);
|
|
|
}
|
|
|
|
|
|
- if (UseLayoutRounding)
|
|
|
- {
|
|
|
- width = Math.Ceiling(width);
|
|
|
- height = Math.Ceiling(height);
|
|
|
- }
|
|
|
-
|
|
|
return new Size(width, height);
|
|
|
}
|
|
|
|
|
|
@@ -537,6 +540,7 @@ namespace Perspex.Layout
|
|
|
Math.Max(0, finalRect.Width - Margin.Left - Margin.Right),
|
|
|
Math.Max(0, finalRect.Height - Margin.Top - Margin.Bottom));
|
|
|
var size = sizeMinusMargins;
|
|
|
+ var scale = GetLayoutScale();
|
|
|
|
|
|
if (HorizontalAlignment != HorizontalAlignment.Stretch)
|
|
|
{
|
|
|
@@ -553,11 +557,11 @@ namespace Perspex.Layout
|
|
|
if (UseLayoutRounding)
|
|
|
{
|
|
|
size = new Size(
|
|
|
- Math.Ceiling(size.Width),
|
|
|
- Math.Ceiling(size.Height));
|
|
|
+ Math.Ceiling(size.Width * scale) / scale,
|
|
|
+ Math.Ceiling(size.Height * scale) / scale);
|
|
|
sizeMinusMargins = new Size(
|
|
|
- Math.Ceiling(sizeMinusMargins.Width),
|
|
|
- Math.Ceiling(sizeMinusMargins.Height));
|
|
|
+ Math.Ceiling(sizeMinusMargins.Width * scale) / scale,
|
|
|
+ Math.Ceiling(sizeMinusMargins.Height * scale) / scale);
|
|
|
}
|
|
|
|
|
|
size = ArrangeOverride(size).Constrain(size);
|
|
|
@@ -586,8 +590,8 @@ namespace Perspex.Layout
|
|
|
|
|
|
if (UseLayoutRounding)
|
|
|
{
|
|
|
- originX = Math.Floor(originX);
|
|
|
- originY = Math.Floor(originY);
|
|
|
+ originX = Math.Floor(originX * scale) / scale;
|
|
|
+ originY = Math.Floor(originY * scale) / scale;
|
|
|
}
|
|
|
|
|
|
Bounds = new Rect(originX, originY, size.Width, size.Height);
|
|
|
@@ -666,5 +670,10 @@ namespace Perspex.Layout
|
|
|
{
|
|
|
return new Size(Math.Max(size.Width, 0), Math.Max(size.Height, 0));
|
|
|
}
|
|
|
+
|
|
|
+ private static double GetLayoutScale()
|
|
|
+ {
|
|
|
+ return PerspexLocator.Current.GetService<IPlatformSettings>()?.LayoutScalingFactor ?? 1.0;
|
|
|
+ }
|
|
|
}
|
|
|
}
|