|
|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|
|