This commit is contained in:
2023-09-25 22:18:23 +02:00
parent 092d01dcae
commit c96db94de4
14 changed files with 323 additions and 47 deletions

View File

@@ -0,0 +1,39 @@
using DaggerFramework.Rendering;
namespace DaggerFramework.UI;
public class TextLabel : UIElement
{
public string Text { get; set; } = string.Empty;
public Font Font
{
get => _font; set
{
_isDirty = true;
_font = value;
}
}
public int FontSize { get; set; } = 16;
public Color FontColor { get; set; } = Color.White;
protected override void OnRender(Renderer renderer)
{
if (_isDirty && _font != null)
{
_fontHandle = renderer.LoadFont(_font);
_isDirty = false;
}
if (_font == null)
{
renderer.DrawDebugText(Text, FontSize, FontColor);
}
else
{
renderer.DrawText(_fontHandle, Text, FontSize, FontColor);
}
}
private Font? _font;
private int _fontHandle;
private bool _isDirty;
}