Browse Source

Fix layout error.

pull/488/head
Steven Kirk 11 years ago
parent
commit
46c93b70bf
  1. 6
      src/Perspex.Layout/Layoutable.cs
  2. 17
      tests/Perspex.Layout.UnitTests/ArrangeTests.cs

6
src/Perspex.Layout/Layoutable.cs

@ -534,14 +534,12 @@ namespace Perspex.Layout
if (horizontalAlignment != HorizontalAlignment.Stretch)
{
size = size.WithWidth(Math.Min(size.Width, DesiredSize.Width)
- margin.Left - margin.Right);
size = size.WithWidth(Math.Min(size.Width, DesiredSize.Width - margin.Left - margin.Right));
}
if (verticalAlignment != VerticalAlignment.Stretch)
{
size = size.WithHeight(Math.Min(size.Height, DesiredSize.Height)
- margin.Top - margin.Bottom);
size = size.WithHeight(Math.Min(size.Height, DesiredSize.Height - margin.Top - margin.Bottom));
}
size = LayoutHelper.ApplyLayoutConstraints(this, size);

17
tests/Perspex.Layout.UnitTests/ArrangeTests.cs

@ -58,6 +58,23 @@ namespace Perspex.Layout.UnitTests
Assert.Equal(new Size(184, 184), target.ArrangeFinalSize);
}
[Fact]
public void ArrangeOverride_Receives_Requested_Size_When_Arranged_To_DesiredSize()
{
var target = new TestControl
{
MeasureResult = new Size(100, 100),
HorizontalAlignment = HorizontalAlignment.Center,
VerticalAlignment = VerticalAlignment.Center,
Margin = new Thickness(8),
};
target.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
target.Arrange(new Rect(target.DesiredSize));
Assert.Equal(new Size(100, 100), target.ArrangeFinalSize);
}
[Fact]
public void Arrange_With_IsMeasureValid_False_Calls_Measure()
{

Loading…
Cancel
Save