Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
ex_gui_detach.c
Go to the documentation of this file.
1/*
2 * Nilorea Library
3 * Copyright (C) 2005-2026 Castagnier Mickael
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14 * implied. See the License for the specific language governing
15 * permissions and limitations under the License.
16 *
17 * SPDX-License-Identifier: Apache-2.0
18 */
19
44#define ALLEGRO_UNSTABLE 1
45
46#include <stdio.h>
47#include <stdlib.h>
48#include <string.h>
49#include <unistd.h>
50
51#include "nilorea/n_common.h"
52#include "nilorea/n_gui.h"
53#include "nilorea/n_log.h"
54
55#define WIDTH 960
56#define HEIGHT 640
57#define LAYOUT_FILE "ex_gui_detach_layout.json"
58
60typedef struct DEMO_PANEL {
62 int win;
64 int btn;
68 const char* name;
70
71static int log_level = LOG_NOTICE;
72static int DONE = 0;
74static double quit_after = 0.0;
76static int auto_detach = 0;
77
78static N_GUI_CTX* gui = NULL;
80static int nb_panels = 0;
81static int lbl_status = -1;
82static int lbl_hint = -1;
84static int notes_txt = -1;
85
86static void process_args(int argc, char** argv) {
87 int opt;
88 while ((opt = getopt(argc, argv, "haq:V:")) != -1) {
89 switch (opt) {
90 case 'a':
91 auto_detach = 1;
92 break;
93 case 'q':
94 quit_after = atof(optarg);
95 break;
96 case 'V':
97 if (!strcmp("LOG_NULL", optarg))
99 else if (!strcmp("LOG_NOTICE", optarg))
101 else if (!strcmp("LOG_INFO", optarg))
103 else if (!strcmp("LOG_ERR", optarg))
105 else if (!strcmp("LOG_DEBUG", optarg))
107 else {
108 n_log(LOG_ERR, "%s is not a valid log level", optarg);
109 exit(1);
110 }
111 break;
112 case 'h':
113 default:
114 printf(
115 "Usage: %s [-V LOG_LEVEL] [-a] [-q SECONDS]\n"
116 " -a detach every panel at startup\n"
117 " -q SECONDS quit after SECONDS (0 = until ESC)\n",
118 argv[0]);
119 exit(0);
120 }
121 }
123}
124
126static DEMO_PANEL* panel_of(int window_id) {
127 for (int i = 0; i < nb_panels; i++) {
128 if (panels[i].win == window_id) return &panels[i];
129 }
130 return NULL;
131}
132
134static void refresh_buttons(void) {
135 for (int i = 0; i < nb_panels; i++) {
136 int detached = n_gui_window_is_detached(gui, panels[i].win);
137 n_gui_button_set_label(gui, panels[i].btn, detached ? "Attach to main window" : "Detach to its own window");
138 }
139 if (lbl_status >= 0) {
140 char buf[192];
141 char detail[128];
142 detail[0] = '\0';
143 for (int i = 0; i < nb_panels; i++) {
144 char one[48];
145 snprintf(one, sizeof(one), "%s%s:%s", detail[0] ? " " : "", panels[i].name,
146 n_gui_window_is_detached(gui, panels[i].win) ? "native" : "popup");
147 strncat(detail, one, sizeof(detail) - strlen(detail) - 1);
148 }
149 snprintf(buf, sizeof(buf), "%d native window(s) %s", n_gui_count_detached(gui), detail);
151 }
152}
153
155static void on_toggle_detach(int widget_id, void* user_data) {
156 (void)widget_id;
157 DEMO_PANEL* p = (DEMO_PANEL*)user_data;
158 if (!p) return;
161 n_log(LOG_NOTICE, "%s is a pop-up again", p->name);
162 } else if (n_gui_window_detach(gui, p->win, p->detach_flags) == 0) {
163 n_log(LOG_NOTICE, "%s detached into a native window", p->name);
164 } else {
165 n_log(LOG_ERR, "%s could not be detached", p->name);
166 }
168}
169
170static void on_detach_all(int widget_id, void* user_data) {
171 (void)widget_id;
172 (void)user_data;
173 for (int i = 0; i < nb_panels; i++) {
174 if (!n_gui_window_is_detached(gui, panels[i].win))
175 n_gui_window_detach(gui, panels[i].win, panels[i].detach_flags);
176 }
178}
179
180static void on_attach_all(int widget_id, void* user_data) {
181 (void)widget_id;
182 (void)user_data;
183 for (int i = 0; i < nb_panels; i++) {
185 }
187}
188
193static void on_panel_close(int window_id, void* user_data) {
194 (void)user_data;
195 DEMO_PANEL* p = panel_of(window_id);
196 n_gui_close_window(gui, window_id);
197 n_log(LOG_NOTICE, "%s closed, use 'Show all panels' to bring it back", p ? p->name : "panel");
198}
199
200static void on_show_all(int widget_id, void* user_data) {
201 (void)widget_id;
202 (void)user_data;
203 for (int i = 0; i < nb_panels; i++) {
204 /* a panel closed while detached remembers that it wants a native
205 window, so opening it re-creates one instead of a pop-up */
207 }
209}
210
211static void on_save_layout(int widget_id, void* user_data) {
212 (void)widget_id;
213 (void)user_data;
215 n_log(LOG_NOTICE, "layout saved to %s (detached state included)", LAYOUT_FILE);
216 else
217 n_log(LOG_ERR, "could not save %s", LAYOUT_FILE);
218}
219
220static void on_load_layout(int widget_id, void* user_data) {
221 (void)widget_id;
222 (void)user_data;
224 n_log(LOG_NOTICE, "layout loaded from %s", LAYOUT_FILE);
225 else
226 n_log(LOG_ERR, "could not load %s (save one first with F5)", LAYOUT_FILE);
228}
229
230static void on_slider_change(int widget_id, double value, void* user_data) {
231 (void)widget_id;
232 (void)user_data;
233 n_log(LOG_INFO, "slider: %.1f", value);
234}
235
237static int build_panel(const char* title, float x, float y, float w, float h, int detach_flags, const char* name) {
238 int win = n_gui_add_window(gui, title, x, y, w, h);
239 if (win < 0) return -1;
242
244 p->win = win;
245 p->detach_flags = detach_flags;
246 p->name = name;
247 p->btn = n_gui_add_button(gui, win, "Detach to its own window",
248 10.0f, 10.0f, w - 20.0f, 26.0f, N_GUI_SHAPE_ROUNDED,
250 n_gui_set_widget_tooltip(gui, p->btn, "Promote this panel to a real OS window, and back");
251 nb_panels++;
252 return win;
253}
254
255int main(int argc, char** argv) {
257 process_args(argc, argv);
258
259 if (!al_init()) {
260 n_log(LOG_ERR, "unable to initialize allegro");
261 return 1;
262 }
263 if (!al_init_primitives_addon() || !al_init_font_addon()) {
264 n_log(LOG_ERR, "unable to initialize allegro addons");
265 return 1;
266 }
267 al_install_keyboard();
268 al_install_mouse();
269
270 ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();
271 if (!queue) {
272 n_log(LOG_ERR, "unable to create the event queue");
273 return 1;
274 }
275
276 al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE);
277 ALLEGRO_DISPLAY* display = al_create_display(WIDTH, HEIGHT);
278 if (!display) {
279 n_log(LOG_ERR, "unable to create a display, is a graphical session available?");
280 al_destroy_event_queue(queue);
281 return 1;
282 }
283 al_set_window_title(display, "Nilorea GUI, detachable windows");
284
285 ALLEGRO_TIMER* fps_timer = al_create_timer(1.0 / 60.0);
286 al_register_event_source(queue, al_get_display_event_source(display));
287 al_register_event_source(queue, al_get_timer_event_source(fps_timer));
288 al_register_event_source(queue, al_get_keyboard_event_source());
289 al_register_event_source(queue, al_get_mouse_event_source());
290
291 ALLEGRO_FONT* font = al_create_builtin_font();
292 if (!font) {
293 n_log(LOG_ERR, "unable to create the builtin font");
294 al_destroy_timer(fps_timer);
295 al_destroy_display(display);
296 al_destroy_event_queue(queue);
297 return 1;
298 }
299
300 gui = n_gui_new_ctx(font);
301 if (!gui) {
302 n_log(LOG_ERR, "unable to create the GUI context");
303 al_destroy_font(font);
304 al_destroy_timer(fps_timer);
305 al_destroy_display(display);
306 al_destroy_event_queue(queue);
307 return 1;
308 }
310 n_gui_set_display_size(gui, (float)WIDTH, (float)HEIGHT);
311 /* the virtual canvas keeps the main display's layout resolution-independent;
312 a native window is always drawn 1:1 in its own display */
313 n_gui_set_virtual_size(gui, (float)WIDTH, (float)HEIGHT);
314
315 /* REQUIRED before detaching: the context registers each native window's
316 event source into this queue, so its events reach n_gui_process_event */
318
319 /* control panel */
320 {
321 int win = n_gui_add_window(gui, "Control", 20.0f, 20.0f, 500.0f, 210.0f);
323 n_gui_add_button(gui, win, "Detach all panels", 10.0f, 10.0f, 235.0f, 26.0f,
325 n_gui_add_button(gui, win, "Attach all panels", 255.0f, 10.0f, 235.0f, 26.0f,
327 n_gui_add_button(gui, win, "Show all panels", 10.0f, 44.0f, 235.0f, 26.0f,
329 n_gui_add_button(gui, win, "Save layout (F5)", 255.0f, 44.0f, 235.0f, 26.0f,
331 n_gui_add_button(gui, win, "Load layout (F9)", 255.0f, 78.0f, 235.0f, 26.0f,
333 lbl_status = n_gui_add_label(gui, win, "", 10.0f, 116.0f, 480.0f, 16.0f, N_GUI_ALIGN_LEFT);
335 "Close a native window: 'Show all panels' brings it back.",
336 10.0f, 138.0f, 480.0f, 16.0f, N_GUI_ALIGN_LEFT);
337 (void)lbl_hint;
338 }
339
340 /* Panel 1, the default: the window manager draws the title bar */
341 {
342 int win = build_panel("Mixer (OS chrome)", 20.0f, 250.0f, 300.0f, 220.0f,
343 N_GUI_DETACH_RESIZABLE, "Mixer");
344 n_gui_add_label(gui, win, "Volume", 10.0f, 46.0f, 100.0f, 16.0f, N_GUI_ALIGN_LEFT);
345 int sld = n_gui_add_slider(gui, win, 10.0f, 66.0f, 230.0f, 22.0f,
346 0.0, 100.0, 65.0, N_GUI_SLIDER_PERCENT, on_slider_change, NULL);
347 n_gui_slider_set_step(gui, sld, 5.0);
348 n_gui_add_checkbox(gui, win, "Mute", 10.0f, 96.0f, 120.0f, 20.0f, 0, NULL, NULL);
349 n_gui_add_progressbar(gui, win, 10.0f, 124.0f, 280.0f, 18.0f);
350 n_gui_add_label(gui, win, "The OS draws this frame.",
351 10.0f, 150.0f, 280.0f, 16.0f, N_GUI_ALIGN_LEFT);
352 }
353
354 /* Panel 2, N_GUI_DETACH_OWN_CHROME: our own title bar inside a frameless
355 native window, so the panel keeps its skin on the desktop */
356 {
357 int win = build_panel("Notes (N_GUI chrome)", 340.0f, 250.0f, 300.0f, 220.0f,
359 notes_txt = n_gui_add_textarea(gui, win, 10.0f, 46.0f, 280.0f, 100.0f, 1, 512, NULL, NULL);
361 "Copy and paste still reach\n"
362 "the right display.\n\n"
363 "Drag me by my own title bar.");
364 n_gui_add_label(gui, win, "Frameless window, N_GUI chrome.",
365 10.0f, 152.0f, 280.0f, 16.0f, N_GUI_ALIGN_LEFT);
366 }
367
368 /* Panel 3, N_GUI_DETACH_SCALE_CONTENT: widgets follow the native window */
369 {
370 int win = build_panel("Files (scaling)", 660.0f, 250.0f, 280.0f, 220.0f,
372 int lb = n_gui_add_listbox(gui, win, 10.0f, 46.0f, 260.0f, 120.0f,
373 N_GUI_SELECT_SINGLE, NULL, NULL);
374 n_gui_listbox_add_item(gui, lb, "n_gui.c");
375 n_gui_listbox_add_item(gui, lb, "n_network.c");
376 n_gui_listbox_add_item(gui, lb, "n_reactor.c");
377 n_gui_listbox_add_item(gui, lb, "n_str.c");
378 n_gui_listbox_add_item(gui, lb, "n_hash.c");
379 n_gui_listbox_add_item(gui, lb, "n_list.c");
380 n_gui_add_label(gui, win, "Widgets scale with it.",
381 10.0f, 172.0f, 260.0f, 16.0f, N_GUI_ALIGN_LEFT);
382 }
383
384 if (auto_detach) {
385 on_detach_all(-1, NULL);
386 }
388
389 n_log(LOG_NOTICE, "ex_gui_detach: click a panel's button to give it its own OS window. ESC quits.");
390
391 al_start_timer(fps_timer);
392 int do_draw = 0;
393 double started_at = al_get_time();
394 al_flush_event_queue(queue);
395
396 while (!DONE) {
397 ALLEGRO_EVENT ev;
398 al_wait_for_event(queue, &ev);
399
400 /* Only the MAIN display's close ends the demo. A native window's close
401 belongs to the panel that owns it and is handled by N_GUI, which
402 routes it to on_panel_close. */
403 if (ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE && ev.display.source == display) {
404 DONE = 1;
405 }
406 if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
407 if (ev.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
408 DONE = 1;
409 else if (ev.keyboard.keycode == ALLEGRO_KEY_F5)
410 on_save_layout(-1, NULL);
411 else if (ev.keyboard.keycode == ALLEGRO_KEY_F9)
412 on_load_layout(-1, NULL);
413 }
414 /* main display resize only, a native window's resize is N_GUI's job */
415 if (ev.type == ALLEGRO_EVENT_DISPLAY_RESIZE && ev.display.source == display) {
416 al_acknowledge_resize(display);
417 n_gui_set_display_size(gui, (float)al_get_display_width(display),
418 (float)al_get_display_height(display));
419 }
420
421 /* Every event goes through the GUI, which routes it to the display it
422 came from. This is what makes a click inside a native window reach
423 that window's widgets and nothing else. */
425
426 if (ev.type == ALLEGRO_EVENT_TIMER) {
428 do_draw = 1;
429 if (quit_after > 0.0 && (al_get_time() - started_at) >= quit_after) {
430 n_log(LOG_NOTICE, "ex_gui_detach: -q reached, quitting");
431 DONE = 1;
432 }
433 }
434
435 if (do_draw && al_is_event_queue_empty(queue)) {
436 /* main display: pop-up panels only */
437 al_set_target_backbuffer(display);
438 al_clear_to_color(al_map_rgb(28, 30, 36));
440 {
441 ALLEGRO_TRANSFORM tf;
442 al_identity_transform(&tf);
443 if (gui->virtual_w > 0 && gui->gui_scale > 0) {
444 al_scale_transform(&tf, gui->gui_scale, gui->gui_scale);
445 al_translate_transform(&tf, gui->gui_offset_x, gui->gui_offset_y);
446 }
447 al_use_transform(&tf);
448 al_draw_text(font, al_map_rgb(170, 175, 185), 10.0f, (float)HEIGHT - 18.0f, 0,
449 "Detach a panel to give it a real OS window | F5 save layout | F9 load layout | ESC quit");
450 al_identity_transform(&tf);
451 al_use_transform(&tf);
452 }
453 al_flip_display();
454
455 /* native windows: renders and flips each one, and releases the ones
456 whose close was requested. Called after the queue is drained, so
457 no queued event can name a display that is about to go away. */
459
460 do_draw = 0;
461 }
462 }
463
464 /* the context owns every native window still open and destroys them here */
466 al_destroy_font(font);
467 al_destroy_timer(fps_timer);
468 al_destroy_event_queue(queue);
469 al_destroy_display(display);
470
471 n_log(LOG_NOTICE, "ex_gui_detach: done");
472 return 0;
473}
int main(void)
void process_args(int argc, char **argv)
Definition ex_common.c:48
ALLEGRO_TIMER * fps_timer
Definition ex_fluid.c:65
int DONE
Definition ex_fluid.c:58
int log_level
Definition ex_fluid.c:60
ALLEGRO_DISPLAY * display
Definition ex_fluid.c:54
#define WIDTH
Definition ex_gui.c:42
void on_slider_change(int widget_id, double value, void *user_data)
Definition ex_gui.c:100
static int lbl_status
Definition ex_gui.c:70
#define HEIGHT
Definition ex_gui.c:43
static void on_panel_close(int window_id, void *user_data)
A native window's close button (the window manager's, or N_GUI's own when the panel keeps its chrome)...
#define LAYOUT_FILE
static double quit_after
seconds after which the demo quits on its own (0 = run until ESC)
static int lbl_hint
static N_GUI_CTX * gui
static void on_save_layout(int widget_id, void *user_data)
static void refresh_buttons(void)
keep each panel's button label in sync with what it will do next
static int auto_detach
1 to detach every panel at startup (-a)
static void on_show_all(int widget_id, void *user_data)
static void on_toggle_detach(int widget_id, void *user_data)
the per-panel button: toggle this panel between pop-up and native window
static void on_attach_all(int widget_id, void *user_data)
static DEMO_PANEL * panel_of(int window_id)
find the panel a window id belongs to, or NULL
const char * name
short name used in the status line
static int build_panel(const char *title, float x, float y, float w, float h, int detach_flags, const char *name)
build one demo panel: a few ordinary widgets plus its detach button
static DEMO_PANEL panels[3]
static void on_detach_all(int widget_id, void *user_data)
int detach_flags
options this panel detaches with (N_GUI_DETACH_*)
int btn
id of the panel's own detach / attach button
static void on_load_layout(int widget_id, void *user_data)
int win
window id
static int notes_txt
text area of the "Notes" panel, used by the copy/paste hint
static int nb_panels
one demo panel: a window plus the button that detaches / attaches it
float gui_offset_x
horizontal letterbox offset for virtual canvas
Definition n_gui.h:1416
float gui_offset_y
vertical letterbox offset for virtual canvas
Definition n_gui.h:1418
float virtual_w
virtual canvas width (0 = disabled / identity transform)
Definition n_gui.h:1410
float gui_scale
computed uniform scale factor for virtual canvas
Definition n_gui.h:1414
void n_gui_set_display_size(N_GUI_CTX *ctx, float w, float h)
Set the display (viewport) size for global scrollbar computation.
Definition n_gui.c:9034
#define N_GUI_ALIGN_LEFT
left aligned text
Definition n_gui.h:189
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.
Definition n_gui.c:2442
void n_gui_textarea_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set the text content of a textarea widget
Definition n_gui.c:3263
int n_gui_save_layout_json(N_GUI_CTX *ctx, const char *filepath)
save the geometry + persistent state of every window to a JSON file
Definition n_gui.c:12712
int n_gui_window_detach(N_GUI_CTX *ctx, int window_id, int detach_flags)
Promote a pop-up window to a native OS window.
Definition n_gui.c:1409
#define N_GUI_DETACH_SCALE_CONTENT
scale the window's widgets when the native window is resized by the user.
Definition n_gui.h:256
#define N_GUI_SLIDER_PERCENT
slider uses 0-100 percentage
Definition n_gui.h:157
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:9071
void n_gui_set_widget_tooltip(N_GUI_CTX *ctx, int widget_id, const char *text)
Set (or clear) the tooltip text of any widget.
Definition n_gui.c:2240
void n_gui_label_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set the text of a label widget
Definition n_gui.c:4511
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:2620
int n_gui_process_event(N_GUI_CTX *ctx, ALLEGRO_EVENT event)
Process an allegro event through the GUI system.
Definition n_gui.c:9836
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.
Definition n_gui.c:2966
void n_gui_close_window(N_GUI_CTX *ctx, int window_id)
Close (hide) a window.
Definition n_gui.c:1191
int n_gui_listbox_add_item(N_GUI_CTX *ctx, int widget_id, const char *text)
add an item to a listbox widget
Definition n_gui.c:3371
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:8831
void n_gui_button_set_label(N_GUI_CTX *ctx, int widget_id, const char *label)
Replace the label text drawn on a button.
Definition n_gui.c:2221
#define N_GUI_SELECT_SINGLE
single item selection
Definition n_gui.h:175
#define N_GUI_DETACH_RESIZABLE
the native window can be resized by the user through the OS window manager
Definition n_gui.h:250
int n_gui_window_is_detached(N_GUI_CTX *ctx, int window_id)
Check whether a window currently lives in a native OS window.
Definition n_gui.c:1575
void n_gui_slider_set_step(N_GUI_CTX *ctx, int widget_id, double step)
set slider step increment.
Definition n_gui.c:3211
int n_gui_add_progressbar(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h)
add a horizontal progress bar (display only); returns the widget id or -1
Definition n_gui.c:4253
void n_gui_draw(N_GUI_CTX *ctx)
Draw all visible windows and their widgets.
Definition n_gui.c:8542
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.
Definition n_gui.c:1063
int n_gui_window_attach(N_GUI_CTX *ctx, int window_id)
Return a detached window to being an in-display pop-up.
Definition n_gui.c:1542
void n_gui_draw_detached(N_GUI_CTX *ctx)
Render and flip every detached window, and release the ones whose native window was closed.
Definition n_gui.c:8737
N_GUI_CTX * n_gui_new_ctx(ALLEGRO_FONT *default_font)
Create a new GUI context.
Definition n_gui.c:903
void n_gui_window_set_close_callback(N_GUI_CTX *ctx, int window_id, void(*on_close)(int, void *), void *user_data)
Set the close button callback for a window.
Definition n_gui.c:1655
#define N_GUI_DETACH_OWN_CHROME
keep N_GUI's own window chrome instead of the window manager's: the native window is created frameles...
Definition n_gui.h:266
#define N_GUI_WIN_BTN_MINIMIZE
enable minimize button on the title bar
Definition n_gui.h:235
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
Destroy a GUI context and all its windows/widgets.
Definition n_gui.c:995
void n_gui_open_window(N_GUI_CTX *ctx, int window_id)
Open (show) a window.
Definition n_gui.c:1206
int n_gui_count_detached(N_GUI_CTX *ctx)
Count the windows currently detached into native OS windows.
Definition n_gui.c:1609
int n_gui_load_layout_json(N_GUI_CTX *ctx, const char *filepath)
load a JSON window layout file and apply it to matching windows
Definition n_gui.c:12870
#define N_GUI_SHAPE_ROUNDED
rounded rectangle shape
Definition n_gui.h:149
void n_gui_window_set_flags(N_GUI_CTX *ctx, int window_id, int flags)
Set feature flags on a window.
Definition n_gui.c:1968
#define N_GUI_WIN_BTN_ALL
enable all three title bar buttons (minimize + maximize + close)
Definition n_gui.h:241
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:2498
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:2543
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.
Definition n_gui.c:2124
void n_gui_set_event_queue(N_GUI_CTX *ctx, ALLEGRO_EVENT_QUEUE *queue)
Set the event queue used to register native window event sources.
Definition n_gui.c:1356
#define N_GUI_WIN_RESIZABLE
enable user-resizable window with a drag handle at bottom-right
Definition n_gui.h:229
The top-level GUI context that holds all windows.
Definition n_gui.h:1354
#define n_log(__LEVEL__,...)
Logging function wrapper to get line and func.
Definition n_log.h:89
#define LOG_DEBUG
debug-level messages
Definition n_log.h:84
#define LOG_ERR
error conditions
Definition n_log.h:76
void set_log_level(const int log_level)
Set the global log level value ( static int LOG_LEVEL )
Definition n_log.c:121
#define LOG_NOTICE
normal but significant condition
Definition n_log.h:80
#define LOG_NULL
no log output
Definition n_log.h:46
#define LOG_INFO
informational
Definition n_log.h:82
Common headers and low-level functions & define.
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.
Generic log system.