Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_gui.h
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <https://www.gnu.org/licenses/>.
17 */
18
27#ifndef __NILOREA_GUI__
28#define __NILOREA_GUI__
29
30#ifdef __cplusplus
31extern "C" {
32#endif
33
70#include <stdio.h>
71#include <stdlib.h>
72#include <string.h>
73#include <ctype.h>
74#include <stdbool.h>
75
76#include <nilorea/n_allegro5.h>
77#include <nilorea/n_common.h>
78#include <nilorea/n_str.h>
79#include <nilorea/n_log.h>
80#include <nilorea/n_list.h>
81#include <nilorea/n_hash.h>
82
84#define N_GUI_ID_MAX 128
86#define N_GUI_TEXT_MAX 4096
87
88/* ---- widget type enum ---- */
90#define N_GUI_TYPE_BUTTON 1
92#define N_GUI_TYPE_SLIDER 2
94#define N_GUI_TYPE_TEXTAREA 3
96#define N_GUI_TYPE_CHECKBOX 4
98#define N_GUI_TYPE_SCROLLBAR 5
100#define N_GUI_TYPE_LISTBOX 6
102#define N_GUI_TYPE_RADIOLIST 7
104#define N_GUI_TYPE_COMBOBOX 8
106#define N_GUI_TYPE_IMAGE 9
108#define N_GUI_TYPE_LABEL 10
110#define N_GUI_TYPE_DROPMENU 11
111
112/* ---- shape flags ---- */
114#define N_GUI_SHAPE_RECT 0
116#define N_GUI_SHAPE_ROUNDED 1
118#define N_GUI_SHAPE_BITMAP 2
119
120/* ---- slider mode ---- */
122#define N_GUI_SLIDER_VALUE 0
124#define N_GUI_SLIDER_PERCENT 1
125
126/* ---- slider orientation ---- */
128#define N_GUI_SLIDER_H 0
130#define N_GUI_SLIDER_V 1
131
132/* ---- scrollbar orientation ---- */
134#define N_GUI_SCROLLBAR_H 0
136#define N_GUI_SCROLLBAR_V 1
137
138/* ---- list selection modes ---- */
140#define N_GUI_SELECT_NONE 0
142#define N_GUI_SELECT_SINGLE 1
144#define N_GUI_SELECT_MULTIPLE 2
145
146/* ---- image scale modes ---- */
148#define N_GUI_IMAGE_FIT 0
150#define N_GUI_IMAGE_STRETCH 1
152#define N_GUI_IMAGE_CENTER 2
153
154/* ---- text alignment ---- */
156#define N_GUI_ALIGN_LEFT 0
158#define N_GUI_ALIGN_CENTER 1
160#define N_GUI_ALIGN_RIGHT 2
162#define N_GUI_ALIGN_JUSTIFIED 3
163
164/* ---- widget state flags ---- */
166#define N_GUI_STATE_IDLE 0
168#define N_GUI_STATE_HOVER 1
170#define N_GUI_STATE_ACTIVE 2
172#define N_GUI_STATE_FOCUSED 4
174#define N_GUI_STATE_SCROLLBAR_DRAG 8
175
176/* ---- window state flags ---- */
178#define N_GUI_WIN_OPEN 1
180#define N_GUI_WIN_MINIMISED 2
182#define N_GUI_WIN_DRAGGING 4
184#define N_GUI_WIN_RESIZING 8
186#define N_GUI_WIN_VSCROLL_DRAG 16
188#define N_GUI_WIN_HSCROLL_DRAG 32
189
190/* ---- window feature flags (set via n_gui_window_set_flags) ---- */
192#define N_GUI_WIN_AUTO_SCROLLBAR 16
194#define N_GUI_WIN_RESIZABLE 32
196#define N_GUI_WIN_FIXED_POSITION 64
198#define N_GUI_WIN_FRAMELESS 128
199
200/* ---- context-level resize modes (set via n_gui_set_resize_mode) ---- */
202#define N_GUI_RESIZE_VIRTUAL 0
204#define N_GUI_RESIZE_ADAPTIVE 1
205
206/* ---- per-window resize policies (used in ADAPTIVE mode) ---- */
208#define N_GUI_WIN_RESIZE_NONE 0
210#define N_GUI_WIN_RESIZE_MOVE 1
212#define N_GUI_WIN_RESIZE_SCALE 2
213
214/* ---- dialog auto-adjust flags (set via n_gui_window_set_autofit) ---- */
216#define N_GUI_AUTOFIT_W 1
218#define N_GUI_AUTOFIT_H 2
220#define N_GUI_AUTOFIT_WH 3
222#define N_GUI_AUTOFIT_EXPAND_LEFT 4
224#define N_GUI_AUTOFIT_EXPAND_UP 8
226#define N_GUI_AUTOFIT_CENTER 16
227
228/* ---- window z-order modes ---- */
230#define N_GUI_ZORDER_NORMAL 0
232#define N_GUI_ZORDER_ALWAYS_ON_TOP 1
234#define N_GUI_ZORDER_ALWAYS_BEHIND 2
241#define N_GUI_ZORDER_FIXED 3
242
243/* ---- text dimension bounding box ---- */
244
246typedef struct N_GUI_TEXT_DIMS {
247 int x;
248 int y;
249 int w;
250 int h;
252
253/* ---- color theme ---- */
254
256typedef struct N_GUI_THEME {
258 ALLEGRO_COLOR bg_normal;
260 ALLEGRO_COLOR bg_hover;
262 ALLEGRO_COLOR bg_active;
264 ALLEGRO_COLOR border_normal;
266 ALLEGRO_COLOR border_hover;
268 ALLEGRO_COLOR border_active;
270 ALLEGRO_COLOR text_normal;
272 ALLEGRO_COLOR text_hover;
274 ALLEGRO_COLOR text_active;
282 ALLEGRO_COLOR selection_color;
284
285/* ---- button key modifier flags (use with n_gui_button_set_keycode) ---- */
287#define N_GUI_KEY_MOD_MASK (ALLEGRO_KEYMOD_SHIFT | ALLEGRO_KEYMOD_CTRL | ALLEGRO_KEYMOD_ALT | ALLEGRO_KEYMOD_ALTGR)
288
290#define N_GUI_KEY_SOURCES_MAX 8
291
292/* ---- per-widget data ---- */
293
295typedef struct N_GUI_BUTTON_DATA {
299 ALLEGRO_BITMAP* bitmap;
301 ALLEGRO_BITMAP* bitmap_hover;
303 ALLEGRO_BITMAP* bitmap_active;
305 int shape;
326 void (*on_click)(int widget_id, void* user_data);
330
332typedef struct N_GUI_SLIDER_DATA {
334 double min_val;
336 double max_val;
338 double value;
340 double step;
342 int mode;
346 ALLEGRO_BITMAP* track_bitmap;
348 ALLEGRO_BITMAP* fill_bitmap;
350 ALLEGRO_BITMAP* handle_bitmap;
352 ALLEGRO_BITMAP* handle_hover_bitmap;
354 ALLEGRO_BITMAP* handle_active_bitmap;
356 void (*on_change)(int widget_id, double value, void* user_data);
360
362typedef struct N_GUI_TEXTAREA_DATA {
364 char* text;
366 size_t text_len;
377 size_t sel_start;
379 size_t sel_end;
383 float scroll_x;
389 ALLEGRO_BITMAP* bg_bitmap;
393 void (*on_change)(int widget_id, const char* text, void* user_data);
397
399typedef struct N_GUI_CHECKBOX_DATA {
405 ALLEGRO_BITMAP* box_bitmap;
407 ALLEGRO_BITMAP* box_checked_bitmap;
409 ALLEGRO_BITMAP* box_hover_bitmap;
411 void (*on_toggle)(int widget_id, int checked, void* user_data);
415
417typedef struct N_GUI_SCROLLBAR_DATA {
427 int shape;
429 ALLEGRO_BITMAP* track_bitmap;
431 ALLEGRO_BITMAP* thumb_bitmap;
433 ALLEGRO_BITMAP* thumb_hover_bitmap;
435 ALLEGRO_BITMAP* thumb_active_bitmap;
437 void (*on_scroll)(int widget_id, double scroll_pos, void* user_data);
441
449
451typedef struct N_GUI_LISTBOX_DATA {
455 size_t nb_items;
465 ALLEGRO_BITMAP* bg_bitmap;
467 ALLEGRO_BITMAP* item_bg_bitmap;
469 ALLEGRO_BITMAP* item_selected_bitmap;
471 void (*on_select)(int widget_id, int index, int selected, void* user_data);
475
477typedef struct N_GUI_RADIOLIST_DATA {
481 size_t nb_items;
491 ALLEGRO_BITMAP* bg_bitmap;
493 ALLEGRO_BITMAP* item_bg_bitmap;
495 ALLEGRO_BITMAP* item_selected_bitmap;
497 void (*on_select)(int widget_id, int index, void* user_data);
501
502/* ---- combobox feature flags ---- */
504#define N_GUI_COMBOBOX_AUTO_WIDTH 1
505
507typedef struct N_GUI_COMBOBOX_DATA {
511 size_t nb_items;
525 ALLEGRO_BITMAP* bg_bitmap;
527 ALLEGRO_BITMAP* item_bg_bitmap;
529 ALLEGRO_BITMAP* item_selected_bitmap;
531 void (*on_select)(int widget_id, int index, void* user_data);
535 int flags;
537
539typedef struct N_GUI_IMAGE_DATA {
541 ALLEGRO_BITMAP* bitmap;
545
547typedef struct N_GUI_LABEL_DATA {
553 int align;
555 float scroll_y;
563 ALLEGRO_BITMAP* bg_bitmap;
565 void (*on_link_click)(int widget_id, const char* link, void* user_data);
569
571typedef struct N_GUI_DROPMENU_ENTRY {
577 int tag;
579 void (*on_click)(int widget_id, int entry_index, int tag, void* user_data);
583
613
614/* ---- widget ---- */
615
617typedef struct N_GUI_WIDGET {
619 int id;
621 int type;
623 float x;
625 float y;
627 float w;
629 float h;
631 int state;
641 void* data;
643 float norm_x;
645 float norm_y;
647 float norm_w;
649 float norm_h;
651
652/* ---- pseudo window ---- */
653
725
726/* ---- global style (all configurable sizes, colors, paddings) ---- */
727
731typedef struct N_GUI_STYLE {
732 /* window chrome */
743
744 /* window auto-scrollbar */
757
758 /* global display scrollbar */
775
776 /* resize grip */
782 ALLEGRO_COLOR grip_color;
783
784 /* slider */
799
800 /* text area */
807
808 /* checkbox */
819
820 /* radio list */
829
830 /* list items (shared by listbox, radiolist, combobox, dropmenu) */
845
846 /* dropdown arrow (combobox & dropmenu) */
857
858 /* label */
864 ALLEGRO_COLOR link_color_normal;
866 ALLEGRO_COLOR link_color_hover;
867
868 /* scroll step */
873
874 /* combobox auto-width cap */
878
879/* ---- gui context ---- */
880
952
953/* =============== API =============== */
954
955/* ---- style helpers ---- */
956
959
960/* ---- theme helpers ---- */
961
966 ALLEGRO_COLOR bg,
967 ALLEGRO_COLOR bg_hover,
968 ALLEGRO_COLOR bg_active,
969 ALLEGRO_COLOR border,
970 ALLEGRO_COLOR border_hover,
971 ALLEGRO_COLOR border_active,
972 ALLEGRO_COLOR text,
973 ALLEGRO_COLOR text_hover,
974 ALLEGRO_COLOR text_active,
975 float border_thickness,
976 float corner_rx,
977 float corner_ry);
978
979/* ---- text measurement ---- */
980
983N_GUI_TEXT_DIMS n_gui_get_text_dims(ALLEGRO_FONT* font, const char* text);
984
985/* ---- context ---- */
986
988N_GUI_CTX* n_gui_new_ctx(ALLEGRO_FONT* default_font);
990void n_gui_destroy_ctx(N_GUI_CTX** ctx);
991
992/* ---- window management ---- */
993
995int n_gui_add_window(N_GUI_CTX* ctx, const char* title, float x, float y, float w, float h);
997int n_gui_add_window_auto(N_GUI_CTX* ctx, const char* title, float x, float y);
999N_GUI_WINDOW* n_gui_get_window(N_GUI_CTX* ctx, int window_id);
1001void n_gui_close_window(N_GUI_CTX* ctx, int window_id);
1003void n_gui_open_window(N_GUI_CTX* ctx, int window_id);
1005void n_gui_toggle_window(N_GUI_CTX* ctx, int window_id);
1007int n_gui_window_is_open(N_GUI_CTX* ctx, int window_id);
1009void n_gui_minimize_window(N_GUI_CTX* ctx, int window_id);
1011void n_gui_raise_window(N_GUI_CTX* ctx, int window_id);
1013void n_gui_lower_window(N_GUI_CTX* ctx, int window_id);
1019void n_gui_window_set_zorder(N_GUI_CTX* ctx, int window_id, int z_mode, int z_value);
1021int n_gui_window_get_zorder(N_GUI_CTX* ctx, int window_id);
1023int n_gui_window_get_zvalue(N_GUI_CTX* ctx, int window_id);
1028void n_gui_window_set_flags(N_GUI_CTX* ctx, int window_id, int flags);
1030int n_gui_window_get_flags(N_GUI_CTX* ctx, int window_id);
1032void n_gui_window_autosize(N_GUI_CTX* ctx, int window_id);
1038void n_gui_window_set_autofit(N_GUI_CTX* ctx, int window_id, int autofit_flags, float border);
1042void n_gui_window_apply_autofit(N_GUI_CTX* ctx, int window_id);
1043
1044/* ---- resize mode ---- */
1045
1047void n_gui_set_resize_mode(N_GUI_CTX* ctx, int mode);
1048
1051
1055void n_gui_window_set_resize_policy(N_GUI_CTX* ctx, int window_id, int policy);
1056
1058int n_gui_window_get_resize_policy(N_GUI_CTX* ctx, int window_id);
1059
1063void n_gui_window_update_normalized(N_GUI_CTX* ctx, int window_id);
1064
1069void n_gui_apply_adaptive_resize(N_GUI_CTX* ctx, float new_w, float new_h);
1070
1071/* ---- widget creation (returns widget id) ---- */
1072
1074int 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);
1075
1077int n_gui_add_button_bitmap(N_GUI_CTX* ctx, int window_id, const char* label, float x, float y, float w, float h, ALLEGRO_BITMAP* normal, ALLEGRO_BITMAP* hover, ALLEGRO_BITMAP* active, void (*on_click)(int, void*), void* user_data);
1078
1080int 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);
1081
1083int n_gui_button_is_toggled(N_GUI_CTX* ctx, int widget_id);
1085void n_gui_button_set_toggled(N_GUI_CTX* ctx, int widget_id, int toggled);
1087void n_gui_button_set_toggle_mode(N_GUI_CTX* ctx, int widget_id, int toggle_mode);
1088
1089/* button keyboard binding */
1102void n_gui_button_set_keycode(N_GUI_CTX* ctx, int widget_id, int keycode, int modifiers);
1103
1115void n_gui_button_set_keycode_focused(N_GUI_CTX* ctx, int widget_id, int keycode, int modifiers, const int* sources, int source_count);
1116
1118int 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);
1119
1121int 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);
1122
1124int 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);
1125
1127int 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);
1128
1130int 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);
1131
1132/* ---- widget access ---- */
1133
1135N_GUI_WIDGET* n_gui_get_widget(N_GUI_CTX* ctx, int widget_id);
1137void n_gui_set_widget_theme(N_GUI_CTX* ctx, int widget_id, N_GUI_THEME theme);
1139void n_gui_set_widget_visible(N_GUI_CTX* ctx, int widget_id, int visible);
1141void n_gui_set_widget_enabled(N_GUI_CTX* ctx, int widget_id, int enabled);
1143int n_gui_is_widget_enabled(N_GUI_CTX* ctx, int widget_id);
1147void n_gui_set_focus(N_GUI_CTX* ctx, int widget_id);
1148
1149/* slider helpers */
1151double n_gui_slider_get_value(N_GUI_CTX* ctx, int widget_id);
1153void n_gui_slider_set_value(N_GUI_CTX* ctx, int widget_id, double value);
1155void n_gui_slider_set_range(N_GUI_CTX* ctx, int widget_id, double min_val, double max_val);
1157void n_gui_slider_set_step(N_GUI_CTX* ctx, int widget_id, double step);
1158
1159/* textarea helpers */
1161const char* n_gui_textarea_get_text(N_GUI_CTX* ctx, int widget_id);
1163void n_gui_textarea_set_text(N_GUI_CTX* ctx, int widget_id, const char* text);
1165void n_gui_textarea_scroll_to_bottom(N_GUI_CTX* ctx, int widget_id);
1167void n_gui_textarea_set_selection(N_GUI_CTX* ctx, int widget_id, size_t start, size_t end);
1169void n_gui_textarea_scroll_to_offset(N_GUI_CTX* ctx, int widget_id, size_t byte_offset);
1171size_t n_gui_textarea_get_text_length(N_GUI_CTX* ctx, int widget_id);
1172
1173/* checkbox helpers */
1175int n_gui_checkbox_is_checked(N_GUI_CTX* ctx, int widget_id);
1177void n_gui_checkbox_set_checked(N_GUI_CTX* ctx, int widget_id, int checked);
1178
1179/* scrollbar helpers */
1181double n_gui_scrollbar_get_pos(N_GUI_CTX* ctx, int widget_id);
1183void n_gui_scrollbar_set_pos(N_GUI_CTX* ctx, int widget_id, double pos);
1185void n_gui_scrollbar_set_sizes(N_GUI_CTX* ctx, int widget_id, double content_size, double viewport_size);
1186
1187/* ---- listbox ---- */
1188
1190int 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);
1192int n_gui_listbox_add_item(N_GUI_CTX* ctx, int widget_id, const char* text);
1194int n_gui_listbox_remove_item(N_GUI_CTX* ctx, int widget_id, int index);
1196void n_gui_listbox_clear(N_GUI_CTX* ctx, int widget_id);
1198int n_gui_listbox_get_count(N_GUI_CTX* ctx, int widget_id);
1200const char* n_gui_listbox_get_item_text(N_GUI_CTX* ctx, int widget_id, int index);
1202int n_gui_listbox_get_selected(N_GUI_CTX* ctx, int widget_id);
1204int n_gui_listbox_is_selected(N_GUI_CTX* ctx, int widget_id, int index);
1206void n_gui_listbox_set_selected(N_GUI_CTX* ctx, int widget_id, int index, int selected);
1208int n_gui_listbox_get_scroll_offset(N_GUI_CTX* ctx, int widget_id);
1210void n_gui_listbox_set_scroll_offset(N_GUI_CTX* ctx, int widget_id, int offset);
1211
1212/* ---- radiolist ---- */
1213
1215int 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);
1217int n_gui_radiolist_add_item(N_GUI_CTX* ctx, int widget_id, const char* text);
1219void n_gui_radiolist_clear(N_GUI_CTX* ctx, int widget_id);
1221int n_gui_radiolist_get_selected(N_GUI_CTX* ctx, int widget_id);
1223void n_gui_radiolist_set_selected(N_GUI_CTX* ctx, int widget_id, int index);
1224
1225/* ---- combobox ---- */
1226
1228int 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);
1230int n_gui_combobox_add_item(N_GUI_CTX* ctx, int widget_id, const char* text);
1232void n_gui_combobox_clear(N_GUI_CTX* ctx, int widget_id);
1234int n_gui_combobox_get_selected(N_GUI_CTX* ctx, int widget_id);
1236void n_gui_combobox_set_selected(N_GUI_CTX* ctx, int widget_id, int index);
1237
1239void n_gui_combobox_set_flags(N_GUI_CTX* ctx, int widget_id, int flags);
1240
1241/* ---- image ---- */
1242
1244int 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);
1246void n_gui_image_set_bitmap(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bitmap);
1247
1248/* ---- label (static text, optional hyperlink) ---- */
1249
1251int n_gui_add_label(N_GUI_CTX* ctx, int window_id, const char* text, float x, float y, float w, float h, int align);
1253int 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);
1255void n_gui_label_set_text(N_GUI_CTX* ctx, int widget_id, const char* text);
1257void n_gui_label_set_link(N_GUI_CTX* ctx, int widget_id, const char* link);
1258
1259/* ---- dropdown menu ---- */
1260
1272int 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);
1274int 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);
1276int 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);
1278void n_gui_dropmenu_clear_dynamic(N_GUI_CTX* ctx, int widget_id);
1280void n_gui_dropmenu_clear(N_GUI_CTX* ctx, int widget_id);
1282void n_gui_dropmenu_set_entry_text(N_GUI_CTX* ctx, int widget_id, int index, const char* text);
1284int n_gui_dropmenu_get_count(N_GUI_CTX* ctx, int widget_id);
1285
1286/* ---- bitmap skinning ---- */
1287
1297void n_gui_window_set_bitmaps(N_GUI_CTX* ctx, int window_id, ALLEGRO_BITMAP* bg, ALLEGRO_BITMAP* titlebar, int bg_scale_mode);
1298
1303void 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);
1304
1309void n_gui_scrollbar_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* track, ALLEGRO_BITMAP* thumb, ALLEGRO_BITMAP* thumb_hover, ALLEGRO_BITMAP* thumb_active);
1310
1315void n_gui_checkbox_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* box, ALLEGRO_BITMAP* box_checked, ALLEGRO_BITMAP* box_hover);
1316
1320void n_gui_textarea_set_bitmap(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg);
1321
1326void n_gui_textarea_set_mask_char(N_GUI_CTX* ctx, int widget_id, char mask);
1327
1332void n_gui_listbox_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg, ALLEGRO_BITMAP* item_bg, ALLEGRO_BITMAP* item_selected);
1333
1338void n_gui_radiolist_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg, ALLEGRO_BITMAP* item_bg, ALLEGRO_BITMAP* item_selected);
1339
1344void n_gui_combobox_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg, ALLEGRO_BITMAP* item_bg, ALLEGRO_BITMAP* item_selected);
1345
1350void n_gui_dropmenu_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* panel, ALLEGRO_BITMAP* item_hover);
1351
1355void n_gui_label_set_bitmap(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg);
1356
1357/* ---- JSON theme I/O ---- */
1358
1361int n_gui_save_theme_json(N_GUI_CTX* ctx, const char* filepath);
1362
1365int n_gui_load_theme_json(N_GUI_CTX* ctx, const char* filepath);
1366
1367/* ---- virtual canvas / display / DPI ---- */
1368
1375void n_gui_set_virtual_size(N_GUI_CTX* ctx, float w, float h);
1376
1381
1389void n_gui_screen_to_virtual(const N_GUI_CTX* ctx, float sx, float sy, float* vx, float* vy);
1390
1394void n_gui_set_display_size(N_GUI_CTX* ctx, float w, float h);
1396void n_gui_set_display(N_GUI_CTX* ctx, ALLEGRO_DISPLAY* display);
1397
1400void n_gui_set_dpi_scale(N_GUI_CTX* ctx, float scale);
1401
1403float n_gui_get_dpi_scale(const N_GUI_CTX* ctx);
1404
1408float n_gui_detect_dpi_scale(N_GUI_CTX* ctx, ALLEGRO_DISPLAY* display);
1409
1410/* ---- event processing & drawing ---- */
1411
1413int n_gui_process_event(N_GUI_CTX* ctx, ALLEGRO_EVENT event);
1415void n_gui_draw(N_GUI_CTX* ctx);
1419
1421#define N_GUI_TAB_MAX 16
1422
1438
1440N_GUI_TAB_PANEL* n_gui_tab_create(N_GUI_CTX* ctx, int window_id, float x, float y, float button_w, float button_h, void (*on_tab_change)(int, void*), void* user_data);
1442int n_gui_tab_add(N_GUI_TAB_PANEL* panel, const char* label);
1444void n_gui_tab_set_content_window(N_GUI_TAB_PANEL* panel, int tab_index, int window_id);
1446void n_gui_tab_set_active(N_GUI_TAB_PANEL* panel, int index);
1450void n_gui_tab_free(N_GUI_TAB_PANEL** panel);
1451
1453#define N_GUI_TREE_MAX 512
1454
1464
1476
1478N_GUI_TREE* n_gui_tree_create(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h, void (*on_select)(int, void*), void* user_data);
1480int n_gui_tree_add_node(N_GUI_TREE* tree, const char* label, int parent_index, void* user_data);
1482void n_gui_tree_toggle_expand(N_GUI_TREE* tree, int node_index);
1484void n_gui_tree_rebuild(N_GUI_TREE* tree);
1486void n_gui_tree_free(N_GUI_TREE** tree);
1487
1489#define N_GUI_KV_MAX 128
1490
1500
1519
1521N_GUI_KVTABLE* n_gui_kvtable_create(N_GUI_CTX* ctx, int window_id, float row_height, float padding, void (*on_remove)(int, void*), void* user_data);
1524 const char* key,
1525 const char* value,
1526 const char* description,
1527 int enabled);
1529void n_gui_kvtable_remove_row(N_GUI_KVTABLE* table, int row_index);
1533void n_gui_kvtable_free(N_GUI_KVTABLE** table);
1534
1539#ifdef __cplusplus
1540}
1541#endif
1542
1543#endif /* __NILOREA_GUI__ */
ALLEGRO_DISPLAY * display
Definition ex_fluid.c:53
void on_link_click(int widget_id, const char *link, void *user_data)
Definition ex_gui.c:140
void on_scroll(int widget_id, double pos, void *user_data)
Definition ex_gui.c:103
static int mode
char * key
char title[128]
window title
Definition n_gui.h:659
ALLEGRO_BITMAP * thumb_bitmap
optional bitmap for the thumb/handle, normal state (NULL = color theme)
Definition n_gui.h:431
float h
height
Definition n_gui.h:629
float scroll_y
vertical scroll offset for overflowing text (pixels)
Definition n_gui.h:555
float scroll_y
vertical scroll offset for auto-scrollbar (pixels)
Definition n_gui.h:689
int visible
visibility flag
Definition n_gui.h:633
ALLEGRO_BITMAP * panel_bitmap
optional bitmap for the dropdown panel background (NULL = color theme)
Definition n_gui.h:603
ALLEGRO_BITMAP * handle_hover_bitmap
optional bitmap for the handle on hover (NULL = fallback to handle_bitmap)
Definition n_gui.h:352
float button_h
height of each tab button
Definition n_gui.h:1434
int is_open
is dropdown currently open
Definition n_gui.h:517
int content_window_ids[16]
content window IDs (-1 = none)
Definition n_gui.h:1428
int w
bounding box width in pixels
Definition n_gui.h:249
int open_combobox_id
id of the combobox whose dropdown is currently open, or -1
Definition n_gui.h:906
ALLEGRO_COLOR scrollbar_track_color
scrollbar track colour
Definition n_gui.h:754
int max_visible
max visible items in dropdown
Definition n_gui.h:523
int selected_index
currently selected index (-1 = none)
Definition n_gui.h:515
void(* on_remove)(int, void *)
callback on row removal
Definition n_gui.h:1516
size_t items_capacity
allocated capacity
Definition n_gui.h:457
ALLEGRO_COLOR grip_color
grip line colour
Definition n_gui.h:782
float dropdown_border_thickness
dropdown panel border thickness
Definition n_gui.h:856
char * text
text content (dynamically allocated, text_alloc bytes)
Definition n_gui.h:364
int nb_rows
total rows (including removed)
Definition n_gui.h:1506
float slider_handle_edge_offset
handle circle offset from edge
Definition n_gui.h:794
int parent_index
parent node index, or -1 for root
Definition n_gui.h:1458
int shape
shape type: N_GUI_SHAPE_RECT or N_GUI_SHAPE_ROUNDED
Definition n_gui.h:427
float content_h
total content height computed from widgets (internal)
Definition n_gui.h:693
float global_scrollbar_thumb_padding
global thumb inset from track edge
Definition n_gui.h:764
char label[128]
menu label (shown on the button)
Definition n_gui.h:587
size_t items_capacity
allocated capacity
Definition n_gui.h:513
float x
position x on screen
Definition n_gui.h:661
float scrollbar_size
scrollbar track width/height
Definition n_gui.h:746
float norm_y
normalized position y (0.0–1.0 fraction of reference display height)
Definition n_gui.h:719
void(* on_select)(int widget_id, int index, void *user_data)
callback on selection change (widget_id, selected_index, user_data)
Definition n_gui.h:497
float scrollbar_thumb_corner_r
thumb corner radius
Definition n_gui.h:752
int is_dynamic
is this entry dynamic (rebuilt via callback each time menu opens)
Definition n_gui.h:575
float title_padding
padding left of title text
Definition n_gui.h:740
float min_win_h
minimum window height (for resize)
Definition n_gui.h:738
float dropdown_arrow_half_w
horizontal half-extent of the arrow chevron
Definition n_gui.h:854
int toggled
toggle state: 0 = off/unclicked, 1 = on/clicked (only used when toggle_mode=1)
Definition n_gui.h:309
int lbl_enabled
label widget ID for "On" header
Definition n_gui.h:1514
ALLEGRO_BITMAP * item_bg_bitmap
optional bitmap for per-item background, normal state (NULL = color theme)
Definition n_gui.h:467
int scroll_offset
scroll offset in items
Definition n_gui.h:487
float ref_display_h
reference display height at the time normalized values were last captured
Definition n_gui.h:950
float slider_track_corner_r
track corner radius
Definition n_gui.h:788
int y
bounding box y offset from draw origin
Definition n_gui.h:248
float titlebar_h
title bar height
Definition n_gui.h:669
ALLEGRO_BITMAP * handle_active_bitmap
optional bitmap for the handle while dragging (NULL = fallback to handle_bitmap)
Definition n_gui.h:354
void(* on_tab_change)(int, void *)
callback on tab switch (may be NULL)
Definition n_gui.h:1435
float norm_y
normalized position y (fraction of parent window h, used for SCALE resize)
Definition n_gui.h:645
int dropmenu_max_visible
default max visible items for dropmenu panel
Definition n_gui.h:838
float norm_x
normalized position x (0.0–1.0 fraction of reference display width)
Definition n_gui.h:717
float textarea_padding
inner padding
Definition n_gui.h:802
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the label background (NULL = no background)
Definition n_gui.h:563
float item_height
item height
Definition n_gui.h:601
N_GUI_THEME theme
color theme for this widget
Definition n_gui.h:637
float title_max_w_reserve
pixels reserved right of title for truncation
Definition n_gui.h:742
char text[128]
item display text
Definition n_gui.h:445
int nb_tabs
number of tabs
Definition n_gui.h:1429
int key_sources[8]
widget IDs that can trigger this focused key binding.
Definition n_gui.h:324
float checkbox_label_gap
gap between box and label text
Definition n_gui.h:816
int open_dropmenu_id
id of the dropdown menu whose panel is currently open, or -1
Definition n_gui.h:910
float global_scrollbar_thumb_corner_r
global thumb corner radius
Definition n_gui.h:766
N_GUI_THEME default_theme
default theme (applied to new widgets/windows)
Definition n_gui.h:894
float dpi_scale
DPI scale factor (1.0 = normal, 1.25 = 125%, 2.0 = HiDPI, etc.)
Definition n_gui.h:924
void * user_data
user data for callback
Definition n_gui.h:567
int scroll_from_wheel
set to 1 when scroll was changed by mouse wheel, cleared on key input
Definition n_gui.h:385
int btn_add
button widget ID for "+" add row
Definition n_gui.h:1515
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the window body background (NULL = color fill)
Definition n_gui.h:701
float scrollbar_thumb_padding
thumb inset from track edge
Definition n_gui.h:750
float w
width
Definition n_gui.h:627
int visible_map[512]
visible row to node index
Definition n_gui.h:1471
ALLEGRO_COLOR text_normal
text normal
Definition n_gui.h:270
int remove_id
button widget ID for the remove action
Definition n_gui.h:1497
float w
window width
Definition n_gui.h:665
int combobox_max_visible
default max visible items for combobox dropdown
Definition n_gui.h:836
ALLEGRO_BITMAP * item_bg_bitmap
optional bitmap for per-item background, normal state (NULL = color theme)
Definition n_gui.h:527
float norm_h
normalized height (fraction of parent window h)
Definition n_gui.h:649
void * user_data
user data for callback
Definition n_gui.h:1474
void(* on_open)(int widget_id, void *user_data)
callback to rebuild dynamic entries each time the menu is opened.
Definition n_gui.h:609
int mouse_b1_prev
previous mouse button 1 state
Definition n_gui.h:904
int listbox_id
listbox widget ID
Definition n_gui.h:1468
float corner_rx
corner radius for rounded shapes
Definition n_gui.h:278
ALLEGRO_COLOR selection_color
text selection highlight colour (semi-transparent recommended)
Definition n_gui.h:282
ALLEGRO_BITMAP * bitmap
optional bitmap for the button (NULL = color theme)
Definition n_gui.h:299
int flags
bitmask of N_GUI_COMBOBOX_* flags
Definition n_gui.h:535
float gui_offset_x
horizontal letterbox offset for virtual canvas
Definition n_gui.h:932
int key_focus_only
if 1, keycode fires only when the button itself or a source widget has focus.
Definition n_gui.h:321
N_GUI_KV_ROW rows[128]
row storage
Definition n_gui.h:1505
int type
widget type (N_GUI_TYPE_*)
Definition n_gui.h:621
int state
current state flags (N_GUI_STATE_*)
Definition n_gui.h:631
float scroll_step
pixels per mouse wheel notch for window auto-scroll
Definition n_gui.h:870
int multiline
0 = single line, 1 = multiline
Definition n_gui.h:372
int key_id
textarea widget ID for the key
Definition n_gui.h:1493
ALLEGRO_BITMAP * bitmap_hover
optional bitmap for hover state
Definition n_gui.h:301
int button_ids[16]
toggle button widget IDs
Definition n_gui.h:1427
int max_visible
max visible items
Definition n_gui.h:599
float gui_bounds_w
total bounding box width of all windows (computed internally)
Definition n_gui.h:920
float x
position x relative to parent window
Definition n_gui.h:623
float global_scrollbar_size
global scrollbar track width/height
Definition n_gui.h:760
float textarea_cursor_width
cursor width in pixels
Definition n_gui.h:804
char text[4096]
text to display
Definition n_gui.h:549
void * user_data
user data for callback
Definition n_gui.h:1436
float norm_h
normalized height (fraction of reference display height, used in SCALE mode)
Definition n_gui.h:723
float min_win_w
minimum window width (for resize)
Definition n_gui.h:736
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the combobox background (NULL = color theme)
Definition n_gui.h:525
void(* on_change)(int widget_id, double value, void *user_data)
callback on value change
Definition n_gui.h:356
float item_height
item height in pixels
Definition n_gui.h:489
float drag_ox
drag offset x (internal)
Definition n_gui.h:681
void(* on_click)(int widget_id, void *user_data)
callback on click (widget_id passed)
Definition n_gui.h:326
float row_height
height of each row in pixels
Definition n_gui.h:1508
int expanded
1 if expanded
Definition n_gui.h:1459
N_GUI_LISTITEM * items
dynamic array of items
Definition n_gui.h:509
char label[128]
display text
Definition n_gui.h:1457
N_GUI_THEME theme
color theme for this window chrome
Definition n_gui.h:677
int id
unique widget id
Definition n_gui.h:619
int desc_id
textarea widget ID for the description
Definition n_gui.h:1495
int next_window_id
next window id to assign
Definition n_gui.h:890
float item_selection_inset
item highlight inset from left/right edges
Definition n_gui.h:842
ALLEGRO_COLOR border_normal
border normal
Definition n_gui.h:264
void(* on_click)(int widget_id, int entry_index, int tag, void *user_data)
callback when this entry is clicked (widget_id, entry_index, tag, user_data)
Definition n_gui.h:579
int has_children
1 if node has children
Definition n_gui.h:1461
void * user_data
user data for callback
Definition n_gui.h:581
int scroll_offset
scroll offset
Definition n_gui.h:597
ALLEGRO_COLOR text_hover
text hover
Definition n_gui.h:272
float dropdown_arrow_half_h
vertical half-extent of the arrow chevron
Definition n_gui.h:852
int z_value
z-value for N_GUI_ZORDER_FIXED mode (lower = behind, higher = on top)
Definition n_gui.h:699
ALLEGRO_BITMAP * item_bg_bitmap
optional bitmap for per-item background, normal state (NULL = color theme)
Definition n_gui.h:493
double cursor_time
timestamp of last cursor activity (for blink reset)
Definition n_gui.h:387
size_t entries_capacity
allocated capacity
Definition n_gui.h:593
int mouse_y
mouse state tracking
Definition n_gui.h:900
float grip_line_thickness
grip line thickness
Definition n_gui.h:780
int lbl_key
label widget ID for "Key" header
Definition n_gui.h:1511
size_t sel_end
selection end position (tracks cursor during selection)
Definition n_gui.h:379
int resize_policy
per-window resize policy: N_GUI_WIN_RESIZE_NONE, _MOVE, or _SCALE
Definition n_gui.h:715
size_t nb_items
number of items
Definition n_gui.h:481
void * user_data
user data for callback
Definition n_gui.h:533
float padding
horizontal padding
Definition n_gui.h:1509
void(* on_select)(int, void *)
selection callback
Definition n_gui.h:1473
int shape
shape type: N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, N_GUI_SHAPE_BITMAP
Definition n_gui.h:305
int z_order
z-order mode (N_GUI_ZORDER_NORMAL, _ALWAYS_ON_TOP, _ALWAYS_BEHIND, _FIXED)
Definition n_gui.h:697
int tag
user-defined tag for the entry (e.g.
Definition n_gui.h:577
int mouse_b1
mouse button 1 state
Definition n_gui.h:902
float button_w
width of each tab button
Definition n_gui.h:1433
float display_w
display/viewport width (set via n_gui_set_display_size)
Definition n_gui.h:912
N_GUI_LISTITEM * items
dynamic array of items
Definition n_gui.h:479
ALLEGRO_BITMAP * box_hover_bitmap
optional bitmap for the checkbox square on hover (NULL = fallback to box_bitmap/box_checked_bitmap)
Definition n_gui.h:409
int h
bounding box height in pixels
Definition n_gui.h:250
float grip_size
grip area size
Definition n_gui.h:778
float radio_label_gap
gap between circle and label text
Definition n_gui.h:828
N_GUI_CTX * ctx
GUI context.
Definition n_gui.h:1467
ALLEGRO_DISPLAY * display
display pointer for clipboard operations (set via n_gui_set_display)
Definition n_gui.h:942
float norm_w
normalized width (fraction of reference display width, used in SCALE mode)
Definition n_gui.h:721
float content_w
total content width computed from widgets (internal)
Definition n_gui.h:695
void * user_data
user data for this node
Definition n_gui.h:1462
float norm_x
normalized position x (fraction of parent window w, used for SCALE resize)
Definition n_gui.h:643
ALLEGRO_COLOR global_scrollbar_thumb_color
global scrollbar thumb colour
Definition n_gui.h:772
int selected_label_id
id of the label widget with the most recent text selection, or -1
Definition n_gui.h:944
float radio_inner_offset
inner filled circle shrink from outer
Definition n_gui.h:826
float min_w
minimum width
Definition n_gui.h:685
int selected_index
currently selected index (-1 = none)
Definition n_gui.h:485
ALLEGRO_BITMAP * track_bitmap
optional bitmap for the track/rail background (NULL = color theme)
Definition n_gui.h:346
int mouse_x
mouse state tracking
Definition n_gui.h:898
ALLEGRO_COLOR scrollbar_thumb_color
scrollbar thumb colour
Definition n_gui.h:756
int active_tab
currently active tab index
Definition n_gui.h:1430
float checkbox_max_size
maximum box size
Definition n_gui.h:810
size_t nb_entries
number of entries
Definition n_gui.h:591
float checkbox_mark_thickness
checkmark line thickness
Definition n_gui.h:814
int sel_start
selection start byte offset (-1 = no selection)
Definition n_gui.h:557
ALLEGRO_BITMAP * bitmap
bitmap to display (not owned, not freed)
Definition n_gui.h:541
ALLEGRO_BITMAP * fill_bitmap
optional bitmap for the filled portion of the track (NULL = color theme)
Definition n_gui.h:348
float header_height
height of the column header row
Definition n_gui.h:1510
float global_scroll_step
pixels per mouse wheel notch for global scroll
Definition n_gui.h:872
float h
window height
Definition n_gui.h:667
float item_height
item height in dropdown
Definition n_gui.h:521
void * user_data
user data for callback
Definition n_gui.h:413
double scroll_pos
current scroll position
Definition n_gui.h:425
void(* on_change)(int widget_id, const char *text, void *user_data)
callback on text change
Definition n_gui.h:393
ALLEGRO_BITMAP * item_selected_bitmap
optional bitmap for per-item background, selected/highlighted (NULL = color theme)
Definition n_gui.h:529
void * user_data
user data for callback
Definition n_gui.h:358
float autofit_origin_y
original insertion point y for N_GUI_AUTOFIT_CENTER (set by n_gui_window_set_autofit)
Definition n_gui.h:713
int scroll_offset
scroll offset in items
Definition n_gui.h:461
int selected
selection state (for listbox)
Definition n_gui.h:447
ALLEGRO_BITMAP * item_hover_bitmap
optional bitmap for the hovered entry background (NULL = color theme)
Definition n_gui.h:605
float virtual_h
virtual canvas height (0 = disabled / identity transform)
Definition n_gui.h:928
N_GUI_CTX * ctx
GUI context.
Definition n_gui.h:1503
float global_scroll_x
global horizontal scroll offset (when GUI exceeds display)
Definition n_gui.h:916
float checkbox_mark_margin
checkmark inset from box edge
Definition n_gui.h:812
ALLEGRO_BITMAP * track_bitmap
optional bitmap for the scrollbar track background (NULL = color theme)
Definition n_gui.h:429
float checkbox_label_offset
horizontal offset from box edge to label text
Definition n_gui.h:818
ALLEGRO_BITMAP * titlebar_bitmap
optional bitmap for the titlebar background (NULL = color fill)
Definition n_gui.h:703
int scroll_offset
scroll offset in dropdown
Definition n_gui.h:519
N_GUI_CTX * ctx
GUI context.
Definition n_gui.h:1425
void * data
widget-specific data (union via void pointer)
Definition n_gui.h:641
double value
current value (always snapped to step)
Definition n_gui.h:338
N_GUI_DROPMENU_ENTRY * entries
dynamic array of entries
Definition n_gui.h:589
float drag_oy
drag offset y (internal)
Definition n_gui.h:683
float slider_track_border_thickness
track outline thickness
Definition n_gui.h:790
int nb_active
active row count
Definition n_gui.h:1507
ALLEGRO_COLOR link_color_normal
link colour (normal)
Definition n_gui.h:864
float slider_handle_min_r
minimum handle circle radius
Definition n_gui.h:792
int scale_mode
scale mode: N_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, N_GUI_IMAGE_CENTER
Definition n_gui.h:543
ALLEGRO_BITMAP * item_selected_bitmap
optional bitmap for per-item background, selected/highlighted (NULL = color theme)
Definition n_gui.h:495
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the radiolist background (NULL = color theme)
Definition n_gui.h:491
N_GUI_TREE_NODE nodes[512]
node storage
Definition n_gui.h:1469
ALLEGRO_BITMAP * box_bitmap
optional bitmap for the checkbox square, unchecked state (NULL = color theme)
Definition n_gui.h:405
void * on_open_user_data
user data for on_open callback
Definition n_gui.h:611
float y
y origin of tab button row
Definition n_gui.h:1432
float dropdown_arrow_reserve
horizontal space reserved for the arrow on the right
Definition n_gui.h:848
float y
position y relative to parent window
Definition n_gui.h:625
int lbl_desc
label widget ID for "Description" header
Definition n_gui.h:1513
int orientation
orientation: N_GUI_SLIDER_H or N_GUI_SLIDER_V
Definition n_gui.h:344
float global_scrollbar_border_thickness
global thumb border thickness
Definition n_gui.h:768
int state
state flags (N_GUI_WIN_*)
Definition n_gui.h:671
int flags
feature flags (N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_RESIZABLE, etc.)
Definition n_gui.h:673
void * user_data
user data for callback
Definition n_gui.h:439
int active
1 if active, 0 if removed
Definition n_gui.h:1498
double max_val
maximum value
Definition n_gui.h:336
HASH_TABLE * widgets_by_id
hash table for fast widget lookup by id
Definition n_gui.h:886
float border_thickness
border thickness
Definition n_gui.h:276
float link_underline_thickness
link underline thickness
Definition n_gui.h:862
ALLEGRO_BITMAP * box_checked_bitmap
optional bitmap for the checkbox square, checked state (NULL = color theme)
Definition n_gui.h:407
int autofit_flags
bitmask of N_GUI_AUTOFIT_* flags (0 = no auto-fitting)
Definition n_gui.h:707
N_GUI_STYLE style
configurable style (sizes, colours, paddings)
Definition n_gui.h:940
ALLEGRO_FONT * font
font for the title bar
Definition n_gui.h:679
void * user_data
user data for callback
Definition n_gui.h:395
ALLEGRO_COLOR text_active
text active
Definition n_gui.h:274
float ref_display_w
reference display width at the time normalized values were last captured
Definition n_gui.h:948
int nb_nodes
number of nodes
Definition n_gui.h:1470
size_t items_capacity
allocated capacity
Definition n_gui.h:483
int parent_window_id
parent window for tab buttons
Definition n_gui.h:1426
double content_size
total content size
Definition n_gui.h:421
float autofit_origin_x
original insertion point x for N_GUI_AUTOFIT_CENTER (set by n_gui_window_set_autofit)
Definition n_gui.h:711
void * user_data
user data for callback
Definition n_gui.h:473
double step
step increment (0 is treated as 1).
Definition n_gui.h:340
float global_scroll_y
global vertical scroll offset (when GUI exceeds display)
Definition n_gui.h:918
int scrollbar_drag_widget_id
id of the widget whose scrollbar is being dragged, or -1
Definition n_gui.h:908
float min_h
minimum height
Definition n_gui.h:687
float listbox_default_item_height
default item height for listbox
Definition n_gui.h:832
ALLEGRO_COLOR global_scrollbar_thumb_border_color
global scrollbar thumb border colour
Definition n_gui.h:774
ALLEGRO_COLOR border_active
border active
Definition n_gui.h:268
float scroll_x
horizontal scroll offset for single-line text (pixels)
Definition n_gui.h:383
float label_padding
horizontal padding each side
Definition n_gui.h:860
float titlebar_h
title bar height
Definition n_gui.h:734
float gui_offset_y
vertical letterbox offset for virtual canvas
Definition n_gui.h:934
ALLEGRO_BITMAP * item_selected_bitmap
optional bitmap for per-item background, selected/highlighted (NULL = color theme)
Definition n_gui.h:469
void(* on_select)(int widget_id, int index, int selected, void *user_data)
callback on selection change (widget_id, item_index, selected, user_data)
Definition n_gui.h:471
float item_height
item height in pixels
Definition n_gui.h:463
void(* on_select)(int widget_id, int index, void *user_data)
callback on selection change (widget_id, selected_index, user_data)
Definition n_gui.h:531
int focused_widget_id
id of the widget that currently has focus, or -1
Definition n_gui.h:896
int id
unique window id
Definition n_gui.h:657
int global_vscroll_drag
1 if global scrollbar vertical thumb is being dragged
Definition n_gui.h:936
int sel_dragging
1 if mouse is actively dragging to select text
Definition n_gui.h:561
int nb_visible
number of visible rows
Definition n_gui.h:1472
ALLEGRO_COLOR global_scrollbar_track_color
global scrollbar track colour
Definition n_gui.h:770
float item_height_pad
min padding added to font height for item height
Definition n_gui.h:844
float display_h
display/viewport height
Definition n_gui.h:914
N_GUI_LISTITEM * items
dynamic array of items
Definition n_gui.h:453
void * user_data
user data for callback
Definition n_gui.h:499
float corner_ry
corner radius Y for rounded shapes
Definition n_gui.h:280
int checked
checked state
Definition n_gui.h:403
int sel_end
selection end byte offset (-1 = no selection)
Definition n_gui.h:559
int bg_scale_mode
scale mode for bg_bitmap: N_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, or N_GUI_IMAGE_CENTER
Definition n_gui.h:705
size_t text_alloc
allocated buffer size (char_limit + 1)
Definition n_gui.h:368
ALLEGRO_COLOR bg_normal
background normal
Definition n_gui.h:258
ALLEGRO_BITMAP * handle_bitmap
optional bitmap for the draggable handle, normal state (NULL = color theme)
Definition n_gui.h:350
ALLEGRO_FONT * font
font used by this widget (NULL = context default)
Definition n_gui.h:639
float norm_w
normalized width (fraction of parent window w)
Definition n_gui.h:647
int resize_mode
context resize mode: N_GUI_RESIZE_VIRTUAL or N_GUI_RESIZE_ADAPTIVE
Definition n_gui.h:946
float virtual_w
virtual canvas width (0 = disabled / identity transform)
Definition n_gui.h:926
float radiolist_default_item_height
default item height for radiolist
Definition n_gui.h:834
char label[128]
label displayed next to the checkbox
Definition n_gui.h:401
float slider_value_label_offset
gap between slider end and value label
Definition n_gui.h:798
size_t nb_items
number of items
Definition n_gui.h:455
int depth
depth in tree (0 = root)
Definition n_gui.h:1460
ALLEGRO_COLOR bg_active
background active/pressed
Definition n_gui.h:262
char mask_char
mask character for password fields (0 = no masking, e.g.
Definition n_gui.h:391
int global_hscroll_drag
1 if global scrollbar horizontal thumb is being dragged
Definition n_gui.h:938
LIST * windows
ordered list of N_GUI_WINDOW* (back to front)
Definition n_gui.h:884
char text[128]
display text
Definition n_gui.h:573
int scroll_y
scroll offset for long text
Definition n_gui.h:381
void(* on_scroll)(int widget_id, double scroll_pos, void *user_data)
callback on scroll
Definition n_gui.h:437
int x
bounding box x offset from draw origin
Definition n_gui.h:247
float gui_bounds_h
total bounding box height of all windows (computed internally)
Definition n_gui.h:922
double min_val
minimum value
Definition n_gui.h:334
float textarea_cursor_blink_period
cursor blink period in seconds (full cycle on+off)
Definition n_gui.h:806
int lbl_value
label widget ID for "Value" header
Definition n_gui.h:1512
void(* on_toggle)(int widget_id, int checked, void *user_data)
callback on toggle
Definition n_gui.h:411
ALLEGRO_COLOR bg_hover
background hover
Definition n_gui.h:260
size_t sel_start
selection anchor position (where shift-click/shift-arrow started).
Definition n_gui.h:377
int window_id
parent window
Definition n_gui.h:1504
float dropdown_arrow_thickness
arrow stroke thickness
Definition n_gui.h:850
void * user_data
user data for callback
Definition n_gui.h:1517
ALLEGRO_COLOR link_color_hover
link colour (hover)
Definition n_gui.h:866
float radio_circle_min_r
minimum outer circle radius
Definition n_gui.h:822
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the listbox background (NULL = color theme)
Definition n_gui.h:465
float item_text_padding
text padding inside list/combo/dropmenu items
Definition n_gui.h:840
int next_widget_id
next widget id to assign
Definition n_gui.h:888
int enabled_id
checkbox widget ID for the enabled toggle
Definition n_gui.h:1496
float autofit_border
padding/border around content for auto-fit (pixels, applied on each side)
Definition n_gui.h:709
float gui_scale
computed uniform scale factor for virtual canvas
Definition n_gui.h:930
size_t cursor_pos
cursor position in text
Definition n_gui.h:374
void * user_data
user data for callback
Definition n_gui.h:328
int mode
mode: N_GUI_SLIDER_VALUE or N_GUI_SLIDER_PERCENT
Definition n_gui.h:342
size_t char_limit
maximum character limit (0 = N_GUI_TEXT_MAX)
Definition n_gui.h:370
int toggle_mode
toggle mode: 0 = momentary (default), 1 = toggle (stays clicked/unclicked)
Definition n_gui.h:307
int is_open
is the menu currently open
Definition n_gui.h:595
ALLEGRO_COLOR border_hover
border hover
Definition n_gui.h:266
float scrollbar_thumb_min
minimum thumb dimension
Definition n_gui.h:748
float x
x origin of first tab button
Definition n_gui.h:1431
ALLEGRO_BITMAP * thumb_hover_bitmap
optional bitmap for the thumb on hover (NULL = fallback to thumb_bitmap)
Definition n_gui.h:433
int value_id
textarea widget ID for the value
Definition n_gui.h:1494
char label[128]
label displayed on the button
Definition n_gui.h:297
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the text area background (NULL = color theme)
Definition n_gui.h:389
int align
text alignment: N_GUI_ALIGN_LEFT, N_GUI_ALIGN_CENTER, N_GUI_ALIGN_RIGHT
Definition n_gui.h:553
size_t text_len
current text length
Definition n_gui.h:366
char link[4096]
optional hyperlink URL (empty string = no link)
Definition n_gui.h:551
int orientation
orientation: N_GUI_SCROLLBAR_H or N_GUI_SCROLLBAR_V
Definition n_gui.h:419
float global_scrollbar_thumb_min
global minimum thumb dimension
Definition n_gui.h:762
double viewport_size
visible viewport size
Definition n_gui.h:423
void(* on_link_click)(int widget_id, const char *link, void *user_data)
callback when link is clicked (widget_id, link_url, user_data)
Definition n_gui.h:565
ALLEGRO_FONT * default_font
default font (must be set before adding widgets)
Definition n_gui.h:892
float combobox_max_dropdown_width
maximum dropdown width for N_GUI_COMBOBOX_AUTO_WIDTH (0 = display width)
Definition n_gui.h:876
int selection_mode
selection mode: N_GUI_SELECT_NONE, N_GUI_SELECT_SINGLE, N_GUI_SELECT_MULTIPLE
Definition n_gui.h:459
size_t nb_items
number of items
Definition n_gui.h:511
int key_modifiers
required modifier key flags for the keybind (0 = no modifier requirement, matches any modifier state ...
Definition n_gui.h:318
LIST * widgets
list of N_GUI_WIDGET* contained in this window
Definition n_gui.h:675
float y
position y on screen
Definition n_gui.h:663
ALLEGRO_BITMAP * bitmap_active
optional bitmap for active/pressed state
Definition n_gui.h:303
int enabled
enabled flag (1 = enabled, 0 = disabled: drawn dimmed and ignores input)
Definition n_gui.h:635
float radio_circle_border_thickness
outer circle border thickness
Definition n_gui.h:824
int keycode
bound keyboard keycode (0 = none).
Definition n_gui.h:312
ALLEGRO_BITMAP * thumb_active_bitmap
optional bitmap for the thumb while dragging (NULL = fallback to thumb_bitmap)
Definition n_gui.h:435
float slider_track_size
track width (vertical) or height (horizontal)
Definition n_gui.h:786
float scroll_x
horizontal scroll offset for auto-scrollbar (pixels)
Definition n_gui.h:691
float slider_handle_border_thickness
handle border thickness
Definition n_gui.h:796
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.
Definition n_gui.c:5176
void n_gui_combobox_set_bitmaps(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg, ALLEGRO_BITMAP *item_bg, ALLEGRO_BITMAP *item_selected)
set optional bitmap overlays on a combobox widget.
Definition n_gui.c:2522
int n_gui_load_theme_json(N_GUI_CTX *ctx, const char *filepath)
Load a JSON theme file and apply it to the context.
Definition n_gui.c:7536
int n_gui_listbox_get_scroll_offset(N_GUI_CTX *ctx, int widget_id)
get the current scroll offset (in items)
Definition n_gui.c:2001
void n_gui_dropmenu_clear(N_GUI_CTX *ctx, int widget_id)
remove all entries
Definition n_gui.c:2355
void n_gui_update_transform(N_GUI_CTX *ctx)
recalculate scale and offset from virtual canvas to display.
Definition n_gui.c:4992
int n_gui_button_is_toggled(N_GUI_CTX *ctx, int widget_id)
check if button is toggled
Definition n_gui.c:1086
float n_gui_detect_dpi_scale(N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display)
detect and apply DPI scale from the given allegro display.
Definition n_gui.c:5234
void n_gui_toggle_window(N_GUI_CTX *ctx, int window_id)
toggle window visibility (show/hide)
Definition n_gui.c:825
#define N_GUI_TREE_MAX
maximum number of nodes in a tree view
Definition n_gui.h:1453
void n_gui_raise_window(N_GUI_CTX *ctx, int window_id)
raise a window to the top of the stack (respects z-order constraints)
Definition n_gui.c:745
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 horizontal slider widget
Definition n_gui.c:1160
void n_gui_combobox_set_flags(N_GUI_CTX *ctx, int widget_id, int flags)
set combobox feature flags (bitmask of N_GUI_COMBOBOX_* values)
Definition n_gui.c:1446
void n_gui_window_apply_autofit(N_GUI_CTX *ctx, int window_id)
trigger auto-fit recalculation for a window (call after adding/removing/resizing widgets)
Definition n_gui.c:910
void n_gui_textarea_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set text area content
Definition n_gui.c:1752
double n_gui_scrollbar_get_pos(N_GUI_CTX *ctx, int widget_id)
get scrollbar position
Definition n_gui.c:1808
N_GUI_KVTABLE * n_gui_kvtable_create(N_GUI_CTX *ctx, int window_id, float row_height, float padding, void(*on_remove)(int, void *), void *user_data)
create a KV table in an existing window
Definition n_gui.c:7928
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 (same as n_gui_add_slider but oriented vertically)
Definition n_gui.c:1200
void n_gui_set_display(N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display)
set the display pointer for clipboard operations (copy/paste)
Definition n_gui.c:5192
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.
Definition n_gui.c:2397
void n_gui_set_widget_theme(N_GUI_CTX *ctx, int widget_id, N_GUI_THEME theme)
set the theme on a widget
Definition n_gui.c:1575
int n_gui_wants_mouse(N_GUI_CTX *ctx)
check if the mouse is currently over any open GUI window (use to prevent click-through to the game wo...
Definition n_gui.c:7344
int n_gui_dropmenu_get_count(N_GUI_CTX *ctx, int widget_id)
get number of entries
Definition n_gui.c:2380
int n_gui_radiolist_add_item(N_GUI_CTX *ctx, int widget_id, const char *text)
add an item to a radio list
Definition n_gui.c:2028
void n_gui_lower_window(N_GUI_CTX *ctx, int window_id)
lower a window to the bottom of the stack (respects z-order constraints)
Definition n_gui.c:763
void n_gui_label_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set label text content
Definition n_gui.c:2178
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
Definition n_gui.c:1336
#define N_GUI_KV_MAX
maximum number of rows in a KV table
Definition n_gui.h:1489
int n_gui_process_event(N_GUI_CTX *ctx, ALLEGRO_EVENT event)
process an allegro event for the GUI
Definition n_gui.c:5767
int n_gui_window_get_flags(N_GUI_CTX *ctx, int window_id)
get feature flags of a window
Definition n_gui.c:852
void n_gui_minimize_window(N_GUI_CTX *ctx, int window_id)
minimize a window (title bar only)
Definition n_gui.c:662
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 text label widget
Definition n_gui.c:1497
void n_gui_set_widget_enabled(N_GUI_CTX *ctx, int widget_id, int enabled)
set widget enabled state (0 = disabled: drawn dimmed and ignores all input)
Definition n_gui.c:1592
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
Definition n_gui.c:1371
void n_gui_tab_free(N_GUI_TAB_PANEL **panel)
free a tab panel (does not destroy the N_GUI widgets)
Definition n_gui.c:7780
void n_gui_close_window(N_GUI_CTX *ctx, int window_id)
close (hide) a window
Definition n_gui.c:646
void n_gui_listbox_set_bitmaps(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg, ALLEGRO_BITMAP *item_bg, ALLEGRO_BITMAP *item_selected)
set optional bitmap overlays on a listbox widget.
Definition n_gui.c:2490
void n_gui_label_set_link(N_GUI_CTX *ctx, int widget_id, const char *link)
set label hyperlink URL
Definition n_gui.c:2198
void n_gui_kvtable_free(N_GUI_KVTABLE **table)
free a KV table (does not destroy the N_GUI widgets)
Definition n_gui.c:8028
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).
Definition n_gui.c:5081
void n_gui_button_set_keycode_focused(N_GUI_CTX *ctx, int widget_id, int keycode, int modifiers, const int *sources, int source_count)
bind a keyboard key to a button that fires only when specific widgets have focus.
Definition n_gui.c:1139
void n_gui_radiolist_clear(N_GUI_CTX *ctx, int widget_id)
remove all items from a radio list
Definition n_gui.c:2049
void n_gui_listbox_set_selected(N_GUI_CTX *ctx, int widget_id, int index, int selected)
set item selection state
Definition n_gui.c:1990
int n_gui_add_window_auto(N_GUI_CTX *ctx, const char *title, float x, float y)
add a window that sizes itself automatically to fit its widgets (call n_gui_window_autosize after add...
Definition n_gui.c:817
double n_gui_slider_get_value(N_GUI_CTX *ctx, int widget_id)
get slider current value
Definition n_gui.c:1667
int n_gui_listbox_add_item(N_GUI_CTX *ctx, int widget_id, const char *text)
add an item to a listbox
Definition n_gui.c:1860
void n_gui_set_virtual_size(N_GUI_CTX *ctx, float w, float h)
set the virtual canvas size for resolution-independent scaling.
Definition n_gui.c:4974
float n_gui_get_dpi_scale(const N_GUI_CTX *ctx)
get current DPI scale factor
Definition n_gui.c:5210
N_GUI_THEME n_gui_default_theme(void)
return the built-in default theme
Definition n_gui.c:294
void n_gui_window_set_zorder(N_GUI_CTX *ctx, int window_id, int z_mode, int z_value)
set window z-order mode and value
Definition n_gui.c:779
int n_gui_radiolist_get_selected(N_GUI_CTX *ctx, int widget_id)
get the selected item index
Definition n_gui.c:2065
void n_gui_tab_set_content_window(N_GUI_TAB_PANEL *panel, int tab_index, int window_id)
associate a content window with a tab
Definition n_gui.c:7757
int n_gui_save_theme_json(N_GUI_CTX *ctx, const char *filepath)
Save the full theme (default_theme + style) to a JSON file.
Definition n_gui.c:7413
int n_gui_combobox_add_item(N_GUI_CTX *ctx, int widget_id, const char *text)
add an item to a combo box
Definition n_gui.c:2109
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
Definition n_gui.c:862
void n_gui_set_focus(N_GUI_CTX *ctx, int widget_id)
set keyboard focus to a specific widget (-1 to clear focus)
Definition n_gui.c:1613
void n_gui_tree_rebuild(N_GUI_TREE *tree)
rebuild the listbox to reflect current tree state
Definition n_gui.c:7855
void n_gui_textarea_set_selection(N_GUI_CTX *ctx, int widget_id, size_t start, size_t end)
set the text selection range (byte offsets into text content)
Definition n_gui.c:2832
void n_gui_scrollbar_set_bitmaps(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *track, ALLEGRO_BITMAP *thumb, ALLEGRO_BITMAP *thumb_hover, ALLEGRO_BITMAP *thumb_active)
set optional bitmap overlays on a scrollbar widget.
Definition n_gui.c:2430
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
Definition n_gui.c:1406
void n_gui_button_set_toggled(N_GUI_CTX *ctx, int widget_id, int toggled)
set button toggled state
Definition n_gui.c:1097
void n_gui_tab_set_active(N_GUI_TAB_PANEL *panel, int index)
set the active tab (toggles buttons, opens/closes content windows)
Definition n_gui.c:7762
void n_gui_slider_set_step(N_GUI_CTX *ctx, int widget_id, double step)
set slider step increment (0 is treated as 1).
Definition n_gui.c:1719
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)
toggle button creation (returns widget id)
Definition n_gui.c:1070
void n_gui_kvtable_remove_row(N_GUI_KVTABLE *table, int row_index)
remove a row by index (hides widgets, marks inactive)
Definition n_gui.c:8010
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 text label with hyperlink
Definition n_gui.c:1538
void n_gui_textarea_set_mask_char(N_GUI_CTX *ctx, int widget_id, char mask)
set a mask character for password-style input (e.g.
Definition n_gui.c:2477
int n_gui_listbox_get_selected(N_GUI_CTX *ctx, int widget_id)
get the first selected item index
Definition n_gui.c:1954
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 widget
Definition n_gui.c:1468
void n_gui_label_set_bitmap(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg)
set optional background bitmap on a label widget.
Definition n_gui.c:2553
void n_gui_draw(N_GUI_CTX *ctx)
draw all visible GUI windows and widgets
Definition n_gui.c:4800
int n_gui_tab_add(N_GUI_TAB_PANEL *panel, const char *label)
add a tab to the panel, returns tab index
Definition n_gui.c:7742
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.
Definition n_gui.c:2412
int n_gui_window_get_zorder(N_GUI_CTX *ctx, int window_id)
get window z-order mode
Definition n_gui.c:796
void n_gui_tree_free(N_GUI_TREE **tree)
free a tree view (does not destroy the N_GUI listbox)
Definition n_gui.c:7878
int n_gui_window_get_resize_policy(N_GUI_CTX *ctx, int window_id)
get per-window resize policy
Definition n_gui.c:5094
void n_gui_checkbox_set_checked(N_GUI_CTX *ctx, int widget_id, int checked)
set checkbox checked state
Definition n_gui.c:1793
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)
Definition n_gui.c:2301
void n_gui_apply_adaptive_resize(N_GUI_CTX *ctx, float new_w, float new_h)
apply adaptive resize: reposition/resize all windows according to their policies for the new display ...
Definition n_gui.c:5123
int n_gui_is_widget_enabled(N_GUI_CTX *ctx, int widget_id)
check if a widget is enabled
Definition n_gui.c:1601
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.
Definition n_gui.c:1129
int n_gui_window_is_open(N_GUI_CTX *ctx, int window_id)
check if window is visible
Definition n_gui.c:834
void n_gui_set_dpi_scale(N_GUI_CTX *ctx, float scale)
set DPI scale factor manually (default is 1.0).
Definition n_gui.c:5200
int n_gui_get_resize_mode(N_GUI_CTX *ctx)
get current resize mode
Definition n_gui.c:5071
N_GUI_WIDGET * n_gui_get_widget(N_GUI_CTX *ctx, int widget_id)
get a widget by id
Definition n_gui.c:1561
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
Definition n_gui.c:2278
N_GUI_WINDOW * n_gui_get_window(N_GUI_CTX *ctx, int window_id)
get a window by id
Definition n_gui.c:637
void n_gui_dropmenu_set_bitmaps(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *panel, ALLEGRO_BITMAP *item_hover)
set optional bitmap overlays on a dropmenu widget.
Definition n_gui.c:2538
int n_gui_add_window(N_GUI_CTX *ctx, const char *title, float x, float y, float w, float h)
add a window to the GUI context
Definition n_gui.c:581
N_GUI_CTX * n_gui_new_ctx(ALLEGRO_FONT *default_font)
create a new GUI context
Definition n_gui.c:466
void n_gui_slider_set_range(N_GUI_CTX *ctx, int widget_id, double min_val, double max_val)
set slider min/max range, clamping the current value if needed
Definition n_gui.c:1699
const char * n_gui_listbox_get_item_text(N_GUI_CTX *ctx, int widget_id, int index)
get item text by index
Definition n_gui.c:1937
void n_gui_radiolist_set_bitmaps(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg, ALLEGRO_BITMAP *item_bg, ALLEGRO_BITMAP *item_selected)
set optional bitmap overlays on a radiolist widget.
Definition n_gui.c:2506
N_GUI_TREE * n_gui_tree_create(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, void(*on_select)(int, void *), void *user_data)
create a tree view in an existing window
Definition n_gui.c:7799
int n_gui_add_button_bitmap(N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, ALLEGRO_BITMAP *normal, ALLEGRO_BITMAP *hover, ALLEGRO_BITMAP *active, void(*on_click)(int, void *), void *user_data)
add a bitmap-based button widget
Definition n_gui.c:1042
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
Definition n_gui.c:5042
void n_gui_button_set_toggle_mode(N_GUI_CTX *ctx, int widget_id, int toggle_mode)
set button toggle mode
Definition n_gui.c:1110
void n_gui_tree_toggle_expand(N_GUI_TREE *tree, int node_index)
toggle expand/collapse of a node
Definition n_gui.c:7848
void n_gui_textarea_scroll_to_offset(N_GUI_CTX *ctx, int widget_id, size_t byte_offset)
scroll a multiline textarea so that the given byte offset is vertically centered
Definition n_gui.c:2849
void n_gui_textarea_set_bitmap(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg)
set optional background bitmap on a textarea widget.
Definition n_gui.c:2463
void n_gui_listbox_clear(N_GUI_CTX *ctx, int widget_id)
clear all items from a listbox
Definition n_gui.c:1907
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
Definition n_gui.c:1293
N_GUI_TEXT_DIMS n_gui_get_text_dims(ALLEGRO_FONT *font, const char *text)
get the bounding box dimensions of text rendered with the given font.
Definition n_gui.c:58
int n_gui_kvtable_get_count(N_GUI_KVTABLE *table)
get the number of active rows
Definition n_gui.c:8024
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
destroy a GUI context and free all resources
Definition n_gui.c:523
const char * n_gui_textarea_get_text(N_GUI_CTX *ctx, int widget_id)
get text area content
Definition n_gui.c:1738
int n_gui_tab_get_active(N_GUI_TAB_PANEL *panel)
get the active tab index
Definition n_gui.c:7776
int n_gui_kvtable_add_row(N_GUI_KVTABLE *table, const char *key, const char *value, const char *description, int enabled)
add a row to the KV table
Definition n_gui.c:7972
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.
Definition n_gui.c:2447
void n_gui_listbox_set_scroll_offset(N_GUI_CTX *ctx, int widget_id, int offset)
set the scroll offset (in items) — clamps to valid range
Definition n_gui.c:2008
#define N_GUI_TEXT_MAX
maximum length for textarea content
Definition n_gui.h:86
void n_gui_textarea_scroll_to_bottom(N_GUI_CTX *ctx, int widget_id)
scroll a multiline textarea to the bottom
Definition n_gui.c:2810
size_t n_gui_textarea_get_text_length(N_GUI_CTX *ctx, int widget_id)
return the current text length in bytes (0 if widget is invalid)
Definition n_gui.c:2910
void n_gui_open_window(N_GUI_CTX *ctx, int window_id)
open (show) a window
Definition n_gui.c:654
int n_gui_window_get_zvalue(N_GUI_CTX *ctx, int window_id)
get window z-value (for N_GUI_ZORDER_FIXED mode)
Definition n_gui.c:806
void n_gui_dropmenu_set_entry_text(N_GUI_CTX *ctx, int widget_id, int index, const char *text)
update text of an existing entry by index
Definition n_gui.c:2366
int n_gui_tree_add_node(N_GUI_TREE *tree, const char *label, int parent_index, void *user_data)
add a node to the tree
Definition n_gui.c:7827
int n_gui_listbox_get_count(N_GUI_CTX *ctx, int widget_id)
get number of items in a listbox
Definition n_gui.c:1922
int n_gui_checkbox_is_checked(N_GUI_CTX *ctx, int widget_id)
check if checkbox is checked
Definition n_gui.c:1779
int n_gui_combobox_get_selected(N_GUI_CTX *ctx, int widget_id)
get the selected item index
Definition n_gui.c:2131
void n_gui_image_set_bitmap(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bitmap)
set the bitmap on an image widget
Definition n_gui.c:2163
void n_gui_slider_set_value(N_GUI_CTX *ctx, int widget_id, double value)
set slider value
Definition n_gui.c:1681
void n_gui_radiolist_set_selected(N_GUI_CTX *ctx, int widget_id, int index)
set the selected item index
Definition n_gui.c:2079
void n_gui_window_set_flags(N_GUI_CTX *ctx, int window_id, int flags)
set feature flags on a window (N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_RESIZABLE, ...)
Definition n_gui.c:843
void n_gui_set_widget_visible(N_GUI_CTX *ctx, int widget_id, int visible)
set widget visibility
Definition n_gui.c:1583
N_GUI_TAB_PANEL * n_gui_tab_create(N_GUI_CTX *ctx, int window_id, float x, float y, float button_w, float button_h, void(*on_tab_change)(int, void *), void *user_data)
create a tab panel in an existing window
Definition n_gui.c:7720
#define N_GUI_ID_MAX
maximum length for widget id/name strings
Definition n_gui.h:84
N_GUI_STYLE n_gui_default_style(void)
return the built-in default style
Definition n_gui.c:365
#define N_GUI_TAB_MAX
maximum number of tabs in a single tab panel
Definition n_gui.h:1421
void n_gui_scrollbar_set_sizes(N_GUI_CTX *ctx, int widget_id, double content_size, double viewport_size)
set scrollbar content and viewport sizes
Definition n_gui.c:1839
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
Definition n_gui.c:1214
int n_gui_listbox_is_selected(N_GUI_CTX *ctx, int widget_id, int index)
check if an item is selected
Definition n_gui.c:1972
void n_gui_window_update_normalized(N_GUI_CTX *ctx, int window_id)
recapture normalized coordinates for a window from its current absolute position/size.
Definition n_gui.c:5107
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
Definition n_gui.c:1259
void n_gui_combobox_clear(N_GUI_CTX *ctx, int widget_id)
remove all items from a combobox
Definition n_gui.c:2096
void n_gui_combobox_set_selected(N_GUI_CTX *ctx, int widget_id, int index)
set the selected item index
Definition n_gui.c:2145
int n_gui_listbox_remove_item(N_GUI_CTX *ctx, int widget_id, int index)
remove an item from a listbox by index
Definition n_gui.c:1883
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 from individual colors and properties
Definition n_gui.c:328
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 (button that opens a menu panel with entries)
Definition n_gui.c:2237
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.
Definition n_gui.c:5019
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
Definition n_gui.c:1001
#define N_GUI_KEY_SOURCES_MAX
maximum number of source widgets for a focused key binding
Definition n_gui.h:290
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
Definition n_gui.c:891
void n_gui_scrollbar_set_pos(N_GUI_CTX *ctx, int widget_id, double pos)
set scrollbar position
Definition n_gui.c:1822
void n_gui_dropmenu_clear_dynamic(N_GUI_CTX *ctx, int widget_id)
remove all dynamic entries (call from on_open callback before re-adding)
Definition n_gui.c:2326
button specific data
Definition n_gui.h:295
checkbox specific data
Definition n_gui.h:399
combo box specific data
Definition n_gui.h:507
The top-level GUI context that holds all windows.
Definition n_gui.h:882
dropdown menu specific data
Definition n_gui.h:585
A single entry in a dropdown menu (static or dynamic)
Definition n_gui.h:571
image widget specific data
Definition n_gui.h:539
a single row in the KV table
Definition n_gui.h:1492
key-value table built from textareas, checkboxes, and buttons
Definition n_gui.h:1502
static text label specific data
Definition n_gui.h:547
listbox specific data
Definition n_gui.h:451
a single item in a list/radio/combo widget
Definition n_gui.h:443
radio list specific data
Definition n_gui.h:477
scrollbar specific data
Definition n_gui.h:417
slider specific data
Definition n_gui.h:332
Global style holding every configurable layout constant.
Definition n_gui.h:731
tab panel built from toggle buttons with content window management
Definition n_gui.h:1424
bounding box dimensions returned by n_gui_get_text_dims()
Definition n_gui.h:246
text area specific data
Definition n_gui.h:362
Color theme for a widget.
Definition n_gui.h:256
tree view built from an N_GUI listbox
Definition n_gui.h:1466
a single node in the tree view
Definition n_gui.h:1456
A single GUI widget.
Definition n_gui.h:617
A pseudo window that contains widgets.
Definition n_gui.h:655
structure of a hash table
Definition n_hash.h:137
Structure of a generic LIST container.
Definition n_list.h:58
Allegro5 helpers.
Common headers and low-level functions & define.
Hash functions and table.
List structures and definitions.
Generic log system.
N_STR and string function declaration.