mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
35 lines
912 B
C#
35 lines
912 B
C#
using Robust.Shared.Maths;
|
|
|
|
namespace Robust.Client.UserInterface.Controls
|
|
{
|
|
/// <summary>
|
|
/// Container type that centers its children inside itself.
|
|
/// </summary>
|
|
[ControlWrap("CenterContainer")]
|
|
public class CenterContainer : Container
|
|
{
|
|
protected internal override void SortChildren()
|
|
{
|
|
foreach (var child in Children)
|
|
{
|
|
var childSize = child.CombinedMinimumSize;
|
|
var childPos = (Size - childSize) / 2;
|
|
|
|
FitChildInBox(child, UIBox2.FromDimensions(childPos, childSize));
|
|
}
|
|
}
|
|
|
|
protected override Vector2 CalculateMinimumSize()
|
|
{
|
|
var min = Vector2.Zero;
|
|
|
|
foreach (var child in Children)
|
|
{
|
|
min = Vector2.ComponentMax(child.CombinedMinimumSize, min);
|
|
}
|
|
|
|
return min;
|
|
}
|
|
}
|
|
}
|