Files
a9d17337a3 RT Patches for UI improvements (#4841)
* fix up buttons

* wah

* ough

* huhwuhuahsdhsfdj

* loud incorrect buzzer

* wawa

* Allow XmlnsDefinition

* wawa

* Release notes.

* Expose keybind loading.

* address reviews and other things

---------

Co-authored-by: moonheart08 <moonheart08@users.noreply.github.com>
Co-authored-by: Pieter-Jan Briers <pieterjan.briers+git@gmail.com>
2024-02-11 17:18:39 +01:00

62 lines
1.7 KiB
C#

using System.Numerics;
using Robust.Client.Graphics;
using Robust.Shared.Maths;
namespace Robust.Client.UserInterface.Controls
{
[Virtual]
public class PanelContainer : Container
{
public const string StylePropertyPanel = "panel";
public StyleBox? PanelOverride { get; set; }
protected internal override void Draw(DrawingHandleScreen handle)
{
base.Draw(handle);
var style = GetStyleBox();
style?.Draw(handle, PixelSizeBox, UIScale);
}
protected override Vector2 MeasureOverride(Vector2 availableSize)
{
var styleSize = GetStyleBox()?.MinimumSize ?? Vector2.Zero;
var measureSize = Vector2.Max(availableSize - styleSize, Vector2.Zero);
var childSize = Vector2.Zero;
foreach (var child in Children)
{
child.Measure(measureSize);
childSize = Vector2.Max(childSize, child.DesiredSize);
}
return styleSize + childSize;
}
protected override Vector2 ArrangeOverride(Vector2 finalSize)
{
var ourSize = UIBox2.FromDimensions(Vector2.Zero, finalSize);
var contentBox = GetStyleBox()?.GetContentBox(ourSize, 1) ?? ourSize;
foreach (var child in Children)
{
child.Arrange(contentBox);
}
return finalSize;
}
[System.Diagnostics.Contracts.Pure]
protected StyleBox? GetStyleBox()
{
if (PanelOverride != null)
{
return PanelOverride;
}
TryGetStyleProperty<StyleBox>(StylePropertyPanel, out var box);
return box;
}
}
}