diff options
author | 3gg <3gg@shellblade.net> | 2024-07-13 10:52:24 -0700 |
---|---|---|
committer | 3gg <3gg@shellblade.net> | 2024-07-13 10:52:24 -0700 |
commit | a4294e4a94189dffb1fdf99c9a60d87d77272926 (patch) | |
tree | 2e92f7c95116861bc39f4dae1d0ab5d388550000 /src/widget/label.c | |
parent | cf9579d7546c04dbc708bd8719e3f935a28088bd (diff) |
Restructure project.
Diffstat (limited to 'src/widget/label.c')
-rw-r--r-- | src/widget/label.c | 28 |
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 | |||
6 | uiLabel* 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 | |||
25 | const char* uiLabelGetText(const uiLabel* label) { | ||
26 | assert(label); | ||
27 | return string_data(label->text); | ||
28 | } | ||