Button glyph regression test (headless): n_gui_button_set_glyph draws a primitive icon instead of the label on the small square buttons where a label does not fit, keeps the label for a later switch back, and ignores out-of-range values and non-button widgets.
Button glyph regression test (headless): n_gui_button_set_glyph draws a primitive icon instead of the label on the small square buttons where a label does not fit, keeps the label for a later switch back, and ignores out-of-range values and non-button widgets.
#define ALLEGRO_UNSTABLE 1
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
static void expect_eq(
const char* label,
int got,
int want) {
if (got != want) {
n_log(
LOG_ERR,
"%s: got %d, expected %d", label, got, want);
}
}
if (!cond) {
}
}
int main(
int argc,
char** argv) {
(void)argc;
(void)argv;
if (!al_init() || !al_init_font_addon() || !al_init_primitives_addon()) {
return 1;
}
ALLEGRO_FONT*
font = al_create_builtin_font();
return 1;
}
return 1;
}
expect_true(
"buttons created", up >= 0 && down >= 0 && dup >= 0);
}
{
}
return 1;
}
return 0;
}
static void expect_true(const char *label, int cond)
static void expect_eq(const char *label, int got, int want)
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.
#define N_GUI_GLYPH_COPY
two offset sheets: duplicate / copy
#define N_GUI_GLYPH_ARROW_UP
filled triangle pointing up
#define N_GUI_ALIGN_LEFT
left aligned text
#define N_GUI_GLYPH_NONE
no glyph: the button draws its text label (default)
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.
#define N_GUI_GLYPH_CROSS
diagonal cross
int n_gui_button_get_glyph(N_GUI_CTX *ctx, int widget_id)
Get the glyph currently drawn on a button.
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.
#define N_GUI_GLYPH_ARROW_DOWN
filled triangle pointing down
N_GUI_CTX * n_gui_new_ctx(ALLEGRO_FONT *default_font)
Create a new GUI context.
void n_gui_button_set_glyph(N_GUI_CTX *ctx, int widget_id, int glyph)
Draw a glyph on a button instead of its text label.
#define N_GUI_GLYPH_PLUS
plus sign
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
Destroy a GUI context and all its windows/widgets.
#define N_GUI_GLYPH_COUNT
number of defined glyphs, for range checks
#define N_GUI_SHAPE_RECT
rectangle shape (default)
int n_gui_add_button(N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, int shape, void(*on_click)(int, void *), void *user_data)
Add a button widget to a window.
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_NOTICE
normal but significant condition
Common headers and low-level functions & define.
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.