Allow disabling margins on StripeBack.
This commit is contained in:
@@ -12,6 +12,7 @@ namespace Content.Client.UserInterface
|
||||
|
||||
private bool _hasTopEdge = true;
|
||||
private bool _hasBottomEdge = true;
|
||||
private bool _hasMargins = true;
|
||||
|
||||
public const string StylePropertyBackground = "background";
|
||||
|
||||
@@ -35,6 +36,16 @@ namespace Content.Client.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasMargins
|
||||
{
|
||||
get => _hasMargins;
|
||||
set
|
||||
{
|
||||
_hasMargins = value;
|
||||
MinimumSizeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
protected override Vector2 CalculateMinimumSize()
|
||||
{
|
||||
var size = Vector2.Zero;
|
||||
@@ -44,14 +55,16 @@ namespace Content.Client.UserInterface
|
||||
size = Vector2.ComponentMax(size, child.CombinedMinimumSize);
|
||||
}
|
||||
|
||||
var padSize = HasMargins ? PadSize : 0;
|
||||
|
||||
if (HasBottomEdge)
|
||||
{
|
||||
size += (0, PadSize + EdgeSize);
|
||||
size += (0, padSize + EdgeSize);
|
||||
}
|
||||
|
||||
if (HasTopEdge)
|
||||
{
|
||||
size += (0, PadSize + EdgeSize);
|
||||
size += (0, padSize + EdgeSize);
|
||||
}
|
||||
|
||||
return size;
|
||||
@@ -61,14 +74,16 @@ namespace Content.Client.UserInterface
|
||||
{
|
||||
var box = SizeBox;
|
||||
|
||||
var padSize = HasMargins ? PadSize : 0;
|
||||
|
||||
if (HasTopEdge)
|
||||
{
|
||||
box += (0, PadSize + EdgeSize, 0, 0);
|
||||
box += (0, padSize + EdgeSize, 0, 0);
|
||||
}
|
||||
|
||||
if (HasBottomEdge)
|
||||
{
|
||||
box += (0, 0, 0, -(PadSize + EdgeSize));
|
||||
box += (0, 0, 0, -(padSize + EdgeSize));
|
||||
}
|
||||
|
||||
foreach (var child in Children)
|
||||
@@ -81,16 +96,18 @@ namespace Content.Client.UserInterface
|
||||
{
|
||||
UIBox2 centerBox = PixelSizeBox;
|
||||
|
||||
var padSize = HasMargins ? PadSize : 0;
|
||||
|
||||
if (HasTopEdge)
|
||||
{
|
||||
centerBox += (0, (PadSize + EdgeSize) * UIScale, 0, 0);
|
||||
handle.DrawRect(new UIBox2(0, PadSize * UIScale, PixelWidth, centerBox.Top), EdgeColor);
|
||||
centerBox += (0, (padSize + EdgeSize) * UIScale, 0, 0);
|
||||
handle.DrawRect(new UIBox2(0, padSize * UIScale, PixelWidth, centerBox.Top), EdgeColor);
|
||||
}
|
||||
|
||||
if (HasBottomEdge)
|
||||
{
|
||||
centerBox += (0, 0, 0, -((PadSize + EdgeSize) * UIScale));
|
||||
handle.DrawRect(new UIBox2(0, centerBox.Bottom, PixelWidth, PixelHeight - PadSize * UIScale), EdgeColor);
|
||||
centerBox += (0, 0, 0, -((padSize + EdgeSize) * UIScale));
|
||||
handle.DrawRect(new UIBox2(0, centerBox.Bottom, PixelWidth, PixelHeight - padSize * UIScale), EdgeColor);
|
||||
}
|
||||
|
||||
GetActualStyleBox()?.Draw(handle, centerBox);
|
||||
|
||||
Reference in New Issue
Block a user