Browse Source

Make border brush offset content

pull/4/head
Steven Kirk 12 years ago
parent
commit
e26f8f88de
  1. 23
      Perspex.Direct2D1.RenderTests/Controls/BorderTests.cs
  2. 18
      Perspex/Controls/Border.cs
  3. 5
      Perspex/Controls/Decorator.cs
  4. BIN
      TestFiles/Direct2D1/Controls/Border/Border_Brush_Offsets_Content.expected.png

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

@ -73,5 +73,28 @@ namespace Perspex.Direct2D1.RenderTests.Controls
this.RenderToFile(target);
this.CompareImages();
}
[TestMethod]
public void Border_Brush_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,
}
}
};
this.RenderToFile(target);
this.CompareImages();
}
}
}

18
Perspex/Controls/Border.cs

@ -40,5 +40,23 @@ namespace Perspex.Controls
}
}
}
protected override Size ArrangeContent(Size finalSize)
{
Control content = this.Content;
if (content != null)
{
Thickness padding = this.Padding + new Thickness(this.BorderThickness);
content.Arrange(new Rect(finalSize).Deflate(padding));
}
return finalSize;
}
protected override Size MeasureContent(Size availableSize)
{
return this.DefaultMeasure(availableSize, this.Padding + new Thickness(this.BorderThickness));
}
}
}

5
Perspex/Controls/Decorator.cs

@ -76,6 +76,11 @@ namespace Perspex.Controls
}
protected override Size MeasureContent(Size availableSize)
{
return this.DefaultMeasure(availableSize, this.Padding);
}
protected Size DefaultMeasure(Size availableSize, Thickness padding)
{
double width = 0;
double height = 0;

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 615 B

Loading…
Cancel
Save