csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
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.
56 lines
1.6 KiB
56 lines
1.6 KiB
// -----------------------------------------------------------------------
|
|
// <copyright file="LayoutManager.cs" company="Steven Kirk">
|
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|
// </copyright>
|
|
// -----------------------------------------------------------------------
|
|
|
|
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 (this.root != null)
|
|
{
|
|
this.root.Measure(this.root.ClientSize);
|
|
this.root.Arrange(new Rect(this.root.ClientSize));
|
|
}
|
|
|
|
this.root = null;
|
|
}
|
|
|
|
public void InvalidateMeasure(ILayoutable item)
|
|
{
|
|
IVisual visual = item as IVisual;
|
|
this.root = visual.GetVisualAncestorOrSelf<ILayoutRoot>();
|
|
this.layoutNeeded.OnNext(Unit.Default);
|
|
}
|
|
|
|
public void InvalidateArrange(ILayoutable item)
|
|
{
|
|
IVisual visual = item as IVisual;
|
|
this.root = visual.GetVisualAncestorOrSelf<ILayoutRoot>();
|
|
this.layoutNeeded.OnNext(Unit.Default);
|
|
}
|
|
}
|
|
}
|
|
|