diff --git a/Perspex.Controls/Panel.cs b/Perspex.Controls/Panel.cs index a69887e425..417a0d2b45 100644 --- a/Perspex.Controls/Panel.cs +++ b/Perspex.Controls/Panel.cs @@ -29,7 +29,7 @@ namespace Perspex.Controls return this.children; } - + set { Contract.Requires(value != null); @@ -48,6 +48,7 @@ namespace Perspex.Controls { this.children.CollectionChanged += ChildrenChanged; this.AddVisualChildren(value); + this.InvalidateMeasure(); } } } @@ -71,6 +72,8 @@ namespace Perspex.Controls this.AddVisualChildren(this.children); break; } + + this.InvalidateMeasure(); } } } diff --git a/Perspex.Layout/Layoutable.cs b/Perspex.Layout/Layoutable.cs index 8dd8a3f4a0..60a9b17a55 100644 --- a/Perspex.Layout/Layoutable.cs +++ b/Perspex.Layout/Layoutable.cs @@ -8,6 +8,7 @@ namespace Perspex.Layout { using System; using System.Linq; + using Splat; public enum HorizontalAlignment { @@ -25,7 +26,7 @@ namespace Perspex.Layout Bottom, } - public class Layoutable : Visual, ILayoutable + public class Layoutable : Visual, ILayoutable, IEnableLogger { public static readonly PerspexProperty WidthProperty = PerspexProperty.Register("Width", double.NaN); @@ -123,10 +124,22 @@ namespace Perspex.Layout { availableSize = availableSize.Deflate(this.Margin); this.DesiredSize = this.MeasureCore(availableSize).Constrain(availableSize); + + this.Log().Debug(string.Format( + "Measure of {0} (#{1:x8}) requested {2} ", + this.GetType().Name, + this.GetHashCode(), + this.DesiredSize)); } public void Arrange(Rect rect) { + this.Log().Debug(string.Format( + "Arrange of {0} (#{1:x8}) gave {2} ", + this.GetType().Name, + this.GetHashCode(), + rect)); + if (this.DesiredSize.HasValue) { this.ArrangeCore(rect); diff --git a/Perspex.Windows/Window.cs b/Perspex.Windows/Window.cs index a3c1aeb4db..b414e4bff7 100644 --- a/Perspex.Windows/Window.cs +++ b/Perspex.Windows/Window.cs @@ -34,8 +34,6 @@ namespace Perspex.Windows private IInputManager inputManager; - private bool layoutPending; - public Window() { IPlatformRenderInterface factory = Locator.Current.GetService(); @@ -48,9 +46,8 @@ namespace Perspex.Windows this.inputManager = Locator.Current.GetService(); this.Template = ControlTemplate.Create(this.DefaultTemplate); - this.LayoutManager.LayoutNeeded.Where(_ => !this.layoutPending).Subscribe(x => + this.LayoutManager.LayoutNeeded.Subscribe(x => { - this.layoutPending = true; WindowsDispatcher.CurrentDispatcher.BeginInvoke( DispatcherPriority.Render, () => @@ -58,22 +55,18 @@ namespace Perspex.Windows this.LayoutManager.ExecuteLayoutPass(); this.renderer.Render(this); this.RenderManager.RenderFinished(); - this.layoutPending = false; }); }); - this.RenderManager.RenderNeeded.Where(_ => !layoutPending) + this.RenderManager.RenderNeeded .Subscribe(x => { WindowsDispatcher.CurrentDispatcher.BeginInvoke( DispatcherPriority.Render, () => { - if (!this.layoutPending) - { - this.renderer.Render(this); - this.RenderManager.RenderFinished(); - } + this.renderer.Render(this); + this.RenderManager.RenderFinished(); }); }); }