Overlays#
Declared in ui.h. See overlays for layers, dimming and examples.
Modals and menus open a layer each, up to UI_LAYERS (4). Only the top layer takes focus and keys, and everything
below it is drawn dimmed. Overlays record into the overlay stream, so they are drawn on top wherever in the frame
they are called.
Answers#
enum { UI_PENDING = -1, UI_NO, UI_YES };
The values ui_confirm returns: UI_PENDING (-1) while there is no answer, UI_NO (0) and UI_YES (1).
ui_modal_begin#
bool ui_modal_begin(bool *open, const char *title);
Opens a modal when *open is true: a panel ui_metrics.modal pixels wide in ui_style_modal, centered on the
screen, as high as its content, with the title as a heading. Widgets until ui_modal_end go inside it. [clear]
sets *open to false.
Parameter |
Meaning |
|---|---|
|
Whether the modal is open. Its address is also the modal’s id |
|
A heading at the top, or |
Returns true when the modal is open and its content should be placed, false otherwise. Call ui_modal_end only
when it returned true.
ui_modal_end#
void ui_modal_end(void);
Ends the modal started last, sets its height, and handles [clear] for it. It does nothing when the current container
is not a modal.
ui_message#
void ui_message(bool *open, const char *title, const char *text);
A modal with a title, wrapped text and an OK button. OK and [clear] set *open to false. Does nothing when *open
is false.
Parameter |
Meaning |
|---|---|
|
Whether the message is shown |
|
A heading, or |
|
The message, or |
ui_confirm#
int ui_confirm(bool *open, const char *title, const char *text, const char *yes);
A modal with a title, wrapped text and two buttons, Cancel and yes. It closes itself when the user answers.
Parameter |
Meaning |
|---|---|
|
Whether the question is shown |
|
A heading, or |
|
The question, or |
|
The label of the button that confirms, such as “Delete” |
Returns UI_YES in the frame the yes button is picked, UI_NO in the frame Cancel is picked or [clear] is
pressed, and UI_PENDING in every other frame.
ui_toast#
void ui_toast(const char *text);
Shows text in ui_style_toast, centered just above the softkey bar, for UI_TOAST_MS (2000 ms). The text is
copied, up to UI_TOAST_SIZE - 1 (47) characters. A new toast replaces the one showing. It takes no focus and no
keys, and CEUI wakes up by itself to remove it. Call it once, when the event happens.