From 9f07dc5bada0f91243250d74a579fd8b5d76946f Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Sun, 14 Dec 2014 17:31:33 +0100 Subject: [PATCH] Remove LayoutHelper.MeasureDecorator. No longer needed as most of the logic was moved to MeasureCore. --- Perspex.Controls/Border.cs | 15 ++++++++++----- Perspex.Controls/Decorator.cs | 11 ++++++++++- Perspex.Layout/LayoutHelper.cs | 30 ------------------------------ 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/Perspex.Controls/Border.cs b/Perspex.Controls/Border.cs index c702d09ff5..834a162fe2 100644 --- a/Perspex.Controls/Border.cs +++ b/Perspex.Controls/Border.cs @@ -52,11 +52,16 @@ namespace Perspex.Controls protected override Size MeasureOverride(Size availableSize) { - return LayoutHelper.MeasureDecorator( - this, - this.Content, - availableSize, - this.Padding + new Thickness(this.BorderThickness)); + var content = this.Content; + var padding = this.Padding + new Thickness(this.BorderThickness); + + if (content != null) + { + content.Measure(availableSize.Deflate(padding)); + return content.DesiredSize.Value.Inflate(padding); + } + + return new Size(); } } } diff --git a/Perspex.Controls/Decorator.cs b/Perspex.Controls/Decorator.cs index a9d48ca80b..231fe7b820 100644 --- a/Perspex.Controls/Decorator.cs +++ b/Perspex.Controls/Decorator.cs @@ -59,7 +59,16 @@ namespace Perspex.Controls 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(); } } } diff --git a/Perspex.Layout/LayoutHelper.cs b/Perspex.Layout/LayoutHelper.cs index 6708803812..dc365685ae 100644 --- a/Perspex.Layout/LayoutHelper.cs +++ b/Perspex.Layout/LayoutHelper.cs @@ -20,35 +20,5 @@ namespace Perspex.Layout height = Math.Max(height, control.MinHeight); 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); - } } }