Layout#
Declared in ui.h. See layout for how widgets are placed.
Types and constants#
ui_rect_t#
typedef struct {
int x, y, w, h;
} ui_rect_t;
A rectangle in screen pixels: left, top, width and height. CEUI passes one to canvas draw functions.
ui_scroll_t#
typedef struct {
int y, content;
} ui_scroll_t;
The state of a scroll area or text area. y is how far the content is scrolled, in pixels. content is the height
of the content, set when the area ends. Keep it in a static or global variable and start it at zero. You may set y;
it is kept in range when the area ends.
UI_FILL#
#define UI_FILL (-1)
As a column width: an equal share of the width the other columns leave. As the height of ui_scroll_begin or
ui_list_begin: the rest of the container.
UI_AUTO#
#define UI_AUTO 0
As a column width: as wide as the content of the widget in that column, such as the text of a label or button.
Functions#
ui_columns#
void ui_columns(uint8_t count, const int *widths);
Places the next widgets in count columns, left to right, starting a new row after the last column. The columns stay
until the next call or the end of the container. Calling it ends the current row.
Parameter |
Meaning |
|---|---|
|
Number of columns, 1 to |
|
|
Called right after ui_list_begin, it applies to every row of the list.
ui_height#
void ui_height(int h);
Makes the next widget h pixels high instead of its natural height. It applies to one widget.
ui_space#
void ui_space(int h);
Leaves h pixels of empty space, as one widget. In columns, it takes one cell.
ui_separator#
void ui_separator(void);
Draws a 1 pixel horizontal line across the column in ui_style_separator, with the style’s vertical padding above
and below it.
ui_panel_begin#
void ui_panel_begin(const char *title);
Starts a framed container in ui_style_panel (or the style set with ui_next_style), as wide as the current column.
Widgets until ui_panel_end go inside it, in one column. The panel is as high as its content.
Parameter |
Meaning |
|---|---|
|
A line of text at the top of the panel, or |
ui_panel_end#
void ui_panel_end(void);
Ends the panel started last, sets its height and goes back to the parent container and its columns. It does nothing when the current container is not a panel.
ui_scroll_begin#
void ui_scroll_begin(ui_scroll_t *scroll, int h);
Starts a scroll area: a container as wide as the current column and h pixels high that clips its content and shows
a scroll bar when the content is taller. Widgets until ui_scroll_end go inside it.
Parameter |
Meaning |
|---|---|
|
The area’s state. Its address is also the area’s id |
|
Height in pixels, or |
Focus moves scroll the area to keep the focused widget visible. An arrow that finds no widget in its direction
scrolls by one row. An area with no focusable widget is a focus stop of its own, and [left] and [right] page
through it. At most UI_SCROLLS areas are tracked per frame.
ui_scroll_end#
void ui_scroll_end(void);
Ends the scroll area started last: stores the content height in scroll->content, keeps scroll->y in range, draws
the scroll bar and goes back to the parent container. It does nothing when the current container is not a scroll
area.