mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
Fix StyleBoxFlat margins being a mess.
This commit is contained in:
@@ -729,111 +729,9 @@ namespace SS14.Client.Graphics.Drawing
|
||||
}
|
||||
}
|
||||
|
||||
private float _marginLeft;
|
||||
|
||||
public float MarginLeft
|
||||
{
|
||||
get => GameController.OnGodot ? stylebox.ContentMarginLeft : _marginLeft;
|
||||
set
|
||||
{
|
||||
if (GameController.OnGodot)
|
||||
{
|
||||
stylebox.ContentMarginLeft = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_marginLeft = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _marginRight;
|
||||
|
||||
public float MarginRight
|
||||
{
|
||||
get => GameController.OnGodot ? stylebox.ContentMarginRight : _marginRight;
|
||||
set
|
||||
{
|
||||
if (GameController.OnGodot)
|
||||
{
|
||||
stylebox.ContentMarginRight = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_marginRight = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _marginTop;
|
||||
|
||||
public float MarginTop
|
||||
{
|
||||
get => GameController.OnGodot ? stylebox.ContentMarginTop : _marginTop;
|
||||
set
|
||||
{
|
||||
if (GameController.OnGodot)
|
||||
{
|
||||
stylebox.ContentMarginTop = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_marginTop = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private float _marginBottom;
|
||||
|
||||
public float MarginBottom
|
||||
{
|
||||
get => GameController.OnGodot ? stylebox.ContentMarginBottom : _marginBottom;
|
||||
set
|
||||
{
|
||||
if (GameController.OnGodot)
|
||||
{
|
||||
stylebox.ContentMarginBottom = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_marginBottom = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Allows setting multiple margins at once.
|
||||
/// </summary>
|
||||
public void SetContentMargin(Margin margin, float value)
|
||||
{
|
||||
if ((margin & Margin.Top) != 0)
|
||||
{
|
||||
MarginTop = value;
|
||||
}
|
||||
|
||||
if ((margin & Margin.Bottom) != 0)
|
||||
{
|
||||
MarginBottom = value;
|
||||
}
|
||||
|
||||
if ((margin & Margin.Right) != 0)
|
||||
{
|
||||
MarginRight = value;
|
||||
}
|
||||
|
||||
if ((margin & Margin.Left) != 0)
|
||||
{
|
||||
MarginLeft = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void DoDraw(DrawingHandleScreen handle, UIBox2 box)
|
||||
{
|
||||
var topLeft = box.TopLeft + new Vector2(_marginLeft, _marginTop);
|
||||
var bottomRight = box.BottomRight + new Vector2(_marginRight, _marginBottom);
|
||||
|
||||
handle.DrawRect(new UIBox2(topLeft, bottomRight), _backgroundColor);
|
||||
handle.DrawRect(box, _backgroundColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user