Nilorea Library GUI system demo - all widget types including dropdown menus, show/hide windows, auto-sizing, scrollbars, resizable windows, and bitmap skinning.
Nilorea Library GUI system demo - all widget types including dropdown menus, show/hide windows, auto-sizing, scrollbars, resizable windows, and bitmap skinning. Comprehensive demo showcasing every GUI widget available in the nilorea-library n_gui module: buttons (regular + toggle), sliders, text areas, checkboxes, scrollbars, listboxes (single + multi select), radio lists, comboboxes, labels, hyperlinks, images, toggle-button radio groups, dropdown menus with dynamic entries, automatic window sizing, auto-scrollbars, resizable windows, and optional bitmap skinning for windows and widgets.
#define WIDTH 1280
#define HEIGHT 900
#define ALLEGRO_UNSTABLE 1
#define HAVE_CJSON 1
#include "cJSON.h"
static const char*
proj_names[] = {
"Classic 2:1",
"True Isometric",
"Military",
"Staggered"};
#define NUM_WINDOWS 16
(void)user_data;
}
(void)user_data;
}
(void)user_data;
n_log(
LOG_NOTICE,
"Checkbox %d: %s", widget_id, checked ?
"checked" :
"unchecked");
}
void on_text_change(
int widget_id,
const char* text,
void* user_data) {
(void)user_data;
}
void on_scroll(
int widget_id,
double pos,
void* user_data) {
(void)user_data;
}
(void)widget_id;
int*
done = (
int*)user_data;
}
(void)user_data;
}
(void)user_data;
n_log(
LOG_NOTICE,
"Listbox %d: item %d %s", widget_id, index, selected ?
"selected" :
"deselected");
}
(void)user_data;
}
(void)user_data;
}
void on_link_click(
int widget_id,
const char* link,
void* user_data) {
(void)user_data;
}
}
}
}
}
}
for (int i = 0; i < 4; i++) {
} else {
}
}
}
(void)widget_id;
(void)entry_index;
}
snprintf(buf,
sizeof(buf),
"[%s] %s", is_open ?
"X" :
" ",
win_names[i]);
}
}
int main(
int argc,
char* argv[]) {
if (!al_init()) {
n_abort(
"Could not init Allegro.\n");
}
if (!al_install_audio()) {
}
if (!al_init_acodec_addon()) {
}
if (!al_init_image_addon()) {
n_abort(
"Unable to initialize image addon\n");
}
if (!al_init_primitives_addon()) {
n_abort(
"Unable to initialize primitives addon\n");
}
if (!al_init_font_addon()) {
n_abort(
"Unable to initialize font addon\n");
}
if (!al_init_ttf_addon()) {
n_abort(
"Unable to initialize ttf_font addon\n");
}
if (!al_install_keyboard()) {
n_abort(
"Unable to initialize keyboard handler\n");
}
if (!al_install_mouse()) {
n_abort(
"Unable to initialize mouse handler\n");
}
char ver_str[128] = "";
while ((
getoptret = getopt(argc, argv,
"hvV:L:t:")) != EOF) {
case 'h':
n_log(
LOG_NOTICE,
"\n %s -h help -v version -V DEBUGLEVEL -L logfile -t theme.json", argv[0]);
exit(TRUE);
case 'v':
sprintf(ver_str, "%s %s", __DATE__, __TIME__);
exit(TRUE);
break;
case 'V':
if (!strncmp("NOTICE", optarg, 6)) {
} else if (!strncmp("VERBOSE", optarg, 7)) {
} else if (!strncmp("ERROR", optarg, 5)) {
} else if (!strncmp("DEBUG", optarg, 5)) {
} else {
exit(FALSE);
}
break;
case 'L':
break;
case 't':
break;
default:
n_log(
LOG_ERR,
"\n %s -h help -v version -V DEBUGLEVEL -L logfile -t theme.json", argv[0]);
exit(FALSE);
}
}
ALLEGRO_EVENT_QUEUE* event_queue = al_create_event_queue();
if (!event_queue) {
n_abort(
"Failed to create event queue!\n");
}
al_set_new_display_flags(ALLEGRO_OPENGL | ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE);
n_abort(
"Unable to create display\n");
}
al_set_window_title(
display,
"Nilorea GUI Demo - All Widgets + Dropdown Menus");
ALLEGRO_TIMER*
fps_timer = al_create_timer(1.0 / 60.0);
al_register_event_source(event_queue, al_get_display_event_source(
display));
al_register_event_source(event_queue, al_get_timer_event_source(
fps_timer));
al_register_event_source(event_queue, al_get_keyboard_event_source());
al_register_event_source(event_queue, al_get_mouse_event_source());
ALLEGRO_FONT* font = al_create_builtin_font();
if (!font) {
n_abort(
"Unable to create builtin font\n");
}
} else {
}
}
int win_idx = 0;
win_idx++;
"Windows", 10, 2, 120, 22,
"File", 140, 2, 100, 22, NULL, NULL);
win_idx++;
al_map_rgba(120, 30, 30, 230), al_map_rgba(160, 40, 40, 240), al_map_rgba(200, 60, 60, 255),
al_map_rgba(200, 80, 80, 255), al_map_rgba(230, 100, 100, 255), al_map_rgba(255, 120, 120, 255),
al_map_rgba(255, 220, 220, 255), al_map_rgba(255, 255, 255, 255), al_map_rgba(255, 255, 255, 255),
2.0f, 8.0f, 8.0f);
{
}
win_idx++;
n_gui_add_slider(
gui, win2, 20, 20, 180, 24, 0.0, 100.0, 50.0,
N_GUI_SLIDER_VALUE,
on_slider_change, NULL);
n_gui_add_slider(
gui, win2, 20, 60, 180, 24, 0.0, 100.0, 25.0,
N_GUI_SLIDER_PERCENT,
on_slider_change, NULL);
{
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);
}
n_gui_add_vslider(
gui, win2, 240, 10, 24, 120, 0.0, 100.0, 75.0,
N_GUI_SLIDER_VALUE,
on_slider_change, NULL);
n_gui_add_vslider(
gui, win2, 275, 10, 24, 120, 0.0, 100.0, 40.0,
N_GUI_SLIDER_PERCENT,
on_slider_change, NULL);
win_idx++;
win_idx++;
{
}
{
}
win_idx++;
win_idx++;
win_idx++;
win_idx++;
win_names[win_idx] =
"Combo / Labels / Image";
win_idx++;
"Click this link!", "https://example.com",
ALLEGRO_BITMAP* img_192 = al_load_bitmap("DATAS/img/android-chrome-192x192.png");
ALLEGRO_BITMAP* img_32 = al_load_bitmap("DATAS/img/favicon-32x32.png");
win_idx++;
{
int btn_id;
}
win_idx++;
al_map_rgba(40, 60, 40, 230), al_map_rgba(50, 80, 50, 240), al_map_rgba(30, 120, 30, 255),
al_map_rgba(60, 100, 60, 255), al_map_rgba(70, 140, 70, 255), al_map_rgba(40, 160, 40, 255),
al_map_rgba(200, 255, 200, 255), al_map_rgba(255, 255, 255, 255), al_map_rgba(255, 255, 255, 255),
2.0f, 8.0f, 8.0f);
for (int i = 0; i < 4; i++) {
}
win_idx++;
win_names[win_idx] =
"Scrollable (auto scrollbar)";
win_idx++;
for (int i = 0; i < 20; i++) {
char buf[128];
snprintf(buf, sizeof(buf), "Scrollable line %d - content that extends beyond window", i + 1);
}
ALLEGRO_BITMAP* skin_win_bg = NULL;
ALLEGRO_BITMAP* skin_win_tb = NULL;
ALLEGRO_BITMAP* skin_sld_track = NULL;
ALLEGRO_BITMAP* skin_sld_fill = NULL;
ALLEGRO_BITMAP* skin_sld_handle = NULL;
ALLEGRO_BITMAP* skin_sld_handle_h = NULL;
ALLEGRO_BITMAP* skin_chk_unchecked = NULL;
ALLEGRO_BITMAP* skin_chk_checked = NULL;
{
ALLEGRO_BITMAP* prev_target = al_get_target_bitmap();
skin_win_bg = al_create_bitmap(64, 64);
al_set_target_bitmap(skin_win_bg);
for (int row = 0; row < 64; row++) {
float t = (float)row / 63.0f;
al_draw_line(0, (float)row, 64, (float)row,
al_map_rgba((unsigned char)(20 + 40 * t), (unsigned char)(40 + 60 * t), (unsigned char)(80 + 80 * t), 230), 1.0f);
}
skin_win_tb = al_create_bitmap(64, 16);
al_set_target_bitmap(skin_win_tb);
for (int row = 0; row < 16; row++) {
float t = (float)row / 15.0f;
al_draw_line(0, (float)row, 64, (float)row,
al_map_rgba((unsigned char)(60 + 40 * t), (unsigned char)(30 + 30 * t), (unsigned char)(100 + 50 * t), 240), 1.0f);
}
skin_sld_track = al_create_bitmap(32, 8);
al_set_target_bitmap(skin_sld_track);
al_clear_to_color(al_map_rgba(50, 50, 60, 200));
skin_sld_fill = al_create_bitmap(32, 8);
al_set_target_bitmap(skin_sld_fill);
al_clear_to_color(al_map_rgba(100, 180, 255, 230));
skin_sld_handle = al_create_bitmap(16, 16);
al_set_target_bitmap(skin_sld_handle);
al_clear_to_color(al_map_rgba(0, 0, 0, 0));
al_draw_filled_circle(8, 8, 7, al_map_rgba(200, 200, 220, 240));
skin_sld_handle_h = al_create_bitmap(16, 16);
al_set_target_bitmap(skin_sld_handle_h);
al_clear_to_color(al_map_rgba(0, 0, 0, 0));
al_draw_filled_circle(8, 8, 7, al_map_rgba(150, 220, 255, 255));
skin_chk_unchecked = al_create_bitmap(16, 16);
al_set_target_bitmap(skin_chk_unchecked);
al_clear_to_color(al_map_rgba(60, 60, 80, 220));
al_draw_rectangle(0.5f, 0.5f, 15.5f, 15.5f, al_map_rgba(150, 150, 200, 255), 1.0f);
skin_chk_checked = al_create_bitmap(16, 16);
al_set_target_bitmap(skin_chk_checked);
al_clear_to_color(al_map_rgba(80, 140, 255, 240));
al_draw_rectangle(0.5f, 0.5f, 15.5f, 15.5f, al_map_rgba(150, 150, 200, 255), 1.0f);
al_draw_line(3, 8, 7, 13, al_map_rgb(255, 255, 255), 2.0f);
al_draw_line(7, 13, 13, 3, al_map_rgb(255, 255, 255), 2.0f);
al_set_target_bitmap(prev_target);
win_idx++;
n_gui_add_label(
gui, win_skin,
"Window bg, titlebar, slider, checkbox,", 20, 180, 260, 16,
N_GUI_ALIGN_LEFT);
}
{
win_idx++;
}
int do_draw = 0;
int mx = 0, my = 0;
al_clear_keyboard_state(NULL);
al_flush_event_queue(event_queue);
do {
ALLEGRO_EVENT ev;
al_wait_for_event(event_queue, &ev);
if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) {
}
if (ev.type == ALLEGRO_EVENT_KEY_DOWN && ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE) {
}
if (ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE) {
int new_w = al_get_display_width(
display);
int new_h = al_get_display_height(
display);
}
(void)gui_handled;
if (ev.type == ALLEGRO_EVENT_MOUSE_AXES) {
mx = ev.mouse.x;
my = ev.mouse.y;
}
if (ev.type == ALLEGRO_EVENT_TIMER) {
char status_buf[256];
snprintf(status_buf, sizeof(status_buf),
"Player:%s Height:%s Grid:%s Smooth:%s Ghost:%s",
char proj_buf[128];
do_draw = 1;
}
if (do_draw && al_is_event_queue_empty(event_queue)) {
al_set_target_bitmap(al_get_backbuffer(
display));
al_clear_to_color(al_map_rgba(30, 30, 35, 255));
{
float vmx, vmy;
ALLEGRO_TRANSFORM overlay_tf;
al_identity_transform(&overlay_tf);
}
al_use_transform(&overlay_tf);
float cross_thick = 1.0f;
}
al_draw_line(vmx - 6, vmy, vmx + 6, vmy, al_map_rgb(255, 100, 100), cross_thick);
al_draw_line(vmx, vmy - 6, vmx, vmy + 6, al_map_rgb(255, 100, 100), cross_thick);
}
{
ALLEGRO_TRANSFORM instr_tf;
al_identity_transform(&instr_tf);
}
al_use_transform(&instr_tf);
al_draw_text(font, al_map_rgb(180, 180, 180), 10, virt_h - 18, 0,
"Drag windows | Click widgets | Scroll lists | Resize corners/display | 'Windows' dropdown | ESC to quit");
ALLEGRO_TRANSFORM identity;
al_identity_transform(&identity);
al_use_transform(&identity);
}
al_flip_display();
do_draw = 0;
}
if (img_192) al_destroy_bitmap(img_192);
if (img_32) al_destroy_bitmap(img_32);
if (skin_win_bg) al_destroy_bitmap(skin_win_bg);
if (skin_win_tb) al_destroy_bitmap(skin_win_tb);
if (skin_sld_track) al_destroy_bitmap(skin_sld_track);
if (skin_sld_fill) al_destroy_bitmap(skin_sld_fill);
if (skin_sld_handle) al_destroy_bitmap(skin_sld_handle);
if (skin_sld_handle_h) al_destroy_bitmap(skin_sld_handle_h);
if (skin_chk_unchecked) al_destroy_bitmap(skin_chk_unchecked);
if (skin_chk_checked) al_destroy_bitmap(skin_chk_checked);
al_destroy_font(font);
al_destroy_event_queue(event_queue);
al_uninstall_system();
return 0;
}
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.