Files
RobustToolbox/Robust.Client/UserInterface/Controls/PanelContainer.cs
T
SilverandGitHub 25926a17b7 Renames SS14.* to Robust.* (#793)
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
2019-04-15 20:24:59 -06:00

93 lines
2.3 KiB
C#

using JetBrains.Annotations;
using Robust.Client.Graphics.Drawing;
using Robust.Shared.Maths;
namespace Robust.Client.UserInterface.Controls
{
[ControlWrap(typeof(Godot.PanelContainer))]
public class PanelContainer : Container
{
public const string StylePropertyPanel = "panel";
public PanelContainer()
{
}
public PanelContainer(string name) : base(name)
{
}
internal PanelContainer(Godot.PanelContainer container) : base(container)
{
}
private protected override Godot.Control SpawnSceneControl()
{
return new Godot.PanelContainer();
}
private StyleBox _panelOverride;
public StyleBox PanelOverride
{
get => _panelOverride ?? GetStyleBoxOverride("panel");
set => SetStyleBoxOverride("panel", _panelOverride = value);
}
protected internal override void Draw(DrawingHandleScreen handle)
{
base.Draw(handle);
if (GameController.OnGodot)
{
return;
}
var style = _getStyleBox();
style?.Draw(handle, SizeBox);
}
protected override void SortChildren()
{
base.SortChildren();
var contentBox = _getStyleBox()?.GetContentBox(SizeBox) ?? SizeBox;
foreach (var child in Children)
{
FitChildInBox(child, contentBox);
}
}
protected override Vector2 CalculateMinimumSize()
{
if (GameController.OnGodot)
{
return Vector2.Zero;
}
var styleSize = _getStyleBox()?.MinimumSize ?? Vector2.Zero;
var childSize = Vector2.Zero;
foreach (var child in Children)
{
childSize = Vector2.ComponentMax(childSize, child.CombinedMinimumSize);
}
return styleSize + childSize;
}
[System.Diagnostics.Contracts.Pure]
[CanBeNull]
private StyleBox _getStyleBox()
{
if (_panelOverride != null)
{
return _panelOverride;
}
TryGetStyleProperty(StylePropertyPanel, out StyleBox box);
return box;
}
}
}