Browse Source

Remove LayoutHelper.MeasureDecorator.

No longer needed as most of the logic was moved to MeasureCore.
pull/12/merge
Steven Kirk 12 years ago
parent
commit
9f07dc5bad
  1. 15
      Perspex.Controls/Border.cs
  2. 11
      Perspex.Controls/Decorator.cs
  3. 30
      Perspex.Layout/LayoutHelper.cs

15
Perspex.Controls/Border.cs

@ -52,11 +52,16 @@ namespace Perspex.Controls
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
return LayoutHelper.MeasureDecorator( var content = this.Content;
this, var padding = this.Padding + new Thickness(this.BorderThickness);
this.Content,
availableSize, if (content != null)
this.Padding + new Thickness(this.BorderThickness)); {
content.Measure(availableSize.Deflate(padding));
return content.DesiredSize.Value.Inflate(padding);
}
return new Size();
} }
} }
} }

11
Perspex.Controls/Decorator.cs

@ -59,7 +59,16 @@ namespace Perspex.Controls
protected override Size MeasureOverride(Size availableSize) protected override Size MeasureOverride(Size availableSize)
{ {
return LayoutHelper.MeasureDecorator(this, this.Content, availableSize, this.Padding); var content = this.Content;
var padding = this.Padding;
if (content != null)
{
content.Measure(availableSize.Deflate(padding));
return content.DesiredSize.Value.Inflate(padding);
}
return new Size();
} }
} }
} }

30
Perspex.Layout/LayoutHelper.cs

@ -20,35 +20,5 @@ namespace Perspex.Layout
height = Math.Max(height, control.MinHeight); height = Math.Max(height, control.MinHeight);
return new Size(width, height); return new Size(width, height);
} }
public static Size MeasureDecorator(
ILayoutable decorator,
ILayoutable content,
Size availableSize,
Thickness padding)
{
double width = 0;
double height = 0;
if (content != null)
{
content.Measure(availableSize.Deflate(padding));
Size s = content.DesiredSize.Value.Inflate(padding);
width = s.Width;
height = s.Height;
}
if (decorator.Width > 0)
{
width = decorator.Width;
}
if (decorator.Height > 0)
{
height = decorator.Height;
}
return new Size(width, height);
}
} }
} }

Loading…
Cancel
Save