mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Add StyleBox.GetEnvelopBox.
This commit is contained in:
@@ -234,6 +234,24 @@ namespace SS14.Client.Graphics.Drawing
|
||||
return new UIBox2(left, top, right, bottom);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the draw box, positioned at <paramref name="position"/>,
|
||||
/// that envelops a box with the given dimensions perfectly given this box's content margins.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// It's basically a reverse <see cref="GetContentBox"/>.
|
||||
/// </remarks>
|
||||
/// <param name="position">The position at which the new box should be drawn.</param>
|
||||
/// <param name="dimensions">The dimensions of the content box inside this new box.</param>
|
||||
/// <returns>
|
||||
/// A box that, when ran through <see cref="GetContentBox"/>,
|
||||
/// has a content box of size <paramref name="dimensions"/>
|
||||
/// </returns>
|
||||
public UIBox2 GetEnvelopBox(Vector2 position, Vector2 dimensions)
|
||||
{
|
||||
return UIBox2.FromDimensions(position, dimensions + MinimumSize);
|
||||
}
|
||||
|
||||
public void SetContentMarginOverride(Margin margin, float value)
|
||||
{
|
||||
if ((margin & Margin.Left) != 0)
|
||||
|
||||
@@ -25,7 +25,11 @@ namespace SS14.UnitTesting.Client.Graphics
|
||||
|
||||
Assert.That(
|
||||
styleBox.GetEnvelopBox(Vector2.Zero, new Vector2(50, 50)),
|
||||
Is.EqualTo(new UIBox2(3, 5, 60, 66)));
|
||||
Is.EqualTo(new UIBox2(0, 0, 60, 66)));
|
||||
|
||||
Assert.That(
|
||||
styleBox.GetEnvelopBox(new Vector2(10, 10), new Vector2(50, 50)),
|
||||
Is.EqualTo(new UIBox2(10, 10, 70, 76)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,6 +105,7 @@
|
||||
<Compile Include="ApproxEqualityConstraint.cs" />
|
||||
<Compile Include="Client\GameObjects\Components\Transform_Test.cs" />
|
||||
<Compile Include="Client\GameControllerProxyDummy.cs" />
|
||||
<Compile Include="Client\Graphics\StyleBoxTest.cs" />
|
||||
<Compile Include="Client\Graphics\TextureLoadParametersTest.cs" />
|
||||
<Compile Include="Client\UserInterface\ControlTest.cs" />
|
||||
<Compile Include="Client\UserInterface\StylesheetTest.cs" />
|
||||
|
||||
Reference in New Issue
Block a user