Browse Source

Save up to two value lookups when applying layout constraints.

pull/3203/head
Dariusz Komosinski 7 years ago
parent
commit
8eb0f4127a
  1. 7
      src/Avalonia.Layout/LayoutHelper.cs

7
src/Avalonia.Layout/LayoutHelper.cs

@ -21,8 +21,11 @@ namespace Avalonia.Layout
/// <returns>The control's size.</returns>
public static Size ApplyLayoutConstraints(ILayoutable control, Size constraints)
{
double width = (control.Width > 0) ? control.Width : constraints.Width;
double height = (control.Height > 0) ? control.Height : constraints.Height;
var controlWidth = control.Width;
var controlHeight = control.Height;
double width = (controlWidth > 0) ? controlWidth : constraints.Width;
double height = (controlHeight > 0) ? controlHeight : constraints.Height;
width = Math.Min(width, control.MaxWidth);
width = Math.Max(width, control.MinWidth);
height = Math.Min(height, control.MaxHeight);

Loading…
Cancel
Save