Browse Source

DesiredSize doesn't need to be null.

pull/58/head
Steven Kirk 11 years ago
parent
commit
a267e1c070
  1. 2
      Perspex.Controls/Border.cs
  2. 2
      Perspex.Controls/Decorator.cs
  3. 2
      Perspex.Controls/Grid.cs
  4. 2
      Perspex.Controls/Presenters/ContentPresenter.cs
  5. 4
      Perspex.Controls/Presenters/DeckPresenter.cs
  6. 2
      Perspex.Controls/Presenters/ItemsPresenter.cs
  7. 4
      Perspex.Controls/Presenters/ScrollContentPresenter.cs
  8. 2
      Perspex.Controls/Primitives/AdornerLayer.cs
  9. 2
      Perspex.Controls/Primitives/TemplatedControl.cs
  10. 4
      Perspex.Controls/Primitives/Track.cs
  11. 6
      Perspex.Controls/StackPanel.cs
  12. 4
      Perspex.Controls/TopLevel.cs
  13. 2
      Perspex.Layout/ILayoutable.cs
  14. 2
      Perspex.Layout/LayoutManager.cs
  15. 11
      Perspex.Layout/Layoutable.cs

2
Perspex.Controls/Border.cs

@ -85,7 +85,7 @@ namespace Perspex.Controls
if (content != null)
{
content.Measure(availableSize.Deflate(padding));
return content.DesiredSize.Value.Inflate(padding);
return content.DesiredSize.Inflate(padding);
}
return new Size();

2
Perspex.Controls/Decorator.cs

@ -80,7 +80,7 @@ namespace Perspex.Controls
if (content != null)
{
content.Measure(availableSize.Deflate(padding));
return content.DesiredSize.Value.Inflate(padding);
return content.DesiredSize.Inflate(padding);
}
return new Size();

2
Perspex.Controls/Grid.cs

@ -359,7 +359,7 @@ namespace Perspex.Controls
}
child.Measure(new Size(childSizeX, childSizeY));
Size desired = child.DesiredSize.Value;
Size desired = child.DesiredSize;
// Elements distribute their height based on two rules:
// 1) Elements with rowspan/colspan == 1 distribute their height first

2
Perspex.Controls/Presenters/ContentPresenter.cs

@ -65,7 +65,7 @@ namespace Perspex.Controls.Presenters
if (child != null)
{
child.Measure(availableSize);
return child.DesiredSize.Value;
return child.DesiredSize;
}
return new Size();

4
Perspex.Controls/Presenters/DeckPresenter.cs

@ -14,10 +14,8 @@ namespace Perspex.Controls.Presenters
using Perspex.Styling;
using System;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Reactive.Linq;
using System.Threading.Tasks;
public class DeckPresenter : Control, IVisual, IPresenter, ITemplatedControl
{
@ -87,7 +85,7 @@ namespace Perspex.Controls.Presenters
protected override Size MeasureOverride(Size availableSize)
{
this.Panel.Measure(availableSize);
return this.Panel.DesiredSize.Value;
return this.Panel.DesiredSize;
}
protected override Size ArrangeOverride(Size finalSize)

2
Perspex.Controls/Presenters/ItemsPresenter.cs

@ -64,7 +64,7 @@ namespace Perspex.Controls.Presenters
protected override Size MeasureOverride(Size availableSize)
{
this.Panel.Measure(availableSize);
return this.Panel.DesiredSize.Value;
return this.Panel.DesiredSize;
}
protected override Size ArrangeOverride(Size finalSize)

4
Perspex.Controls/Presenters/ScrollContentPresenter.cs

@ -76,7 +76,7 @@ namespace Perspex.Controls.Presenters
}
content.Measure(measureSize);
var size = content.DesiredSize.Value;
var size = content.DesiredSize;
this.measuredExtent = size;
return size.Constrain(availableSize);
}
@ -95,7 +95,7 @@ namespace Perspex.Controls.Presenters
if (child != null)
{
child.Arrange(new Rect((Point)(-this.Offset), child.DesiredSize.Value));
child.Arrange(new Rect((Point)(-this.Offset), child.DesiredSize));
return finalSize;
}

2
Perspex.Controls/Primitives/AdornerLayer.cs

@ -60,7 +60,7 @@ namespace Perspex.Controls.Primitives
}
else
{
child.Arrange(new Rect(child.DesiredSize.Value));
child.Arrange(new Rect(child.DesiredSize));
}
}

2
Perspex.Controls/Primitives/TemplatedControl.cs

@ -166,7 +166,7 @@ namespace Perspex.Controls.Primitives
if (child != null)
{
child.Measure(availableSize);
return child.DesiredSize.Value;
return child.DesiredSize;
}
return new Size();

4
Perspex.Controls/Primitives/Track.cs

@ -103,11 +103,11 @@ namespace Perspex.Controls.Primitives
if (this.Orientation == Orientation.Horizontal)
{
return new Size(0, thumb.DesiredSize.Value.Height);
return new Size(0, thumb.DesiredSize.Height);
}
else
{
return new Size(thumb.DesiredSize.Value.Width, 0);
return new Size(thumb.DesiredSize.Width, 0);
}
}

6
Perspex.Controls/StackPanel.cs

@ -116,7 +116,7 @@ namespace Perspex.Controls
foreach (Control child in this.Children)
{
child.Measure(new Size(childAvailableWidth, childAvailableHeight));
Size size = child.DesiredSize.Value;
Size size = child.DesiredSize;
if (Orientation == Orientation.Vertical)
{
@ -150,8 +150,8 @@ namespace Perspex.Controls
foreach (Control child in this.Children)
{
double childWidth = child.DesiredSize.Value.Width;
double childHeight = child.DesiredSize.Value.Height;
double childWidth = child.DesiredSize.Width;
double childHeight = child.DesiredSize.Height;
if (Orientation == Orientation.Vertical)
{

4
Perspex.Controls/TopLevel.cs

@ -173,8 +173,8 @@ namespace Perspex.Controls
using (this.BeginAutoSizing())
{
this.ClientSize = new Size(
double.IsNaN(this.Width) ? this.DesiredSize.Value.Width : this.ClientSize.Width,
double.IsNaN(this.Height) ? this.DesiredSize.Value.Height : this.ClientSize.Height);
double.IsNaN(this.Width) ? this.DesiredSize.Width : this.ClientSize.Width,
double.IsNaN(this.Height) ? this.DesiredSize.Height : this.ClientSize.Height);
}
this.PlatformImpl.Invalidate(new Rect(this.ClientSize));

2
Perspex.Layout/ILayoutable.cs

@ -9,7 +9,7 @@ namespace Perspex.Layout
// TODO: Probably want to move width/height/etc properties to different interface.
public interface ILayoutable : IVisual
{
Size? DesiredSize { get; }
Size DesiredSize { get; }
double Width { get; }

2
Perspex.Layout/LayoutManager.cs

@ -211,7 +211,7 @@ namespace Perspex.Layout
if (!this.Root.IsArrangeValid && this.Root.IsMeasureValid)
{
this.Root.Arrange(new Rect(this.Root.DesiredSize.Value));
this.Root.Arrange(new Rect(this.Root.DesiredSize));
}
if (this.toMeasure.Count > 0)

11
Perspex.Layout/Layoutable.cs

@ -131,7 +131,7 @@ namespace Perspex.Layout
set { this.SetValue(VerticalAlignmentProperty, value); }
}
public Size? DesiredSize
public Size DesiredSize
{
get;
set;
@ -246,7 +246,6 @@ namespace Perspex.Layout
this.IsArrangeValid = false;
this.previousMeasure = null;
this.previousArrange = null;
this.DesiredSize = null;
if (parent != null && IsResizable(parent))
{
@ -307,12 +306,12 @@ namespace Perspex.Layout
if (this.HorizontalAlignment != HorizontalAlignment.Stretch)
{
size = size.WithWidth(Math.Min(size.Width, this.DesiredSize.Value.Width));
size = size.WithWidth(Math.Min(size.Width, this.DesiredSize.Width));
}
if (this.VerticalAlignment != VerticalAlignment.Stretch)
{
size = size.WithHeight(Math.Min(size.Height, this.DesiredSize.Value.Height));
size = size.WithHeight(Math.Min(size.Height, this.DesiredSize.Height));
}
size = LayoutHelper.ApplyLayoutConstraints(this, size);
@ -411,8 +410,8 @@ namespace Perspex.Layout
foreach (ILayoutable child in this.GetVisualChildren().OfType<ILayoutable>())
{
child.Measure(availableSize);
width = Math.Max(width, child.DesiredSize.Value.Width);
height = Math.Max(height, child.DesiredSize.Value.Height);
width = Math.Max(width, child.DesiredSize.Width);
height = Math.Max(height, child.DesiredSize.Height);
}
return new Size(width, height);

Loading…
Cancel
Save