summaryrefslogtreecommitdiff
path: root/src/widget/label.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/widget/label.c')
-rw-r--r--src/widget/label.c28
1 files changed, 28 insertions, 0 deletions
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 @@
1#include <ui.h>
2
3#include "uiLibrary.h"
4#include "widget.h"
5
6uiLabel* uiMakeLabel(const char* text) {
7 assert(text);
8
9 uiLabel* label = UI_NEW(uiLabel);
10
11 *label = (uiLabel){
12 .widget =
13 (uiWidget){
14 .type = uiTypeLabel,
15 .rect =
16 (uiRect){
17 .width =
18 (int)strlen(text) * g_ui.font->header.glyph_width,
19 .height = g_ui.font->header.glyph_height}},
20 .text = string_new(text),
21 };
22 return label;
23}
24
25const char* uiLabelGetText(const uiLabel* label) {
26 assert(label);
27 return string_data(label->text);
28}