BSB Developer Docs
Loading...
Searching...
No Matches
label.h
Go to the documentation of this file.
1
5#pragma once
6
7#include <gui/widget.h>
8#include <gui/gui.h>
9#include <toolbox/color.h>
10#include <font_registry/fonts.h>
11
12#ifdef __cplusplus
13extern "C" {
14#endif
15
17typedef struct Label Label;
18
28
39
40typedef enum {
41 LabelFontSizeSmall,
42 LabelFontSizeNormal,
43 LabelFontSizeLarge,
44} LabelFontSize;
45
53Label* label_alloc(Widget* parent);
54
60void label_free(Label* instance);
61
70Widget* label_get_base(Label* instance);
71
78void label_set_text(Label* instance, const char* text);
79
86void label_set_text_color(Label* instance, Color color);
87
95void label_set_inline_text_color_formatting(Label* instance, bool enable);
96
102void label_set_text_font_size(Label* instance, LabelFontSize size);
103
111void label_set_text_fmt(Label* instance, const char* fmt, ...)
112 __attribute__((__format__(__printf__, 2, 3)));
113
120void label_set_line_spacing(Label* instance, int32_t spacing);
121
128void label_set_text_align(Label* instance, TextAlign align);
129
137
147void label_set_long_content_anim_start_delay(Label* instance, uint32_t delay);
148
158void label_set_long_content_anim_repeat_delay(Label* instance, uint32_t delay);
159
168void label_set_long_content_anim_speed(Label* instance, uint32_t speed);
169
176void label_set_font(Label* instance, const char* font_path);
177
178#ifdef __cplusplus
179}
180#endif
Color declaration and conversion API.
List of shared fonts.
GUI system APIs.
void label_set_font(Label *instance, const char *font_path)
Set font of label text.
Definition label.c:197
void label_set_long_content_anim_speed(Label *instance, uint32_t speed)
Set the scroll animation speed for a label.
Definition label.c:190
void label_set_long_content_mode(Label *instance, LabelLongContentMode mode)
Set label long content mode.
Definition label.c:171
void label_set_long_content_anim_start_delay(Label *instance, uint32_t delay)
Set the initial delay before the long content animation starts.
Definition label.c:178
Label * label_alloc(Widget *parent)
Create a new Label instance.
Definition label.c:79
void label_set_text_font_size(Label *instance, LabelFontSize size)
Set the label font size.
Definition label.c:119
LabelLongContentMode
Enumeration of possible behaviour with long content.
Definition label.h:30
@ LabelLongContentModeScroll
Keep the size and roll the text back and forth.
Definition label.h:33
@ LabelLongContentModeCount
Count of possible choices.
Definition label.h:37
@ LabelLongContentModeDots
Keep the size and write dots at the end if the text is too long.
Definition label.h:32
@ LabelLongContentModeScrollCircular
Keep the size and roll the text circularly.
Definition label.h:34
@ LabelLongContentModeClip
Keep the size and clip the text out of it.
Definition label.h:35
@ LabelLongContentModeWrap
Keep the object width, wrap lines longer than object width and expand the object height.
Definition label.h:31
void label_set_text(Label *instance, const char *text)
Set the label text.
Definition label.c:99
void label_set_text_color(Label *instance, Color color)
Set the label text color.
Definition label.c:107
void label_set_text_fmt(Label *instance, const char *fmt,...) __attribute__((__format__(__printf__
Set the label text with printf-like formatting.
void label_free(Label *instance)
Delete a Label instance.
Definition label.c:89
void label_set_inline_text_color_formatting(Label *instance, bool enable)
Enable or disable inline text color formatting Example: "This is a #ff0000 red# word".
Definition label.c:113
TextAlign
Enumeration of possible text alignment types.
Definition label.h:20
@ TextAlignRight
Align text to the right.
Definition label.h:24
@ TextAlignMax
Special value, not to be used in application code.
Definition label.h:26
@ TextAlignLeft
Align text to the left.
Definition label.h:22
@ TextAlignCenter
Align text to the centre.
Definition label.h:23
@ TextAlignAuto
Align text automatically.
Definition label.h:21
Widget * label_get_base(Label *instance)
Get a pointer to the base class instance.
Definition label.c:94
void void label_set_line_spacing(Label *instance, int32_t spacing)
Set the label line spacing.
Definition label.c:159
void label_set_long_content_anim_repeat_delay(Label *instance, uint32_t delay)
Set the pause duration between the long content animation repetitions.
Definition label.c:184
void label_set_text_align(Label *instance, TextAlign align)
Set the label text alignment.
Definition label.c:164
RGB color structure.
Definition color.h:42
Definition label.c:9
Definition widget_i.h:35
Base widget class.