21#define ALLEGRO_UNSTABLE 1
49 while ((opt = getopt(argc, argv,
"V:")) != -1) {
65 memset(&ev, 0,
sizeof(ev));
66 ev.type = ALLEGRO_EVENT_MOUSE_AXES;
70 ev.type = ALLEGRO_EVENT_MOUSE_BUTTON_DOWN;
73 ev.type = ALLEGRO_EVENT_MOUSE_BUTTON_UP;
81 memset(&ev, 0,
sizeof(ev));
82 ev.type = ALLEGRO_EVENT_MOUSE_AXES;
97int main(
int argc,
char** argv) {
100 fprintf(stderr,
"Usage: %s [-V LOG_LEVEL]\n", argv[0]);
105 if (!al_init() || !al_init_font_addon()) {
109 ALLEGRO_FONT*
font = al_create_builtin_font();
113 al_destroy_font(
font);
129 expect_true(
"values added once each, found by walking the combobox",
134 expect_true(
"removing an item before the selection succeeds",
157 float x = 0.0f, y = 0.0f, w = 0.0f, h = 0.0f;
191 al_destroy_font(
font);
193 fprintf(stderr,
"ex_gui_combobox_items: %d failure(s)\n",
failures);
196 printf(
"ex_gui_combobox_items: ok\n");
void process_args(int argc, char **argv)
static void expect_true(const char *label, int cond)
static void press_at(N_GUI_CTX *gui, float x, float y)
add a value only when it is not in the list yet, the way a filter built from data does,...
static void add_once(N_GUI_CTX *gui, int combo, const char *text)
static void move_to(N_GUI_CTX *gui, float x, float y)
a move of the pointer to a point, nothing pressed
FONT * font
the default 8x8 font, valid after allegro_init()
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_widget_screen_rect(N_GUI_CTX *ctx, int widget_id, float *x, float *y, float *w, float *h)
Where a widget is on screen, rather than inside its window.
#define N_GUI_ALIGN_LEFT
left aligned text
int n_gui_dropmenu_is_open(N_GUI_CTX *ctx, int widget_id)
Is a dropdown menu's panel showing.
int n_gui_process_event(N_GUI_CTX *ctx, ALLEGRO_EVENT event)
Process an allegro event through the GUI system.
int n_gui_add_label(N_GUI_CTX *ctx, int window_id, const char *text, float x, float y, float w, float h, int align)
Add a static text label.
int n_gui_combobox_get_count(N_GUI_CTX *ctx, int widget_id)
get the number of items in a combobox widget
int n_gui_combobox_add_item(N_GUI_CTX *ctx, int widget_id, const char *text)
add an item to a combo box
int n_gui_add_combobox(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 combo box widget (dropdown selector).
int n_gui_dropmenu_add_entry(N_GUI_CTX *ctx, int widget_id, const char *text, int tag, void(*on_click)(int, int, int, void *), void *user_data)
Add a static entry to a dropdown menu.
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.
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
Destroy a GUI context and all its windows/widgets.
const char * n_gui_combobox_get_item_text(N_GUI_CTX *ctx, int widget_id, int index)
get the text of the combobox item at index ("" if out of range / not a combobox)
int n_gui_combobox_get_selected(N_GUI_CTX *ctx, int widget_id)
get the selected item index in a combobox widget
int n_gui_combobox_remove_item(N_GUI_CTX *ctx, int widget_id, int index)
remove an item from a combobox widget
int n_gui_menu_is_open(const N_GUI_CTX *ctx)
Is a combo box's list or a drop menu's panel currently open.
void n_gui_combobox_set_selected(N_GUI_CTX *ctx, int widget_id, int index)
set the selected item in a combobox widget
int n_gui_add_dropmenu(N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, void(*on_open)(int, void *), void *on_open_user_data)
Add a dropdown menu widget.
The top-level GUI context that holds all windows.
#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_INFO
informational
Common headers and low-level functions & define.
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.