58 lines
1.1 KiB
C#
58 lines
1.1 KiB
C#
using Voile.Rendering;
|
|
|
|
namespace Voile.UI.Containers;
|
|
|
|
/// <summary>
|
|
/// A special container that occupies the entire available size of the parent. <br />
|
|
/// Usually used as a root element for the UI system.
|
|
/// </summary>
|
|
public class FillContainer : Container
|
|
{
|
|
public FillContainer()
|
|
{
|
|
|
|
}
|
|
|
|
public FillContainer(Rect minimumSize) : base(minimumSize)
|
|
{
|
|
|
|
}
|
|
|
|
public override void Arrange()
|
|
{
|
|
|
|
}
|
|
|
|
public override void Render(RenderSystem renderer, Style style)
|
|
{
|
|
base.Render(renderer, style);
|
|
|
|
Rect parentSize;
|
|
|
|
if (Parent != null)
|
|
{
|
|
parentSize = Parent.Size;
|
|
}
|
|
else
|
|
{
|
|
var windowSize = renderer.WindowSize;
|
|
var windowRect = new Rect(windowSize.X, windowSize.Y);
|
|
|
|
parentSize = windowRect;
|
|
}
|
|
|
|
if (_lastParentSize != parentSize)
|
|
{
|
|
Size = parentSize;
|
|
_lastParentSize = parentSize;
|
|
}
|
|
}
|
|
|
|
protected override void OnUpdate()
|
|
{
|
|
base.OnUpdate();
|
|
Size = _lastParentSize;
|
|
}
|
|
|
|
private Rect _lastParentSize = Rect.Zero;
|
|
} |