Rename Frame to FillContainer.
This commit is contained in:
61
Voile/Source/UI/Containers/FillContainer.cs
Normal file
61
Voile/Source/UI/Containers/FillContainer.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
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();
|
||||
|
||||
if (Size == _lastParentSize) return;
|
||||
|
||||
Size = _lastParentSize;
|
||||
}
|
||||
|
||||
private Rect _lastParentSize = Rect.Zero;
|
||||
}
|
||||
Reference in New Issue
Block a user