Browse Source

realtive panel no longer cares about the declaration order. and measures to the largest child when not stretched.

pull/4252/head
Dan Walmsley 6 years ago
parent
commit
09a58d0c14
  1. 25
      src/Avalonia.Controls/RelativePanel.cs

25
src/Avalonia.Controls/RelativePanel.cs

@ -16,12 +16,16 @@ namespace Avalonia.Controls
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
foreach (var child in Children) var maxSize = new Size();
foreach (var child in Children.OfType<Layoutable>())
{ {
child?.Measure(availableSize); child.Measure(availableSize);
maxSize = maxSize.WithWidth(Math.Max(maxSize.Width, child.DesiredSize.Width));
maxSize = maxSize.WithHeight(Math.Max(maxSize.Height, child.DesiredSize.Height));
} }
return availableSize; return maxSize;
} }
protected override Size ArrangeOverride(Size arrangeSize) protected override Size ArrangeOverride(Size arrangeSize)
@ -183,11 +187,14 @@ namespace Avalonia.Controls
_nodeDic.Clear(); _nodeDic.Clear();
} }
public bool CheckCyclic() => CheckCyclic(_nodeDic.Values, null); public bool CheckCyclic() => CheckCyclic(_nodeDic.Values, null, null);
private bool CheckCyclic(IEnumerable<GraphNode> nodes, HashSet<Layoutable>? set) private bool CheckCyclic(IEnumerable<GraphNode> nodes, GraphNode? waitNode, HashSet<Layoutable>? set)
{ {
set ??= new HashSet<Layoutable>(); if (set == null)
{
set = new HashSet<Layoutable>();
}
foreach (var node in nodes) foreach (var node in nodes)
{ {
@ -206,9 +213,13 @@ namespace Avalonia.Controls
if (!set.Add(node.Element)) if (!set.Add(node.Element))
return true; return true;
return CheckCyclic(node.OutgoingNodes, set); return CheckCyclic(node.OutgoingNodes, node.Arranged ? null : node, set);
} }
if (waitNode != null)
{
ArrangeChild(waitNode);
}
return false; return false;
} }

Loading…
Cancel
Save