BSB Developer Docs
Loading...
Searching...
No Matches
widget.h
Go to the documentation of this file.
1
12#pragma once
13
14#include <stdint.h>
15#include <stdbool.h>
16
17#include <toolbox/color.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
24typedef struct Widget Widget;
25
27typedef enum {
29 AlignTopLeft,
30 AlignTopMid,
31 AlignTopRight,
32 AlignBottomLeft,
33 AlignBottomMid,
34 AlignBottomRight,
35 AlignLeftMid,
36 AlignRightMid,
39} Align;
40
42typedef enum {
43 AlignBitmaskLeft = (1 << 0),
44 AlignBitmaskHorCenter = (1 << 1),
45 AlignBitmaskRight = (1 << 2),
46
47 AlignBitmaskTop = (1 << 3),
48 AlignBitmaskVerCenter = (1 << 4),
49 AlignBitmaskBottom = (1 << 5),
51
61
72
81Widget* widget_alloc(Widget* parent);
82
88void widget_free(Widget* instance);
89
98void widget_set_visible(Widget* instance, bool visible);
99
106bool widget_is_visible(const Widget* instance);
107
114void widget_set_ignore_layout(Widget* instance, bool ignore_layout);
115
122bool widget_does_ignore_layout(const Widget* instance);
123
130void widget_set_width(Widget* instance, int32_t width);
131
138int32_t widget_get_width(const Widget* instance);
139
146void widget_set_height(Widget* instance, int32_t height);
147
154int32_t widget_get_height(const Widget* instance);
155
163void widget_set_size(Widget* instance, int32_t width, int32_t height);
164
171void widget_set_max_width(Widget* instance, int32_t max_width);
172
179void widget_set_max_height(Widget* instance, int32_t max_height);
180
188void widget_set_max_size(Widget* instance, int32_t max_width, int32_t max_height);
189
195void widget_set_size_content(Widget* instance);
196
202void widget_set_width_content(Widget* instance);
203
209void widget_set_height_content(Widget* instance);
210
217int32_t widget_get_max_width(const Widget* instance);
218
225int32_t widget_get_max_height(const Widget* instance);
226
235void widget_set_pos_x(Widget* instance, int32_t x);
236
245void widget_set_pos_y(Widget* instance, int32_t y);
246
256void widget_set_pos(Widget* instance, int32_t x, int32_t y);
257
264void widget_set_align(Widget* instance, Align align);
265
271void widget_move_to_foreground(Widget* instance);
272
278void widget_move_to_background(Widget* instance);
279
286void widget_set_scrollbar_enabled(Widget* instance, bool is_enabled);
287
294void widget_set_background_color(Widget* instance, Color color);
295
302void widget_set_opacity(Widget* instance, uint8_t opacity);
303
313void widget_set_padding(Widget* instance, int32_t left, int32_t right, int32_t top, int32_t bottom);
314
324void widget_set_margin(Widget* instance, int32_t left, int32_t right, int32_t top, int32_t bottom);
325
332void widget_set_blend_mode(Widget* instance, WidgetBlendMode blend_mode);
333
341
348void widget_set_context(Widget* instance, void* context);
349
357void* widget_get_context(const Widget* instance);
358
359#ifdef __cplusplus
360}
361#endif
Color declaration and conversion API.
RGB color structure.
Definition color.h:42
Definition widget_i.h:35
void widget_move_to_foreground(Widget *instance)
Make the Widget to be drawn above all others on the same layer.
Definition widget.c:323
WidgetBlendMode widget_get_blend_mode(const Widget *instance)
Get the blend mode for a Widget instance.
Definition widget.c:375
void widget_set_pos_y(Widget *instance, int32_t y)
Set the Widget y (vertical) position.
Definition widget.c:307
AlignBitmask widget_align_to_bitmask(Align align)
Convert Align into AlignBitmask
Definition widget.c:193
void widget_set_width(Widget *instance, int32_t width)
Set the Widget width.
Definition widget.c:236
void widget_set_padding(Widget *instance, int32_t left, int32_t right, int32_t top, int32_t bottom)
Set the padding for a Widget instance.
Definition widget.c:353
void widget_set_blend_mode(Widget *instance, WidgetBlendMode blend_mode)
Set the blend mode for a Widget instance.
Definition widget.c:369
int32_t widget_get_width(const Widget *instance)
Get the Widget width.
Definition widget.c:241
bool widget_is_visible(const Widget *instance)
Check if a Widget instance is currently visible.
Definition widget.c:221
void widget_set_height(Widget *instance, int32_t height)
Set the Widget height.
Definition widget.c:246
void widget_set_pos(Widget *instance, int32_t x, int32_t y)
Set both the x (horizontal) and y (vertical) positions of a Widget.
Definition widget.c:312
void widget_set_size_content(Widget *instance)
Set both the width and height of a Widget to fit its content.
Definition widget.c:277
void widget_set_margin(Widget *instance, int32_t left, int32_t right, int32_t top, int32_t bottom)
Set the margin for a Widget instance.
Definition widget.c:361
int32_t widget_get_max_height(const Widget *instance)
Get the Widget maximum height.
Definition widget.c:297
void widget_set_context(Widget *instance, void *context)
Set the widget context.
Definition widget.c:380
void widget_set_max_height(Widget *instance, int32_t max_height)
Set the maximum height of a Widget.
Definition widget.c:266
int32_t widget_get_max_width(const Widget *instance)
Get the Widget maximum width.
Definition widget.c:292
void widget_set_pos_x(Widget *instance, int32_t x)
Set the Widget x (horizontal) position.
Definition widget.c:302
void widget_set_size(Widget *instance, int32_t width, int32_t height)
Set both the width and height of a Widget.
Definition widget.c:256
int32_t widget_get_height(const Widget *instance)
Get the Widget height.
Definition widget.c:251
void widget_set_opacity(Widget *instance, uint8_t opacity)
Set the global opacity of a Widget instance.
Definition widget.c:348
WidgetBlendMode
Enumeration of possible blend modes for widget.
Definition widget.h:63
@ WidgetBlendModeAdditive
Add the respective color channels.
Definition widget.h:65
@ WidgetBlendModeNormal
Simply mix according to the opacity value.
Definition widget.h:64
@ WidgetBlendModeMultiply
Multiply the foreground and background.
Definition widget.h:67
@ WidgetBlendModesCount
Special value, not to be used in application code.
Definition widget.h:70
@ WidgetBlendModeDifference
Absolute difference between foreground and background.
Definition widget.h:68
@ WidgetBlendModeSubtractive
Subtract the foreground from the background.
Definition widget.h:66
void widget_set_scrollbar_enabled(Widget *instance, bool is_enabled)
Set widget scrollbar mode.
Definition widget.c:333
void widget_set_align(Widget *instance, Align align)
Set the Widget alignment relative to its parent.
Definition widget.c:317
void widget_free(Widget *instance)
Delete a widget instance.
Definition widget.c:207
void widget_move_to_background(Widget *instance)
Make the Widget to be drawn below all others on the same layer.
Definition widget.c:328
void widget_set_background_color(Widget *instance, Color color)
Set the background color and opacity of a Widget instance.
Definition widget.c:342
void widget_set_width_content(Widget *instance)
Set the width of a Widget to fit its content.
Definition widget.c:282
Align
Enumeration of supported widget alignment modes.
Definition widget.h:27
@ AlignDefault
Use the default alignment from the class.
Definition widget.h:28
@ AlignMax
Special value, not to be used in application code.
Definition widget.h:38
@ AlignCenter
Center the widget inside of its parent.
Definition widget.h:37
AlignBitmask
Like Align, but with coded axes for ease of processing.
Definition widget.h:42
bool widget_does_ignore_layout(const Widget *instance)
Check if a Widget instance ignores layout.
Definition widget.c:231
void widget_set_visible(Widget *instance, bool visible)
Show or hide a Widget instance.
Definition widget.c:212
void widget_set_ignore_layout(Widget *instance, bool ignore_layout)
Make widget ignore layout (e.g.
Definition widget.c:226
void widget_set_height_content(Widget *instance)
Set the height of a Widget to fit its content.
Definition widget.c:287
void * widget_get_context(const Widget *instance)
Get the widget context.
Definition widget.c:386
Widget * widget_alloc(Widget *parent)
Create a new widget instance.
Definition widget.c:198
void widget_set_max_width(Widget *instance, int32_t max_width)
Set the maximum width of a Widget.
Definition widget.c:261
void widget_set_max_size(Widget *instance, int32_t max_width, int32_t max_height)
Set the maximum width and height of a Widget.
Definition widget.c:271