Dashboard/Quik/Controls/Label.cs

32 lines
802 B
C#
Raw Normal View History

2024-05-16 21:58:22 +02:00
using Quik.CommandMachine;
using Quik.Media;
using Quik.Typography;
namespace Quik.Controls
{
public class Label : Control
{
public string Text { get; set; }
2024-06-09 21:06:13 +02:00
public QFont Font { get; set; }
2024-05-16 21:58:22 +02:00
public float TextSize { get; set; }
2024-06-09 21:06:13 +02:00
public bool AutoSize { get; set; } = true;
protected override void ValidateLayout()
{
if (AutoSize)
{
QVec2 size = Typesetter.MeasureHorizontal(Text, TextSize, Font);
Size = size;
}
}
2024-05-16 21:58:22 +02:00
protected override void ValidateVisual(CommandList cmd)
{
float padding = Padding;
QVec2 origin = new QVec2(padding, padding);
2024-06-09 21:06:13 +02:00
cmd.TypesetHorizontalDirect(Text, origin, TextSize, Font);
2024-05-16 21:58:22 +02:00
}
}
}