|
|
|
@ -228,6 +228,7 @@ namespace Avalonia.Controls |
|
|
|
bool itemExists = false; |
|
|
|
bool lineExists = false; |
|
|
|
var itemsAlignment = ItemsAlignment; |
|
|
|
var useLayoutRounding = UseLayoutRounding; |
|
|
|
// If we have infinite space on the U axis, we always use Start alignment to avoid strange behavior
|
|
|
|
if (uvConstraint.U is double.PositiveInfinity) |
|
|
|
itemsAlignment = WrapPanelItemsAlignment.Start; |
|
|
|
@ -250,7 +251,7 @@ namespace Avalonia.Controls |
|
|
|
itemHeightSet ? itemHeight : child.DesiredSize.Height); |
|
|
|
|
|
|
|
var nextSpacing = itemExists && child.IsVisible ? itemSpacing : 0; |
|
|
|
if (MathUtilities.GreaterThan(curLineSize.U + childSize.U + nextSpacing, uvConstraint.U)) // Need to switch to another line
|
|
|
|
if (GreaterThan(useLayoutRounding, curLineSize.U + childSize.U + nextSpacing, uvConstraint.U)) // Need to switch to another line
|
|
|
|
{ |
|
|
|
panelSize.U = Max(curLineSize.U, panelSize.U); |
|
|
|
panelSize.V += curLineSize.V + (lineExists ? lineSpacing : 0); |
|
|
|
@ -299,6 +300,7 @@ namespace Avalonia.Controls |
|
|
|
bool itemExists = false; |
|
|
|
bool lineExists = false; |
|
|
|
var itemsAlignment = ItemsAlignment; |
|
|
|
var useLayoutRounding = UseLayoutRounding; |
|
|
|
// If we have infinite space on the U axis, we always use Start alignment to avoid strange behavior
|
|
|
|
if (uvFinalSize.U is double.PositiveInfinity) |
|
|
|
itemsAlignment = WrapPanelItemsAlignment.Start; |
|
|
|
@ -311,7 +313,7 @@ namespace Avalonia.Controls |
|
|
|
itemHeightSet ? itemHeight : child.DesiredSize.Height); |
|
|
|
|
|
|
|
var nextSpacing = itemExists && child.IsVisible ? itemSpacing : 0; |
|
|
|
if (MathUtilities.GreaterThan(curLineSize.U + childSize.U + nextSpacing, uvFinalSize.U)) // Need to switch to another line
|
|
|
|
if (GreaterThan(useLayoutRounding, curLineSize.U + childSize.U + nextSpacing, uvFinalSize.U)) // Need to switch to another line
|
|
|
|
{ |
|
|
|
accumulatedV += lineExists ? lineSpacing : 0; // add spacing to arrange line first
|
|
|
|
ArrangeLine(curLineSize.V, firstInLine, i); |
|
|
|
@ -408,6 +410,13 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private static bool GreaterThan(bool useLayoutRounding, double value1, double value2) |
|
|
|
{ |
|
|
|
return useLayoutRounding |
|
|
|
? value1 > value2 && value1 - value2 > LayoutHelper.LayoutEpsilon |
|
|
|
: MathUtilities.GreaterThan(value1, value2); |
|
|
|
} |
|
|
|
|
|
|
|
private struct UVSize |
|
|
|
{ |
|
|
|
internal UVSize(Orientation orientation, double width, double height) |
|
|
|
|