From a4294e4a94189dffb1fdf99c9a60d87d77272926 Mon Sep 17 00:00:00 2001 From: 3gg <3gg@shellblade.net> Date: Sat, 13 Jul 2024 10:52:24 -0700 Subject: Restructure project. --- src/widget/label.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/widget/label.c (limited to 'src/widget/label.c') diff --git a/src/widget/label.c b/src/widget/label.c new file mode 100644 index 0000000..30ca0ec --- /dev/null +++ b/src/widget/label.c @@ -0,0 +1,28 @@ +#include + +#include "uiLibrary.h" +#include "widget.h" + +uiLabel* uiMakeLabel(const char* text) { + assert(text); + + uiLabel* label = UI_NEW(uiLabel); + + *label = (uiLabel){ + .widget = + (uiWidget){ + .type = uiTypeLabel, + .rect = + (uiRect){ + .width = + (int)strlen(text) * g_ui.font->header.glyph_width, + .height = g_ui.font->header.glyph_height}}, + .text = string_new(text), + }; + return label; +} + +const char* uiLabelGetText(const uiLabel* label) { + assert(label); + return string_data(label->text); +} -- cgit v1.2.3