summaryrefslogtreecommitdiff
path: root/src/widget/label.c
blob: 30ca0ec331adcb83875453429c77fec6ca00f38c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <ui.h>

#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);
}