Update TODO
This commit is contained in:
@@ -110,6 +110,60 @@ public abstract class UIElement : IElement, IRenderableElement, IResizeableEleme
|
||||
public abstract void Render(RenderSystem renderer, Style style);
|
||||
protected abstract void OnUpdate();
|
||||
|
||||
/// <summary>
|
||||
/// Renders a stylebox from a given style.
|
||||
/// </summary>
|
||||
/// <param name="renderer"></param>
|
||||
/// <param name="style"></param>
|
||||
protected void RenderStyleBox(RenderSystem renderer, Style style)
|
||||
{
|
||||
var backgroundColor = style.BackgroundColor;
|
||||
var borderColor = style.BorderColor;
|
||||
var borderSize = style.BorderSize;
|
||||
|
||||
renderer.SetTransform(GlobalPosition, Vector2.Zero);
|
||||
|
||||
renderer.DrawRectangle(new Vector2(Size.Width, Size.Height), backgroundColor);
|
||||
|
||||
if (borderSize.Left > 0)
|
||||
{
|
||||
renderer.SetTransform(GlobalPosition, Vector2.Zero);
|
||||
renderer.DrawRectangle(
|
||||
new Vector2(borderSize.Left, Size.Height),
|
||||
borderColor
|
||||
);
|
||||
}
|
||||
|
||||
if (borderSize.Top > 0)
|
||||
{
|
||||
renderer.SetTransform(GlobalPosition, Vector2.Zero);
|
||||
renderer.DrawRectangle(
|
||||
new Vector2(Size.Width, borderSize.Top),
|
||||
borderColor
|
||||
);
|
||||
}
|
||||
|
||||
if (borderSize.Right > 0)
|
||||
{
|
||||
var rightX = GlobalPosition.X + Size.Width - borderSize.Right;
|
||||
renderer.SetTransform(new Vector2(rightX, GlobalPosition.Y), Vector2.Zero);
|
||||
renderer.DrawRectangle(
|
||||
new Vector2(borderSize.Right, Size.Height),
|
||||
borderColor
|
||||
);
|
||||
}
|
||||
|
||||
if (borderSize.Bottom > 0)
|
||||
{
|
||||
var bottomY = GlobalPosition.Y + Size.Height - borderSize.Bottom;
|
||||
renderer.SetTransform(new Vector2(GlobalPosition.X, bottomY), Vector2.Zero);
|
||||
renderer.DrawRectangle(
|
||||
new Vector2(Size.Width, borderSize.Bottom),
|
||||
borderColor
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public void DrawSize(RenderSystem renderer)
|
||||
{
|
||||
renderer.SetTransform(GlobalPosition, Vector2.Zero);
|
||||
|
||||
Reference in New Issue
Block a user