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 * 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
27
28#ifndef __NILOREA_GUI__
29#define __NILOREA_GUI__
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
70
71#include <stdio.h>
72#include <stdlib.h>
73#include <string.h>
74#include <ctype.h>
75#include <stdbool.h>
76
77#include <nilorea/n_allegro5.h>
78#include <nilorea/n_common.h>
79#include <nilorea/n_str.h>
80#include <nilorea/n_log.h>
81#include <nilorea/n_gui_md.h>
82#include <nilorea/n_list.h>
83#include <nilorea/n_hash.h>
84
86#define N_GUI_ID_MAX 128
88#define N_GUI_TEXT_MAX 4096
89
94#define N_GUI_SUGGEST_MAX 64
95
98#define N_GUI_SUGGEST_VISIBLE 8
99
102#define N_GUI_SUGGEST_SEP_MAX 8
103
104/* widget type enum */
106#define N_GUI_TYPE_BUTTON 1
108#define N_GUI_TYPE_SLIDER 2
110#define N_GUI_TYPE_TEXTAREA 3
112#define N_GUI_TYPE_CHECKBOX 4
114#define N_GUI_TYPE_SCROLLBAR 5
116#define N_GUI_TYPE_LISTBOX 6
118#define N_GUI_TYPE_RADIOLIST 7
120#define N_GUI_TYPE_COMBOBOX 8
122#define N_GUI_TYPE_IMAGE 9
124#define N_GUI_TYPE_LABEL 10
126#define N_GUI_TYPE_DROPMENU 11
128#define N_GUI_TYPE_SPLITPANE 12
130#define N_GUI_TYPE_HEXVIEW 13
132#define N_GUI_TYPE_SYNTAXVIEW 14
134#define N_GUI_TYPE_DATAGRID 15
135
137#define N_GUI_TYPE_PROGRESSBAR 16
138
140#define N_GUI_TYPE_CUSTOM 17
141
143#define N_GUI_TYPE_MARKDOWNVIEW 18
144
146#define N_GUI_SPLIT_VERTICAL 0
148#define N_GUI_SPLIT_HORIZONTAL 1
149
151#define N_GUI_SYNTAX_PLAIN 0
153#define N_GUI_SYNTAX_HTTP 1
155#define N_GUI_SYNTAX_JSON 2
157#define N_GUI_SYNTAX_XML 3
159#define N_GUI_SYNTAX_YAML 4
161#define N_GUI_SYNTAX_JS 5
166#define N_GUI_SYNTAX_DIFF 6
167
168/* shape flags */
170#define N_GUI_SHAPE_RECT 0
172#define N_GUI_SHAPE_ROUNDED 1
174#define N_GUI_SHAPE_BITMAP 2
175
176/* slider mode */
178#define N_GUI_SLIDER_VALUE 0
180#define N_GUI_SLIDER_PERCENT 1
181
182/* slider orientation */
184#define N_GUI_SLIDER_H 0
186#define N_GUI_SLIDER_V 1
187
188/* scrollbar orientation */
190#define N_GUI_SCROLLBAR_H 0
192#define N_GUI_SCROLLBAR_V 1
193
194/* list selection modes */
196#define N_GUI_SELECT_NONE 0
198#define N_GUI_SELECT_SINGLE 1
200#define N_GUI_SELECT_MULTIPLE 2
201
202/* image scale modes */
204#define N_GUI_IMAGE_FIT 0
206#define N_GUI_IMAGE_STRETCH 1
208#define N_GUI_IMAGE_CENTER 2
209
210/* text alignment */
212#define N_GUI_ALIGN_LEFT 0
214#define N_GUI_ALIGN_CENTER 1
216#define N_GUI_ALIGN_RIGHT 2
218#define N_GUI_ALIGN_JUSTIFIED 3
219
222#define N_GUI_TRUNCATE_END 0
225#define N_GUI_TRUNCATE_START 1
229#define N_GUI_TRUNCATE_PATH 2
230
231/* widget state flags */
233#define N_GUI_STATE_IDLE 0
235#define N_GUI_STATE_HOVER 1
237#define N_GUI_STATE_ACTIVE 2
239#define N_GUI_STATE_FOCUSED 4
241#define N_GUI_STATE_SCROLLBAR_DRAG 8
242
243/* window state flags */
245#define N_GUI_WIN_OPEN 1
247#define N_GUI_WIN_MINIMISED 2
249#define N_GUI_WIN_DRAGGING 4
251#define N_GUI_WIN_RESIZING 8
253#define N_GUI_WIN_VSCROLL_DRAG 16
255#define N_GUI_WIN_HSCROLL_DRAG 32
257#define N_GUI_WIN_MAXIMISED 64
259#define N_GUI_WIN_VSCROLL_HOVER 128
261#define N_GUI_WIN_HSCROLL_HOVER 256
262
263/* window feature flags (set via n_gui_window_set_flags) */
267#define N_GUI_GLOBAL_SCROLL_SLACK 0.5f
268
270#define N_GUI_WIN_AUTO_SCROLLBAR 16
272#define N_GUI_WIN_RESIZABLE 32
274#define N_GUI_WIN_FIXED_POSITION 64
276#define N_GUI_WIN_FRAMELESS 128
278#define N_GUI_WIN_BTN_MINIMIZE 256
280#define N_GUI_WIN_BTN_MAXIMIZE 512
282#define N_GUI_WIN_BTN_CLOSE 1024
284#define N_GUI_WIN_BTN_ALL (N_GUI_WIN_BTN_MINIMIZE | N_GUI_WIN_BTN_MAXIMIZE | N_GUI_WIN_BTN_CLOSE)
287#define N_GUI_WIN_NO_HSCROLL 2048
288
289/* native (detached) window options, passed to n_gui_window_detach */
291#define N_GUI_DETACH_NONE 0
293#define N_GUI_DETACH_RESIZABLE 1
299#define N_GUI_DETACH_SCALE_CONTENT 2
309#define N_GUI_DETACH_OWN_CHROME 4
310
311/* titlebar button indices */
313#define N_GUI_TB_BTN_NONE 0
315#define N_GUI_TB_BTN_MINIMIZE 1
317#define N_GUI_TB_BTN_MAXIMIZE 2
319#define N_GUI_TB_BTN_CLOSE 3
320
321/* context-level resize modes (set via n_gui_set_resize_mode) */
323#define N_GUI_RESIZE_VIRTUAL 0
325#define N_GUI_RESIZE_ADAPTIVE 1
326
327/* per-window resize policies (used in ADAPTIVE mode) */
329#define N_GUI_WIN_RESIZE_NONE 0
331#define N_GUI_WIN_RESIZE_MOVE 1
333#define N_GUI_WIN_RESIZE_SCALE 2
334
335/* dialog auto-adjust flags (set via n_gui_window_set_autofit) */
337#define N_GUI_AUTOFIT_W 1
339#define N_GUI_AUTOFIT_H 2
341#define N_GUI_AUTOFIT_WH 3
343#define N_GUI_AUTOFIT_EXPAND_LEFT 4
345#define N_GUI_AUTOFIT_EXPAND_UP 8
347#define N_GUI_AUTOFIT_CENTER 16
348
349/* window z-order modes */
351#define N_GUI_ZORDER_NORMAL 0
353#define N_GUI_ZORDER_ALWAYS_ON_TOP 1
355#define N_GUI_ZORDER_ALWAYS_BEHIND 2
362#define N_GUI_ZORDER_FIXED 3
369#define N_GUI_ZORDER_POPUP 4
370
371/* text dimension bounding box */
372
374typedef struct N_GUI_TEXT_DIMS {
375 int x;
376 int y;
377 int w;
378 int h;
380
381/* color theme */
382
384typedef struct N_GUI_THEME {
386 ALLEGRO_COLOR bg_normal;
388 ALLEGRO_COLOR bg_hover;
390 ALLEGRO_COLOR bg_active;
392 ALLEGRO_COLOR border_normal;
394 ALLEGRO_COLOR border_hover;
396 ALLEGRO_COLOR border_active;
398 ALLEGRO_COLOR text_normal;
400 ALLEGRO_COLOR text_hover;
402 ALLEGRO_COLOR text_active;
410 ALLEGRO_COLOR selection_color;
412
413/* button glyphs: small icons drawn with primitives in the button's text colour,
414 * for square buttons where a text label would not fit or would read poorly
415 * (a row of "move up / move down / duplicate" actions, a toolbar of arrows).
416 * They cost no assets, follow the theme, and stay crisp at any size. */
418#define N_GUI_GLYPH_NONE 0
420#define N_GUI_GLYPH_ARROW_UP 1
422#define N_GUI_GLYPH_ARROW_DOWN 2
424#define N_GUI_GLYPH_ARROW_LEFT 3
426#define N_GUI_GLYPH_ARROW_RIGHT 4
428#define N_GUI_GLYPH_PLUS 5
430#define N_GUI_GLYPH_MINUS 6
432#define N_GUI_GLYPH_CROSS 7
434#define N_GUI_GLYPH_COPY 8
436#define N_GUI_GLYPH_COUNT 9
437
438/* button key modifier flags (use with n_gui_button_set_keycode) */
440#define N_GUI_KEY_MOD_MASK (ALLEGRO_KEYMOD_SHIFT | ALLEGRO_KEYMOD_CTRL | ALLEGRO_KEYMOD_ALT | ALLEGRO_KEYMOD_ALTGR)
441
443#define N_GUI_KEY_SOURCES_MAX 8
444
463typedef struct N_GUI_SB_TRACK {
465 float x;
467 float y;
469 float w;
471 float h;
476
477/* per-widget data */
478
480typedef struct N_GUI_BUTTON_DATA {
484 ALLEGRO_BITMAP* bitmap;
486 ALLEGRO_BITMAP* bitmap_hover;
488 ALLEGRO_BITMAP* bitmap_active;
490 int shape;
495 int glyph;
520 void (*on_click)(int widget_id, void* user_data);
524
526typedef struct N_GUI_SLIDER_DATA {
528 double min_val;
530 double max_val;
532 double value;
534 double step;
539 double key_step;
541 int mode;
545 ALLEGRO_BITMAP* track_bitmap;
547 ALLEGRO_BITMAP* fill_bitmap;
549 ALLEGRO_BITMAP* handle_bitmap;
551 ALLEGRO_BITMAP* handle_hover_bitmap;
553 ALLEGRO_BITMAP* handle_active_bitmap;
555 void (*on_change)(int widget_id, double value, void* user_data);
562 char value_format[32];
574
582
589
601
613typedef void (*N_GUI_SUGGEST_FN)(const char* prefix, N_GUI_SUGGEST_SINK* sink, void* user_data);
614
675
677typedef struct N_GUI_CHECKBOX_DATA {
683 ALLEGRO_BITMAP* box_bitmap;
685 ALLEGRO_BITMAP* box_checked_bitmap;
687 ALLEGRO_BITMAP* box_hover_bitmap;
689 void (*on_toggle)(int widget_id, int checked, void* user_data);
693
695typedef struct N_GUI_SCROLLBAR_DATA {
708 int shape;
710 ALLEGRO_BITMAP* track_bitmap;
712 ALLEGRO_BITMAP* thumb_bitmap;
714 ALLEGRO_BITMAP* thumb_hover_bitmap;
716 ALLEGRO_BITMAP* thumb_active_bitmap;
718 void (*on_scroll)(int widget_id, double scroll_pos, void* user_data);
722
724typedef struct N_GUI_LISTBOX_DATA {
728 size_t nb_items;
739 float h_scroll;
747 ALLEGRO_BITMAP* bg_bitmap;
749 ALLEGRO_BITMAP* item_bg_bitmap;
751 ALLEGRO_BITMAP* item_selected_bitmap;
753 void (*on_select)(int widget_id, int index, int selected, void* user_data);
761
763typedef struct N_GUI_SPLITPANE_DATA {
767 float ratio;
773 float divider;
775 void (*on_change)(int widget_id, float ratio, void* user_data);
779
781typedef struct N_GUI_HEXVIEW_DATA {
783 unsigned char* data;
785 size_t len;
787 size_t cap;
795 size_t cursor;
799 void (*on_change)(int widget_id, const unsigned char* data, size_t len, void* user_data);
803
843
853
855typedef struct N_GUI_DATAGRID_DATA {
859 size_t nb_cols;
861 size_t cols_cap;
864 size_t* col_order;
874 void (*on_columns_changed)(int widget_id, void* user_data);
876 char** cells;
878 size_t nb_rows;
880 size_t rows_cap;
890 unsigned char* row_sel;
894 ALLEGRO_COLOR* row_color;
897 unsigned char* row_has_color;
902 float h_scroll;
907 void (*on_select)(int widget_id, int row, void* user_data);
911 void (*on_context)(int widget_id, int row, int x, int y, void* user_data);
915
917typedef struct N_GUI_RADIOLIST_DATA {
921 size_t nb_items;
931 ALLEGRO_BITMAP* bg_bitmap;
933 ALLEGRO_BITMAP* item_bg_bitmap;
935 ALLEGRO_BITMAP* item_selected_bitmap;
937 void (*on_select)(int widget_id, int index, void* user_data);
941
942/* combobox feature flags */
944#define N_GUI_COMBOBOX_AUTO_WIDTH 1
949#define N_GUI_COMBOBOX_EXPAND_UP 2
950
952typedef struct N_GUI_COMBOBOX_DATA {
956 size_t nb_items;
975 ALLEGRO_BITMAP* bg_bitmap;
977 ALLEGRO_BITMAP* item_bg_bitmap;
979 ALLEGRO_BITMAP* item_selected_bitmap;
981 void (*on_select)(int widget_id, int index, void* user_data);
985 int flags;
987
989typedef struct N_GUI_IMAGE_DATA {
991 ALLEGRO_BITMAP* bitmap;
995
997typedef struct N_GUI_LABEL_DATA {
1017 ALLEGRO_BITMAP* bg_bitmap;
1019 void (*on_link_click)(int widget_id, const char* link, void* user_data);
1023
1031
1033typedef struct N_GUI_DROPMENU_ENTRY {
1039 int tag;
1041 void (*on_click)(int widget_id, int entry_index, int tag, void* user_data);
1045
1046/* dropmenu feature flags */
1050#define N_GUI_DROPMENU_EXPAND_UP 1
1051
1088
1089/* widget */
1090
1140
1174
1184typedef void (*N_GUI_CUSTOM_DRAW)(N_GUI_WIDGET* widget, float x, float y, ALLEGRO_FONT* font, void* user_data);
1185
1187#define N_GUI_MOUSE_DOWN 1
1190#define N_GUI_MOUSE_UP 2
1192#define N_GUI_MOUSE_MOVE 3
1195#define N_GUI_MOUSE_DRAG 4
1197#define N_GUI_MOUSE_WHEEL 5
1198
1200typedef struct N_GUI_MOUSE_EVENT {
1202 int type;
1206 float x;
1208 float y;
1210 int dz;
1217
1225typedef int (*N_GUI_CUSTOM_MOUSE)(int widget_id, const N_GUI_MOUSE_EVENT* ev, void* user_data);
1226
1242
1243/* titlebar buttons state */
1244
1246typedef struct N_GUI_TB_BUTTONS {
1264 ALLEGRO_BITMAP* minimize_bitmap;
1266 ALLEGRO_BITMAP* minimize_hover_bitmap;
1268 ALLEGRO_BITMAP* minimize_active_bitmap;
1270 ALLEGRO_BITMAP* maximize_bitmap;
1272 ALLEGRO_BITMAP* maximize_hover_bitmap;
1274 ALLEGRO_BITMAP* maximize_active_bitmap;
1276 ALLEGRO_BITMAP* close_bitmap;
1278 ALLEGRO_BITMAP* close_hover_bitmap;
1280 ALLEGRO_BITMAP* close_active_bitmap;
1282 void (*on_minimize)(int window_id, void* user_data);
1286 void (*on_maximize)(int window_id, void* user_data);
1290 void (*on_close)(int window_id, void* user_data);
1294
1295/* pseudo window */
1296
1448
1449/* global style (all configurable sizes, colors, paddings) */
1450
1454typedef struct N_GUI_STYLE {
1455 /* window chrome */
1466
1467 /* titlebar buttons */
1476
1477 /* window auto-scrollbar */
1490
1491 /* global display scrollbar */
1508
1509 /* resize grip */
1515 ALLEGRO_COLOR grip_color;
1516
1517 /* slider */
1532
1533 /* text area */
1538 ALLEGRO_COLOR tooltip_bg;
1540 ALLEGRO_COLOR tooltip_border;
1542 ALLEGRO_COLOR tooltip_fg;
1553
1554 /* checkbox */
1565
1566 /* radio list */
1575
1576 /* list items (shared by listbox, radiolist, combobox, dropmenu) */
1591
1592 /* dropdown arrow (combobox & dropmenu) */
1603
1613
1614 /* label */
1620 ALLEGRO_COLOR link_color_normal;
1622 ALLEGRO_COLOR link_color_hover;
1623
1624 /* scroll step */
1629
1630 /* combobox auto-width cap */
1633} N_GUI_STYLE;
1634
1635/* gui context */
1636
1639typedef struct N_GUI_PENDING_GEOM {
1641 float x;
1642 float y;
1643 float w;
1644 float h;
1645 int state;
1646 unsigned char consumed;
1648
1650#define N_GUI_PERSIST_MAX_COLS 64
1651
1667
1669typedef struct N_GUI_CTX {
1681 ALLEGRO_FONT* default_font;
1700 ALLEGRO_MOUSE_CURSOR* cursor_custom;
1706 ALLEGRO_MOUSE_CURSOR* cursor_want_custom;
1782 ALLEGRO_DISPLAY* display;
1814 ALLEGRO_EVENT_QUEUE* event_queue;
1821 ALLEGRO_DISPLAY* pass_display;
1824 ALLEGRO_DISPLAY* active_display;
1843} N_GUI_CTX;
1844
1845/* API */
1846
1847/* style helpers */
1848
1851
1852/* theme helpers */
1853
1862 ALLEGRO_COLOR bg,
1863 ALLEGRO_COLOR bg_hover,
1864 ALLEGRO_COLOR bg_active,
1865 ALLEGRO_COLOR border,
1866 ALLEGRO_COLOR border_hover,
1867 ALLEGRO_COLOR border_active,
1868 ALLEGRO_COLOR text,
1869 ALLEGRO_COLOR text_hover,
1870 ALLEGRO_COLOR text_active,
1871 float border_thickness,
1872 float corner_rx,
1873 float corner_ry);
1874
1886
1887/* text measurement */
1888
1891N_GUI_TEXT_DIMS n_gui_get_text_dims(ALLEGRO_FONT* font, const char* text);
1892
1900int n_gui_text_shorten(ALLEGRO_FONT* font, const char* text, float max_w, int mode, char* out, size_t out_len);
1901
1902/* context */
1903
1905N_GUI_CTX* n_gui_new_ctx(ALLEGRO_FONT* default_font);
1906int n_gui_set_default_font(N_GUI_CTX* ctx, ALLEGRO_FONT* font);
1908void n_gui_destroy_ctx(N_GUI_CTX** ctx);
1909
1910/* window management */
1911
1913int n_gui_add_window(N_GUI_CTX* ctx, const char* title, float x, float y, float w, float h);
1915int n_gui_add_window_auto(N_GUI_CTX* ctx, const char* title, float x, float y);
1917N_GUI_WINDOW* n_gui_get_window(N_GUI_CTX* ctx, int window_id);
1919void n_gui_close_window(N_GUI_CTX* ctx, int window_id);
1921void n_gui_open_window(N_GUI_CTX* ctx, int window_id);
1923void n_gui_toggle_window(N_GUI_CTX* ctx, int window_id);
1925int n_gui_window_is_open(N_GUI_CTX* ctx, int window_id);
1942int n_gui_window_button_rect(N_GUI_CTX* ctx, int window_id, int btn_type, float* x, float* y, float* w, float* h);
1954int n_gui_menu_is_open(const N_GUI_CTX* ctx);
1963void n_gui_close_menus(N_GUI_CTX* ctx);
1965void n_gui_minimize_window(N_GUI_CTX* ctx, int window_id);
1967void n_gui_restore_window(N_GUI_CTX* ctx, int window_id);
1969int n_gui_window_is_minimised(N_GUI_CTX* ctx, int window_id);
1971void n_gui_maximize_window(N_GUI_CTX* ctx, int window_id);
1973int n_gui_window_is_maximised(N_GUI_CTX* ctx, int window_id);
1974
1975/* native (detached) windows: promote a pop-up to a real OS window */
1976
1981void n_gui_set_event_queue(N_GUI_CTX* ctx, ALLEGRO_EVENT_QUEUE* queue);
1983ALLEGRO_EVENT_QUEUE* n_gui_get_event_queue(N_GUI_CTX* ctx);
2001int n_gui_window_detach(N_GUI_CTX* ctx, int window_id, int detach_flags);
2006int n_gui_window_attach(N_GUI_CTX* ctx, int window_id);
2008int n_gui_window_is_detached(N_GUI_CTX* ctx, int window_id);
2010ALLEGRO_DISPLAY* n_gui_window_get_display(N_GUI_CTX* ctx, int window_id);
2013int n_gui_window_from_display(N_GUI_CTX* ctx, ALLEGRO_DISPLAY* display);
2028int n_gui_window_set_native_icons(N_GUI_CTX* ctx, int window_id, ALLEGRO_BITMAP** icons, int num_icons);
2033int n_gui_window_native_is_hidden(N_GUI_CTX* ctx, int window_id);
2044void n_gui_window_set_close_callback(N_GUI_CTX* ctx, int window_id, void (*on_close)(int, void*), void* user_data);
2051void n_gui_window_set_content_draw_callback(N_GUI_CTX* ctx, int window_id, void (*on_content_draw)(int, void*), void* user_data);
2057void n_gui_window_set_minimize_callback(N_GUI_CTX* ctx, int window_id, void (*on_minimize)(int, void*), void* user_data);
2063void n_gui_window_set_maximize_callback(N_GUI_CTX* ctx, int window_id, void (*on_maximize)(int, void*), void* user_data);
2065void n_gui_window_set_tb_btn_theme(N_GUI_CTX* ctx, int window_id, N_GUI_THEME theme);
2067void n_gui_window_set_tb_close_theme(N_GUI_CTX* ctx, int window_id, N_GUI_THEME theme);
2075void n_gui_window_set_tb_button_bitmaps(N_GUI_CTX* ctx, int window_id, int btn_type, ALLEGRO_BITMAP* normal, ALLEGRO_BITMAP* hover, ALLEGRO_BITMAP* active);
2077void n_gui_raise_window(N_GUI_CTX* ctx, int window_id);
2079void n_gui_lower_window(N_GUI_CTX* ctx, int window_id);
2086void n_gui_focus_window(N_GUI_CTX* ctx, int window_id);
2092void n_gui_window_set_zorder(N_GUI_CTX* ctx, int window_id, int z_mode, int z_value);
2101void n_gui_window_set_caption(N_GUI_CTX* ctx, int window_id, const char* caption);
2112void n_gui_window_set_wheel_scrollbar(N_GUI_CTX* ctx, int window_id, int scrollbar_id);
2114int n_gui_window_get_zorder(N_GUI_CTX* ctx, int window_id);
2116int n_gui_window_get_zvalue(N_GUI_CTX* ctx, int window_id);
2121void n_gui_window_set_flags(N_GUI_CTX* ctx, int window_id, int flags);
2123int n_gui_window_get_flags(N_GUI_CTX* ctx, int window_id);
2125void n_gui_window_autosize(N_GUI_CTX* ctx, int window_id);
2131void n_gui_window_set_autofit(N_GUI_CTX* ctx, int window_id, int autofit_flags, float border);
2135void n_gui_window_apply_autofit(N_GUI_CTX* ctx, int window_id);
2136
2137/* resize mode */
2138
2140void n_gui_set_resize_mode(N_GUI_CTX* ctx, int mode);
2141
2144
2148void n_gui_window_set_resize_policy(N_GUI_CTX* ctx, int window_id, int policy);
2149
2151int n_gui_window_get_resize_policy(N_GUI_CTX* ctx, int window_id);
2152
2156void n_gui_window_update_normalized(N_GUI_CTX* ctx, int window_id);
2157
2164void n_gui_window_set_rect(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h);
2165
2171void n_gui_window_set_rect_axes(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h, int scale_x, int scale_y);
2172
2177void n_gui_apply_adaptive_resize(N_GUI_CTX* ctx, float new_w, float new_h);
2178
2179/* widget creation (returns widget id) */
2180
2182int 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);
2183
2185int 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);
2186
2188int 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);
2189
2191int n_gui_button_is_toggled(N_GUI_CTX* ctx, int widget_id);
2192
2194void n_gui_button_set_label(N_GUI_CTX* ctx, int widget_id, const char* label);
2206const char* n_gui_button_get_label(N_GUI_CTX* ctx, int widget_id);
2217int n_gui_window_find_button(N_GUI_CTX* ctx, int window_id, const char* label);
2221void n_gui_button_set_glyph(N_GUI_CTX* ctx, int widget_id, int glyph);
2224int n_gui_button_get_glyph(N_GUI_CTX* ctx, int widget_id);
2226void n_gui_button_set_state_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* normal, ALLEGRO_BITMAP* hover, ALLEGRO_BITMAP* active);
2230void n_gui_set_widget_tooltip(N_GUI_CTX* ctx, int widget_id, const char* text);
2234void n_gui_button_set_toggled(N_GUI_CTX* ctx, int widget_id, int toggled);
2235
2257void n_gui_set_cursor(N_GUI_CTX* ctx, int system_shape, ALLEGRO_MOUSE_CURSOR* custom);
2258
2271int n_gui_get_cursor(N_GUI_CTX* ctx, ALLEGRO_MOUSE_CURSOR** custom);
2273void n_gui_button_set_toggle_mode(N_GUI_CTX* ctx, int widget_id, int toggle_mode);
2274
2275/* button keyboard binding */
2288void n_gui_button_set_keycode(N_GUI_CTX* ctx, int widget_id, int keycode, int modifiers);
2289
2301void n_gui_button_set_keycode_focused(N_GUI_CTX* ctx, int widget_id, int keycode, int modifiers, const int* sources, int source_count);
2302
2304int 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);
2305
2307int 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);
2308
2310int 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);
2311
2315int 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);
2316
2318int 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);
2319
2320/* widget access */
2321
2323N_GUI_WIDGET* n_gui_get_widget(N_GUI_CTX* ctx, int widget_id);
2327int n_gui_hovered_widget(const N_GUI_CTX* ctx);
2334int n_gui_was_double_click(const N_GUI_CTX* ctx, int widget_id);
2336void n_gui_set_double_click_time(N_GUI_CTX* ctx, double seconds);
2338void n_gui_set_double_click_radius(N_GUI_CTX* ctx, int pixels);
2340void n_gui_set_widget_theme(N_GUI_CTX* ctx, int widget_id, N_GUI_THEME theme);
2344void n_gui_set_widget_visible(N_GUI_CTX* ctx, int widget_id, int visible);
2355int n_gui_widget_is_visible(N_GUI_CTX* ctx, int widget_id);
2359void n_gui_widget_set_rect(N_GUI_CTX* ctx, int widget_id, float x, float y, float w, float h);
2380int n_gui_widget_screen_rect(N_GUI_CTX* ctx, int widget_id, float* x, float* y, float* w, float* h);
2382void n_gui_set_widget_enabled(N_GUI_CTX* ctx, int widget_id, int enabled);
2384int n_gui_is_widget_enabled(N_GUI_CTX* ctx, int widget_id);
2388void n_gui_set_focus(N_GUI_CTX* ctx, int widget_id);
2398int n_gui_get_focus(const N_GUI_CTX* ctx);
2419int n_gui_focus_takes_key(const N_GUI_CTX* ctx, int keycode);
2420
2421/* slider helpers */
2423double n_gui_slider_get_value(N_GUI_CTX* ctx, int widget_id);
2425void n_gui_slider_set_value(N_GUI_CTX* ctx, int widget_id, double value);
2427void n_gui_slider_set_range(N_GUI_CTX* ctx, int widget_id, double min_val, double max_val);
2429void n_gui_slider_set_step(N_GUI_CTX* ctx, int widget_id, double step);
2431void n_gui_slider_set_key_step(N_GUI_CTX* ctx, int widget_id, double step);
2433double n_gui_slider_get_key_step(N_GUI_CTX* ctx, int widget_id);
2450void n_gui_slider_set_default(N_GUI_CTX* ctx, int widget_id, double value);
2456int n_gui_slider_get_default(N_GUI_CTX* ctx, int widget_id, double* value);
2471int n_gui_slider_handle_pos(N_GUI_CTX* ctx, int widget_id, float* pos, float* radius);
2477void n_gui_slider_set_value_format(N_GUI_CTX* ctx, int widget_id, const char* fmt);
2481void n_gui_slider_set_value_visible(N_GUI_CTX* ctx, int widget_id, int visible);
2482
2499float n_gui_slider_value_width(N_GUI_CTX* ctx, int widget_id);
2500
2501/* textarea helpers */
2503const char* n_gui_textarea_get_text(N_GUI_CTX* ctx, int widget_id);
2505void n_gui_textarea_set_text(N_GUI_CTX* ctx, int widget_id, const char* text);
2507void n_gui_textarea_scroll_to_bottom(N_GUI_CTX* ctx, int widget_id);
2509void n_gui_textarea_set_selection(N_GUI_CTX* ctx, int widget_id, size_t start, size_t end);
2511void n_gui_textarea_scroll_to_offset(N_GUI_CTX* ctx, int widget_id, size_t byte_offset);
2513size_t n_gui_textarea_get_text_length(N_GUI_CTX* ctx, int widget_id);
2515int n_gui_textarea_has_selection(N_GUI_CTX* ctx, int widget_id);
2516
2517/* checkbox helpers */
2519int n_gui_checkbox_is_checked(N_GUI_CTX* ctx, int widget_id);
2521void n_gui_checkbox_set_checked(N_GUI_CTX* ctx, int widget_id, int checked);
2531void n_gui_checkbox_set_label(N_GUI_CTX* ctx, int widget_id, const char* label);
2538const char* n_gui_checkbox_get_label(N_GUI_CTX* ctx, int widget_id);
2539
2540/* scrollbar helpers */
2542double n_gui_scrollbar_get_pos(N_GUI_CTX* ctx, int widget_id);
2544void n_gui_scrollbar_set_pos(N_GUI_CTX* ctx, int widget_id, double pos);
2546void n_gui_scrollbar_set_sizes(N_GUI_CTX* ctx, int widget_id, double content_size, double viewport_size);
2551void n_gui_scrollbar_set_wheel_step(N_GUI_CTX* ctx, int widget_id, double step);
2552
2553/* listbox */
2554
2556int 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);
2558int n_gui_listbox_add_item(N_GUI_CTX* ctx, int widget_id, const char* text);
2560int n_gui_listbox_remove_item(N_GUI_CTX* ctx, int widget_id, int index);
2562void n_gui_listbox_clear(N_GUI_CTX* ctx, int widget_id);
2564int n_gui_listbox_get_count(N_GUI_CTX* ctx, int widget_id);
2566const char* n_gui_listbox_get_item_text(N_GUI_CTX* ctx, int widget_id, int index);
2568int n_gui_listbox_get_selected(N_GUI_CTX* ctx, int widget_id);
2570int n_gui_listbox_is_selected(N_GUI_CTX* ctx, int widget_id, int index);
2572void n_gui_listbox_set_selected(N_GUI_CTX* ctx, int widget_id, int index, int selected);
2574int n_gui_listbox_get_scroll_offset(N_GUI_CTX* ctx, int widget_id);
2576void n_gui_listbox_set_scroll_offset(N_GUI_CTX* ctx, int widget_id, int offset);
2581float n_gui_listbox_content_width(N_GUI_CTX* ctx, int widget_id);
2583float n_gui_listbox_get_h_scroll(N_GUI_CTX* ctx, int widget_id);
2586void n_gui_listbox_set_h_scroll(N_GUI_CTX* ctx, int widget_id, float px);
2587
2588/* split pane */
2589
2591int n_gui_add_splitpane(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h, int orientation, float ratio, void (*on_change)(int, float, void*), void* user_data);
2593float n_gui_splitpane_get_ratio(N_GUI_CTX* ctx, int widget_id);
2595void n_gui_splitpane_set_ratio(N_GUI_CTX* ctx, int widget_id, float ratio);
2597void n_gui_splitpane_set_limits(N_GUI_CTX* ctx, int widget_id, float min_ratio, float max_ratio);
2598
2615int n_gui_splitpane_at(N_GUI_CTX* ctx, float x, float y);
2630float n_gui_splitpane_band(N_GUI_CTX* ctx, int widget_id);
2631
2632/* hex view */
2633
2635int n_gui_add_hexview(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h);
2637void n_gui_hexview_set_data(N_GUI_CTX* ctx, int widget_id, const unsigned char* data, size_t len);
2639size_t n_gui_hexview_get_length(N_GUI_CTX* ctx, int widget_id);
2648void n_gui_hexview_set_editable(N_GUI_CTX* ctx, int widget_id, int editable);
2650void n_gui_hexview_set_on_change(N_GUI_CTX* ctx, int widget_id, void (*on_change)(int, const unsigned char*, size_t, void*), void* user_data);
2653const unsigned char* n_gui_hexview_get_data(N_GUI_CTX* ctx, int widget_id, size_t* len);
2655void n_gui_hexview_set_cursor(N_GUI_CTX* ctx, int widget_id, size_t offset);
2657size_t n_gui_hexview_get_cursor(N_GUI_CTX* ctx, int widget_id);
2658
2659/* syntax view */
2660
2662int n_gui_add_syntaxview(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h, int mode);
2664void n_gui_syntaxview_set_text(N_GUI_CTX* ctx, int widget_id, const char* text);
2666void n_gui_syntaxview_set_mode(N_GUI_CTX* ctx, int widget_id, int mode);
2668int n_gui_syntaxview_get_line_count(N_GUI_CTX* ctx, int widget_id);
2670const char* n_gui_syntaxview_get_text(N_GUI_CTX* ctx, int widget_id);
2673char* n_gui_syntaxview_get_selected_text(N_GUI_CTX* ctx, int widget_id);
2676void n_gui_syntaxview_set_selection(N_GUI_CTX* ctx, int widget_id, int start, int end);
2678void n_gui_syntaxview_select_all(N_GUI_CTX* ctx, int widget_id);
2681void n_gui_syntaxview_scroll_to_offset(N_GUI_CTX* ctx, int widget_id, int byte_offset);
2683float n_gui_syntaxview_content_width(N_GUI_CTX* ctx, int widget_id);
2686float n_gui_syntaxview_get_h_scroll(N_GUI_CTX* ctx, int widget_id);
2689void n_gui_syntaxview_set_h_scroll(N_GUI_CTX* ctx, int widget_id, float px);
2690
2691/* data grid */
2692
2694int n_gui_add_datagrid(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h, void (*on_select)(int, int, void*), void* user_data);
2696int n_gui_datagrid_add_column(N_GUI_CTX* ctx, int widget_id, const char* title, float width);
2698int n_gui_datagrid_add_row(N_GUI_CTX* ctx, int widget_id, const char** values);
2700void n_gui_datagrid_clear_rows(N_GUI_CTX* ctx, int widget_id);
2702int n_gui_datagrid_get_row_count(N_GUI_CTX* ctx, int widget_id);
2704const char* n_gui_datagrid_get_cell(N_GUI_CTX* ctx, int widget_id, int row, int col);
2706int n_gui_datagrid_get_selected(N_GUI_CTX* ctx, int widget_id);
2709void n_gui_datagrid_set_selected(N_GUI_CTX* ctx, int widget_id, int row);
2713void n_gui_datagrid_set_on_context(N_GUI_CTX* ctx, int widget_id, void (*on_context)(int, int, int, int, void*));
2715void n_gui_datagrid_sort(N_GUI_CTX* ctx, int widget_id, int col, int dir);
2730int n_gui_datagrid_get_sort(N_GUI_CTX* ctx, int widget_id, int* col, int* dir);
2735void n_gui_datagrid_set_multiselect(N_GUI_CTX* ctx, int widget_id, int enabled);
2737int n_gui_datagrid_is_row_selected(N_GUI_CTX* ctx, int widget_id, int row);
2741size_t n_gui_datagrid_get_selected_rows(N_GUI_CTX* ctx, int widget_id, int* out, size_t max);
2743void n_gui_datagrid_clear_selection(N_GUI_CTX* ctx, int widget_id);
2746void n_gui_datagrid_select_row(N_GUI_CTX* ctx, int widget_id, int row, int selected);
2747
2755void n_gui_datagrid_set_row_color(N_GUI_CTX* ctx, int widget_id, int row, ALLEGRO_COLOR color);
2757void n_gui_datagrid_clear_row_color(N_GUI_CTX* ctx, int widget_id, int row);
2760int n_gui_datagrid_get_row_color(N_GUI_CTX* ctx, int widget_id, int row, ALLEGRO_COLOR* out);
2762void n_gui_datagrid_clear_row_colors(N_GUI_CTX* ctx, int widget_id);
2766int n_gui_datagrid_get_scroll_offset(N_GUI_CTX* ctx, int widget_id);
2771void n_gui_datagrid_set_scroll_offset(N_GUI_CTX* ctx, int widget_id, int offset);
2781float n_gui_datagrid_columns_width(N_GUI_CTX* ctx, int widget_id);
2782
2783float n_gui_datagrid_get_h_scroll(N_GUI_CTX* ctx, int widget_id);
2787void n_gui_datagrid_set_h_scroll(N_GUI_CTX* ctx, int widget_id, float px);
2788
2790size_t n_gui_datagrid_get_column_count(N_GUI_CTX* ctx, int widget_id);
2792const char* n_gui_datagrid_get_column_title(N_GUI_CTX* ctx, int widget_id, int col);
2795void n_gui_datagrid_set_column_visible(N_GUI_CTX* ctx, int widget_id, int col, int visible);
2797int n_gui_datagrid_get_column_visible(N_GUI_CTX* ctx, int widget_id, int col);
2799void n_gui_datagrid_set_column_width(N_GUI_CTX* ctx, int widget_id, int col, float width);
2801float n_gui_datagrid_get_column_width(N_GUI_CTX* ctx, int widget_id, int col);
2803int n_gui_datagrid_display_to_physical(N_GUI_CTX* ctx, int widget_id, int display_pos);
2807void n_gui_datagrid_move_column(N_GUI_CTX* ctx, int widget_id, int from, int to);
2810void n_gui_datagrid_set_on_columns_changed(N_GUI_CTX* ctx, int widget_id, void (*cb)(int, void*));
2811
2812/* progress bar */
2813
2815int n_gui_add_progressbar(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h);
2817void n_gui_progressbar_set_value(N_GUI_CTX* ctx, int widget_id, float value);
2819float n_gui_progressbar_get_value(N_GUI_CTX* ctx, int widget_id);
2821void n_gui_progressbar_set_text(N_GUI_CTX* ctx, int widget_id, const char* text);
2822
2823/* custom (owner-draw) widget */
2824
2844int n_gui_add_custom(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h, N_GUI_CUSTOM_DRAW draw, void* user_data);
2845
2862void n_gui_custom_set_mouse(N_GUI_CTX* ctx, int widget_id, N_GUI_CUSTOM_MOUSE on_mouse, void* user_data);
2863
2883int n_gui_get_key_modifiers(const N_GUI_CTX* ctx);
2884
2898void n_gui_custom_set_destroy(N_GUI_CTX* ctx, int widget_id, void (*destroy)(void* user_data));
2899
2900/* markdownview */
2901
2913int n_gui_add_markdownview(N_GUI_CTX* ctx, int window_id, float x, float y, float w, float h, const N_GUI_MD_FONTS* fonts);
2915void n_gui_markdownview_set_text(N_GUI_CTX* ctx, int widget_id, const char* text);
2917const char* n_gui_markdownview_get_text(N_GUI_CTX* ctx, int widget_id);
2919void n_gui_markdownview_set_fonts(N_GUI_CTX* ctx, int widget_id, const N_GUI_MD_FONTS* fonts);
2925void n_gui_markdownview_scroll_to(N_GUI_CTX* ctx, int widget_id, float y);
2927float n_gui_markdownview_get_scroll(N_GUI_CTX* ctx, int widget_id);
2930float n_gui_markdownview_content_height(N_GUI_CTX* ctx, int widget_id);
2933void n_gui_markdownview_set_on_link(N_GUI_CTX* ctx, int widget_id, void (*on_link)(int widget_id, const char* url, void* user_data), void* user_data);
2934
2935/* radiolist */
2936
2938int 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);
2940int n_gui_radiolist_add_item(N_GUI_CTX* ctx, int widget_id, const char* text);
2942void n_gui_radiolist_clear(N_GUI_CTX* ctx, int widget_id);
2944int n_gui_radiolist_get_selected(N_GUI_CTX* ctx, int widget_id);
2946void n_gui_radiolist_set_selected(N_GUI_CTX* ctx, int widget_id, int index);
2947
2948/* combobox */
2949
2951int 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);
2953int n_gui_combobox_add_item(N_GUI_CTX* ctx, int widget_id, const char* text);
2955void n_gui_combobox_clear(N_GUI_CTX* ctx, int widget_id);
2957int n_gui_combobox_get_selected(N_GUI_CTX* ctx, int widget_id);
2959const char* n_gui_combobox_get_item_text(N_GUI_CTX* ctx, int widget_id, int index);
2963int n_gui_combobox_get_count(N_GUI_CTX* ctx, int widget_id);
2968int n_gui_combobox_remove_item(N_GUI_CTX* ctx, int widget_id, int index);
2970void n_gui_combobox_set_selected(N_GUI_CTX* ctx, int widget_id, int index);
2971
2973void n_gui_combobox_set_flags(N_GUI_CTX* ctx, int widget_id, int flags);
2974
2975/* image */
2976
2978int 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);
2980void n_gui_image_set_bitmap(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bitmap);
2981
2982/* label (static text, optional hyperlink) */
2983
2985int n_gui_add_label(N_GUI_CTX* ctx, int window_id, const char* text, float x, float y, float w, float h, int align);
2987int 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);
2989void n_gui_label_set_text(N_GUI_CTX* ctx, int widget_id, const char* text);
3000const char* n_gui_label_get_text(N_GUI_CTX* ctx, int widget_id);
3002void n_gui_label_set_link(N_GUI_CTX* ctx, int widget_id, const char* link);
3007void n_gui_label_set_truncate(N_GUI_CTX* ctx, int widget_id, int mode);
3009int n_gui_label_get_truncate(N_GUI_CTX* ctx, int widget_id);
3012int n_gui_label_fits(N_GUI_CTX* ctx, int widget_id, float* needed_w, float* needed_h);
3013
3014/* dropdown menu */
3015
3027int 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);
3029int 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);
3031int 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);
3033void n_gui_dropmenu_clear_dynamic(N_GUI_CTX* ctx, int widget_id);
3035void n_gui_dropmenu_clear(N_GUI_CTX* ctx, int widget_id);
3037void n_gui_dropmenu_set_entry_text(N_GUI_CTX* ctx, int widget_id, int index, const char* text);
3039int n_gui_dropmenu_get_count(N_GUI_CTX* ctx, int widget_id);
3058int n_gui_dropmenu_set_open(N_GUI_CTX* ctx, int widget_id, int open);
3060int n_gui_dropmenu_is_open(N_GUI_CTX* ctx, int widget_id);
3065float n_gui_dropmenu_panel_width(N_GUI_CTX* ctx, int widget_id);
3067void n_gui_dropmenu_set_flags(N_GUI_CTX* ctx, int widget_id, int flags);
3069void n_gui_dropmenu_set_label(N_GUI_CTX* ctx, int widget_id, const char* label);
3070
3071/* bitmap skinning */
3072
3082void n_gui_window_set_bitmaps(N_GUI_CTX* ctx, int window_id, ALLEGRO_BITMAP* bg, ALLEGRO_BITMAP* titlebar, int bg_scale_mode);
3083
3088void 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);
3089
3094void 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);
3095
3100void n_gui_checkbox_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* box, ALLEGRO_BITMAP* box_checked, ALLEGRO_BITMAP* box_hover);
3101
3105void n_gui_textarea_set_bitmap(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg);
3106
3111void n_gui_textarea_set_mask_char(N_GUI_CTX* ctx, int widget_id, char mask);
3112
3119void n_gui_textarea_set_placeholder(N_GUI_CTX* ctx, int widget_id, const char* text);
3120
3144void n_gui_textarea_set_suggest(N_GUI_CTX* ctx, int widget_id, N_GUI_SUGGEST_FN fn, const char* separators, void* user_data);
3145
3150int n_gui_textarea_suggest_is_open(N_GUI_CTX* ctx, int widget_id);
3151
3159void n_gui_textarea_suggest_close(N_GUI_CTX* ctx, int widget_id);
3160
3165void n_gui_listbox_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg, ALLEGRO_BITMAP* item_bg, ALLEGRO_BITMAP* item_selected);
3166
3171void n_gui_radiolist_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg, ALLEGRO_BITMAP* item_bg, ALLEGRO_BITMAP* item_selected);
3172
3177void n_gui_combobox_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg, ALLEGRO_BITMAP* item_bg, ALLEGRO_BITMAP* item_selected);
3178
3183void n_gui_dropmenu_set_bitmaps(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* panel, ALLEGRO_BITMAP* item_hover);
3184
3188void n_gui_label_set_bitmap(N_GUI_CTX* ctx, int widget_id, ALLEGRO_BITMAP* bg);
3189
3190/* JSON theme I/O */
3191
3194int n_gui_save_theme_json(N_GUI_CTX* ctx, const char* filepath);
3195
3198int n_gui_load_theme_json(N_GUI_CTX* ctx, const char* filepath);
3199
3200/* JSON window layout I/O */
3201
3211int n_gui_save_layout_json(N_GUI_CTX* ctx, const char* filepath);
3212
3223int n_gui_load_layout_json(N_GUI_CTX* ctx, const char* filepath);
3224
3232void n_gui_widget_set_persist_key(N_GUI_CTX* ctx, int widget_id, const char* key);
3233
3235const char* n_gui_widget_get_persist_key(N_GUI_CTX* ctx, int widget_id);
3236
3237/* virtual canvas / display / DPI */
3238
3245void n_gui_set_virtual_size(N_GUI_CTX* ctx, float w, float h);
3246
3251
3259void n_gui_screen_to_virtual(const N_GUI_CTX* ctx, float sx, float sy, float* vx, float* vy);
3260
3267void n_gui_set_display_size(N_GUI_CTX* ctx, float w, float h);
3269void n_gui_set_display(N_GUI_CTX* ctx, ALLEGRO_DISPLAY* display);
3270
3272void n_gui_set_shape_mode(N_GUI_CTX* ctx, int shape_mode);
3273
3276
3279void n_gui_set_dpi_scale(N_GUI_CTX* ctx, float scale);
3280
3282float n_gui_get_dpi_scale(const N_GUI_CTX* ctx);
3283
3287float n_gui_detect_dpi_scale(N_GUI_CTX* ctx, ALLEGRO_DISPLAY* display);
3288
3289/* event processing & drawing */
3290
3292int n_gui_process_event(N_GUI_CTX* ctx, ALLEGRO_EVENT event);
3294void n_gui_draw(N_GUI_CTX* ctx);
3298
3303void n_gui_mark_dirty(N_GUI_CTX* ctx);
3304
3319
3321#define N_GUI_TAB_MAX 16
3322
3338
3340N_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);
3342int n_gui_tab_add(N_GUI_TAB_PANEL* panel, const char* label);
3344void n_gui_tab_set_content_window(N_GUI_TAB_PANEL* panel, int tab_index, int window_id);
3346void n_gui_tab_set_active(N_GUI_TAB_PANEL* panel, int index);
3348int n_gui_tab_get_active(const N_GUI_TAB_PANEL* panel);
3352void n_gui_tab_relayout(N_GUI_TAB_PANEL* panel, float x, float y, float button_w, float button_h);
3354void n_gui_tab_free(N_GUI_TAB_PANEL** panel);
3355
3357#define N_GUI_SECTIONLIST_MAX 16
3358
3363#define N_GUI_SECTION_WIDGETS_MAX 96
3364
3376
3396
3398N_GUI_SECTIONLIST* n_gui_sectionlist_create(N_GUI_CTX* ctx, int window_id, float x, float y0, float width, float header_h, float gap, void (*on_toggle)(int, int, void*), void* user_data);
3400int n_gui_sectionlist_add_section(N_GUI_SECTIONLIST* sl, const char* title, float header_y, int folded);
3404int n_gui_sectionlist_add_widget(N_GUI_SECTIONLIST* sl, int section_index, int widget_id);
3410void n_gui_sectionlist_set_widget_offset(N_GUI_SECTIONLIST* sl, int section_index, int widget_id, float dy);
3415void n_gui_sectionlist_set_widget_hidden(N_GUI_SECTIONLIST* sl, int section_index, int widget_id, int hidden);
3420void n_gui_sectionlist_set_geometry(N_GUI_SECTIONLIST* sl, float x, float y0, float width, float header_h, float gap);
3426void n_gui_sectionlist_set_folded(N_GUI_SECTIONLIST* sl, int section_index, int folded);
3428int n_gui_sectionlist_is_folded(const N_GUI_SECTIONLIST* sl, int section_index);
3445void n_gui_sectionlist_set_order(N_GUI_SECTIONLIST* sl, const int* order, int count);
3450int n_gui_sectionlist_get_order(const N_GUI_SECTIONLIST* sl, int position);
3456void n_gui_sectionlist_set_section_hidden(N_GUI_SECTIONLIST* sl, int section_index, int hidden);
3461int n_gui_sectionlist_is_section_hidden(const N_GUI_SECTIONLIST* sl, int section_index);
3464
3466#define N_GUI_TREE_MAX 2048
3467
3480
3482#define N_GUI_DROP_BEFORE 0
3483#define N_GUI_DROP_INTO 1
3484#define N_GUI_DROP_AFTER 2
3485
3492typedef int (*n_gui_tree_on_drop_t)(int src_node, int dst_node, int position, void* user_data);
3493
3520
3522#define N_GUI_TREE_STATE_MAX 512
3524#define N_GUI_TREE_PATH_MAX 1024
3527#define N_GUI_TREE_PATH_SEP '\x1f'
3528
3539
3541N_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);
3543int n_gui_tree_add_node(N_GUI_TREE* tree, const char* label, int parent_index, void* user_data);
3545void n_gui_tree_clear(N_GUI_TREE* tree);
3549void n_gui_tree_remove_node(N_GUI_TREE* tree, int node_index);
3551void n_gui_tree_set_label(N_GUI_TREE* tree, int node_index, const char* new_label);
3558void n_gui_tree_set_selection(N_GUI_TREE* tree, int node_index);
3563int n_gui_tree_find_by_user_data(const N_GUI_TREE* tree, const void* ptr);
3566void n_gui_tree_toggle_expand(N_GUI_TREE* tree, int node_index);
3570void n_gui_tree_expand(N_GUI_TREE* tree, int node_index);
3577void n_gui_tree_set_expand_callback(N_GUI_TREE* tree, void (*on_expand)(int node_index, void* user_data), void* user_data);
3580void n_gui_tree_set_expandable(N_GUI_TREE* tree, int node_index, int expandable);
3582void n_gui_tree_rebuild(N_GUI_TREE* tree);
3584void n_gui_tree_free(N_GUI_TREE** tree);
3585
3589int n_gui_tree_node_path(const N_GUI_TREE* tree, int node_index, char* buf, size_t bufsz);
3592int n_gui_tree_find_by_path(const N_GUI_TREE* tree, const char* path);
3603void n_gui_tree_state_apply(N_GUI_TREE* tree, const N_GUI_TREE_STATE* state);
3606
3610 n_gui_tree_on_drop_t on_drop,
3611 void* user_data);
3612
3616void n_gui_tree_tick(N_GUI_TREE* tree);
3617
3622
3624#define N_GUI_KV_MAX 128
3625
3638
3673
3675N_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);
3678 const char* key,
3679 const char* value,
3680 const char* description,
3681 int enabled);
3683void n_gui_kvtable_remove_row(N_GUI_KVTABLE* table, int row_index);
3694void n_gui_kvtable_set_columns(N_GUI_KVTABLE* table, int show_value, int show_desc, int show_enabled);
3701void n_gui_kvtable_set_row_actions(N_GUI_KVTABLE* table, int enabled);
3706int n_gui_kvtable_move_row(N_GUI_KVTABLE* table, int row_index, int direction);
3710int n_gui_kvtable_duplicate_row(N_GUI_KVTABLE* table, int row_index);
3714void n_gui_kvtable_set_placeholders(N_GUI_KVTABLE* table, const char* key_hint, const char* value_hint);
3718void n_gui_kvtable_set_top_offset(N_GUI_KVTABLE* table, float top_offset);
3720int n_gui_kvtable_get_count(const N_GUI_KVTABLE* table);
3726void n_gui_kvtable_free(N_GUI_KVTABLE** table);
3727
3731
3732#ifdef __cplusplus
3733}
3734#endif
3735
3736#endif /* __NILOREA_GUI__ */
ALLEGRO_DISPLAY * display
Definition ex_fluid.c:54
void on_link_click(int widget_id, const char *link, void *user_data)
Definition ex_gui.c:192
void on_scroll(int widget_id, double pos, void *user_data)
Definition ex_gui.c:133
static void on_click(int widget_id, void *user_data)
a button's click: counted
static void on_toggle(int widget_id, int checked, void *user_data)
the checkbox callback
static void on_change(const float rgba[4], void *user_data)
the picker's callback
static int on_mouse(int widget_id, const N_GUI_MOUSE_EVENT *ev, void *user_data)
the widget's mouse callback
static void on_select(int widget_id, int row, void *user_data)
Record a row selection, to prove the keyboard path fires the same callback a click does.
static void draw(N_GUI_CTX *gui)
draw the whole context into a memory bitmap
static void visible(int widget_id, size_t first, size_t last, void *user_data)
the range to prepare
Definition ex_gui_grid.c:86
static int mode
static void on_expand(int node, void *user_data)
the expand callback: a "folder" gets two subfolders, both themselves openable, except the one that st...
static const char * row(N_GUI_TREE *tree, int index)
the text of a visible row, "" past the end
an in-memory sink for n_http_response_write()
static int h(void *ctx, const N_ROUTE_MATCH *m)
a handler that does nothing (the test only routes)
static N_HTTP_RESP * text(int status, const char *body)
text response
static N_HTTP_SERVER * start(N_HTTP_SERVER_CONFIG *cfg, char *port, int base)
start a server on the first free port from base
volatile char key[227]
TRUE while the key is held.
FONT * font
the default 8x8 font, valid after allegro_init()
char title[128]
column header title
Definition n_gui.h:847
int expandable
1 if the node can be opened before it has children: its children are added by the expand callback
Definition n_gui.h:3476
char title[128]
window title.
Definition n_gui.h:1303
ALLEGRO_BITMAP * thumb_bitmap
optional bitmap for the thumb/handle, normal state (NULL = color theme)
Definition n_gui.h:712
float h
height
Definition n_gui.h:1104
float scroll_y
vertical scroll offset for overflowing text (pixels)
Definition n_gui.h:1009
float scroll_y
vertical scroll offset for auto-scrollbar (pixels)
Definition n_gui.h:1340
int visible
visibility flag
Definition n_gui.h:1114
float cached_content_w
cached pixel width of the widest line, valid when width_valid
Definition n_gui.h:838
ALLEGRO_BITMAP * panel_bitmap
optional bitmap for the dropdown panel background (NULL = color theme)
Definition n_gui.h:1076
int saved_flags
embedded feature flags saved by n_gui_window_detach (a detached window is forced frameless because th...
Definition n_gui.h:1412
char * text
owned copy of the text, or NULL
Definition n_gui.h:807
size_t * col_order
display order: display_pos -> physical column index (sized cols_cap), or NULL when the display order ...
Definition n_gui.h:864
ALLEGRO_BITMAP * handle_hover_bitmap
optional bitmap for the handle on hover (NULL = fallback to handle_bitmap)
Definition n_gui.h:551
int window_id
owning window for coord math
Definition n_gui.h:3498
float button_h
height of each tab button
Definition n_gui.h:3334
int is_open
is dropdown currently open
Definition n_gui.h:962
int show_actions
1 to show the per-row move-up / move-down / duplicate buttons (default 0)
Definition n_gui.h:3664
int content_window_ids[16]
content window IDs (-1 = none)
Definition n_gui.h:3328
int cursor_want_shape
the cursor the application asked for with n_gui_set_cursor(), shown wherever the GUI has no cursor of...
Definition n_gui.h:1704
int w
bounding box width in pixels
Definition n_gui.h:377
int native_drag_wx
native window x at the drag grab, the move is native_drag_wx plus the desktop cursor travel since the...
Definition n_gui.h:1433
float gap
vertical gap between rows
Definition n_gui.h:3387
int wheel_scrollbar
the scrollbar the wheel moves anywhere over the window when no widget under the pointer takes it,...
Definition n_gui.h:1310
int open_combobox_id
id of the combobox whose dropdown is currently open, or -1
Definition n_gui.h:1735
ALLEGRO_COLOR scrollbar_track_color
scrollbar track colour
Definition n_gui.h:1487
int folded
1 = collapsed (members hidden), 0 = expanded
Definition n_gui.h:3373
int max_visible
max visible items in dropdown
Definition n_gui.h:973
int selected_index
currently selected index (-1 = none)
Definition n_gui.h:960
void(* on_remove)(int, void *)
callback on row removal
Definition n_gui.h:3659
ALLEGRO_BITMAP * minimize_active_bitmap
optional bitmap for minimize button active state
Definition n_gui.h:1268
int sort_col
column index used for sorting, or -1
Definition n_gui.h:882
int scroll_offset
first visible row
Definition n_gui.h:791
size_t items_capacity
allocated capacity
Definition n_gui.h:730
ALLEGRO_COLOR grip_color
grip line colour
Definition n_gui.h:1515
float dropdown_border_thickness
dropdown panel border thickness
Definition n_gui.h:1602
char * text
text content (dynamically allocated, text_alloc bytes)
Definition n_gui.h:618
int nb_rows
total rows (including removed)
Definition n_gui.h:3647
float slider_handle_edge_offset
handle circle offset from edge
Definition n_gui.h:1527
int bytes_per_row
bytes shown per row
Definition n_gui.h:789
int selected_row
selected data row (the primary / last-clicked row), or -1
Definition n_gui.h:886
int parent_index
parent node index, or -1 for root
Definition n_gui.h:3471
int shape
shape type: N_GUI_SHAPE_RECT or N_GUI_SHAPE_ROUNDED
Definition n_gui.h:708
float x
saved x (already display-scaled)
Definition n_gui.h:1641
float content_h
total content height computed from widgets (internal)
Definition n_gui.h:1344
float global_scrollbar_thumb_padding
global thumb inset from track edge
Definition n_gui.h:1497
char label[128]
menu label (shown on the button)
Definition n_gui.h:1055
size_t items_capacity
allocated capacity
Definition n_gui.h:958
N_GUI_TREE_NODE nodes[2048]
node storage
Definition n_gui.h:3499
float y
pointer y from the widget's top edge; outside 0..h during a DRAG
Definition n_gui.h:1208
float x
position x on screen
Definition n_gui.h:1312
float scrollbar_size
scrollbar track width/height
Definition n_gui.h:1479
float norm_y
normalized position y (0.0-1.0 fraction of reference display height)
Definition n_gui.h:1370
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:937
float scrollbar_thumb_corner_r
thumb corner radius
Definition n_gui.h:1485
void(* on_change)(int widget_id, float ratio, void *user_data)
callback fired while the divider is dragged (widget_id, ratio, user_data)
Definition n_gui.h:775
int nb_widgets
number of member widgets
Definition n_gui.h:3372
int is_dynamic
is this entry dynamic (rebuilt via callback each time menu opens)
Definition n_gui.h:1037
float title_padding
padding left of title text
Definition n_gui.h:1463
float min_win_h
minimum window height (for resize)
Definition n_gui.h:1461
float dropdown_arrow_half_w
horizontal half-extent of the arrow chevron
Definition n_gui.h:1600
int nibble
which half of the cursor byte a typed hex digit lands in: 0 high, 1 low
Definition n_gui.h:797
int toggled
toggle state: 0 = off/unclicked, 1 = on/clicked (only used when toggle_mode=1)
Definition n_gui.h:499
char ** cells
row-major cell strings (nb_rows * nb_cols owned char*)
Definition n_gui.h:876
int lbl_enabled
label widget ID for "On" header
Definition n_gui.h:3657
ALLEGRO_BITMAP * item_bg_bitmap
optional bitmap for per-item background, normal state (NULL = color theme)
Definition n_gui.h:749
int scroll_offset
scroll offset in items
Definition n_gui.h:927
float ref_display_h
reference display height at the time normalized values were last captured
Definition n_gui.h:1792
float slider_track_corner_r
track corner radius
Definition n_gui.h:1521
int y
bounding box y offset from draw origin
Definition n_gui.h:376
float titlebar_h
title bar height
Definition n_gui.h:1320
int frac_cols
visible text column count col_frac was computed for; when it changes the fractions reset to equal wid...
Definition n_gui.h:3669
ALLEGRO_BITMAP * handle_active_bitmap
optional bitmap for the handle while dragging (NULL = fallback to handle_bitmap)
Definition n_gui.h:553
void(* on_tab_change)(int, void *)
callback on tab switch (may be NULL)
Definition n_gui.h:3335
int display_size_warned
non-zero once the fallback above has logged that it is in use
Definition n_gui.h:1754
int selected_syntaxview_id
id of the syntax-view widget with the most recent text selection, or -1
Definition n_gui.h:1786
int filled
1 once the expand callback has run for this node
Definition n_gui.h:3478
float top_offset
unscaled y offset of the header row from the window top (default 0), to reserve space above the table...
Definition n_gui.h:3667
float norm_y
normalized position y (fraction of parent window h, used for SCALE resize)
Definition n_gui.h:1134
int dropmenu_max_visible
default max visible items for dropmenu panel
Definition n_gui.h:1584
float norm_x
normalized position x (0.0-1.0 fraction of reference display width)
Definition n_gui.h:1368
float textarea_padding
Definition n_gui.h:1548
int sel_start
selection start byte offset into text, or -1 when nothing is selected
Definition n_gui.h:821
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the label background (NULL = no background)
Definition n_gui.h:1017
float item_height
item height
Definition n_gui.h:1074
N_GUI_THEME theme
color theme for this widget
Definition n_gui.h:1118
float title_max_w_reserve
pixels reserved right of title for truncation
Definition n_gui.h:1465
int multiselect
1 = multi-row selection enabled (Ctrl/Shift-click), 0 = single-select
Definition n_gui.h:888
double anim_until
deadline (al_get_time seconds) until which a transient animation is in progress (button key-press fla...
Definition n_gui.h:1834
int double_click_radius
how far the pointer may move between the two presses and still count, in pixels.
Definition n_gui.h:1725
size_t rows_cap
allocated row capacity (in rows)
Definition n_gui.h:880
int want_native
1 when the window should live in a native OS window: set by n_gui_window_detach and by a loaded layou...
Definition n_gui.h:1395
char text[128]
item display text
Definition n_gui.h:578
int nb_tabs
number of tabs
Definition n_gui.h:3329
int key_sources[8]
widget IDs that can trigger this focused key binding.
Definition n_gui.h:514
float checkbox_label_gap
gap between box and label text
Definition n_gui.h:1562
int open_dropmenu_id
id of the dropdown menu whose panel is currently open, or -1
Definition n_gui.h:1739
float global_scrollbar_thumb_corner_r
global thumb corner radius
Definition n_gui.h:1499
N_GUI_THEME default_theme
default theme (applied to new widgets/windows)
Definition n_gui.h:1683
int flags
bitmask of N_GUI_DROPMENU_* flags
Definition n_gui.h:1086
float saved_y
embedded y saved by n_gui_window_detach, restored by n_gui_window_attach
Definition n_gui.h:1405
int hovered
non-zero while the pointer is inside the rectangle above, and while a drag that began inside it is st...
Definition n_gui.h:474
float dpi_scale
DPI scale factor (1.0 = normal, 1.25 = 125%, 2.0 = HiDPI, etc.).
Definition n_gui.h:1764
void * user_data
user data for callback
Definition n_gui.h:1021
int scroll_from_wheel
set to 1 when scroll was changed by mouse wheel, cleared on key input
Definition n_gui.h:639
float tooltip_max_w
widest a tooltip bubble's text may get before it word-wraps, in pixels (0 = wrap only at the display ...
Definition n_gui.h:1547
ALLEGRO_COLOR tooltip_fg
tooltip text color
Definition n_gui.h:1542
int btn_add
button widget ID for "+" add row
Definition n_gui.h:3658
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the window body background (NULL = color fill)
Definition n_gui.h:1352
float scrollbar_thumb_padding
thumb inset from track edge
Definition n_gui.h:1483
float w
width
Definition n_gui.h:1102
ALLEGRO_COLOR text_normal
text normal
Definition n_gui.h:398
int remove_id
button widget ID for the remove action
Definition n_gui.h:3632
int pressed
which button is currently pressed (N_GUI_TB_BTN_*)
Definition n_gui.h:1250
void * on_maximize_user_data
user data for on_maximize callback
Definition n_gui.h:1288
int order[16]
display order: order[k] is the index of the section stacked k-th; indices themselves never change
Definition n_gui.h:3391
int drop_position
N_GUI_DROP_BEFORE / INTO / AFTER.
Definition n_gui.h:3514
float w
window width
Definition n_gui.h:1316
int open_suggest_id
id of the textarea whose completion panel is currently open, or -1.
Definition n_gui.h:1743
int combobox_max_visible
default max visible items for combobox dropdown
Definition n_gui.h:1582
ALLEGRO_BITMAP * item_bg_bitmap
optional bitmap for per-item background, normal state (NULL = color theme)
Definition n_gui.h:977
float norm_h
normalized height (fraction of parent window h)
Definition n_gui.h:1138
void * user_data
user data for callback
Definition n_gui.h:3504
int sel_dragging
1 while a mouse drag is extending the selection, 0 otherwise
Definition n_gui.h:825
float scroll_y
how far down the content the view is, in pixels
Definition n_gui.h:1157
void(* on_open)(int widget_id, void *user_data)
callback to rebuild dynamic entries each time the menu is opened.
Definition n_gui.h:1082
size_t cursor
byte the cursor sits on (<= len)
Definition n_gui.h:795
size_t cols_cap
allocated column capacity
Definition n_gui.h:861
int mouse_b1_prev
previous mouse button 1 state
Definition n_gui.h:1693
int listbox_id
listbox widget ID
Definition n_gui.h:3497
float corner_rx
corner radius for rounded shapes
Definition n_gui.h:406
ALLEGRO_COLOR selection_color
text selection highlight colour (semi-transparent recommended)
Definition n_gui.h:410
int drag_hover_node
current hover node, or -1
Definition n_gui.h:3513
ALLEGRO_BITMAP * bitmap
optional bitmap for the button (NULL = color theme)
Definition n_gui.h:484
int click_y
pointer y at that press
Definition n_gui.h:1715
int flags
bitmask of N_GUI_COMBOBOX_* flags
Definition n_gui.h:985
ALLEGRO_MOUSE_CURSOR * cursor_custom
the custom cursor currently applied to the display, or NULL when a system cursor is (cursor_shape the...
Definition n_gui.h:1700
float gui_offset_x
horizontal letterbox offset for virtual canvas
Definition n_gui.h:1772
int h_scroll_dragging
1 while the user is dragging the horizontal scrollbar thumb (so the shared scrollbar-drag handler rou...
Definition n_gui.h:905
int pending_layout_count
number of valid entries in pending_layout
Definition n_gui.h:1804
int state
saved minimised/maximised bits, applied on create
Definition n_gui.h:1645
float tooltip_delay
inner padding
Definition n_gui.h:1536
int key_focus_only
if 1, keycode fires only when the button itself or a source widget has focus.
Definition n_gui.h:511
int value_visible
draw the built-in value label next to/below the handle.
Definition n_gui.h:567
int ncols
column count (kind == DATAGRID)
Definition n_gui.h:1661
N_GUI_KV_ROW rows[128]
row storage
Definition n_gui.h:3646
char * tooltip
owned tooltip text shown after the pointer rests on the widget (NULL = none); heap-allocated with no ...
Definition n_gui.h:1125
int type
widget type (N_GUI_TYPE_*)
Definition n_gui.h:1096
int state
current state flags (N_GUI_STATE_*)
Definition n_gui.h:1106
float scroll_step
pixels per mouse wheel notch for window auto-scroll
Definition n_gui.h:1626
int widget_hidden[96]
1 = the caller keeps this member hidden whatever the fold state, and it does not count towards natura...
Definition n_gui.h:3371
int h_scroll_dragging
1 while the user is dragging the horizontal scrollbar thumb, so the shared scrollbar-drag handler rou...
Definition n_gui.h:743
int multiline
0 = single line, 1 = multiline
Definition n_gui.h:626
int lines_valid
0 when cached_nb_lines / cached_headers_end are stale (rebuild on next use).
Definition n_gui.h:829
int key_id
textarea widget ID for the key
Definition n_gui.h:3628
N_GUI_LISTITEM * suggest_items
what the provider last answered, allocated on the first ask
Definition n_gui.h:662
ALLEGRO_BITMAP * bitmap_hover
optional bitmap for hover state
Definition n_gui.h:486
char suggest_separators[8]
characters that end a word, so a field holding a list completes the one the cursor is in rather than ...
Definition n_gui.h:660
int kind
N_GUI_TYPE_SPLITPANE or N_GUI_TYPE_DATAGRID.
Definition n_gui.h:1659
int button_ids[16]
toggle button widget IDs
Definition n_gui.h:3327
int max_visible
max visible items
Definition n_gui.h:1072
int suggest_scroll
first item the panel shows
Definition n_gui.h:668
float widget_dy[96]
each member's y offset from the section content top, captured at add time and settable with n_gui_sec...
Definition n_gui.h:3370
float gui_bounds_w
total bounding box width of all windows (computed internally)
Definition n_gui.h:1760
double key_press_until
absolute al_get_time() deadline until which the button is rendered in its pressed (N_GUI_STATE_ACTIVE...
Definition n_gui.h:518
float x
position x relative to parent window
Definition n_gui.h:1098
float drag_press_x
mouse x at press time
Definition n_gui.h:3516
float global_scrollbar_size
global scrollbar track width/height
Definition n_gui.h:1493
int highlight_index
open-panel navigation cursor for the wheel and Up/Down keys (-1 = none).
Definition n_gui.h:1070
void(* on_toggle)(int, int, void *)
callback(section_index, folded, user_data) on a header click (may be NULL)
Definition n_gui.h:3393
float textarea_cursor_width
cursor width in pixels
Definition n_gui.h:1550
char text[4096]
text to display
Definition n_gui.h:999
N_GUI_MD_STYLE style
colours and metrics, the caller's to change through n_gui_markdownview_style()
Definition n_gui.h:1155
void * user_data
user data for callback
Definition n_gui.h:3336
int held_modifier_keys
the modifier keys held down, one bit per key (left and right apart, so letting go of one Ctrl while t...
Definition n_gui.h:1842
char title[128]
owning window title to match on
Definition n_gui.h:1657
float tb_btn_size
titlebar button size (0 = auto: titlebar_h - 4)
Definition n_gui.h:1469
float norm_h
normalized height (fraction of reference display height, used in SCALE mode)
Definition n_gui.h:1374
char value_format[32]
printf-style format string applied to the numeric value when the built-in readout draws.
Definition n_gui.h:562
float min_win_w
minimum window width (for resize)
Definition n_gui.h:1459
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the combobox background (NULL = color theme)
Definition n_gui.h:975
ALLEGRO_BITMAP * maximize_bitmap
optional bitmap for maximize button normal state (NULL = color theme)
Definition n_gui.h:1270
void(* on_change)(int widget_id, double value, void *user_data)
callback on value change
Definition n_gui.h:555
float item_height
item height in pixels
Definition n_gui.h:929
int native_drag_wy
native window y at the drag grab (see native_drag_wx)
Definition n_gui.h:1435
float drag_ox
drag offset x (internal)
Definition n_gui.h:1332
void * user_data
user data for on_link
Definition n_gui.h:1172
int dup_id
button widget ID for the duplicate action (row actions only)
Definition n_gui.h:3635
int scroll_offset
first visible row
Definition n_gui.h:3536
void(* on_click)(int widget_id, void *user_data)
callback on click (widget_id passed)
Definition n_gui.h:520
float row_height
unscaled row height in pixels
Definition n_gui.h:3649
int expanded
1 if expanded
Definition n_gui.h:3472
N_GUI_LISTITEM * items
dynamic array of items
Definition n_gui.h:954
char label[128]
display text
Definition n_gui.h:3470
int mode
highlighting mode: N_GUI_SYNTAX_*
Definition n_gui.h:811
int drag_armed_node
pressed-but-not-yet-dragging
Definition n_gui.h:3512
ALLEGRO_BITMAP * close_hover_bitmap
optional bitmap for close button hover state
Definition n_gui.h:1278
int show_enabled
1 to show the enabled-checkbox column (default 1)
Definition n_gui.h:3663
N_GUI_THEME theme
color theme for this window chrome
Definition n_gui.h:1328
int display_size_set
non-zero once n_gui_set_display_size() has been called.
Definition n_gui.h:1752
int sel_end
selection end byte offset (tracks the cursor while a drag is in progress)
Definition n_gui.h:823
int id
unique widget id
Definition n_gui.h:1094
int native_close_pending
1 when the native window must be released at the next safe point (an ALLEGRO_EVENT_DISPLAY_CLOSE arri...
Definition n_gui.h:1401
int sort_dir
sort direction: 1 ascending, -1 descending
Definition n_gui.h:884
float saved_w
embedded width saved by n_gui_window_detach, restored by n_gui_window_attach
Definition n_gui.h:1407
char title[64]
section title (header label minus the fold glyph)
Definition n_gui.h:3367
int desc_id
textarea widget ID for the description
Definition n_gui.h:3630
float width
column width in pixels
Definition n_gui.h:849
int next_window_id
next window id to assign
Definition n_gui.h:1677
float item_selection_inset
item highlight inset from left/right edges
Definition n_gui.h:1588
int header_id
clickable header button widget id
Definition n_gui.h:3368
float saved_h
embedded height saved by n_gui_window_detach, restored by n_gui_window_attach
Definition n_gui.h:1409
ALLEGRO_COLOR border_normal
border normal
Definition n_gui.h:392
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:1041
float h_scroll
horizontal scroll offset in pixels: how far the item text is scrolled to the left when the widest ite...
Definition n_gui.h:739
N_GUI_SECTION sections[16]
section storage
Definition n_gui.h:3388
void(* on_content_draw)(int window_id, void *user_data)
optional callback invoked during n_gui_draw immediately after this window's own content is drawn,...
Definition n_gui.h:1381
float init_win_w
parent window width at create time
Definition n_gui.h:3652
int has_children
1 if node has children
Definition n_gui.h:3474
N_GUI_THEME close_theme
theme for close button (defaults to red hover/active)
Definition n_gui.h:1262
void * user_data
user data for callback
Definition n_gui.h:1043
float value
progress fraction, clamped to 0.0 .
Definition n_gui.h:1027
int scroll_offset
scroll offset
Definition n_gui.h:1065
ALLEGRO_COLOR tooltip_bg
tooltip bubble background color
Definition n_gui.h:1538
ALLEGRO_COLOR text_hover
text hover
Definition n_gui.h:400
float restore_x
saved x position before maximise (for restore)
Definition n_gui.h:1252
float dropdown_arrow_half_h
vertical half-extent of the arrow chevron
Definition n_gui.h:1598
int z_value
z-value for N_GUI_ZORDER_FIXED mode (lower = behind, higher = on top)
Definition n_gui.h:1350
ALLEGRO_BITMAP * item_bg_bitmap
optional bitmap for per-item background, normal state (NULL = color theme)
Definition n_gui.h:933
char * expanded[512]
paths of the expanded nodes
Definition n_gui.h:3533
int highlight_index
open-panel navigation cursor for the wheel and Up/Down keys (-1 = none).
Definition n_gui.h:969
double cursor_time
timestamp of last cursor activity (for blink reset)
Definition n_gui.h:641
int click_widget_id
widget the previous primary press landed on, for double click detection (-1 = none yet)
Definition n_gui.h:1709
size_t entries_capacity
allocated capacity
Definition n_gui.h:1061
int mouse_y
mouse state tracking
Definition n_gui.h:1689
float grip_line_thickness
grip line thickness
Definition n_gui.h:1513
int window_id
window holding the headers and members
Definition n_gui.h:3382
float w
width; zero when no bar was painted
Definition n_gui.h:469
int has_default
non-zero once n_gui_slider_set_default() gave the slider a default, which a double click on it puts b...
Definition n_gui.h:570
int lbl_key
label widget ID for "Key" header
Definition n_gui.h:3654
char key[128]
widget persist key to match on
Definition n_gui.h:1658
N_GUI_CUSTOM_MOUSE on_mouse
mouse callback (NULL = the widget takes no mouse input)
Definition n_gui.h:1235
size_t sel_end
selection end position (tracks cursor during selection)
Definition n_gui.h:633
int resize_policy
per-window resize policy: N_GUI_WIN_RESIZE_NONE, _MOVE, or _SCALE
Definition n_gui.h:1366
N_GUI_THEME default_tb_close_theme
default theme for titlebar close button
Definition n_gui.h:1796
size_t nb_items
number of items
Definition n_gui.h:921
char suggest_prefix[128]
the word the answers are for, so the provider is asked once per word rather than once per key
Definition n_gui.h:673
char persist_key[128]
optional stable key for persisting this widget's user-adjustable state (splitpane divider ratio,...
Definition n_gui.h:1130
int native_drag_cx
desktop x of the mouse cursor when a native (N_GUI_DETACH_OWN_CHROME) title bar drag started.
Definition n_gui.h:1428
void(* on_close)(int window_id, void *user_data)
callback on close button click (NULL = default: clear N_GUI_WIN_OPEN)
Definition n_gui.h:1290
char title[128]
window title to match on
Definition n_gui.h:1640
void * suggest_user_data
user data handed back to the provider
Definition n_gui.h:656
void * user_data
user data for callback
Definition n_gui.h:983
float first_inset
content-local left inset applied to the FIRST header only, so a button can sit before it on the same ...
Definition n_gui.h:3390
int double_clicked_widget_id
widget the press just processed double clicked, or -1.
Definition n_gui.h:1718
float h
height; zero when no bar was painted
Definition n_gui.h:471
int cached_nb_lines
cached line count (matches _text_line_count), valid when lines_valid
Definition n_gui.h:831
float padding
unscaled padding in pixels
Definition n_gui.h:3650
unsigned char * data
owned copy of the bytes, or NULL
Definition n_gui.h:783
int detach_flags
options the window was detached with (N_GUI_DETACH_*), remembered so a close/open cycle and a restore...
Definition n_gui.h:1391
n_gui_tree_on_drop_t on_drop
drag-reorder state (managed by n_gui_tree_tick)
Definition n_gui.h:3509
void * mouse_user_data
opaque user pointer handed back to on_mouse (not owned by n_gui)
Definition n_gui.h:1237
void(* on_select)(int, void *)
selection callback
Definition n_gui.h:3503
int shape
shape type: N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, N_GUI_SHAPE_BITMAP
Definition n_gui.h:490
int z_order
z-order mode (N_GUI_ZORDER_NORMAL, _ALWAYS_ON_TOP, _ALWAYS_BEHIND, _FIXED)
Definition n_gui.h:1348
int theme_derived
1 while the style is still the one derived from the widget's theme, so a palette change is followed; ...
Definition n_gui.h:1168
float max_ratio
upper clamp applied to ratio
Definition n_gui.h:771
int tag
user-defined tag for the entry (e.g.
Definition n_gui.h:1039
int mouse_b1
mouse button 1 state
Definition n_gui.h:1691
float button_w
width of each tab button
Definition n_gui.h:3333
float display_w
display/viewport width (set via n_gui_set_display_size)
Definition n_gui.h:1745
double click_time
time of that press, from al_get_time()
Definition n_gui.h:1711
int nb_sections
number of sections
Definition n_gui.h:3389
N_GUI_LISTITEM * items
dynamic array of items
Definition n_gui.h:919
float width
header width
Definition n_gui.h:3385
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:687
float col_frac[3]
width fraction of each visible text column over the text area, summing to 1; user-adjusted by the col...
Definition n_gui.h:3668
int h
bounding box height in pixels
Definition n_gui.h:378
float grip_size
grip area size
Definition n_gui.h:1511
void * user_data
opaque user pointer handed back to the callback (not owned by n_gui)
Definition n_gui.h:1233
float radio_label_gap
gap between circle and label text
Definition n_gui.h:1574
N_GUI_CTX * ctx
GUI context.
Definition n_gui.h:3496
ALLEGRO_DISPLAY * display
display pointer for clipboard operations (set via n_gui_set_display)
Definition n_gui.h:1782
void * drop_user_data
user data for on_drop
Definition n_gui.h:3510
float saved_x
embedded x saved by n_gui_window_detach, restored by n_gui_window_attach
Definition n_gui.h:1403
float norm_w
normalized width (fraction of reference display width, used in SCALE mode)
Definition n_gui.h:1372
float content_w
total content width computed from widgets (internal)
Definition n_gui.h:1346
N_GUI_PENDING_WIDGET * pending_widgets
saved widget state for keyed widgets that did NOT exist when the layout was loaded; n_gui_widget_set_...
Definition n_gui.h:1809
void * user_data
user data for this node
Definition n_gui.h:3475
float norm_x
normalized position x (fraction of parent window w, used for SCALE resize)
Definition n_gui.h:1132
ALLEGRO_COLOR global_scrollbar_thumb_color
global scrollbar thumb colour
Definition n_gui.h:1505
float content_h
the height the whole document last measured at
Definition n_gui.h:1159
int width_valid
0 when cached_content_w is stale.
Definition n_gui.h:836
int selected_label_id
id of the label widget with the most recent text selection, or -1
Definition n_gui.h:1784
float radio_inner_offset
inner filled circle shrink from outer
Definition n_gui.h:1572
float min_ratio
lower clamp applied to ratio
Definition n_gui.h:769
float min_w
minimum width
Definition n_gui.h:1336
unsigned char * row_sel
per-row selection flags (1 = selected), sized rows_cap; NULL until needed
Definition n_gui.h:890
int selected_index
currently selected index (-1 = none)
Definition n_gui.h:925
void(* destroy)(void *user_data)
called with user_data when the widget is destroyed, for a caller that hands its state to the widget (...
Definition n_gui.h:1240
N_GUI_MD_FONTS fonts
the faces, borrowed: the caller owns them and they must outlive the widget, the same rule every ALLEG...
Definition n_gui.h:1152
ALLEGRO_BITMAP * track_bitmap
optional bitmap for the track/rail background (NULL = color theme)
Definition n_gui.h:545
int mouse_x
mouse state tracking
Definition n_gui.h:1687
N_GUI_TB_BUTTONS tb_buttons
titlebar button state (minimize, maximize, close)
Definition n_gui.h:1376
int order[64]
display position -> physical column
Definition n_gui.h:1662
ALLEGRO_COLOR scrollbar_thumb_color
scrollbar thumb colour
Definition n_gui.h:1489
int active_tab
currently active tab index
Definition n_gui.h:3330
float y
saved y
Definition n_gui.h:1642
float native_h
last known native window height (see native_w)
Definition n_gui.h:1418
float checkbox_max_size
maximum box size
Definition n_gui.h:1556
double default_value
the value a double click puts back, when has_default is set
Definition n_gui.h:572
size_t nb_entries
number of entries
Definition n_gui.h:1059
int visible_map[2048]
visible row to node index
Definition n_gui.h:3501
int tooltip_anchor_x
pointer x when the tooltip was last armed (movement re-arms)
Definition n_gui.h:1731
float checkbox_mark_thickness
checkmark line thickness
Definition n_gui.h:1560
int nb_expanded
number of paths stored
Definition n_gui.h:3534
unsigned char * row_has_color
per-row tint flags (1 = row_color[row] is painted), sized rows_cap; NULL until a row color is set
Definition n_gui.h:897
ALLEGRO_BITMAP * close_bitmap
optional bitmap for close button normal state (NULL = color theme)
Definition n_gui.h:1276
int sel_start
selection start byte offset (-1 = no selection)
Definition n_gui.h:1011
N_GUI_SUGGEST_FN suggest
completion provider, NULL when the field offers none
Definition n_gui.h:654
ALLEGRO_BITMAP * bitmap
bitmap to display (not owned, not freed)
Definition n_gui.h:991
ALLEGRO_BITMAP * fill_bitmap
optional bitmap for the filled portion of the track (NULL = color theme)
Definition n_gui.h:547
ALLEGRO_COLOR tooltip_border
tooltip bubble border color
Definition n_gui.h:1540
void * on_close_user_data
user data for on_close callback
Definition n_gui.h:1292
N_GUI_THEME default_tb_btn_theme
default theme for titlebar minimize/maximize buttons
Definition n_gui.h:1794
int tooltip_widget_id
widget the pointer is resting on for tooltip purposes (-1 = none)
Definition n_gui.h:1727
float header_height
unscaled column-header row height
Definition n_gui.h:3651
float global_scroll_step
pixels per mouse wheel notch for global scroll
Definition n_gui.h:1628
double key_step
increment applied by the arrow keys and the mouse wheel, when it should differ from step.
Definition n_gui.h:539
int click_x
pointer x at that press
Definition n_gui.h:1713
float h
window height
Definition n_gui.h:1318
float item_height
item height in dropdown
Definition n_gui.h:971
int hover_row
index of the row the mouse is currently over, or -1.
Definition n_gui.h:759
void * user_data
user data for callback
Definition n_gui.h:691
double scroll_pos
current scroll position
Definition n_gui.h:703
void(* on_change)(int widget_id, const char *text, void *user_data)
callback on text change
Definition n_gui.h:650
char * text
the source, owned, NUL-terminated; never NULL after creation
Definition n_gui.h:1149
ALLEGRO_BITMAP * item_selected_bitmap
optional bitmap for per-item background, selected/highlighted (NULL = color theme)
Definition n_gui.h:979
void * user_data
user data for callback
Definition n_gui.h:557
float autofit_origin_y
original insertion point y for N_GUI_AUTOFIT_CENTER (set by n_gui_window_set_autofit)
Definition n_gui.h:1364
N_GUI_DATAGRID_COL * cols
column definitions (physical/storage order; cells are indexed by these)
Definition n_gui.h:857
int scroll_offset
scroll offset in items
Definition n_gui.h:734
int native_drag_cy
desktop y of the mouse cursor at the drag grab (see native_drag_cx)
Definition n_gui.h:1430
float h_scroll
horizontal scroll offset in pixels: the view does not wrap, so a line wider than the widget is reache...
Definition n_gui.h:816
size_t len
number of bytes
Definition n_gui.h:785
int selected
selection state (for listbox)
Definition n_gui.h:580
ALLEGRO_BITMAP * minimize_hover_bitmap
optional bitmap for minimize button hover state
Definition n_gui.h:1266
int dirty
set when the text, the faces or the style changed under a measure
Definition n_gui.h:1164
ALLEGRO_BITMAP * item_hover_bitmap
optional bitmap for the hovered entry background (NULL = color theme)
Definition n_gui.h:1078
float virtual_h
virtual canvas height (0 = disabled / identity transform)
Definition n_gui.h:1768
int drag_active
1 once past threshold
Definition n_gui.h:3515
N_GUI_SB_TRACK sb_v
the vertical scrollbar this widget draws inside itself, if it draws one, so the pointer can be tested...
Definition n_gui.h:1110
float y0
content-local y of the first header
Definition n_gui.h:3384
N_GUI_CTX * ctx
GUI context.
Definition n_gui.h:3644
int shape_mode
global widget shape override: N_GUI_SHAPE_ROUNDED forces a rounded GUI, N_GUI_SHAPE_RECT forces a squ...
Definition n_gui.h:1612
int visible
1 = drawn, 0 = hidden (kept in storage, skipped in the header and rows)
Definition n_gui.h:851
float global_scroll_x
global horizontal scroll offset (when GUI exceeds display)
Definition n_gui.h:1756
int cached_headers_end
cached first blank-line index (HTTP headers end), or INT_MAX; valid when lines_valid
Definition n_gui.h:833
int dz
wheel steps for WHEEL, positive away from the user; 0 otherwise
Definition n_gui.h:1210
int native_pos_x
last known native window position on the desktop, applied when the native window is re-created.
Definition n_gui.h:1421
float init_win_h
parent window height at create time
Definition n_gui.h:3653
float checkbox_mark_margin
checkmark inset from box edge
Definition n_gui.h:1558
ALLEGRO_BITMAP * track_bitmap
optional bitmap for the scrollbar track background (NULL = color theme)
Definition n_gui.h:710
ALLEGRO_DISPLAY * native
native OS window backing this pseudo-window, or NULL (the default) when the window is drawn as a pop-...
Definition n_gui.h:1388
float checkbox_label_offset
horizontal offset from box edge to label text
Definition n_gui.h:1564
int button
1 left, 2 right for DOWN; 1 for UP and DRAG; 0 otherwise
Definition n_gui.h:1204
N_GUI_CUSTOM_DRAW draw
paint callback invoked during n_gui_draw (NULL = draw nothing)
Definition n_gui.h:1231
void(* on_columns_changed)(int widget_id, void *user_data)
callback fired after the user resizes a column by dragging its header border (widget_id,...
Definition n_gui.h:874
ALLEGRO_BITMAP * maximize_active_bitmap
optional bitmap for maximize button active state
Definition n_gui.h:1274
ALLEGRO_BITMAP * titlebar_bitmap
optional bitmap for the titlebar background (NULL = color fill)
Definition n_gui.h:1354
int scroll_offset
scroll offset in dropdown
Definition n_gui.h:964
int h_scroll_dragging
1 while the horizontal scrollbar thumb is being dragged (so the shared scrollbar-drag handler routes ...
Definition n_gui.h:819
N_GUI_CTX * ctx
GUI context.
Definition n_gui.h:3325
int mouse_b1_prev
previous frame's b1 state
Definition n_gui.h:3518
void * data
widget-specific data (union via void pointer)
Definition n_gui.h:1122
void(* on_link)(int widget_id, const char *url, void *user_data)
called when a link is clicked, or NULL
Definition n_gui.h:1170
int suggest_open
the panel is up
Definition n_gui.h:670
double value
current value (always snapped to step)
Definition n_gui.h:532
N_GUI_DROPMENU_ENTRY * entries
dynamic array of entries
Definition n_gui.h:1057
float x
left edge, in the coordinates the paint drew in
Definition n_gui.h:465
float drag_oy
drag offset y (internal)
Definition n_gui.h:1334
float slider_track_border_thickness
track outline thickness
Definition n_gui.h:1523
int pending_widgets_count
number of valid entries in pending_widgets
Definition n_gui.h:1811
int nb_active
active row count
Definition n_gui.h:3648
ALLEGRO_COLOR link_color_normal
link colour (normal)
Definition n_gui.h:1620
float slider_handle_min_r
minimum handle circle radius
Definition n_gui.h:1525
int scale_mode
scale mode: N_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, N_GUI_IMAGE_CENTER
Definition n_gui.h:993
float restore_h
saved height before maximise (for restore)
Definition n_gui.h:1258
ALLEGRO_BITMAP * item_selected_bitmap
optional bitmap for per-item background, selected/highlighted (NULL = color theme)
Definition n_gui.h:935
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the radiolist background (NULL = color theme)
Definition n_gui.h:931
int truncate
how text too wide for the label is shortened: N_GUI_TRUNCATE_END (the default), N_GUI_TRUNCATE_START ...
Definition n_gui.h:1007
float x
content-local x of every header and the layout origin
Definition n_gui.h:3383
int show_value
1 to show the Value column (default 1)
Definition n_gui.h:3661
ALLEGRO_BITMAP * box_bitmap
optional bitmap for the checkbox square, unchecked state (NULL = color theme)
Definition n_gui.h:683
float h_scroll
horizontal scroll offset in pixels
Definition n_gui.h:3537
void * on_open_user_data
user data for on_open callback
Definition n_gui.h:1084
float drag_press_y
mouse y at press time
Definition n_gui.h:3517
int show_desc
1 to show the Description column (default 1)
Definition n_gui.h:3662
float y
y origin of tab button row
Definition n_gui.h:3332
float divider
divider thickness in pixels
Definition n_gui.h:773
float dropdown_arrow_reserve
horizontal space reserved for the arrow on the right
Definition n_gui.h:1594
void * user_data
opaque pointer handed back to on_change
Definition n_gui.h:801
ALLEGRO_BITMAP * close_active_bitmap
optional bitmap for close button active state
Definition n_gui.h:1280
float y
position y relative to parent window
Definition n_gui.h:1100
int lbl_desc
label widget ID for "Description" header
Definition n_gui.h:3656
int type
N_GUI_MOUSE_DOWN, _UP, _MOVE, _DRAG or _WHEEL.
Definition n_gui.h:1202
const ALLEGRO_FONT * metrics_font
font cached_content_w was measured with (a text keeps its width only for as long as the font it was m...
Definition n_gui.h:841
int orientation
orientation: N_GUI_SLIDER_H or N_GUI_SLIDER_V
Definition n_gui.h:543
float global_scrollbar_border_thickness
global thumb border thickness
Definition n_gui.h:1501
int state
state flags (N_GUI_WIN_*)
Definition n_gui.h:1322
int visible[64]
per-physical-column visibility
Definition n_gui.h:1663
int flags
feature flags (N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_RESIZABLE, etc.)
Definition n_gui.h:1324
int orientation
N_GUI_SPLIT_VERTICAL or N_GUI_SPLIT_HORIZONTAL.
Definition n_gui.h:765
void * user_data
user data for callback
Definition n_gui.h:720
int active
1 if active, 0 if removed
Definition n_gui.h:3636
double max_val
maximum value
Definition n_gui.h:530
HASH_TABLE * widgets_by_id
hash table for fast widget lookup by id
Definition n_gui.h:1673
float border_thickness
border thickness
Definition n_gui.h:404
float link_underline_thickness
link underline thickness
Definition n_gui.h:1618
ALLEGRO_BITMAP * box_checked_bitmap
optional bitmap for the checkbox square, checked state (NULL = color theme)
Definition n_gui.h:685
int autofit_flags
bitmask of N_GUI_AUTOFIT_* flags (0 = no auto-fitting)
Definition n_gui.h:1358
unsigned char consumed
1 once applied to a created window
Definition n_gui.h:1646
float ratio
divider position as a fraction of the widget extent (0..1)
Definition n_gui.h:767
int drag_source_node
node being dragged, or -1
Definition n_gui.h:3511
N_GUI_STYLE style
configurable style (sizes, colours, paddings)
Definition n_gui.h:1780
ALLEGRO_FONT * font
font for the title bar
Definition n_gui.h:1330
float col_resize_x0
cursor x at the start of a column-resize drag
Definition n_gui.h:868
int split_a
splitpane widget ID of the divider after the first text column, or -1
Definition n_gui.h:3670
char * key_placeholder
owned hint shown in each key textarea, or NULL
Definition n_gui.h:3665
void * expand_user_data
user data for on_expand
Definition n_gui.h:3506
void * user_data
user data for callback
Definition n_gui.h:652
N_GUI_THEME btn_theme
theme for minimize and maximize buttons
Definition n_gui.h:1260
ALLEGRO_COLOR text_active
text active
Definition n_gui.h:402
float ref_display_w
reference display width at the time normalized values were last captured
Definition n_gui.h:1790
float restore_w
saved width before maximise (for restore)
Definition n_gui.h:1256
int nb_nodes
number of nodes
Definition n_gui.h:3500
size_t items_capacity
allocated capacity
Definition n_gui.h:923
int parent_window_id
parent window for tab buttons
Definition n_gui.h:3326
double content_size
total content size
Definition n_gui.h:699
float autofit_origin_x
original insertion point x for N_GUI_AUTOFIT_CENTER (set by n_gui_window_set_autofit)
Definition n_gui.h:1362
void * user_data
user data for callback
Definition n_gui.h:755
double step
step increment (0 is treated as 1).
Definition n_gui.h:534
float global_scroll_y
global vertical scroll offset (when GUI exceeds display)
Definition n_gui.h:1758
size_t cap
bytes allocated (>= len; edits grow the buffer)
Definition n_gui.h:787
int scrollbar_drag_widget_id
id of the widget whose scrollbar is being dragged, or -1
Definition n_gui.h:1737
ALLEGRO_BITMAP * maximize_hover_bitmap
optional bitmap for maximize button hover state
Definition n_gui.h:1272
char caption[128]
what the title bar shows instead of the title when not empty, set by n_gui_window_set_caption(); neve...
Definition n_gui.h:1306
float min_h
minimum height
Definition n_gui.h:1338
float listbox_default_item_height
default item height for listbox
Definition n_gui.h:1578
void * user_data
user data for callback
Definition n_gui.h:913
size_t nb_cols
number of columns
Definition n_gui.h:859
ALLEGRO_COLOR global_scrollbar_thumb_border_color
global scrollbar thumb border colour
Definition n_gui.h:1507
float tb_btn_spacing
gap between titlebar buttons
Definition n_gui.h:1471
ALLEGRO_COLOR border_active
border active
Definition n_gui.h:396
float scroll_x
horizontal scroll offset for single-line text (pixels)
Definition n_gui.h:637
float label_padding
horizontal padding each side
Definition n_gui.h:1616
ALLEGRO_MOUSE_CURSOR * cursor_want_custom
... or a custom one, borrowed, which wins over the shape when set
Definition n_gui.h:1706
float titlebar_h
title bar height
Definition n_gui.h:1457
ALLEGRO_EVENT_QUEUE * event_queue
event queue the context registers native window event sources into (set via n_gui_set_event_queue).
Definition n_gui.h:1814
float ratio
divider ratio (kind == SPLITPANE)
Definition n_gui.h:1660
float gui_offset_y
vertical letterbox offset for virtual canvas
Definition n_gui.h:1774
int hovered
which button is currently hovered (N_GUI_TB_BTN_*)
Definition n_gui.h:1248
ALLEGRO_BITMAP * item_selected_bitmap
optional bitmap for per-item background, selected/highlighted (NULL = color theme)
Definition n_gui.h:751
N_GUI_PENDING_GEOM * pending_layout
layout entries for windows that did NOT exist when the saved layout was loaded (lazily-created panels...
Definition n_gui.h:1802
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:753
float natural_h
stacked height of the members when expanded, recomputed by n_gui_sectionlist_relayout() from the live...
Definition n_gui.h:3374
int scroll_offset
first visible line
Definition n_gui.h:813
float item_height
item height in pixels
Definition n_gui.h:745
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:981
int focused_widget_id
id of the widget that currently has focus, or -1
Definition n_gui.h:1685
float h_scroll
horizontal scroll offset in pixels: how far the columns are scrolled to the left when their total wid...
Definition n_gui.h:902
int id
unique window id
Definition n_gui.h:1300
float y
top edge
Definition n_gui.h:467
int global_vscroll_drag
1 if global scrollbar vertical thumb is being dragged
Definition n_gui.h:1776
int sel_dragging
1 if mouse is actively dragging to select text
Definition n_gui.h:1015
char * selected
path of the selected node, or NULL
Definition n_gui.h:3535
int nb_visible
number of visible rows
Definition n_gui.h:3502
ALLEGRO_COLOR global_scrollbar_track_color
global scrollbar track colour
Definition n_gui.h:1503
float item_height_pad
min padding added to font height for item height
Definition n_gui.h:1590
int up_id
button widget ID for the move-up action (row actions only)
Definition n_gui.h:3633
int section_hidden[16]
1 = the whole section, header and members, is left out of the stack
Definition n_gui.h:3392
float display_h
display/viewport height
Definition n_gui.h:1747
size_t len
text length in bytes
Definition n_gui.h:809
N_GUI_LISTITEM * items
dynamic array of items
Definition n_gui.h:726
void * user_data
user data for callback
Definition n_gui.h:939
float corner_ry
corner radius Y for rounded shapes
Definition n_gui.h:408
int checked
checked state
Definition n_gui.h:681
int sel_end
selection end byte offset (-1 = no selection)
Definition n_gui.h:1013
float width[64]
per-physical-column width
Definition n_gui.h:1664
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:1356
int modifiers
the modifier keys held when the event came, ALLEGRO_KEYMOD_SHIFT, _CTRL, _ALT and _ALTGR ORed,...
Definition n_gui.h:1215
N_GUI_SB_TRACK sb_h
and the horizontal one
Definition n_gui.h:1112
size_t text_alloc
allocated buffer size (char_limit + 1)
Definition n_gui.h:622
ALLEGRO_DISPLAY * pass_display
display the pass currently being processed or drawn belongs to: NULL for the host's main display (and...
Definition n_gui.h:1821
ALLEGRO_COLOR bg_normal
background normal
Definition n_gui.h:386
ALLEGRO_BITMAP * handle_bitmap
optional bitmap for the draggable handle, normal state (NULL = color theme)
Definition n_gui.h:549
ALLEGRO_FONT * font
font used by this widget (NULL = context default)
Definition n_gui.h:1120
float norm_w
normalized width (fraction of parent window w)
Definition n_gui.h:1136
int resize_mode
context resize mode: N_GUI_RESIZE_VIRTUAL or N_GUI_RESIZE_ADAPTIVE
Definition n_gui.h:1788
float virtual_w
virtual canvas width (0 = disabled / identity transform)
Definition n_gui.h:1766
float radiolist_default_item_height
default item height for radiolist
Definition n_gui.h:1580
void * user_data
user data for the callback
Definition n_gui.h:3394
void(* on_minimize)(int window_id, void *user_data)
callback on minimize button click (NULL = default: toggle N_GUI_WIN_MINIMISED)
Definition n_gui.h:1282
char label[128]
label displayed next to the checkbox
Definition n_gui.h:679
float slider_value_label_offset
gap between slider end and value label
Definition n_gui.h:1531
void(* on_context)(int widget_id, int row, int x, int y, void *user_data)
callback on right-click over a data row, for a context menu (widget_id, row, x, y,...
Definition n_gui.h:911
size_t nb_items
number of items
Definition n_gui.h:728
int depth
depth in tree (0 = root)
Definition n_gui.h:3473
float tb_btn_glyph_thickness
line thickness for titlebar button glyphs
Definition n_gui.h:1475
ALLEGRO_COLOR bg_active
background active/pressed
Definition n_gui.h:390
char mask_char
mask character for password fields (0 = no masking, e.g.
Definition n_gui.h:645
ALLEGRO_BITMAP * minimize_bitmap
optional bitmap for minimize button normal state (NULL = color theme)
Definition n_gui.h:1264
int split_b
splitpane widget ID of the divider after the second text column, or -1
Definition n_gui.h:3671
int global_hscroll_drag
1 if global scrollbar horizontal thumb is being dragged
Definition n_gui.h:1778
float w
saved width (display-scaled), 0 when absent
Definition n_gui.h:1643
LIST * windows
ordered list of N_GUI_WINDOW* (back to front)
Definition n_gui.h:1671
char text[128]
display text
Definition n_gui.h:1035
int scroll_y
scroll offset for long text
Definition n_gui.h:635
char text[4096]
optional centered overlay text (empty string = none)
Definition n_gui.h:1029
void(* on_scroll)(int widget_id, double scroll_pos, void *user_data)
callback on scroll
Definition n_gui.h:718
int x
bounding box x offset from draw origin
Definition n_gui.h:375
float gui_bounds_h
total bounding box height of all windows (computed internally)
Definition n_gui.h:1762
double min_val
minimum value
Definition n_gui.h:528
float textarea_cursor_blink_period
cursor blink period in seconds (full cycle on+off)
Definition n_gui.h:1552
int lbl_value
label widget ID for "Value" header
Definition n_gui.h:3655
void(* on_toggle)(int widget_id, int checked, void *user_data)
callback on toggle
Definition n_gui.h:689
void(* on_expand)(int, void *)
fills a node the first time it opens, or NULL
Definition n_gui.h:3505
ALLEGRO_COLOR bg_hover
background hover
Definition n_gui.h:388
size_t sel_start
selection anchor position (where shift-click/shift-arrow started).
Definition n_gui.h:631
int window_id
parent window
Definition n_gui.h:3645
int cursor_shape
system mouse cursor currently applied to the display (an ALLEGRO_SYSTEM_MOUSE_CURSOR_* value),...
Definition n_gui.h:1697
void * on_content_draw_data
user data passed to on_content_draw
Definition n_gui.h:1383
void(* on_change)(int widget_id, const unsigned char *data, size_t len, void *user_data)
called after any edit, with the new byte count
Definition n_gui.h:799
float dropdown_arrow_thickness
arrow stroke thickness
Definition n_gui.h:1596
float tb_btn_right_margin
right margin from window edge to rightmost button
Definition n_gui.h:1473
void * user_data
user data for callback
Definition n_gui.h:3660
ALLEGRO_COLOR link_color_hover
link colour (hover)
Definition n_gui.h:1622
float radio_circle_min_r
minimum outer circle radius
Definition n_gui.h:1568
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the listbox background (NULL = color theme)
Definition n_gui.h:747
float item_text_padding
text padding inside list/combo/dropmenu items
Definition n_gui.h:1586
int next_widget_id
next widget id to assign
Definition n_gui.h:1675
int enabled_id
checkbox widget ID for the enabled toggle
Definition n_gui.h:3631
char * value_placeholder
owned hint shown in each value textarea, or NULL
Definition n_gui.h:3666
float autofit_border
padding/border around content for auto-fit (pixels, applied on each side)
Definition n_gui.h:1360
int suggest_count
how many of them
Definition n_gui.h:664
float gui_scale
computed uniform scale factor for virtual canvas
Definition n_gui.h:1770
int anchor_row
anchor row for Shift-click range selection, or -1
Definition n_gui.h:892
int glyph
NGUI_GLYPH* icon drawn centred in the button's text colour instead of the label (N_GUI_GLYPH_NONE,...
Definition n_gui.h:495
int native_drag_anchored
1 when the four native_drag_* fields hold a usable grab, that is when al_get_mouse_cursor_position wo...
Definition n_gui.h:1440
size_t cursor_pos
cursor position in text
Definition n_gui.h:628
float restore_y
saved y position before maximise (for restore)
Definition n_gui.h:1254
int scroll_offset
first visible data row
Definition n_gui.h:899
void * user_data
user data for callback
Definition n_gui.h:522
int mode
mode: N_GUI_SLIDER_VALUE or N_GUI_SLIDER_PERCENT
Definition n_gui.h:541
int dirty
non-zero when the GUI's appearance may have changed since the last n_gui_draw.
Definition n_gui.h:1830
size_t char_limit
maximum character limit (0 = N_GUI_TEXT_MAX)
Definition n_gui.h:624
int editable
1 when the bytes can be edited in place
Definition n_gui.h:793
void(* on_select)(int widget_id, int row, void *user_data)
callback on row selection (widget_id, row, user_data)
Definition n_gui.h:907
int toggle_mode
toggle mode: 0 = momentary (default), 1 = toggle (stays clicked/unclicked)
Definition n_gui.h:497
int is_open
is the menu currently open
Definition n_gui.h:1063
float measured_w
the width it was measured at, so a resize re-measures and nothing else has to remember to
Definition n_gui.h:1162
ALLEGRO_COLOR border_hover
border hover
Definition n_gui.h:394
N_GUI_CTX * ctx
GUI context.
Definition n_gui.h:3381
void * on_minimize_user_data
user data for on_minimize callback
Definition n_gui.h:1284
float scrollbar_thumb_min
minimum thumb dimension
Definition n_gui.h:1481
int down_id
button widget ID for the move-down action (row actions only)
Definition n_gui.h:3634
float x
pointer x from the widget's left edge; outside 0..w during a DRAG
Definition n_gui.h:1206
int native_halted
1 while the native window's drawing is halted.
Definition n_gui.h:1446
double wheel_step
how far one wheel notch moves it, in content units; 0 (the default) is a twentieth of the range.
Definition n_gui.h:706
int native_pos_y
last known native window y position (see native_pos_x)
Definition n_gui.h:1423
float x
x origin of first tab button
Definition n_gui.h:3331
ALLEGRO_BITMAP * thumb_hover_bitmap
optional bitmap for the thumb on hover (NULL = fallback to thumb_bitmap)
Definition n_gui.h:714
double double_click_time
how long after a press a second one still counts as a double click, in seconds.
Definition n_gui.h:1721
int suggest_highlight
which one the keys and the pointer are on (-1 = none)
Definition n_gui.h:666
int value_id
textarea widget ID for the value
Definition n_gui.h:3629
char label[128]
label displayed on the button
Definition n_gui.h:482
ALLEGRO_BITMAP * bg_bitmap
optional bitmap for the text area background (NULL = color theme)
Definition n_gui.h:643
int align
text alignment: N_GUI_ALIGN_LEFT, N_GUI_ALIGN_CENTER, N_GUI_ALIGN_RIGHT
Definition n_gui.h:1003
int prev_over_win
whether the pointer was over a window on the previous motion event, so a motion that leaves the GUI s...
Definition n_gui.h:1837
float native_w
last known native window width, 0 until the window is first detached.
Definition n_gui.h:1416
size_t nb_rows
number of rows
Definition n_gui.h:878
void(* on_maximize)(int window_id, void *user_data)
callback on maximize button click (NULL = default: toggle N_GUI_WIN_MAXIMISED)
Definition n_gui.h:1286
size_t text_len
current text length
Definition n_gui.h:620
char link[4096]
optional hyperlink URL (empty string = no link)
Definition n_gui.h:1001
int orientation
orientation: N_GUI_SCROLLBAR_H or N_GUI_SCROLLBAR_V
Definition n_gui.h:697
float global_scrollbar_thumb_min
global minimum thumb dimension
Definition n_gui.h:1495
double viewport_size
visible viewport size
Definition n_gui.h:701
int col_resize_col
physical column being resized by a header-border drag, or -1
Definition n_gui.h:866
unsigned char consumed
1 once applied
Definition n_gui.h:1665
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:1019
ALLEGRO_FONT * default_font
default font.
Definition n_gui.h:1681
float combobox_max_dropdown_width
maximum dropdown width for N_GUI_COMBOBOX_AUTO_WIDTH (0 = display width)
Definition n_gui.h:1632
int selection_mode
selection mode: N_GUI_SELECT_NONE, N_GUI_SELECT_SINGLE, N_GUI_SELECT_MULTIPLE
Definition n_gui.h:732
float h
saved height (display-scaled), 0 when absent
Definition n_gui.h:1644
size_t nb_items
number of items
Definition n_gui.h:956
int key_modifiers
required modifier key flags for the keybind (0 = no modifier requirement, matches any modifier state ...
Definition n_gui.h:508
ALLEGRO_COLOR * row_color
per-row background tint, sized rows_cap; NULL until a row color is set
Definition n_gui.h:894
float header_h
header button height
Definition n_gui.h:3386
int widget_ids[96]
member widget ids
Definition n_gui.h:3369
LIST * widgets
list of N_GUI_WIDGET* contained in this window
Definition n_gui.h:1326
void * user_data
user data for callback
Definition n_gui.h:777
float y
position y on screen
Definition n_gui.h:1314
ALLEGRO_BITMAP * bitmap_active
optional bitmap for active/pressed state
Definition n_gui.h:488
int tooltip_anchor_y
pointer y when the tooltip was last armed
Definition n_gui.h:1733
double tooltip_armed_at
time the tooltip hover was (re)armed, from al_get_time()
Definition n_gui.h:1729
char * placeholder
optional placeholder/hint text drawn dimmed while the field is empty (NULL = none); cleared from view...
Definition n_gui.h:648
int enabled
enabled flag (1 = enabled, 0 = disabled: drawn dimmed and ignores input)
Definition n_gui.h:1116
float radio_circle_border_thickness
outer circle border thickness
Definition n_gui.h:1570
float col_resize_w0
original width of the column at the start of a resize drag
Definition n_gui.h:870
int keycode
bound keyboard keycode (0 = none).
Definition n_gui.h:502
ALLEGRO_BITMAP * thumb_active_bitmap
optional bitmap for the thumb while dragging (NULL = fallback to thumb_bitmap)
Definition n_gui.h:716
float slider_track_size
track width (vertical) or height (horizontal)
Definition n_gui.h:1519
ALLEGRO_DISPLAY * active_display
display that last received input, used to pick the display for clipboard and mouse-cursor calls.
Definition n_gui.h:1824
float scroll_x
horizontal scroll offset for auto-scrollbar (pixels)
Definition n_gui.h:1342
float slider_handle_border_thickness
handle border thickness
Definition n_gui.h:1529
const char * n_gui_syntaxview_get_text(N_GUI_CTX *ctx, int widget_id)
get the text shown by a syntax view (borrowed pointer, do not free; NULL if empty)
Definition n_gui.c:4971
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:12348
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:6732
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:16796
int n_gui_suggest_add(N_GUI_SUGGEST_SINK *sink, const char *text)
add one completion to a suggestion sink
Definition n_gui.c:12705
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:4502
void n_gui_dropmenu_clear(N_GUI_CTX *ctx, int widget_id)
remove all entries
Definition n_gui.c:6452
int n_gui_widget_screen_rect(N_GUI_CTX *ctx, int widget_id, float *x, float *y, float *w, float *h)
Where a widget is on screen, rather than inside its window.
Definition n_gui.c:2091
void n_gui_sectionlist_set_folded(N_GUI_SECTIONLIST *sl, int section_index, int folded)
set a section's folded state and relayout; does NOT fire on_toggle (for programmatic restore)
Definition n_gui.c:19278
void n_gui_update_transform(N_GUI_CTX *ctx)
recalculate scale and offset from virtual canvas to display.
Definition n_gui.c:12045
int n_gui_add_hexview(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h)
add a read-only hex viewer; returns the widget id or -1
Definition n_gui.c:3372
int n_gui_button_is_toggled(N_GUI_CTX *ctx, int widget_id)
check if button is toggled
Definition n_gui.c:2806
void n_gui_datagrid_sort(N_GUI_CTX *ctx, int widget_id, int col, int dir)
sort the rows by a column (dir 1 ascending, -1 descending)
Definition n_gui.c:5559
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:12420
float n_gui_splitpane_get_ratio(N_GUI_CTX *ctx, int widget_id)
get the current divider ratio (0..1), or 0.5 if the widget is invalid
Definition n_gui.c:4588
void n_gui_toggle_window(N_GUI_CTX *ctx, int window_id)
toggle window visibility (show/hide)
Definition n_gui.c:2497
void n_gui_datagrid_set_on_columns_changed(N_GUI_CTX *ctx, int widget_id, void(*cb)(int, void *))
set the callback fired after the user drags a column border to resize it, so the host can persist the...
Definition n_gui.c:5537
void n_gui_sectionlist_set_widget_offset(N_GUI_SECTIONLIST *sl, int section_index, int widget_id, float dy)
state a member's y offset from the section's content top, for a caller that computes its own layout a...
Definition n_gui.c:19154
void n_gui_datagrid_set_selected(N_GUI_CTX *ctx, int widget_id, int row)
set the selected row index (fires the on_select callback).
Definition n_gui.c:5306
N_GUI_MD_STYLE * n_gui_markdownview_style(N_GUI_CTX *ctx, int widget_id)
the view's style, to read or to change in place, or NULL if there is no such widget.
Definition n_gui.c:5881
void n_gui_hexview_set_data(N_GUI_CTX *ctx, int widget_id, const unsigned char *data, size_t len)
set (copy) the bytes shown by a hex viewer; data may be NULL to clear
Definition n_gui.c:4805
#define N_GUI_TREE_MAX
maximum number of nodes in a tree view
Definition n_gui.h:3466
void n_gui_tree_state_apply(N_GUI_TREE *tree, const N_GUI_TREE_STATE *state)
re-expand, re-select and re-scroll a rebuilt tree from a saved state.
Definition n_gui.c:17986
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:2058
void n_gui_label_set_truncate(N_GUI_CTX *ctx, int widget_id, int mode)
choose where a label's text is shortened when it does not fit: N_GUI_TRUNCATE_END (the default),...
Definition n_gui.c:6156
void n_gui_datagrid_clear_row_color(N_GUI_CTX *ctx, int widget_id, int row)
remove the background tint of data row row (it draws untinted again)
Definition n_gui.c:5401
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:3106
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:3588
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:2582
void n_gui_kvtable_set_top_offset(N_GUI_KVTABLE *table, float top_offset)
reserve top_offset unscaled pixels above the header row so other widgets (a toolbar,...
Definition n_gui.c:19028
int n_gui_needs_redraw(N_GUI_CTX *ctx)
Return non-zero if the GUI must be redrawn this frame, i.e.
Definition n_gui.c:1192
void n_gui_hexview_set_cursor(N_GUI_CTX *ctx, int widget_id, size_t offset)
move the edit cursor to a byte offset (clamped to the data length)
Definition n_gui.c:4872
int n_gui_datagrid_get_row_count(N_GUI_CTX *ctx, int widget_id)
get the number of rows in a data grid
Definition n_gui.c:5286
void n_gui_textarea_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set text area content
Definition n_gui.c:4210
void n_gui_kvtable_relayout(N_GUI_KVTABLE *table)
re-apply layout to all KV table widgets (positions, sizes, normalized coords).
Definition n_gui.c:19038
int n_gui_save_layout_json(N_GUI_CTX *ctx, const char *filepath)
Save the geometry + persistent state of every window in the context to a JSON file.
Definition n_gui.c:16950
int n_gui_add_markdownview(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, const N_GUI_MD_FONTS *fonts)
add a read-only scrolling Markdown view.
Definition n_gui.c:5814
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:1639
int n_gui_kvtable_get_count(const N_GUI_KVTABLE *table)
get the number of active rows
Definition n_gui.c:19034
int n_gui_dropmenu_is_open(N_GUI_CTX *ctx, int widget_id)
is a dropdown menu's panel showing
Definition n_gui.c:6542
void n_gui_sectionlist_set_widget_hidden(N_GUI_SECTIONLIST *sl, int section_index, int widget_id, int hidden)
keep a member hidden whatever the fold state, and leave it out of the section's height.
Definition n_gui.c:19160
const unsigned char * n_gui_hexview_get_data(N_GUI_CTX *ctx, int widget_id, size_t *len)
borrow the bytes a hex view holds (valid until the next edit or set_data); *len receives the count.
Definition n_gui.c:4858
double n_gui_scrollbar_get_pos(N_GUI_CTX *ctx, int widget_id)
get scrollbar position
Definition n_gui.c:4293
void n_gui_tree_set_label(N_GUI_TREE *tree, int node_index, const char *new_label)
change the display label of a node
Definition n_gui.c:17766
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:18689
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:3148
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:12378
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:6591
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:3795
#define N_GUI_SECTIONLIST_MAX
maximum number of foldable sections in a section list
Definition n_gui.h:3357
const char * n_gui_datagrid_get_cell(N_GUI_CTX *ctx, int widget_id, int row, int col)
get a cell string by row and column, or NULL if out of range
Definition n_gui.c:5292
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:16575
int n_gui_dropmenu_get_count(N_GUI_CTX *ctx, int widget_id)
get number of entries
Definition n_gui.c:6477
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:5930
int n_gui_focus_takes_key(const N_GUI_CTX *ctx, int keycode)
Would the focused widget do something with this particular key.
Definition n_gui.c:2284
void n_gui_set_widget_tooltip(N_GUI_CTX *ctx, int widget_id, const char *text)
set (or clear with "" / NULL) the tooltip text shown after the pointer rests on a widget.
Definition n_gui.c:2880
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:2076
void n_gui_label_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set label text content
Definition n_gui.c:6184
int n_gui_window_native_is_hidden(N_GUI_CTX *ctx, int window_id)
check whether a detached window's drawing is currently halted by the OS (Android surface loss) or the...
Definition n_gui.c:1878
size_t n_gui_datagrid_get_column_count(N_GUI_CTX *ctx, int widget_id)
number of columns in a data grid (physical), or 0
Definition n_gui.c:5481
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:3285
void n_gui_window_set_rect(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h)
move and resize a window at runtime, rescaling its child widgets from their normalized coordinates (w...
Definition n_gui.c:12196
int n_gui_text_shorten(ALLEGRO_FONT *font, const char *text, float max_w, int mode, char *out, size_t out_len)
shorten text to fit max_w pixels in font, the way a label with truncate mode mode shows it: unchanged...
Definition n_gui.c:6890
float n_gui_listbox_get_h_scroll(N_GUI_CTX *ctx, int widget_id)
current horizontal scroll offset in pixels (0 = leftmost)
Definition n_gui.c:4556
#define N_GUI_PERSIST_MAX_COLS
Maximum datagrid columns whose layout is persisted per widget.
Definition n_gui.h:1650
float n_gui_datagrid_get_h_scroll(N_GUI_CTX *ctx, int widget_id)
Definition n_gui.c:5459
int n_gui_set_default_font(N_GUI_CTX *ctx, ALLEGRO_FONT *font)
Replace the context's default font, keeping every widget and its state.
Definition n_gui.c:1084
void n_gui_datagrid_set_row_color(N_GUI_CTX *ctx, int widget_id, int row, ALLEGRO_COLOR color)
paint data row row with a background tint (a per-row highlight, e.g.
Definition n_gui.c:5391
void n_gui_widget_set_rect(N_GUI_CTX *ctx, int widget_id, float x, float y, float w, float h)
move/resize a widget after creation, refreshing the normalized coordinates the resize passes read.
Definition n_gui.c:3854
void n_gui_datagrid_set_scroll_offset(N_GUI_CTX *ctx, int widget_id, int offset)
set the first visible data row (clamped to the row count); the draw path re-clamps to the live viewpo...
Definition n_gui.c:5432
size_t n_gui_datagrid_get_selected_rows(N_GUI_CTX *ctx, int widget_id, int *out, size_t max)
fill out with the indices of the selected rows (ascending), up to max, and return the total number of...
Definition n_gui.c:5345
int n_gui_datagrid_get_scroll_offset(N_GUI_CTX *ctx, int widget_id)
first visible data row (the vertical scroll position), or 0.
Definition n_gui.c:5426
int n_gui_slider_handle_pos(N_GUI_CTX *ctx, int widget_id, float *pos, float *radius)
Where a slider's handle is drawn and how big it is.
Definition n_gui.c:4108
void n_gui_window_set_tb_button_bitmaps(N_GUI_CTX *ctx, int window_id, int btn_type, ALLEGRO_BITMAP *normal, ALLEGRO_BITMAP *hover, ALLEGRO_BITMAP *active)
set optional bitmap overlays on a titlebar button
Definition n_gui.c:1957
void n_gui_focus_window(N_GUI_CTX *ctx, int window_id)
give a window keyboard focus: raise it within its z-order group and focus its first focusable widget ...
Definition n_gui.c:2381
#define N_GUI_KV_MAX
maximum number of rows in a KV table
Definition n_gui.h:3624
float n_gui_syntaxview_get_h_scroll(N_GUI_CTX *ctx, int widget_id)
current horizontal scroll offset of a syntax view, in pixels.
Definition n_gui.c:5109
int n_gui_hovered_widget(const N_GUI_CTX *ctx)
id of the widget currently under the mouse pointer (hover/active flag, maintained by n_gui_process_ev...
Definition n_gui.c:3723
int n_gui_process_event(N_GUI_CTX *ctx, ALLEGRO_EVENT event)
process an allegro event for the GUI
Definition n_gui.c:13611
int n_gui_window_get_flags(N_GUI_CTX *ctx, int window_id)
get feature flags of a window
Definition n_gui.c:2524
void n_gui_minimize_window(N_GUI_CTX *ctx, int window_id)
minimize a window (title bar only)
Definition n_gui.c:1454
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:3639
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:3887
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:3512
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:17595
void n_gui_close_window(N_GUI_CTX *ctx, int window_id)
close (hide) a window
Definition n_gui.c:1406
void n_gui_maximize_window(N_GUI_CTX *ctx, int window_id)
toggle maximised state (full display or restore to previous size)
Definition n_gui.c:1497
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:6700
void n_gui_label_set_link(N_GUI_CTX *ctx, int widget_id, const char *link)
set label hyperlink URL
Definition n_gui.c:6260
#define N_GUI_SUGGEST_SEP_MAX
longest separator set a suggestion-aware textarea takes, including the terminator
Definition n_gui.h:102
void n_gui_datagrid_set_on_context(N_GUI_CTX *ctx, int widget_id, void(*on_context)(int, int, int, int, void *))
set the right-click context callback; fired (with the cursor x/y in GUI coordinates) when a data row ...
Definition n_gui.c:5317
ALLEGRO_EVENT_QUEUE * n_gui_get_event_queue(N_GUI_CTX *ctx)
get the event queue previously given to n_gui_set_event_queue (NULL if none)
Definition n_gui.c:1595
void n_gui_kvtable_free(N_GUI_KVTABLE **table)
free a KV table (does not destroy the N_GUI widgets)
Definition n_gui.c:19042
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:12132
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:3085
void n_gui_radiolist_clear(N_GUI_CTX *ctx, int widget_id)
remove all items from a radio list
Definition n_gui.c:5951
int n_gui_combobox_get_count(N_GUI_CTX *ctx, int widget_id)
get the number of items in a combobox (0 if not a combobox).
Definition n_gui.c:6059
void n_gui_kvtable_clear(N_GUI_KVTABLE *table)
remove every row at once.
Definition n_gui.c:18854
void n_gui_markdownview_scroll_to(N_GUI_CTX *ctx, int widget_id, float y)
scroll to y pixels down the content, clamped to what there is
Definition n_gui.c:5893
int(* N_GUI_CUSTOM_MOUSE)(int widget_id, const N_GUI_MOUSE_EVENT *ev, void *user_data)
Mouse callback for a custom widget, set with n_gui_custom_set_mouse().
Definition n_gui.h:1225
void n_gui_slider_set_value_format(N_GUI_CTX *ctx, int widget_id, const char *fmt)
Override the built-in value readout's printf format string.
Definition n_gui.c:4144
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:4491
int(* n_gui_tree_on_drop_t)(int src_node, int dst_node, int position, void *user_data)
drag-reorder drop callback.
Definition n_gui.h:3492
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:2489
int n_gui_tree_find_by_path(const N_GUI_TREE *tree, const char *path)
index of the first node with the given path, or -1.
Definition n_gui.c:17951
void n_gui_syntaxview_set_selection(N_GUI_CTX *ctx, int widget_id, int start, int end)
set the selection range (byte offsets into the text, clamped to its length); pass start == end to cle...
Definition n_gui.c:5011
void n_gui_syntaxview_set_h_scroll(N_GUI_CTX *ctx, int widget_id, float px)
set the horizontal scroll offset of a syntax view, in pixels (clamped to the content width by the dra...
Definition n_gui.c:5122
int n_gui_dropmenu_set_open(N_GUI_CTX *ctx, int widget_id, int open)
open or close a dropdown menu without anybody clicking its button.
Definition n_gui.c:6498
double n_gui_slider_get_value(N_GUI_CTX *ctx, int widget_id)
get slider current value
Definition n_gui.c:3962
#define N_GUI_TREE_STATE_MAX
maximum number of expanded paths remembered by an N_GUI_TREE_STATE
Definition n_gui.h:3522
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:4359
void n_gui_window_set_caption(N_GUI_CTX *ctx, int window_id, const char *caption)
show a caption in a window's title bar in place of its title, for a title that carries live state ("E...
Definition n_gui.c:2442
void n_gui_listbox_set_h_scroll(N_GUI_CTX *ctx, int widget_id, float px)
set the horizontal scroll offset in pixels; clamped to >= 0 here and to the live content width by the...
Definition n_gui.c:4572
void n_gui_tree_set_expandable(N_GUI_TREE *tree, int node_index, int expandable)
mark a node as openable before it has children, so it shows an expander and the expand callback fills...
Definition n_gui.c:17858
N_GUI_THEME n_gui_default_tb_btn_theme(void)
return the built-in default theme for titlebar minimize/maximize buttons
Definition n_gui.c:889
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:12027
int n_gui_tooltip_pending(N_GUI_CTX *ctx)
tooltip phase: 0 = none (or tooltips disabled via style.tooltip_delay <= 0), 1 = arming (hosts with c...
Definition n_gui.c:2970
int n_gui_datagrid_is_row_selected(N_GUI_CTX *ctx, int widget_id, int row)
report whether a given data row is selected (1) or not (0)
Definition n_gui.c:5336
float n_gui_get_dpi_scale(const N_GUI_CTX *ctx)
get current DPI scale factor
Definition n_gui.c:12396
void n_gui_tree_clear(N_GUI_TREE *tree)
remove all nodes and clear the backing listbox; tree object remains valid
Definition n_gui.c:17705
N_GUI_THEME n_gui_default_theme(void)
return the built-in default theme
Definition n_gui.c:791
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:2403
int n_gui_radiolist_get_selected(N_GUI_CTX *ctx, int widget_id)
get the selected item index
Definition n_gui.c:5967
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:17537
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:2818
void n_gui_button_set_state_bitmaps(N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *normal, ALLEGRO_BITMAP *hover, ALLEGRO_BITMAP *active)
skin a button or toggle button with caller-owned per-state bitmaps (switches its shape to N_GUI_SHAPE...
Definition n_gui.c:3029
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:16667
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:6012
void n_gui_kvtable_set_placeholders(N_GUI_KVTABLE *table, const char *key_hint, const char *value_hint)
set the placeholder/hint text shown in each row's key (and value) textarea while it is empty.
Definition n_gui.c:19014
float n_gui_sectionlist_content_height(const N_GUI_SECTIONLIST *sl)
total content height in pixels under the current fold state, for sizing/scrolling the host window
Definition n_gui.c:19289
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:2534
int n_gui_syntaxview_get_line_count(N_GUI_CTX *ctx, int widget_id)
get the number of text lines in a syntax view
Definition n_gui.c:4959
#define N_GUI_SECTION_WIDGETS_MAX
maximum number of member widgets per section.
Definition n_gui.h:3363
int n_gui_window_button_rect(N_GUI_CTX *ctx, int window_id, int btn_type, float *x, float *y, float *w, float *h)
Where one of a window's title bar buttons is, on screen.
Definition n_gui.c:2108
void n_gui_window_set_minimize_callback(N_GUI_CTX *ctx, int window_id, void(*on_minimize)(int, void *), void *user_data)
set the minimize button callback for a window (NULL = default: toggle minimised)
Definition n_gui.c:1915
int n_gui_kvtable_move_row(N_GUI_KVTABLE *table, int row_index, int direction)
move the row at row_index one position up (direction < 0) or down (direction > 0) among the ACTIVE ro...
Definition n_gui.c:18929
int n_gui_add_splitpane(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int orientation, float ratio, void(*on_change)(int, float, void *), void *user_data)
add a split pane (draggable divider); returns the widget id or -1
Definition n_gui.c:3331
const char * n_gui_widget_get_persist_key(N_GUI_CTX *ctx, int widget_id)
Get a widget's persist key ("" when unset), or NULL when the widget is invalid.
Definition n_gui.c:2946
int n_gui_datagrid_add_column(N_GUI_CTX *ctx, int widget_id, const char *title, float width)
append a column with a header title and pixel width; returns the column index or -1
Definition n_gui.c:5153
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:3908
void n_gui_tree_rebuild(N_GUI_TREE *tree)
rebuild the listbox to reflect current tree state
Definition n_gui.c:17864
void n_gui_datagrid_set_h_scroll(N_GUI_CTX *ctx, int widget_id, float px)
set the horizontal scroll offset in pixels (clamped to >= 0; the draw path re-clamps to the live cont...
Definition n_gui.c:5465
void n_gui_datagrid_set_multiselect(N_GUI_CTX *ctx, int widget_id, int enabled)
enable (1) or disable (0) multi-row selection.
Definition n_gui.c:5323
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:7316
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:6624
int n_gui_window_find_button(N_GUI_CTX *ctx, int window_id, const char *label)
Find the button in a window whose label is exactly this.
Definition n_gui.c:2135
void n_gui_set_shape_mode(N_GUI_CTX *ctx, int shape_mode)
set the global widget shape (N_GUI_SHAPE_ROUNDED for a round GUI, else square)
Definition n_gui.c:12361
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:3547
void n_gui_syntaxview_set_mode(N_GUI_CTX *ctx, int widget_id, int mode)
set the highlighting mode (N_GUI_SYNTAX_*) of a syntax view
Definition n_gui.c:4947
void n_gui_button_set_toggled(N_GUI_CTX *ctx, int widget_id, int toggled)
set button toggled state
Definition n_gui.c:3043
void n_gui_custom_set_mouse(N_GUI_CTX *ctx, int widget_id, N_GUI_CUSTOM_MOUSE on_mouse, void *user_data)
give a custom widget mouse input
Definition n_gui.c:5730
void n_gui_set_double_click_time(N_GUI_CTX *ctx, double seconds)
how long after a press a second one still counts, in seconds (default 0.4)
Definition n_gui.c:3776
void n_gui_progressbar_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set the centered overlay text (NULL or "" clears it)
Definition n_gui.c:5680
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:17542
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:1809
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:4014
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:2790
int n_gui_get_topmost_open_window(const N_GUI_CTX *ctx)
get the id of the frontmost open, non-minimized window (the last one in draw order),...
Definition n_gui.c:2361
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:18836
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:3680
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:6671
void n_gui_window_set_tb_close_theme(N_GUI_CTX *ctx, int window_id, N_GUI_THEME theme)
set the theme for the titlebar close button on a specific window
Definition n_gui.c:1947
void n_gui_window_set_tb_btn_theme(N_GUI_CTX *ctx, int window_id, N_GUI_THEME theme)
set the theme for titlebar minimize/maximize buttons on a specific window
Definition n_gui.c:1937
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:5636
int n_gui_tab_get_active(const N_GUI_TAB_PANEL *panel)
get the active tab index
Definition n_gui.c:17556
size_t n_gui_hexview_get_length(N_GUI_CTX *ctx, int widget_id)
get the number of bytes currently held by a hex viewer
Definition n_gui.c:4899
int n_gui_listbox_get_selected(N_GUI_CTX *ctx, int widget_id)
get the first selected item index
Definition n_gui.c:4455
float n_gui_datagrid_columns_width(N_GUI_CTX *ctx, int widget_id)
horizontal scroll offset in pixels (how far the columns are scrolled left when their total width exce...
Definition n_gui.c:5443
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:3610
int n_gui_double_clicked_widget(const N_GUI_CTX *ctx)
id of the widget the primary press just processed double clicked, or -1.
Definition n_gui.c:3753
void n_gui_widget_set_persist_key(N_GUI_CTX *ctx, int widget_id, const char *key)
Give a widget a stable key so its user-adjustable state (a splitpane's divider ratio,...
Definition n_gui.c:2933
void n_gui_set_double_click_radius(N_GUI_CTX *ctx, int pixels)
how far the pointer may move between the two presses, in pixels (default 4)
Definition n_gui.c:3787
int n_gui_button_get_glyph(N_GUI_CTX *ctx, int widget_id)
current glyph of a button, or N_GUI_GLYPH_NONE when it draws its label (also for a non-button widget)
Definition n_gui.c:2859
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:6763
void n_gui_draw(N_GUI_CTX *ctx)
draw all visible GUI windows and widgets
Definition n_gui.c:11735
void n_gui_progressbar_set_value(N_GUI_CTX *ctx, int widget_id, float value)
set the progress fraction (clamped to 0.0 .
Definition n_gui.c:5662
void n_gui_markdownview_set_on_link(N_GUI_CTX *ctx, int widget_id, void(*on_link)(int widget_id, const char *url, void *user_data), void *user_data)
call on_link when a link in the view is clicked (NULL to stop).
Definition n_gui.c:5913
int n_gui_tree_find_by_user_data(const N_GUI_TREE *tree, const void *ptr)
find the first node whose user_data pointer equals ptr, or -1.
Definition n_gui.c:17803
void n_gui_scrollbar_set_wheel_step(N_GUI_CTX *ctx, int widget_id, double step)
set how far one wheel notch moves a scrollbar, in its content units: 1 for a list whose content is co...
Definition n_gui.c:4323
void n_gui_hexview_set_editable(N_GUI_CTX *ctx, int widget_id, int editable)
make a hex view editable (or read-only again)
Definition n_gui.c:4831
void n_gui_tree_set_selection(N_GUI_TREE *tree, int node_index)
programmatically select a node; ancestors are expanded so the node is visible, and the listbox scroll...
Definition n_gui.c:17781
void n_gui_markdownview_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set the Markdown source (copied; NULL clears it).
Definition n_gui.c:5852
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:17522
void n_gui_tree_set_on_drop(N_GUI_TREE *tree, n_gui_tree_on_drop_t on_drop, void *user_data)
install (or clear, with NULL) a drag-reorder drop callback.
Definition n_gui.c:18038
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:6606
int n_gui_window_get_zorder(N_GUI_CTX *ctx, int window_id)
get window z-order mode
Definition n_gui.c:2468
void n_gui_tree_free(N_GUI_TREE **tree)
free a tree view (does not destroy the N_GUI listbox)
Definition n_gui.c:17898
N_GUI_SECTIONLIST * n_gui_sectionlist_create(N_GUI_CTX *ctx, int window_id, float x, float y0, float width, float header_h, float gap, void(*on_toggle)(int, int, void *), void *user_data)
create an empty section list anchored at (x,y0) in window_id; sections stack downward from y0
Definition n_gui.c:19081
void n_gui_sectionlist_set_order(N_GUI_SECTIONLIST *sl, const int *order, int count)
Stack the sections in another order.
Definition n_gui.c:19243
void n_gui_datagrid_move_column(N_GUI_CTX *ctx, int widget_id, int from, int to)
move the column at display position from to display position to, shifting the columns in between (reo...
Definition n_gui.c:5522
int n_gui_window_get_resize_policy(N_GUI_CTX *ctx, int window_id)
get per-window resize policy
Definition n_gui.c:12145
void n_gui_checkbox_set_checked(N_GUI_CTX *ctx, int widget_id, int checked)
set checkbox checked state
Definition n_gui.c:4251
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:6398
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:12269
int n_gui_tree_get_selection(N_GUI_TREE *tree)
get the index of the currently selected node, or -1 when nothing is selected or the selection points ...
Definition n_gui.c:17774
void n_gui_hexview_set_on_change(N_GUI_CTX *ctx, int widget_id, void(*on_change)(int, const unsigned char *, size_t, void *), void *user_data)
set the callback fired after each edit (NULL to clear)
Definition n_gui.c:4844
int n_gui_tree_node_path(const N_GUI_TREE *tree, int node_index, char *buf, size_t bufsz)
write the path of a node (its label and its ancestors', joined by N_GUI_TREE_PATH_SEP) into buf.
Definition n_gui.c:17921
int n_gui_is_widget_enabled(N_GUI_CTX *ctx, int widget_id)
check if a widget is enabled
Definition n_gui.c:3896
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:3075
float n_gui_listbox_content_width(N_GUI_CTX *ctx, int widget_id)
width in pixels the widest item needs to be drawn in full (text padding included),...
Definition n_gui.c:4532
double n_gui_slider_get_key_step(N_GUI_CTX *ctx, int widget_id)
get the arrow key and wheel increment actually in use for a slider
Definition n_gui.c:4136
N_GUI_THEME n_gui_default_tb_close_theme(void)
return the built-in default theme for the titlebar close button (red hover/active)
Definition n_gui.c:912
char * n_gui_syntaxview_get_selected_text(N_GUI_CTX *ctx, int widget_id)
copy of the currently selected text in a syntax view, or NULL when nothing is selected.
Definition n_gui.c:4984
int n_gui_window_is_open(N_GUI_CTX *ctx, int window_id)
check if window is visible
Definition n_gui.c:2506
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:12386
int n_gui_get_resize_mode(N_GUI_CTX *ctx)
get current resize mode
Definition n_gui.c:12122
void n_gui_slider_set_key_step(N_GUI_CTX *ctx, int widget_id, double step)
set how far one arrow key press or wheel notch moves a slider, without snapping its drag
Definition n_gui.c:4061
float n_gui_markdownview_get_scroll(N_GUI_CTX *ctx, int widget_id)
how far down the content the view is, in pixels
Definition n_gui.c:5903
N_GUI_WIDGET * n_gui_get_widget(N_GUI_CTX *ctx, int widget_id)
get a widget by id
Definition n_gui.c:3701
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:6375
int n_gui_get_focus(const N_GUI_CTX *ctx)
Which widget has the keyboard, or -1 when none has.
Definition n_gui.c:2168
int n_gui_datagrid_get_row_color(N_GUI_CTX *ctx, int widget_id, int row, ALLEGRO_COLOR *out)
report whether data row row carries a background tint (1) or not (0), and copy the tint into out when...
Definition n_gui.c:5409
void n_gui_window_set_wheel_scrollbar(N_GUI_CTX *ctx, int window_id, int scrollbar_id)
make the wheel anywhere over a window move one of its scrollbars, for a window that scrolls its own r...
Definition n_gui.c:2458
N_GUI_WINDOW * n_gui_get_window(N_GUI_CTX *ctx, int window_id)
get a window by id
Definition n_gui.c:1397
int n_gui_add_syntaxview(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int mode)
add a read-only syntax-highlighted text view; returns the widget id or -1
Definition n_gui.c:3410
void n_gui_datagrid_clear_selection(N_GUI_CTX *ctx, int widget_id)
clear the entire selection (no row selected)
Definition n_gui.c:5366
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:6748
int n_gui_slider_get_default(N_GUI_CTX *ctx, int widget_id, double *value)
A slider's default, as n_gui_slider_set_default() gave it.
Definition n_gui.c:4091
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:1277
void n_gui_slider_set_value_visible(N_GUI_CTX *ctx, int widget_id, int visible)
Toggle the built-in value label.
Definition n_gui.c:4156
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:1776
void n_gui_tree_state_free(N_GUI_TREE_STATE *state)
release the strings owned by a saved state (safe on a zeroed struct)
Definition n_gui.c:18023
void n_gui_datagrid_select_row(N_GUI_CTX *ctx, int widget_id, int row, int selected)
select (1) or deselect (0) a single row in a multi-select grid programmatically (e....
Definition n_gui.c:5375
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:11932
N_GUI_CTX * n_gui_new_ctx(ALLEGRO_FONT *default_font)
create a new GUI context
Definition n_gui.c:1103
void n_gui_datagrid_clear_rows(N_GUI_CTX *ctx, int widget_id)
remove all rows from a data grid (columns are kept)
Definition n_gui.c:5268
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:3994
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:4438
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:6716
void n_gui_kvtable_set_row_actions(N_GUI_KVTABLE *table, int enabled)
show (1) or hide (0, the default) the per-row action buttons: move up, move down and duplicate,...
Definition n_gui.c:18897
void n_gui_button_set_glyph(N_GUI_CTX *ctx, int widget_id, int glyph)
draw an N_GUI_GLYPH_* icon (primitives, in the button's text colour) instead of the label; N_GUI_GLYP...
Definition n_gui.c:2843
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:17615
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:2762
int n_gui_kvtable_duplicate_row(N_GUI_KVTABLE *table, int row_index)
insert a copy of the row at row_index directly after it.
Definition n_gui.c:18973
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 (NULL = default: hide window)
Definition n_gui.c:1889
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:12093
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:3056
int n_gui_datagrid_display_to_physical(N_GUI_CTX *ctx, int widget_id, int display_pos)
physical column shown at display position display_pos, or -1 if out of range
Definition n_gui.c:5516
float n_gui_datagrid_get_column_width(N_GUI_CTX *ctx, int widget_id, int col)
current pixel width of physical column col, or 0 if out of range
Definition n_gui.c:5510
void n_gui_tree_toggle_expand(N_GUI_TREE *tree, int node_index)
toggle expand/collapse of a node.
Definition n_gui.c:17836
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:7333
void n_gui_kvtable_set_columns(N_GUI_KVTABLE *table, int show_value, int show_desc, int show_enabled)
choose which optional columns are shown: Value, Description, and the enabled checkbox.
Definition n_gui.c:18875
const char * n_gui_datagrid_get_column_title(N_GUI_CTX *ctx, int widget_id, int col)
header title of physical column col, or "" if out of range
Definition n_gui.c:5486
void(* N_GUI_CUSTOM_DRAW)(N_GUI_WIDGET *widget, float x, float y, ALLEGRO_FONT *font, void *user_data)
Owner-draw callback for a custom widget (N_GUI_TYPE_CUSTOM).
Definition n_gui.h:1184
void n_gui_sectionlist_set_geometry(N_GUI_SECTIONLIST *sl, float x, float y0, float width, float header_h, float gap)
restate where the list stacks from, how wide its headers are and the two heights it stacks with,...
Definition n_gui.c:19167
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:6657
void n_gui_listbox_clear(N_GUI_CTX *ctx, int widget_id)
clear all items from a listbox
Definition n_gui.c:4406
float n_gui_dropmenu_panel_width(N_GUI_CTX *ctx, int widget_id)
width the open panel needs to show its entries without truncation: the larger of the collapsed button...
Definition n_gui.c:6565
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:3241
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:106
void n_gui_textarea_set_suggest(N_GUI_CTX *ctx, int widget_id, N_GUI_SUGGEST_FN fn, const char *separators, void *user_data)
offer completions in a textarea
Definition n_gui.c:12852
void n_gui_destroy_ctx(N_GUI_CTX **ctx)
destroy a GUI context and free all resources
Definition n_gui.c:1209
int n_gui_window_is_minimised(N_GUI_CTX *ctx, int window_id)
check if a window is currently minimised
Definition n_gui.c:1485
void n_gui_restore_window(N_GUI_CTX *ctx, int window_id)
restore a minimised window to its full size
Definition n_gui.c:1472
void n_gui_checkbox_set_label(N_GUI_CTX *ctx, int widget_id, const char *label)
Replace the text drawn beside a checkbox.
Definition n_gui.c:4261
const char * n_gui_textarea_get_text(N_GUI_CTX *ctx, int widget_id)
get text area content
Definition n_gui.c:4196
const char * n_gui_markdownview_get_text(N_GUI_CTX *ctx, int widget_id)
the Markdown source, owned by the widget, or NULL
Definition n_gui.c:5867
void n_gui_slider_set_default(N_GUI_CTX *ctx, int widget_id, double value)
Give a slider a default value, which a double click on it puts back.
Definition n_gui.c:4075
int n_gui_splitpane_at(N_GUI_CTX *ctx, float x, float y)
report the split pane whose divider band is under a point, or -1.
Definition n_gui.c:13570
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:18750
int n_gui_get_shape_mode(N_GUI_CTX *ctx)
get the global widget shape (N_GUI_SHAPE_ROUNDED or N_GUI_SHAPE_RECT)
Definition n_gui.c:12371
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:6641
int n_gui_sectionlist_add_widget(N_GUI_SECTIONLIST *sl, int section_index, int widget_id)
register an existing widget as a member of a section (captures its current y as the fold offset).
Definition n_gui.c:19120
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:4509
float n_gui_progressbar_get_value(N_GUI_CTX *ctx, int widget_id)
get the current progress fraction (0.0 on an invalid widget)
Definition n_gui.c:5673
int n_gui_sectionlist_get_count(const N_GUI_SECTIONLIST *sl)
number of sections in the list
Definition n_gui.c:19300
#define N_GUI_TEXT_MAX
maximum length for textarea content
Definition n_gui.h:88
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:7294
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:7389
void n_gui_open_window(N_GUI_CTX *ctx, int window_id)
open (show) a window
Definition n_gui.c:1436
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:2478
ALLEGRO_DISPLAY * n_gui_window_get_display(N_GUI_CTX *ctx, int window_id)
get the native display backing a window, or NULL when it is a pop-up
Definition n_gui.c:1818
int n_gui_textarea_has_selection(N_GUI_CTX *ctx, int widget_id)
is any text selected in a text area (0 for no selection or a bad id)
Definition n_gui.c:7409
int n_gui_get_key_modifiers(const N_GUI_CTX *ctx)
the modifier keys held down now, as the GUI has seen them
Definition n_gui.c:13281
int n_gui_sectionlist_add_section(N_GUI_SECTIONLIST *sl, const char *title, float header_y, int folded)
add a section with a header button at header_y (members added next are captured relative to it); retu...
Definition n_gui.c:19100
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:6463
void n_gui_window_set_content_draw_callback(N_GUI_CTX *ctx, int window_id, void(*on_content_draw)(int, void *), void *user_data)
set a content-draw callback for a window, invoked during n_gui_draw right after the window's own cont...
Definition n_gui.c:1904
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:17682
int n_gui_listbox_get_count(N_GUI_CTX *ctx, int widget_id)
get number of items in a listbox
Definition n_gui.c:4423
int n_gui_sectionlist_is_section_hidden(const N_GUI_SECTIONLIST *sl, int section_index)
Is a section left out of the stack.
Definition n_gui.c:19273
int n_gui_window_set_native_icons(N_GUI_CTX *ctx, int window_id, ALLEGRO_BITMAP **icons, int num_icons)
give a detached window's OS window a taskbar / title bar icon
Definition n_gui.c:1856
void n_gui_dropmenu_set_label(N_GUI_CTX *ctx, int widget_id, const char *label)
replace the button label shown on a dropmenu (NULL clears it)
Definition n_gui.c:6360
void n_gui_custom_set_destroy(N_GUI_CTX *ctx, int widget_id, void(*destroy)(void *user_data))
hand a custom widget's paint user pointer to the widget
Definition n_gui.c:5745
int n_gui_sectionlist_get_order(const N_GUI_SECTIONLIST *sl, int position)
The section stacked at a position.
Definition n_gui.c:19262
void n_gui_tree_draw_overlay(N_GUI_TREE *tree)
per-frame overlay drawing: draws the active drop-indicator on top of the listbox.
Definition n_gui.c:18195
const char * n_gui_checkbox_get_label(N_GUI_CTX *ctx, int widget_id)
What a checkbox says.
Definition n_gui.c:4276
float n_gui_markdownview_content_height(N_GUI_CTX *ctx, int widget_id)
the height of the whole document at the width it was last drawn at, or 0 before the first draw
Definition n_gui.c:5908
void n_gui_close_menus(N_GUI_CTX *ctx)
Put away any open combo box list or drop menu panel.
Definition n_gui.c:2334
const char * n_gui_combobox_get_item_text(N_GUI_CTX *ctx, int widget_id, int index)
get the text of the combobox item at index ("" if out of range / not a combobox)
Definition n_gui.c:6042
int n_gui_count_detached(N_GUI_CTX *ctx)
count the windows currently detached into native OS windows
Definition n_gui.c:1843
int n_gui_textarea_suggest_is_open(N_GUI_CTX *ctx, int widget_id)
is a textarea's completion panel up
Definition n_gui.c:12871
void n_gui_dropmenu_set_flags(N_GUI_CTX *ctx, int widget_id, int flags)
set dropmenu feature flags (bitmask of N_GUI_DROPMENU_* values)
Definition n_gui.c:6341
int n_gui_get_cursor(N_GUI_CTX *ctx, ALLEGRO_MOUSE_CURSOR **custom)
The cursor the GUI last applied to the display.
Definition n_gui.c:491
int n_gui_label_fits(N_GUI_CTX *ctx, int widget_id, float *needed_w, float *needed_h)
report whether a label's text is drawn in full inside its own box, and how big it would have to be to...
Definition n_gui.c:6215
void n_gui_splitpane_set_ratio(N_GUI_CTX *ctx, int widget_id, float ratio)
set the divider ratio (clamped to the configured min/max)
Definition n_gui.c:4600
int n_gui_checkbox_is_checked(N_GUI_CTX *ctx, int widget_id)
check if checkbox is checked
Definition n_gui.c:4237
int n_gui_label_get_truncate(N_GUI_CTX *ctx, int widget_id)
the label's truncate mode, N_GUI_TRUNCATE_END when it is not a label
Definition n_gui.c:6169
void n_gui_splitpane_set_limits(N_GUI_CTX *ctx, int widget_id, float min_ratio, float max_ratio)
set the minimum and maximum allowed divider ratio
Definition n_gui.c:4616
void n_gui_set_default_theme(N_GUI_CTX *ctx, N_GUI_THEME theme)
Set the default theme on a context and sync scrollbar style colors.
Definition n_gui.c:919
int n_gui_combobox_get_selected(N_GUI_CTX *ctx, int widget_id)
get the selected item index
Definition n_gui.c:6034
void n_gui_tree_remove_node(N_GUI_TREE *tree, int node_index)
remove a node and its entire subtree; remaining node indices are compacted (callers holding indices a...
Definition n_gui.c:17712
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:6134
const char * n_gui_button_get_label(N_GUI_CTX *ctx, int widget_id)
What a button says.
Definition n_gui.c:2124
int n_gui_tree_state_save(const N_GUI_TREE *tree, N_GUI_TREE_STATE *out)
capture which nodes are expanded, which one is selected, and where the view is scrolled,...
Definition n_gui.c:17962
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 in the context.
Definition n_gui.c:17108
int n_gui_window_is_maximised(N_GUI_CTX *ctx, int window_id)
check if a window is currently maximised
Definition n_gui.c:1574
int n_gui_datagrid_add_row(N_GUI_CTX *ctx, int widget_id, const char **values)
append a row of cell strings (values must have one entry per column); returns the row index or -1
Definition n_gui.c:5210
void n_gui_syntaxview_set_text(N_GUI_CTX *ctx, int widget_id, const char *text)
set (copy) the text shown by a syntax view; text may be NULL to clear
Definition n_gui.c:4913
void n_gui_slider_set_value(N_GUI_CTX *ctx, int widget_id, double value)
set slider value
Definition n_gui.c:3976
int n_gui_datagrid_get_sort(N_GUI_CTX *ctx, int widget_id, int *col, int *dir)
read back the sort a datagrid is currently showing.
Definition n_gui.c:5542
void n_gui_tree_set_expand_callback(N_GUI_TREE *tree, void(*on_expand)(int node_index, void *user_data), void *user_data)
set the callback that fills a node the first time it is opened, for a tree too large to build before ...
Definition n_gui.c:17852
int n_gui_sectionlist_is_folded(const N_GUI_SECTIONLIST *sl, int section_index)
query a section's folded state (1 = folded, 0 = expanded)
Definition n_gui.c:19284
void n_gui_datagrid_set_column_width(N_GUI_CTX *ctx, int widget_id, int col, float width)
set the pixel width of physical column col (clamped to a small minimum)
Definition n_gui.c:5504
void n_gui_syntaxview_scroll_to_offset(N_GUI_CTX *ctx, int widget_id, int byte_offset)
scroll a syntax view so the line holding the given byte offset is vertically centered,...
Definition n_gui.c:5044
void n_gui_datagrid_set_column_visible(N_GUI_CTX *ctx, int widget_id, int col, int visible)
show (1) or hide (0) physical column col; hidden columns keep their cells but are skipped in the head...
Definition n_gui.c:5492
void n_gui_sectionlist_set_first_inset(N_GUI_SECTIONLIST *sl, float inset)
set a left inset applied to the FIRST section's header only, so a caller can place a button before it...
Definition n_gui.c:19176
void n_gui_sectionlist_set_section_hidden(N_GUI_SECTIONLIST *sl, int section_index, int hidden)
Leave a whole section out of the stack, header and members, or put it back.
Definition n_gui.c:19267
void n_gui_radiolist_set_selected(N_GUI_CTX *ctx, int widget_id, int index)
set the selected item index
Definition n_gui.c:5981
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:2515
float n_gui_syntaxview_content_width(N_GUI_CTX *ctx, int widget_id)
pixel width the widest line of a syntax view needs, padding included
Definition n_gui.c:5095
void(* N_GUI_SUGGEST_FN)(const char *prefix, N_GUI_SUGGEST_SINK *sink, void *user_data)
asked for the completions of what has been typed so far
Definition n_gui.h:613
int n_gui_combobox_remove_item(N_GUI_CTX *ctx, int widget_id, int index)
remove the item at index from a combobox.
Definition n_gui.c:6087
void n_gui_set_widget_visible(N_GUI_CTX *ctx, int widget_id, int visible)
set widget visibility
Definition n_gui.c:3828
void n_gui_syntaxview_select_all(N_GUI_CTX *ctx, int widget_id)
select the entire text of a syntax view
Definition n_gui.c:5031
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:17500
void n_gui_mark_dirty(N_GUI_CTX *ctx)
Mark the GUI as needing a redraw.
Definition n_gui.c:1188
#define N_GUI_ID_MAX
maximum length for widget id/name strings
Definition n_gui.h:86
N_GUI_STYLE n_gui_default_style(void)
return the built-in default style
Definition n_gui.c:949
#define N_GUI_TAB_MAX
maximum number of tabs in a single tab panel
Definition n_gui.h:3321
void n_gui_datagrid_clear_row_colors(N_GUI_CTX *ctx, int widget_id)
remove every row background tint (the rows and cells are kept)
Definition n_gui.c:5419
void n_gui_window_set_maximize_callback(N_GUI_CTX *ctx, int window_id, void(*on_maximize)(int, void *), void *user_data)
set the maximize button callback for a window (NULL = default: toggle maximised)
Definition n_gui.c:1926
void n_gui_tab_relayout(N_GUI_TAB_PANEL *panel, float x, float y, float button_w, float button_h)
move/resize the button row after creation (a host-owned or resizable layout); pass <= 0 for button_w ...
Definition n_gui.c:17576
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:4338
int n_gui_window_from_display(N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display)
find the window detached into a given display
Definition n_gui.c:1830
void n_gui_set_cursor(N_GUI_CTX *ctx, int system_shape, ALLEGRO_MOUSE_CURSOR *custom)
Say which mouse cursor the application wants.
Definition n_gui.c:479
void n_gui_markdownview_set_fonts(N_GUI_CTX *ctx, int widget_id, const N_GUI_MD_FONTS *fonts)
replace the faces; the new ones are borrowed on the same terms
Definition n_gui.c:5872
int n_gui_menu_is_open(const N_GUI_CTX *ctx)
Is a combo box's list or a drop menu's panel currently open.
Definition n_gui.c:2326
float n_gui_splitpane_band(N_GUI_CTX *ctx, int widget_id)
How far either side of a split pane's divider a press still counts as the divider's.
Definition n_gui.c:13574
void n_gui_tree_expand(N_GUI_TREE *tree, int node_index)
open a node, filling it first through the expand callback if it has not been; a node already open sta...
Definition n_gui.c:17846
void n_gui_textarea_set_placeholder(N_GUI_CTX *ctx, int widget_id, const char *text)
set placeholder/hint text for a textarea, shown dimmed while the field is empty and cleared from view...
Definition n_gui.c:6683
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:3162
void n_gui_sectionlist_free(N_GUI_SECTIONLIST **sl)
free the section list (does not destroy the N_GUI widgets or window)
Definition n_gui.c:19304
void n_gui_textarea_suggest_close(N_GUI_CTX *ctx, int widget_id)
put a textarea's completion panel away
Definition n_gui.c:12878
float n_gui_slider_value_width(N_GUI_CTX *ctx, int widget_id)
width in pixels a slider's built-in readout needs beside it, the gap between track and text included.
Definition n_gui.c:4163
int n_gui_datagrid_get_selected(N_GUI_CTX *ctx, int widget_id)
get the selected row index, or -1 if none
Definition n_gui.c:5300
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:4473
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:12158
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:3207
void n_gui_combobox_clear(N_GUI_CTX *ctx, int widget_id)
remove all items from a combobox
Definition n_gui.c:5998
void n_gui_sectionlist_relayout(N_GUI_SECTIONLIST *sl)
re-stack all sections from y0 by current fold state: hide folded members, show and reposition expande...
Definition n_gui.c:19181
int n_gui_was_double_click(const N_GUI_CTX *ctx, int widget_id)
whether the press just processed double clicked this particular widget
Definition n_gui.c:3764
int n_gui_datagrid_get_column_visible(N_GUI_CTX *ctx, int widget_id, int col)
whether physical column col is visible (1) or hidden (0); 0 if out of range
Definition n_gui.c:5498
void n_gui_combobox_set_selected(N_GUI_CTX *ctx, int widget_id, int index)
set the selected item index
Definition n_gui.c:6116
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:4382
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:825
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:6297
void n_gui_window_set_rect_axes(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int scale_x, int scale_y)
n_gui_window_set_rect with per-axis reflow control.
Definition n_gui.c:12223
int n_gui_add_datagrid(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 sortable data grid; returns the widget id or -1
Definition n_gui.c:3460
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:12072
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:2720
size_t n_gui_hexview_get_cursor(N_GUI_CTX *ctx, int widget_id)
the byte offset the edit cursor sits on
Definition n_gui.c:4887
void n_gui_set_event_queue(N_GUI_CTX *ctx, ALLEGRO_EVENT_QUEUE *queue)
give the context the event queue it registers native window event sources into
Definition n_gui.c:1586
int n_gui_add_custom(N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, N_GUI_CUSTOM_DRAW draw, void *user_data)
Add an owner-draw custom widget to a window.
Definition n_gui.c:5698
#define N_GUI_KEY_SOURCES_MAX
maximum number of source widgets for a focused key binding
Definition n_gui.h:443
const char * n_gui_label_get_text(N_GUI_CTX *ctx, int widget_id)
What a label says now.
Definition n_gui.c:6175
void n_gui_tree_tick(N_GUI_TREE *tree)
per-frame poll: reads ctx->mouse_* to track drag state and fires the on_drop callback on release.
Definition n_gui.c:18133
void n_gui_reset_all_widget_themes(N_GUI_CTX *ctx)
reset all widget and window themes to ctx->default_theme
Definition n_gui.c:3809
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:2563
int n_gui_widget_is_visible(N_GUI_CTX *ctx, int widget_id)
Is a widget currently shown.
Definition n_gui.c:2316
void n_gui_scrollbar_set_pos(N_GUI_CTX *ctx, int widget_id, double pos)
set scrollbar position
Definition n_gui.c:4307
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:6423
button specific data
Definition n_gui.h:480
checkbox specific data
Definition n_gui.h:677
combo box specific data
Definition n_gui.h:952
The top-level GUI context that holds all windows.
Definition n_gui.h:1669
Owner-draw custom widget data: a paint callback, an optional mouse callback, and their user pointers.
Definition n_gui.h:1229
one data grid column definition
Definition n_gui.h:845
data grid specific data: a sortable column table
Definition n_gui.h:855
dropdown menu specific data
Definition n_gui.h:1053
A single entry in a dropdown menu (static or dynamic).
Definition n_gui.h:1033
hex viewer specific data: a read-only byte dump
Definition n_gui.h:781
image widget specific data
Definition n_gui.h:989
a single row in the KV table
Definition n_gui.h:3627
key-value table built from textareas, checkboxes, and buttons.
Definition n_gui.h:3643
static text label specific data
Definition n_gui.h:997
listbox specific data
Definition n_gui.h:724
a single item in a list/radio/combo widget
Definition n_gui.h:576
markdownview specific data.
Definition n_gui.h:1147
A mouse event handed to a custom widget, in the widget's own coordinates.
Definition n_gui.h:1200
A saved window position retained for a window not yet created at load time (see N_GUI_CTX::pending_la...
Definition n_gui.h:1639
Saved user-adjustable state for a keyed widget that did not exist when the layout was loaded (a lazil...
Definition n_gui.h:1656
Progress-bar widget data (display only).
Definition n_gui.h:1025
radio list specific data
Definition n_gui.h:917
Where a scrollbar a widget draws inside itself was last painted, and whether the pointer is on it.
Definition n_gui.h:463
scrollbar specific data
Definition n_gui.h:695
a single foldable section: a clickable header plus the member widgets it shows/hides
Definition n_gui.h:3366
a vertical accordion of foldable sections inside one window; folding hides a section's widgets and re...
Definition n_gui.h:3380
slider specific data
Definition n_gui.h:526
split pane specific data: a draggable divider between two regions
Definition n_gui.h:763
Global style holding every configurable layout constant.
Definition n_gui.h:1454
syntax view specific data: read-only highlighted text
Definition n_gui.h:805
tab panel built from toggle buttons with content window management
Definition n_gui.h:3324
Titlebar button state for a window (minimize, maximize, close).
Definition n_gui.h:1246
bounding box dimensions returned by n_gui_get_text_dims()
Definition n_gui.h:374
text area specific data
Definition n_gui.h:616
Color theme for a widget.
Definition n_gui.h:384
tree view built from an N_GUI listbox
Definition n_gui.h:3495
a single node in the tree view
Definition n_gui.h:3469
A tree's view state, captured by path so it survives a rebuild that replaces every node (a reloaded m...
Definition n_gui.h:3532
A single GUI widget.
Definition n_gui.h:1092
A pseudo window that contains widgets.
Definition n_gui.h:1298
structure of a hash table
Definition n_hash.h:138
Structure of a generic LIST container.
Definition n_list.h:59
Allegro5 helpers.
Common headers and low-level functions & define.
handle textarea key input.
Definition n_gui.c:12700
Lay out and draw n_markdown's block model with Allegro fonts.
The faces a render uses.
Definition n_gui_md.h:65
Colours and metrics.
Definition n_gui_md.h:87
Hash functions and table.
List structures and definitions.
Generic log system.
N_STR and string function declaration.