39#define ALLEGRO_UNSTABLE 1
61static const char*
proj_names[] = {
"Classic 2:1",
"True Isometric",
"Military",
"Staggered"};
93 n_log(
LOG_NOTICE,
"Checkbox %d: %s", widget_id, checked ?
"checked" :
"unchecked");
103void on_scroll(
int widget_id,
double pos,
void* user_data) {
111 int*
done = (
int*)user_data;
124 n_log(
LOG_NOTICE,
"Listbox %d: item %d %s", widget_id, index, selected ?
"selected" :
"deselected");
180 for (
int i = 0; i < 4; i++) {
214 snprintf(buf,
sizeof(buf),
"[%s] %s", is_open ?
"X" :
" ",
win_names[i]);
220int main(
int argc,
char* argv[]) {
227 n_abort(
"Could not init Allegro.\n");
229 if (!al_install_audio()) {
232 if (!al_init_acodec_addon()) {
233 n_log(
LOG_ERR,
"Unable to initialize audio codec addon");
235 if (!al_init_image_addon()) {
236 n_abort(
"Unable to initialize image addon\n");
238 if (!al_init_primitives_addon()) {
239 n_abort(
"Unable to initialize primitives addon\n");
241 if (!al_init_font_addon()) {
242 n_abort(
"Unable to initialize font addon\n");
244 if (!al_init_ttf_addon()) {
245 n_abort(
"Unable to initialize ttf_font addon\n");
247 if (!al_install_keyboard()) {
248 n_abort(
"Unable to initialize keyboard handler\n");
250 if (!al_install_mouse()) {
251 n_abort(
"Unable to initialize mouse handler\n");
255 char ver_str[128] =
"";
256 while ((
getoptret = getopt(argc, argv,
"hvV:L:t:")) != EOF) {
259 n_log(
LOG_NOTICE,
"\n %s -h help -v version -V DEBUGLEVEL -L logfile -t theme.json", argv[0]);
262 sprintf(ver_str,
"%s %s", __DATE__, __TIME__);
266 if (!strncmp(
"NOTICE", optarg, 6)) {
268 }
else if (!strncmp(
"VERBOSE", optarg, 7)) {
270 }
else if (!strncmp(
"ERROR", optarg, 5)) {
272 }
else if (!strncmp(
"DEBUG", optarg, 5)) {
288 n_log(
LOG_ERR,
"\n %s -h help -v version -V DEBUGLEVEL -L logfile -t theme.json", argv[0]);
293 ALLEGRO_EVENT_QUEUE* event_queue = al_create_event_queue();
295 n_abort(
"Failed to create event queue!\n");
298 al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE);
301 n_abort(
"Unable to create display\n");
303 al_set_window_title(
display,
"Nilorea GUI Demo - All Widgets + Dropdown Menus");
305 ALLEGRO_TIMER*
fps_timer = al_create_timer(1.0 / 60.0);
307 al_register_event_source(event_queue, al_get_display_event_source(
display));
308 al_register_event_source(event_queue, al_get_timer_event_source(
fps_timer));
309 al_register_event_source(event_queue, al_get_keyboard_event_source());
310 al_register_event_source(event_queue, al_get_mouse_event_source());
314 ALLEGRO_FONT* font = al_create_builtin_font();
316 n_abort(
"Unable to create builtin font\n");
350 int win_menu =
win_ids[win_idx];
356 "Windows", 10, 2, 120, 22,
361 "File", 140, 2, 100, 22, NULL, NULL);
379 al_map_rgba(120, 30, 30, 230), al_map_rgba(160, 40, 40, 240), al_map_rgba(200, 60, 60, 255),
380 al_map_rgba(200, 80, 80, 255), al_map_rgba(230, 100, 100, 255), al_map_rgba(255, 120, 120, 255),
381 al_map_rgba(255, 220, 220, 255), al_map_rgba(255, 255, 255, 255), al_map_rgba(255, 255, 255, 255),
392 win_names[win_idx] =
"Sliders (resizable)";
397 n_gui_add_slider(
gui, win2, 20, 20, 180, 24, 0.0, 100.0, 50.0,
N_GUI_SLIDER_VALUE,
on_slider_change, NULL);
398 n_gui_add_slider(
gui, win2, 20, 60, 180, 24, 0.0, 100.0, 25.0,
N_GUI_SLIDER_PERCENT,
on_slider_change, NULL);
400 int sld_dis =
n_gui_add_slider(
gui, win2, 20, 100, 180, 24, -50.0, 50.0, 0.0,
N_GUI_SLIDER_VALUE,
on_slider_change, NULL);
405 n_gui_add_vslider(
gui, win2, 240, 10, 24, 120, 0.0, 100.0, 75.0,
N_GUI_SLIDER_VALUE,
on_slider_change, NULL);
406 n_gui_add_vslider(
gui, win2, 275, 10, 24, 120, 0.0, 100.0, 40.0,
N_GUI_SLIDER_PERCENT,
on_slider_change, NULL);
420 win_names[win_idx] =
"Checkboxes (auto)";
519 win_names[win_idx] =
"Combo / Labels / Image";
545 "Click this link!",
"https://example.com",
550 ALLEGRO_BITMAP* img_192 = al_load_bitmap(
"DATAS/img/android-chrome-192x192.png");
551 ALLEGRO_BITMAP* img_32 = al_load_bitmap(
"DATAS/img/favicon-32x32.png");
617 al_map_rgba(40, 60, 40, 230), al_map_rgba(50, 80, 50, 240), al_map_rgba(30, 120, 30, 255),
618 al_map_rgba(60, 100, 60, 255), al_map_rgba(70, 140, 70, 255), al_map_rgba(40, 160, 40, 255),
619 al_map_rgba(200, 255, 200, 255), al_map_rgba(255, 255, 255, 255), al_map_rgba(255, 255, 255, 255),
621 for (
int i = 0; i < 4; i++) {
640 win_names[win_idx] =
"Scrollable (auto scrollbar)";
641 int win_scroll =
win_ids[win_idx];
646 for (
int i = 0; i < 20; i++) {
648 snprintf(buf,
sizeof(buf),
"Scrollable line %d - content that extends beyond window", i + 1);
659 ALLEGRO_BITMAP* skin_win_bg = NULL;
660 ALLEGRO_BITMAP* skin_win_tb = NULL;
661 ALLEGRO_BITMAP* skin_sld_track = NULL;
662 ALLEGRO_BITMAP* skin_sld_fill = NULL;
663 ALLEGRO_BITMAP* skin_sld_handle = NULL;
664 ALLEGRO_BITMAP* skin_sld_handle_h = NULL;
665 ALLEGRO_BITMAP* skin_chk_unchecked = NULL;
666 ALLEGRO_BITMAP* skin_chk_checked = NULL;
669 ALLEGRO_BITMAP* prev_target = al_get_target_bitmap();
672 skin_win_bg = al_create_bitmap(64, 64);
673 al_set_target_bitmap(skin_win_bg);
674 for (
int row = 0; row < 64; row++) {
675 float t = (float)row / 63.0f;
676 al_draw_line(0, (
float)row, 64, (
float)row,
677 al_map_rgba((
unsigned char)(20 + 40 * t), (
unsigned char)(40 + 60 * t), (
unsigned char)(80 + 80 * t), 230), 1.0f);
681 skin_win_tb = al_create_bitmap(64, 16);
682 al_set_target_bitmap(skin_win_tb);
683 for (
int row = 0; row < 16; row++) {
684 float t = (float)row / 15.0f;
685 al_draw_line(0, (
float)row, 64, (
float)row,
686 al_map_rgba((
unsigned char)(60 + 40 * t), (
unsigned char)(30 + 30 * t), (
unsigned char)(100 + 50 * t), 240), 1.0f);
690 skin_sld_track = al_create_bitmap(32, 8);
691 al_set_target_bitmap(skin_sld_track);
692 al_clear_to_color(al_map_rgba(50, 50, 60, 200));
695 skin_sld_fill = al_create_bitmap(32, 8);
696 al_set_target_bitmap(skin_sld_fill);
697 al_clear_to_color(al_map_rgba(100, 180, 255, 230));
700 skin_sld_handle = al_create_bitmap(16, 16);
701 al_set_target_bitmap(skin_sld_handle);
702 al_clear_to_color(al_map_rgba(0, 0, 0, 0));
703 al_draw_filled_circle(8, 8, 7, al_map_rgba(200, 200, 220, 240));
706 skin_sld_handle_h = al_create_bitmap(16, 16);
707 al_set_target_bitmap(skin_sld_handle_h);
708 al_clear_to_color(al_map_rgba(0, 0, 0, 0));
709 al_draw_filled_circle(8, 8, 7, al_map_rgba(150, 220, 255, 255));
712 skin_chk_unchecked = al_create_bitmap(16, 16);
713 al_set_target_bitmap(skin_chk_unchecked);
714 al_clear_to_color(al_map_rgba(60, 60, 80, 220));
715 al_draw_rectangle(0.5f, 0.5f, 15.5f, 15.5f, al_map_rgba(150, 150, 200, 255), 1.0f);
717 skin_chk_checked = al_create_bitmap(16, 16);
718 al_set_target_bitmap(skin_chk_checked);
719 al_clear_to_color(al_map_rgba(80, 140, 255, 240));
720 al_draw_rectangle(0.5f, 0.5f, 15.5f, 15.5f, al_map_rgba(150, 150, 200, 255), 1.0f);
721 al_draw_line(3, 8, 7, 13, al_map_rgb(255, 255, 255), 2.0f);
722 al_draw_line(7, 13, 13, 3, al_map_rgb(255, 255, 255), 2.0f);
724 al_set_target_bitmap(prev_target);
729 int win_skin =
win_ids[win_idx];
752 n_gui_add_label(
gui, win_skin,
"Window bg, titlebar, slider, checkbox,", 20, 180, 260, 16,
N_GUI_ALIGN_LEFT);
760 int win_login =
win_ids[win_idx];
806 al_clear_keyboard_state(NULL);
807 al_flush_event_queue(event_queue);
811 al_wait_for_event(event_queue, &ev);
813 if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
816 if (ev.type == ALLEGRO_EVENT_KEY_DOWN && ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
822 if (ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE) {
823 al_acknowledge_resize(
display);
824 int new_w = al_get_display_width(
display);
825 int new_h = al_get_display_height(
display);
836 if (ev.type == ALLEGRO_EVENT_MOUSE_AXES) {
841 if (ev.type == ALLEGRO_EVENT_TIMER) {
843 char status_buf[256];
844 snprintf(status_buf,
sizeof(status_buf),
845 "Player:%s Height:%s Grid:%s Smooth:%s Ghost:%s",
860 if (do_draw && al_is_event_queue_empty(event_queue)) {
861 al_set_target_bitmap(al_get_backbuffer(
display));
862 al_clear_to_color(al_map_rgba(30, 30, 35, 255));
872 ALLEGRO_TRANSFORM overlay_tf;
873 al_identity_transform(&overlay_tf);
878 al_use_transform(&overlay_tf);
880 float cross_thick = 1.0f;
884 al_draw_line(vmx - 6, vmy, vmx + 6, vmy, al_map_rgb(255, 100, 100), cross_thick);
885 al_draw_line(vmx, vmy - 6, vmx, vmy + 6, al_map_rgb(255, 100, 100), cross_thick);
892 ALLEGRO_TRANSFORM instr_tf;
893 al_identity_transform(&instr_tf);
898 al_use_transform(&instr_tf);
900 al_draw_text(font, al_map_rgb(180, 180, 180), 10, virt_h - 18, 0,
901 "Drag windows | Click widgets | Scroll lists | Resize corners/display | 'Windows' dropdown | ESC to quit");
903 ALLEGRO_TRANSFORM identity;
904 al_identity_transform(&identity);
905 al_use_transform(&identity);
915 if (img_192) al_destroy_bitmap(img_192);
916 if (img_32) al_destroy_bitmap(img_32);
918 if (skin_win_bg) al_destroy_bitmap(skin_win_bg);
919 if (skin_win_tb) al_destroy_bitmap(skin_win_tb);
920 if (skin_sld_track) al_destroy_bitmap(skin_sld_track);
921 if (skin_sld_fill) al_destroy_bitmap(skin_sld_fill);
922 if (skin_sld_handle) al_destroy_bitmap(skin_sld_handle);
923 if (skin_sld_handle_h) al_destroy_bitmap(skin_sld_handle_h);
924 if (skin_chk_unchecked) al_destroy_bitmap(skin_chk_unchecked);
925 if (skin_chk_checked) al_destroy_bitmap(skin_chk_checked);
926 al_destroy_font(font);
928 al_destroy_event_queue(event_queue);
930 al_uninstall_system();
ALLEGRO_TIMER * fps_timer
ALLEGRO_DISPLAY * display
void on_listbox_select(int widget_id, int index, int selected, void *user_data)
static int proj_btn_ids[4]
void on_link_click(int widget_id, const char *link, void *user_data)
void on_grid_toggle(int widget_id, void *user_data)
void on_player_toggle(int widget_id, void *user_data)
void on_login_click(int widget_id, void *user_data)
void on_window_toggle_click(int widget_id, int entry_index, int tag, void *user_data)
void on_checkbox_toggle(int widget_id, int checked, void *user_data)
void on_slider_change(int widget_id, double value, void *user_data)
void on_button_click(int widget_id, void *user_data)
static char theme_file[512]
void on_windows_menu_open(int widget_id, void *user_data)
void on_smooth_toggle(int widget_id, void *user_data)
static const char * win_names[16]
void on_radiolist_select(int widget_id, int index, void *user_data)
static int dropmenu_windows_id
void on_combobox_select(int widget_id, int index, void *user_data)
void on_ghost_toggle(int widget_id, void *user_data)
static const char * proj_names[]
void on_proj_select(int widget_id, void *user_data)
void on_height_toggle(int widget_id, void *user_data)
void on_text_change(int widget_id, const char *text, void *user_data)
void on_quit_click(int widget_id, void *user_data)
void on_scroll(int widget_id, double pos, void *user_data)
void n_abort(char const *format,...)
abort program with a text
float gui_offset_x
horizontal letterbox offset for virtual canvas
float virtual_h
virtual canvas height (0 = disabled / identity transform)
float gui_offset_y
vertical letterbox offset for virtual canvas
float virtual_w
virtual canvas width (0 = disabled / identity transform)
float gui_scale
computed uniform scale factor for virtual canvas
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_load_theme_json(N_GUI_CTX *ctx, const char *filepath)
load a theme and style from a JSON file
int n_gui_button_is_toggled(N_GUI_CTX *ctx, int widget_id)
Check if a toggle button is currently in the "on" state.
float n_gui_detect_dpi_scale(N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display)
Detect and apply DPI scale from an Allegro display.
void n_gui_toggle_window(N_GUI_CTX *ctx, int window_id)
Toggle window visibility (show if hidden, hide if shown)
#define N_GUI_ALIGN_LEFT
left aligned text
#define N_GUI_IMAGE_FIT
scale to fit within bounds, keep aspect ratio
int n_gui_add_slider(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, double min_val, double max_val, double initial, int mode, void(*on_change)(int, double, void *), void *user_data)
Add a slider widget.
void n_gui_window_apply_autofit(N_GUI_CTX *ctx, int window_id)
Trigger auto-fit recalculation for a window.
void n_gui_textarea_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set the text content of a textarea widget
#define N_GUI_SLIDER_PERCENT
slider uses 0-100 percentage
int n_gui_add_vslider(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, double min_val, double max_val, double initial, int mode, void(*on_change)(int, double, void *), void *user_data)
Add a vertical slider widget.
void n_gui_set_display(N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display)
Set the display pointer for clipboard operations (copy/paste).
void n_gui_window_set_bitmaps(N_GUI_CTX *ctx, int window_id, ALLEGRO_BITMAP *bg, ALLEGRO_BITMAP *titlebar, int bg_scale_mode)
Set optional bitmap overlays on a window's body and titlebar.
void n_gui_set_widget_theme(N_GUI_CTX *ctx, int widget_id, N_GUI_THEME theme)
Override the theme of a specific widget.
int n_gui_radiolist_add_item(N_GUI_CTX *ctx, int widget_id, const char *text)
add an item to a radiolist widget
void n_gui_label_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set the text of a label widget
int n_gui_add_listbox(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int selection_mode, void(*on_select)(int, int, int, void *), void *user_data)
Add a listbox widget.
#define N_GUI_WIN_RESIZE_SCALE
reposition AND resize proportionally, child widgets scale too
#define N_GUI_SLIDER_VALUE
slider uses raw start/end values
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.
void n_gui_set_widget_enabled(N_GUI_CTX *ctx, int widget_id, int enabled)
Enable or disable a widget.
int n_gui_add_radiolist(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 radio list widget (single selection with radio bullets)
#define N_GUI_WIN_FIXED_POSITION
disable window dragging (default:enable)
void n_gui_window_set_resize_policy(N_GUI_CTX *ctx, int window_id, int policy)
Set per-window resize policy (N_GUI_WIN_RESIZE_NONE / _MOVE / _SCALE).
void n_gui_listbox_set_selected(N_GUI_CTX *ctx, int widget_id, int index, int selected)
set the selection state of a listbox item
int n_gui_add_window_auto(N_GUI_CTX *ctx, const char *title, float x, float y)
Add a window with automatic sizing (use n_gui_window_autosize after adding widgets)
int n_gui_listbox_add_item(N_GUI_CTX *ctx, int widget_id, const char *text)
add an item to a listbox widget
void n_gui_set_virtual_size(N_GUI_CTX *ctx, float w, float h)
Set the virtual canvas size for resolution-independent scaling.
#define N_GUI_WIN_RESIZE_NONE
no adaptation: absolute position and size unchanged
#define N_GUI_AUTOFIT_WH
auto-adjust both width and height (convenience: W|H)
#define N_GUI_SELECT_SINGLE
single item selection
int n_gui_combobox_add_item(N_GUI_CTX *ctx, int widget_id, const char *text)
add an item to a combo box
void n_gui_window_autosize(N_GUI_CTX *ctx, int window_id)
Recompute and apply minimum-fit size for a window based on its current widgets.
void n_gui_set_focus(N_GUI_CTX *ctx, int widget_id)
Set keyboard focus to a specific widget.
#define N_GUI_SELECT_MULTIPLE
multiple item selection
#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_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)
void n_gui_button_set_toggled(N_GUI_CTX *ctx, int widget_id, int toggled)
Set the toggle state of a button.
int n_gui_add_toggle_button(N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, int shape, int initial_state, void(*on_click)(int, void *), void *user_data)
Add a toggle button widget (stays clicked/unclicked on single click)
int n_gui_add_label_link(N_GUI_CTX *ctx, int window_id, const char *text, const char *link, float x, float y, float w, float h, int align, void(*on_link_click)(int, const char *, void *), void *user_data)
Add a static text label with hyperlink.
int n_gui_add_image(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, ALLEGRO_BITMAP *bitmap, int scale_mode)
Add an image display widget.
void n_gui_label_set_bitmap(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg)
Set optional background bitmap on a label widget.
void n_gui_draw(N_GUI_CTX *ctx)
Draw all visible windows and their widgets.
#define N_GUI_AUTOFIT_CENTER
center the window on its insertion point after auto-fit (overrides EXPAND_LEFT/EXPAND_UP for centerin...
void n_gui_slider_set_bitmaps(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *track, ALLEGRO_BITMAP *fill, ALLEGRO_BITMAP *handle, ALLEGRO_BITMAP *handle_hover, ALLEGRO_BITMAP *handle_active)
Set optional bitmap overlays on a slider widget.
#define N_GUI_SCROLLBAR_H
horizontal scrollbar
int n_gui_dropmenu_add_dynamic_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 dynamic entry (rebuilt each time menu opens)
void n_gui_button_set_keycode(N_GUI_CTX *ctx, int widget_id, int keycode, int modifiers)
Bind a keyboard key with optional modifier requirements to a button.
int n_gui_window_is_open(N_GUI_CTX *ctx, int window_id)
Check if a window is currently visible.
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.
#define N_GUI_IMAGE_STRETCH
stretch to fill bounds
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_IMAGE_CENTER
draw at original size, centered
void n_gui_set_resize_mode(N_GUI_CTX *ctx, int mode)
Set context-level resize mode: N_GUI_RESIZE_VIRTUAL (default) or N_GUI_RESIZE_ADAPTIVE.
#define N_GUI_ALIGN_CENTER
center aligned text
int n_gui_add_scrollbar(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int orientation, int shape, double content_size, double viewport_size, void(*on_scroll)(int, double, void *), void *user_data)
Add a scrollbar widget.
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
Destroy a GUI context and all its windows/widgets.
void n_gui_checkbox_set_bitmaps(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *box, ALLEGRO_BITMAP *box_checked, ALLEGRO_BITMAP *box_hover)
Set optional bitmap overlays on a checkbox widget.
#define N_GUI_WIN_RESIZE_MOVE
reposition proportionally, keep pixel size
#define N_GUI_SHAPE_ROUNDED
rounded rectangle shape
#define N_GUI_ALIGN_RIGHT
right aligned text
void n_gui_radiolist_set_selected(N_GUI_CTX *ctx, int widget_id, int index)
set the selected item in a radiolist widget
void n_gui_window_set_flags(N_GUI_CTX *ctx, int window_id, int flags)
Set feature flags on a window.
#define N_GUI_ALIGN_JUSTIFIED
justified text (spread words to fill width)
void n_gui_set_widget_visible(N_GUI_CTX *ctx, int widget_id, int visible)
Show or hide a widget.
#define N_GUI_ID_MAX
maximum length for widget id/name strings
#define N_GUI_WIN_AUTO_SCROLLBAR
enable automatic scrollbars when content exceeds window size
#define N_GUI_RESIZE_ADAPTIVE
virtual size tracks display; windows adapt per their resize_policy
int n_gui_add_textarea(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int multiline, size_t char_limit, void(*on_change)(int, const char *, void *), void *user_data)
Add a text area widget.
int n_gui_add_checkbox(N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, int initial_checked, void(*on_toggle)(int, int, void *), void *user_data)
Add a checkbox widget.
#define N_GUI_SHAPE_RECT
rectangle shape (default)
void n_gui_combobox_set_selected(N_GUI_CTX *ctx, int widget_id, int index)
set the selected item in a combobox widget
#define N_GUI_SCROLLBAR_V
vertical scrollbar
N_GUI_THEME n_gui_make_theme(ALLEGRO_COLOR bg, ALLEGRO_COLOR bg_hover, ALLEGRO_COLOR bg_active, ALLEGRO_COLOR border, ALLEGRO_COLOR border_hover, ALLEGRO_COLOR border_active, ALLEGRO_COLOR text, ALLEGRO_COLOR text_hover, ALLEGRO_COLOR text_active, float border_thickness, float corner_rx, float corner_ry)
Create a custom theme with explicit colours.
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.
void n_gui_screen_to_virtual(const N_GUI_CTX *ctx, float sx, float sy, float *vx, float *vy)
Convert physical screen coordinates to virtual canvas coordinates.
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.
#define N_GUI_WIN_RESIZABLE
enable user-resizable window with a drag handle at bottom-right
void n_gui_window_set_autofit(N_GUI_CTX *ctx, int window_id, int autofit_flags, float border)
Configure auto-fit behavior for a dialog window.
void n_gui_dropmenu_clear_dynamic(N_GUI_CTX *ctx, int widget_id)
Remove all dynamic entries (keep static ones)
The top-level GUI context that holds all windows.
Color theme for a widget.
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
#define LOG_DEBUG
debug-level messages
#define LOG_ERR
error conditions
int set_log_file(char *file)
Set the logging to a file instead of stderr.
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_INFO
informational
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.