Browse Source

Added padding.

pull/4/head
grokys 12 years ago
parent
commit
fcbdc60dc1
  1. 2
      Perspex.Windows/Window.cs
  2. 1
      Perspex/Controls/Button.cs
  3. 13
      Perspex/Controls/Decorator.cs

2
Perspex.Windows/Window.cs

@ -69,7 +69,7 @@
protected override Visual DefaultTemplate()
{
Border border = new Border();
border.Background = new Perspex.Media.SolidColorBrush(0xff808080);
border.Background = new Perspex.Media.SolidColorBrush(0xffffffff);
ContentPresenter contentPresenter = new ContentPresenter();
contentPresenter.Bind(ContentPresenter.ContentProperty, this.GetObservable(ContentProperty));
border.Content = contentPresenter;

1
Perspex/Controls/Button.cs

@ -14,6 +14,7 @@ namespace Perspex.Controls
border.Background = new Perspex.Media.SolidColorBrush(0xff808080);
border.BorderBrush = new Perspex.Media.SolidColorBrush(0xff000000);
border.BorderThickness = 2;
border.Padding = new Thickness(3);
ContentPresenter contentPresenter = new ContentPresenter();
contentPresenter.Bind(ContentPresenter.ContentProperty, this.GetObservable(ContentProperty));
border.Content = contentPresenter;

13
Perspex/Controls/Decorator.cs

@ -9,6 +9,9 @@
public static readonly PerspexProperty<Control> ContentProperty =
PerspexProperty.Register<ContentControl, Control>("Content");
public static readonly PerspexProperty<Thickness> PaddingProperty =
PerspexProperty.Register<ContentControl, Thickness>("Padding");
public Decorator()
{
// TODO: Unset old content's visual parent.
@ -27,6 +30,12 @@
set { this.SetValue(ContentProperty, value); }
}
public Thickness Padding
{
get { return this.GetValue(PaddingProperty); }
set { this.SetValue(PaddingProperty, value); }
}
public override IEnumerable<Visual> VisualChildren
{
get
@ -42,7 +51,7 @@
if (content != null)
{
content.Arrange(new Rect(finalSize));
content.Arrange(new Rect(finalSize).Deflate(this.Padding));
}
return finalSize;
@ -55,7 +64,7 @@
if (content != null)
{
content.Measure(availableSize);
return content.DesiredSize.Value;
return content.DesiredSize.Value.Inflate(this.Padding);
}
else
{

Loading…
Cancel
Save