mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-16 15:22:27 +02:00
RobustToolbox projects should be named Robust.* This PR changes the RobustToolbox projects from SS14.* to Robust.* Updates SS14.* prefixes/namespaces to Robust.* Updates SpaceStation14.sln to RobustToolbox.sln Updates MSBUILD/SS14.* to MSBUILD/Robust.* Updates CSProject and MSBuild references for the above Updates git_helper.py Removes Runserver and Runclient as they are unusable
121 lines
3.1 KiB
C#
121 lines
3.1 KiB
C#
using Robust.Shared.Maths;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Robust.Client.UserInterface.Controls
|
|
{
|
|
[ControlWrap(typeof(Godot.Container))]
|
|
public class Container : Control
|
|
{
|
|
public Container() : base()
|
|
{
|
|
}
|
|
|
|
public Container(string name) : base(name)
|
|
{
|
|
}
|
|
|
|
// So for SOME REASON Godot.TabContainer wasn't a Container until 3.1.
|
|
// ???
|
|
internal Container(Godot.Control sceneControl) : base(sceneControl)
|
|
{
|
|
}
|
|
|
|
private protected override Godot.Control SpawnSceneControl()
|
|
{
|
|
return new Godot.Container();
|
|
}
|
|
|
|
protected virtual void SortChildren()
|
|
{
|
|
|
|
}
|
|
|
|
protected override void ChildAdded(Control newChild)
|
|
{
|
|
base.ChildAdded(newChild);
|
|
|
|
if (!GameController.OnGodot)
|
|
{
|
|
newChild.OnMinimumSizeChanged += _childChanged;
|
|
newChild.OnVisibilityChanged += _childChanged;
|
|
MinimumSizeChanged();
|
|
SortChildren();
|
|
}
|
|
}
|
|
|
|
protected override void ChildRemoved(Control child)
|
|
{
|
|
base.ChildRemoved(child);
|
|
|
|
if (!GameController.OnGodot)
|
|
{
|
|
child.OnMinimumSizeChanged -= _childChanged;
|
|
child.OnVisibilityChanged -= _childChanged;
|
|
MinimumSizeChanged();
|
|
SortChildren();
|
|
}
|
|
}
|
|
|
|
protected void FitChildInBox(Control child, UIBox2 box)
|
|
{
|
|
DebugTools.Assert(child.Parent == this);
|
|
|
|
var (minX, minY) = child.CombinedMinimumSize;
|
|
var newPosX = box.Left;
|
|
var newSizeX = minX;
|
|
|
|
if (child.SizeFlagsHorizontal == SizeFlags.ShrinkEnd)
|
|
{
|
|
newPosX += (box.Width - minX);
|
|
}
|
|
else if (child.SizeFlagsHorizontal == SizeFlags.ShrinkCenter)
|
|
{
|
|
newPosX += (box.Width - minX) / 2;
|
|
}
|
|
else if ((child.SizeFlagsHorizontal & SizeFlags.Fill) != 0)
|
|
{
|
|
newSizeX = box.Width;
|
|
}
|
|
|
|
var newPosY = box.Top;
|
|
var newSizeY = minY;
|
|
|
|
if (child.SizeFlagsVertical == SizeFlags.ShrinkEnd)
|
|
{
|
|
newPosY += (box.Height - minY);
|
|
}
|
|
else if (child.SizeFlagsVertical == SizeFlags.ShrinkCenter)
|
|
{
|
|
newPosY += (box.Height - minY) / 2;
|
|
}
|
|
else if ((child.SizeFlagsVertical & SizeFlags.Fill) != 0)
|
|
{
|
|
newSizeY = box.Height;
|
|
}
|
|
|
|
child.SetAnchorPreset(LayoutPreset.TopLeft, true);
|
|
|
|
child.Position = new Vector2(newPosX, newPosY);
|
|
child.Size = new Vector2(newSizeX, newSizeY);
|
|
}
|
|
|
|
private void _childChanged(Control child)
|
|
{
|
|
MinimumSizeChanged();
|
|
SortChildren();
|
|
}
|
|
|
|
protected override void Resized()
|
|
{
|
|
base.Resized();
|
|
|
|
if (GameController.OnGodot)
|
|
{
|
|
return;
|
|
}
|
|
|
|
SortChildren();
|
|
}
|
|
}
|
|
}
|