A cross-platform UI framework for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

48 lines
1.1 KiB

namespace Perspex.Layout
{
using System;
using System.Collections.Generic;
using System.Reactive;
using System.Reactive.Subjects;
using Perspex.Controls;
public class LayoutManager : ILayoutManager
{
private ILayoutRoot root;
private Subject<Unit> layoutNeeded;
public LayoutManager()
{
this.layoutNeeded = new Subject<Unit>();
}
public IObservable<Unit> LayoutNeeded
{
get { return this.layoutNeeded; }
}
public void ExecuteLayoutPass()
{
if (root != null)
{
root.Measure(root.ClientSize);
root.Arrange(new Rect(root.ClientSize));
}
root = null;
}
public void InvalidateMeasure(ILayoutable item)
{
this.root = item.GetLayoutRoot();
this.layoutNeeded.OnNext(Unit.Default);
}
public void InvalidateArrange(ILayoutable item)
{
this.root = item.GetLayoutRoot();
this.layoutNeeded.OnNext(Unit.Default);
}
}
}