Browse Source

Merge branch 'master' into feature/ireflectabletype

pull/8119/head
Max Katz 4 years ago
committed by GitHub
parent
commit
d365312d30
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 75
      src/Avalonia.Controls/Canvas.cs
  2. 2
      src/Avalonia.Controls/Primitives/AdornerLayer.cs

75
src/Avalonia.Controls/Canvas.cs

@ -1,4 +1,5 @@
using System;
using System.Reactive.Concurrency;
using Avalonia.Input;
using Avalonia.Layout;
@ -159,47 +160,57 @@ namespace Avalonia.Controls
}
/// <summary>
/// Arranges the control's children.
/// Arranges a single child.
/// </summary>
/// <param name="finalSize">The size allocated to the control.</param>
/// <returns>The space taken.</returns>
protected override Size ArrangeOverride(Size finalSize)
/// <param name="child">The child to arrange.</param>
/// <param name="finalSize">The size allocated to the canvas.</param>
protected virtual void ArrangeChild(Control child, Size finalSize)
{
foreach (Control child in Children)
{
double x = 0.0;
double y = 0.0;
double elementLeft = GetLeft(child);
double x = 0.0;
double y = 0.0;
double elementLeft = GetLeft(child);
if (!double.IsNaN(elementLeft))
{
x = elementLeft;
}
else
if (!double.IsNaN(elementLeft))
{
x = elementLeft;
}
else
{
// Arrange with right.
double elementRight = GetRight(child);
if (!double.IsNaN(elementRight))
{
// Arrange with right.
double elementRight = GetRight(child);
if (!double.IsNaN(elementRight))
{
x = finalSize.Width - child.DesiredSize.Width - elementRight;
}
x = finalSize.Width - child.DesiredSize.Width - elementRight;
}
}
double elementTop = GetTop(child);
if (!double.IsNaN(elementTop) )
{
y = elementTop;
}
else
double elementTop = GetTop(child);
if (!double.IsNaN(elementTop))
{
y = elementTop;
}
else
{
double elementBottom = GetBottom(child);
if (!double.IsNaN(elementBottom))
{
double elementBottom = GetBottom(child);
if (!double.IsNaN(elementBottom))
{
y = finalSize.Height - child.DesiredSize.Height - elementBottom;
}
y = finalSize.Height - child.DesiredSize.Height - elementBottom;
}
}
child.Arrange(new Rect(new Point(x, y), child.DesiredSize));
child.Arrange(new Rect(new Point(x, y), child.DesiredSize));
}
/// <summary>
/// Arranges the control's children.
/// </summary>
/// <param name="finalSize">The size allocated to the control.</param>
/// <returns>The space taken.</returns>
protected override Size ArrangeOverride(Size finalSize)
{
foreach (Control child in Children)
{
ArrangeChild(child, finalSize);
}
return finalSize;

2
src/Avalonia.Controls/Primitives/AdornerLayer.cs

@ -105,7 +105,7 @@ namespace Avalonia.Controls.Primitives
}
else
{
child.Arrange(new Rect(finalSize));
ArrangeChild((Control) child, finalSize);
}
}
}

Loading…
Cancel
Save