29#define ALLEGRO_UNSTABLE 1
53 int api, users, admin;
64int main(
int argc,
char** argv) {
69 if (!al_init() || !al_init_font_addon()) {
73 ALLEGRO_FONT*
font = al_create_builtin_font();
81 al_destroy_font(
font);
97 for (
int i = 0; i < 7; i++) {
109 strcmp(buf,
"API") == 0);
149 "POST /users") == 0);
165 expect_true(
"selection points at the new model object",
182 expect_true(
"missing selection leaves none selected",
193 memset(&empty, 0,
sizeof(empty));
202 al_destroy_font(
font);
static void expect_true(const char *label, int cond)
static void build_tree(N_GUI_TREE *tree, void **tags)
FONT * font
the default 8x8 font, valid after allegro_init()
N_GUI_TREE_NODE nodes[2048]
node storage
int listbox_id
listbox widget ID
int expanded
1 if expanded
int nb_expanded
number of paths stored
int nb_nodes
number of nodes
char * selected
path of the selected node, or NULL
void n_gui_set_display_size(N_GUI_CTX *ctx, float w, float h)
set the display (viewport) size so global scrollbars can be computed.
int n_gui_listbox_get_scroll_offset(N_GUI_CTX *ctx, int widget_id)
get the current scroll offset (in items)
void n_gui_tree_state_apply(N_GUI_TREE *tree, const N_GUI_TREE_STATE *state)
re-expand, re-select and re-scroll a rebuilt tree from a saved state.
float n_gui_listbox_get_h_scroll(N_GUI_CTX *ctx, int widget_id)
get a listbox's horizontal scroll offset in pixels (0 = leftmost)
int n_gui_tree_find_by_path(const N_GUI_TREE *tree, const char *path)
index of the first node with the given path, or -1.
#define N_GUI_TREE_PATH_MAX
maximum length of a node path (labels from the root, joined)
void n_gui_listbox_set_h_scroll(N_GUI_CTX *ctx, int widget_id, float px)
set a listbox's horizontal scroll offset in pixels
void n_gui_tree_clear(N_GUI_TREE *tree)
remove all nodes and clear the backing listbox; tree object remains valid
void n_gui_tree_set_selection(N_GUI_TREE *tree, int node_index)
programmatically select a node; ancestors are expanded so the node is visible, and the listbox scroll...
void n_gui_tree_free(N_GUI_TREE **tree)
free a tree view (does not destroy the N_GUI listbox)
int n_gui_tree_get_selection(N_GUI_TREE *tree)
get the index of the currently selected node, or -1 when nothing is selected or the selection points ...
int n_gui_tree_node_path(const N_GUI_TREE *tree, int node_index, char *buf, size_t bufsz)
Write the path of a node into a buffer.
int n_gui_add_window(N_GUI_CTX *ctx, const char *title, float x, float y, float w, float h)
Add a new pseudo-window to the context.
void n_gui_tree_state_free(N_GUI_TREE_STATE *state)
release the strings owned by a saved state (safe on a zeroed struct)
N_GUI_CTX * n_gui_new_ctx(ALLEGRO_FONT *default_font)
Create a new GUI context.
N_GUI_TREE * n_gui_tree_create(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, void(*on_select)(int, void *), void *user_data)
create a tree view in an existing window
void n_gui_tree_toggle_expand(N_GUI_TREE *tree, int node_index)
toggle expand/collapse of a node.
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
Destroy a GUI context and all its windows/widgets.
void n_gui_listbox_set_scroll_offset(N_GUI_CTX *ctx, int widget_id, int offset)
set the scroll offset (in items), clamps to valid range
int n_gui_tree_add_node(N_GUI_TREE *tree, const char *label, int parent_index, void *user_data)
add a node to the tree
int n_gui_tree_state_save(const N_GUI_TREE *tree, N_GUI_TREE_STATE *out)
capture which nodes are expanded, which one is selected, and where the view is scrolled,...
The top-level GUI context that holds all windows.
tree view built from an N_GUI listbox
A tree's view state, captured by path so it survives a rebuild that replaces every node (a reloaded m...
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_ERR
error conditions
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL ).
#define LOG_NOTICE
normal but significant condition
Common headers and low-level functions & define.
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.