27#define ALLEGRO_UNSTABLE 1
44 while ((opt = getopt(argc, argv,
"V:")) != -1) {
47 if (!strcmp(
"LOG_NULL", optarg))
49 else if (!strcmp(
"LOG_NOTICE", optarg))
51 else if (!strcmp(
"LOG_INFO", optarg))
53 else if (!strcmp(
"LOG_ERR", optarg))
55 else if (!strcmp(
"LOG_DEBUG", optarg))
84 memset(&ev, 0,
sizeof(ev));
88 ev.type = ALLEGRO_EVENT_MOUSE_BUTTON_DOWN;
90 ev.type = ALLEGRO_EVENT_MOUSE_BUTTON_UP;
94int main(
int argc,
char** argv) {
98 fprintf(stderr,
"Usage: %s [-V LOG_LEVEL]\n", argv[0]);
103 if (!al_init() || !al_init_font_addon()) {
107 ALLEGRO_FONT* font = al_create_builtin_font();
115 al_destroy_font(font);
134 for (i = 0; i < 20; i++) {
137 snprintf(a,
sizeof(a),
"%d", i + 1);
138 snprintf(b,
sizeof(b),
"row %d", i + 1);
153 al_destroy_font(font);
void process_args(int argc, char **argv)
static void expect_true(const char *label, int cond)
static int g_selected_row
static void click_at(N_GUI_CTX *gui, int x, int y)
static void on_grid_select(int widget_id, int row, void *user_data)
void n_gui_set_display_size(N_GUI_CTX *ctx, float w, float h)
Set the display (viewport) size for global scrollbar computation.
int n_gui_process_event(N_GUI_CTX *ctx, ALLEGRO_EVENT event)
Process an allegro event through the GUI system.
int n_gui_add_splitpane(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int orientation, float ratio, void(*on_change)(int, float, void *), void *user_data)
Add a split pane widget: a draggable divider between two regions.
int n_gui_datagrid_add_column(N_GUI_CTX *ctx, int widget_id, const char *title, float width)
append a column with a header title and pixel width; returns the column index or -1
#define N_GUI_WIN_FRAMELESS
frameless window: no title bar drawn, drag via window body unless N_GUI_WIN_FIXED_POSITION is also se...
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.
N_GUI_CTX * n_gui_new_ctx(ALLEGRO_FONT *default_font)
Create a new GUI context.
#define N_GUI_SPLIT_VERTICAL
split pane: vertical divider, regions are left and right
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
Destroy a GUI context and all its windows/widgets.
int n_gui_datagrid_add_row(N_GUI_CTX *ctx, int widget_id, const char **values)
append a row of cell strings (values must have one entry per column); returns the row index or -1
void n_gui_window_set_flags(N_GUI_CTX *ctx, int window_id, int flags)
Set feature flags on a window.
int n_gui_add_datagrid(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, void(*on_select)(int, int, void *), void *user_data)
Add a sortable data grid widget.
The top-level GUI context that holds all windows.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#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
#define LOG_NULL
no log output
#define LOG_INFO
informational
char ** split(const char *str, const char *delim, int empty)
split the strings into a an array of char *pointer , ended by a NULL one.
Common headers and low-level functions & define.
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.