mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-02 01:57:07 +02:00
28 lines
739 B
C#
28 lines
739 B
C#
using System.Numerics;
|
|
using Robust.Shared.Maths;
|
|
|
|
namespace Robust.Client.UserInterface.Controls
|
|
{
|
|
/// <summary>
|
|
/// Container type that centers its children inside itself.
|
|
/// </summary>
|
|
[Virtual]
|
|
public class CenterContainer : Container
|
|
{
|
|
protected override Vector2 ArrangeOverride(Vector2 finalSize)
|
|
{
|
|
var max = Vector2.Zero;
|
|
foreach (var child in Children)
|
|
{
|
|
var childSize = child.DesiredSize;
|
|
var childPos = (finalSize - childSize) / 2;
|
|
|
|
child.Arrange(UIBox2.FromDimensions(childPos, childSize));
|
|
|
|
max = Vector2.Max(max, childSize);
|
|
}
|
|
return max;
|
|
}
|
|
}
|
|
}
|