Browse Source

Fix and test margin layout.

pull/4/head
Steven Kirk 12 years ago
parent
commit
7838c41a70
  1. 24
      Perspex.Direct2D1.RenderTests/Controls/BorderTests.cs
  2. 6
      Perspex/Controls/Control.cs
  3. BIN
      TestFiles/Direct2D1/Controls/Border/Border_Margin_Offsets_Content.expected.png

24
Perspex.Direct2D1.RenderTests/Controls/BorderTests.cs

@ -120,5 +120,29 @@ namespace Perspex.Direct2D1.RenderTests.Controls
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Margin_Offsets_Content()
{
Decorator target = new Decorator
{
Padding = new Thickness(8),
Width = 200,
Height = 200,
Content = new Border
{
BorderBrush = Brushes.Black,
BorderThickness = 2,
Content = new Border
{
Background = Brushes.Red,
Margin = new Thickness(2),
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
}
}

6
Perspex/Controls/Control.cs

@ -327,9 +327,11 @@ namespace Perspex.Controls
public void Arrange(Rect rect)
{
Thickness margin = this.Margin;
this.Bounds = new Rect(
rect.Position,
this.ArrangeContent(rect.Size.Deflate(this.Margin).Constrain(rect.Size)));
new Point(rect.Position.X + margin.Left, rect.Position.Y + margin.Top),
this.ArrangeContent(rect.Size.Deflate(margin).Constrain(rect.Size)));
}
public void Measure(Size availableSize)

BIN
TestFiles/Direct2D1/Controls/Border/Border_Margin_Offsets_Content.expected.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

Loading…
Cancel
Save