Browse Source

Fixed a few more layout bugs.

pull/10/head
Steven Kirk 12 years ago
parent
commit
f9952e85cc
  1. 7
      Perspex.Layout/LayoutManager.cs
  2. 57
      Perspex.Layout/Layoutable.cs

7
Perspex.Layout/LayoutManager.cs

@ -161,11 +161,12 @@ namespace Perspex.Layout
{ {
this.Root.Measure(this.Root.ClientSize); this.Root.Measure(this.Root.ClientSize);
} }
else
foreach (var item in measure)
{ {
foreach (var item in measure) if (!item.Control.IsMeasureValid)
{ {
if (!item.Control.IsMeasureValid) if (item.Control != this.Root)
{ {
var parent = item.Control.GetVisualParent<ILayoutable>(); var parent = item.Control.GetVisualParent<ILayoutable>();

57
Perspex.Layout/Layoutable.cs

@ -173,12 +173,12 @@ namespace Perspex.Layout
throw new InvalidOperationException("Cannot call Measure using a size with NaN values."); throw new InvalidOperationException("Cannot call Measure using a size with NaN values.");
} }
if (force || this.previousMeasure != availableSize) if (force || !this.IsMeasureValid || this.previousMeasure != availableSize)
{ {
++DebugMeasureCount; ++DebugMeasureCount;
this.DesiredSize = this.MeasureCore(availableSize).Constrain(availableSize);
this.IsMeasureValid = true; this.IsMeasureValid = true;
this.DesiredSize = this.MeasureCore(availableSize).Constrain(availableSize);
this.previousMeasure = availableSize; this.previousMeasure = availableSize;
this.Log().Debug( this.Log().Debug(
@ -203,7 +203,7 @@ namespace Perspex.Layout
throw new InvalidOperationException("Arrange called before Measure."); throw new InvalidOperationException("Arrange called before Measure.");
} }
if (force || this.previousArrange != rect) if (force || !this.IsArrangeValid || this.previousArrange != rect)
{ {
++DebugArrangeCount; ++DebugArrangeCount;
@ -213,53 +213,46 @@ namespace Perspex.Layout
this.GetHashCode(), this.GetHashCode(),
rect); rect);
this.IsArrangeValid = true;
this.ArrangeCore(rect); this.ArrangeCore(rect);
this.previousArrange = rect; this.previousArrange = rect;
} }
this.IsArrangeValid = true;
} }
public void InvalidateMeasure() public void InvalidateMeasure()
{ {
if (this.IsMeasureValid) var parent = this.GetVisualParent<ILayoutable>();
{
var parent = this.GetVisualParent<ILayoutable>();
this.IsMeasureValid = false; this.IsMeasureValid = false;
this.IsArrangeValid = false; this.IsArrangeValid = false;
this.previousMeasure = null; this.previousMeasure = null;
this.previousArrange = null; this.previousArrange = null;
if (parent != null && IsResizable(parent)) if (parent != null && IsResizable(parent))
{ {
parent.InvalidateMeasure(); parent.InvalidateMeasure();
} }
else else
{ {
var root = this.GetLayoutRoot(); var root = this.GetLayoutRoot();
if (root != null && root.Item1.LayoutManager != null) if (root != null && root.Item1.LayoutManager != null)
{ {
root.Item1.LayoutManager.InvalidateMeasure(this, root.Item2); root.Item1.LayoutManager.InvalidateMeasure(this, root.Item2);
}
} }
} }
} }
public void InvalidateArrange() public void InvalidateArrange()
{ {
if (this.IsArrangeValid) var root = this.GetLayoutRoot();
{
var root = this.GetLayoutRoot();
this.IsArrangeValid = false; this.IsArrangeValid = false;
this.previousArrange = null; this.previousArrange = null;
if (root != null && root.Item1.LayoutManager != null) if (root != null && root.Item1.LayoutManager != null)
{ {
root.Item1.LayoutManager.InvalidateArrange(this, root.Item2); root.Item1.LayoutManager.InvalidateArrange(this, root.Item2);
}
} }
} }

Loading…
Cancel
Save