Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
GUI: allegro5 widget system with pseudo-windows

Data Structures

struct  N_GUI_BUTTON_DATA
 button specific data More...
 
struct  N_GUI_CHECKBOX_DATA
 checkbox specific data More...
 
struct  N_GUI_COMBOBOX_DATA
 combo box specific data More...
 
struct  N_GUI_CTX
 The top-level GUI context that holds all windows. More...
 
struct  N_GUI_DROPMENU_DATA
 dropdown menu specific data More...
 
struct  N_GUI_DROPMENU_ENTRY
 A single entry in a dropdown menu (static or dynamic) More...
 
struct  N_GUI_IMAGE_DATA
 image widget specific data More...
 
struct  N_GUI_KV_ROW
 a single row in the KV table More...
 
struct  N_GUI_KVTABLE
 key-value table built from textareas, checkboxes, and buttons More...
 
struct  N_GUI_LABEL_DATA
 static text label specific data More...
 
struct  N_GUI_LISTBOX_DATA
 listbox specific data More...
 
struct  N_GUI_LISTITEM
 a single item in a list/radio/combo widget More...
 
struct  N_GUI_RADIOLIST_DATA
 radio list specific data More...
 
struct  N_GUI_SCROLLBAR_DATA
 scrollbar specific data More...
 
struct  N_GUI_SLIDER_DATA
 slider specific data More...
 
struct  N_GUI_STYLE
 Global style holding every configurable layout constant. More...
 
struct  N_GUI_TAB_PANEL
 tab panel built from toggle buttons with content window management More...
 
struct  N_GUI_TEXT_DIMS
 bounding box dimensions returned by n_gui_get_text_dims() More...
 
struct  N_GUI_TEXTAREA_DATA
 text area specific data More...
 
struct  N_GUI_THEME
 Color theme for a widget. More...
 
struct  N_GUI_TREE
 tree view built from an N_GUI listbox More...
 
struct  N_GUI_TREE_NODE
 a single node in the tree view More...
 
struct  N_GUI_WIDGET
 A single GUI widget. More...
 
struct  N_GUI_WINDOW
 A pseudo window that contains widgets. More...
 

Macros

#define N_GUI_ALIGN_CENTER   1
 center aligned text
 
#define N_GUI_ALIGN_JUSTIFIED   3
 justified text (spread words to fill width)
 
#define N_GUI_ALIGN_LEFT   0
 left aligned text
 
#define N_GUI_ALIGN_RIGHT   2
 right aligned text
 
#define N_GUI_AUTOFIT_CENTER   16
 center the window on its insertion point after auto-fit (overrides EXPAND_LEFT/EXPAND_UP for centering)
 
#define N_GUI_AUTOFIT_EXPAND_LEFT   4
 expand leftward instead of rightward when adjusting width
 
#define N_GUI_AUTOFIT_EXPAND_UP   8
 expand upward instead of downward when adjusting height
 
#define N_GUI_AUTOFIT_H   2
 auto-adjust window height to content
 
#define N_GUI_AUTOFIT_W   1
 auto-adjust window width to content
 
#define N_GUI_AUTOFIT_WH   3
 auto-adjust both width and height (convenience: W|H)
 
#define N_GUI_COMBOBOX_AUTO_WIDTH   1
 dropdown panel expands to fit the longest item text
 
#define N_GUI_ID_MAX   128
 maximum length for widget id/name strings
 
#define N_GUI_IMAGE_CENTER   2
 draw at original size, centered
 
#define N_GUI_IMAGE_FIT   0
 scale to fit within bounds, keep aspect ratio
 
#define N_GUI_IMAGE_STRETCH   1
 stretch to fill bounds
 
#define N_GUI_KEY_MOD_MASK   (ALLEGRO_KEYMOD_SHIFT | ALLEGRO_KEYMOD_CTRL | ALLEGRO_KEYMOD_ALT | ALLEGRO_KEYMOD_ALTGR)
 mask of supported modifier flags for button keybind matching
 
#define N_GUI_KEY_SOURCES_MAX   8
 maximum number of source widgets for a focused key binding
 
#define N_GUI_KV_MAX   128
 maximum number of rows in a KV table
 
#define N_GUI_RESIZE_ADAPTIVE   1
 virtual size tracks display; windows adapt per their resize_policy
 
#define N_GUI_RESIZE_VIRTUAL   0
 fixed virtual canvas with uniform scaling (default/existing behavior)
 
#define N_GUI_SCROLLBAR_H   0
 horizontal scrollbar
 
#define N_GUI_SCROLLBAR_V   1
 vertical scrollbar
 
#define N_GUI_SELECT_MULTIPLE   2
 multiple item selection
 
#define N_GUI_SELECT_NONE   0
 no selection allowed (display only)
 
#define N_GUI_SELECT_SINGLE   1
 single item selection
 
#define N_GUI_SHAPE_BITMAP   2
 bitmap-based rendering
 
#define N_GUI_SHAPE_RECT   0
 rectangle shape (default)
 
#define N_GUI_SHAPE_ROUNDED   1
 rounded rectangle shape
 
#define N_GUI_SLIDER_H   0
 horizontal slider (default)
 
#define N_GUI_SLIDER_PERCENT   1
 slider uses 0-100 percentage
 
#define N_GUI_SLIDER_V   1
 vertical slider
 
#define N_GUI_SLIDER_VALUE   0
 slider uses raw start/end values
 
#define N_GUI_STATE_ACTIVE   2
 widget is being pressed / dragged
 
#define N_GUI_STATE_FOCUSED   4
 widget has keyboard focus
 
#define N_GUI_STATE_HOVER   1
 mouse is hovering the widget
 
#define N_GUI_STATE_IDLE   0
 widget is idle / normal state
 
#define N_GUI_STATE_SCROLLBAR_DRAG   8
 widget scrollbar is being dragged
 
#define N_GUI_TAB_MAX   16
 maximum number of tabs in a single tab panel
 
#define N_GUI_TEXT_MAX   4096
 maximum length for textarea content
 
#define N_GUI_TREE_MAX   512
 maximum number of nodes in a tree view
 
#define N_GUI_TYPE_BUTTON   1
 widget type: button
 
#define N_GUI_TYPE_CHECKBOX   4
 widget type: checkbox
 
#define N_GUI_TYPE_COMBOBOX   8
 widget type: combo box (dropdown)
 
#define N_GUI_TYPE_DROPMENU   11
 widget type: dropdown menu with static and dynamic entries
 
#define N_GUI_TYPE_IMAGE   9
 widget type: image display
 
#define N_GUI_TYPE_LABEL   10
 widget type: static text label (with optional hyperlink)
 
#define N_GUI_TYPE_LISTBOX   6
 widget type: listbox (selectable list)
 
#define N_GUI_TYPE_RADIOLIST   7
 widget type: radio list (single select radio buttons)
 
#define N_GUI_TYPE_SCROLLBAR   5
 widget type: scrollbar
 
#define N_GUI_TYPE_SLIDER   2
 widget type: slider
 
#define N_GUI_TYPE_TEXTAREA   3
 widget type: text area
 
#define N_GUI_WIN_AUTO_SCROLLBAR   16
 enable automatic scrollbars when content exceeds window size
 
#define N_GUI_WIN_DRAGGING   4
 window is being dragged
 
#define N_GUI_WIN_FIXED_POSITION   64
 disable window dragging (default:enable)
 
#define N_GUI_WIN_FRAMELESS   128
 frameless window: no title bar drawn, drag via window body unless N_GUI_WIN_FIXED_POSITION is also set
 
#define N_GUI_WIN_HSCROLL_DRAG   32
 window horizontal auto-scrollbar is being dragged
 
#define N_GUI_WIN_MINIMISED   2
 window is minimised (title bar only)
 
#define N_GUI_WIN_OPEN   1
 window is visible
 
#define N_GUI_WIN_RESIZABLE   32
 enable user-resizable window with a drag handle at bottom-right
 
#define N_GUI_WIN_RESIZE_MOVE   1
 reposition proportionally, keep pixel size
 
#define N_GUI_WIN_RESIZE_NONE   0
 no adaptation: absolute position and size unchanged
 
#define N_GUI_WIN_RESIZE_SCALE   2
 reposition AND resize proportionally, child widgets scale too
 
#define N_GUI_WIN_RESIZING   8
 window is being resized
 
#define N_GUI_WIN_VSCROLL_DRAG   16
 window vertical auto-scrollbar is being dragged
 
#define N_GUI_ZORDER_ALWAYS_BEHIND   2
 always drawn behind normal windows, cannot be raised above them
 
#define N_GUI_ZORDER_ALWAYS_ON_TOP   1
 always drawn on top of normal windows, cannot be lowered behind them
 
#define N_GUI_ZORDER_FIXED   3
 fixed z-value: window is sorted within a dedicated group between ALWAYS_BEHIND and NORMAL windows.
 
#define N_GUI_ZORDER_NORMAL   0
 default z-order: window participates in normal raise/lower ordering
 

Functions

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
 
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
 
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
 
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
 
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)
 
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
 
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
 
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
 
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
 
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
 
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
 
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
 
int n_gui_add_textarea (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int multiline, size_t char_limit, void(*on_change)(int, const char *, void *), void *user_data)
 add a text area widget
 
int n_gui_add_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)
 
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)
 
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
 
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 adding all widgets)
 
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 dimensions.
 
int n_gui_button_is_toggled (N_GUI_CTX *ctx, int widget_id)
 check if button is toggled
 
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.
 
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.
 
void n_gui_button_set_toggle_mode (N_GUI_CTX *ctx, int widget_id, int toggle_mode)
 set button toggle mode
 
void n_gui_button_set_toggled (N_GUI_CTX *ctx, int widget_id, int toggled)
 set button toggled state
 
int n_gui_checkbox_is_checked (N_GUI_CTX *ctx, int widget_id)
 check if checkbox is checked
 
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.
 
void n_gui_checkbox_set_checked (N_GUI_CTX *ctx, int widget_id, int checked)
 set checkbox checked state
 
void n_gui_close_window (N_GUI_CTX *ctx, int window_id)
 close (hide) a window
 
int n_gui_combobox_add_item (N_GUI_CTX *ctx, int widget_id, const char *text)
 add an item to a combo box
 
void n_gui_combobox_clear (N_GUI_CTX *ctx, int widget_id)
 remove all items from a combobox
 
int n_gui_combobox_get_selected (N_GUI_CTX *ctx, int widget_id)
 get the selected item index
 
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.
 
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)
 
void n_gui_combobox_set_selected (N_GUI_CTX *ctx, int widget_id, int index)
 set the selected item index
 
N_GUI_STYLE n_gui_default_style (void)
 return the built-in default style
 
N_GUI_THEME n_gui_default_theme (void)
 return the built-in default theme
 
void n_gui_destroy_ctx (N_GUI_CTX **ctx)
 destroy a GUI context and free all resources
 
float n_gui_detect_dpi_scale (N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display)
 detect and apply DPI scale from the given allegro display.
 
void n_gui_draw (N_GUI_CTX *ctx)
 draw all visible GUI windows and widgets
 
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)
 
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
 
void n_gui_dropmenu_clear (N_GUI_CTX *ctx, int widget_id)
 remove all entries
 
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)
 
int n_gui_dropmenu_get_count (N_GUI_CTX *ctx, int widget_id)
 get number of entries
 
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.
 
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
 
float n_gui_get_dpi_scale (const N_GUI_CTX *ctx)
 get current DPI scale factor
 
int n_gui_get_resize_mode (N_GUI_CTX *ctx)
 get current resize mode
 
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.
 
N_GUI_WIDGETn_gui_get_widget (N_GUI_CTX *ctx, int widget_id)
 get a widget by id
 
N_GUI_WINDOWn_gui_get_window (N_GUI_CTX *ctx, int window_id)
 get a window by id
 
void n_gui_image_set_bitmap (N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bitmap)
 set the bitmap on an image widget
 
int n_gui_is_widget_enabled (N_GUI_CTX *ctx, int widget_id)
 check if a widget is enabled
 
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
 
N_GUI_KVTABLEn_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
 
void n_gui_kvtable_free (N_GUI_KVTABLE **table)
 free a KV table (does not destroy the N_GUI widgets)
 
int n_gui_kvtable_get_count (N_GUI_KVTABLE *table)
 get the number of active rows
 
void n_gui_kvtable_remove_row (N_GUI_KVTABLE *table, int row_index)
 remove a row by index (hides widgets, marks inactive)
 
void n_gui_label_set_bitmap (N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg)
 set optional background bitmap on a label widget.
 
void n_gui_label_set_link (N_GUI_CTX *ctx, int widget_id, const char *link)
 set label hyperlink URL
 
void n_gui_label_set_text (N_GUI_CTX *ctx, int widget_id, const char *text)
 set label text content
 
int n_gui_listbox_add_item (N_GUI_CTX *ctx, int widget_id, const char *text)
 add an item to a listbox
 
void n_gui_listbox_clear (N_GUI_CTX *ctx, int widget_id)
 clear all items from a listbox
 
int n_gui_listbox_get_count (N_GUI_CTX *ctx, int widget_id)
 get number of items in a listbox
 
const char * n_gui_listbox_get_item_text (N_GUI_CTX *ctx, int widget_id, int index)
 get item text by index
 
int n_gui_listbox_get_scroll_offset (N_GUI_CTX *ctx, int widget_id)
 get the current scroll offset (in items)
 
int n_gui_listbox_get_selected (N_GUI_CTX *ctx, int widget_id)
 get the first selected item index
 
int n_gui_listbox_is_selected (N_GUI_CTX *ctx, int widget_id, int index)
 check if an item is selected
 
int n_gui_listbox_remove_item (N_GUI_CTX *ctx, int widget_id, int index)
 remove an item from a listbox by index
 
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.
 
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
 
void n_gui_listbox_set_selected (N_GUI_CTX *ctx, int widget_id, int index, int selected)
 set item selection state
 
int n_gui_load_theme_json (N_GUI_CTX *ctx, const char *filepath)
 Load a JSON theme file and apply it to the context.
 
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)
 
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
 
void n_gui_minimize_window (N_GUI_CTX *ctx, int window_id)
 minimize a window (title bar only)
 
N_GUI_CTXn_gui_new_ctx (ALLEGRO_FONT *default_font)
 create a new GUI context
 
void n_gui_open_window (N_GUI_CTX *ctx, int window_id)
 open (show) a window
 
int n_gui_process_event (N_GUI_CTX *ctx, ALLEGRO_EVENT event)
 process an allegro event for the GUI
 
int n_gui_radiolist_add_item (N_GUI_CTX *ctx, int widget_id, const char *text)
 add an item to a radio list
 
void n_gui_radiolist_clear (N_GUI_CTX *ctx, int widget_id)
 remove all items from a radio list
 
int n_gui_radiolist_get_selected (N_GUI_CTX *ctx, int widget_id)
 get the selected item index
 
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.
 
void n_gui_radiolist_set_selected (N_GUI_CTX *ctx, int widget_id, int index)
 set the selected item index
 
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)
 
int n_gui_save_theme_json (N_GUI_CTX *ctx, const char *filepath)
 Save the full theme (default_theme + style) to a JSON file.
 
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.
 
double n_gui_scrollbar_get_pos (N_GUI_CTX *ctx, int widget_id)
 get scrollbar position
 
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.
 
void n_gui_scrollbar_set_pos (N_GUI_CTX *ctx, int widget_id, double pos)
 set scrollbar position
 
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
 
void n_gui_set_display (N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display)
 set the display pointer for clipboard operations (copy/paste)
 
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.
 
void n_gui_set_dpi_scale (N_GUI_CTX *ctx, float scale)
 set DPI scale factor manually (default is 1.0).
 
void n_gui_set_focus (N_GUI_CTX *ctx, int widget_id)
 set keyboard focus to a specific widget (-1 to clear focus)
 
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
 
void n_gui_set_virtual_size (N_GUI_CTX *ctx, float w, float h)
 set the virtual canvas size for resolution-independent scaling.
 
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)
 
void n_gui_set_widget_theme (N_GUI_CTX *ctx, int widget_id, N_GUI_THEME theme)
 set the theme on a widget
 
void n_gui_set_widget_visible (N_GUI_CTX *ctx, int widget_id, int visible)
 set widget visibility
 
double n_gui_slider_get_value (N_GUI_CTX *ctx, int widget_id)
 get slider current value
 
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.
 
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
 
void n_gui_slider_set_step (N_GUI_CTX *ctx, int widget_id, double step)
 set slider step increment (0 is treated as 1).
 
void n_gui_slider_set_value (N_GUI_CTX *ctx, int widget_id, double value)
 set slider value
 
int n_gui_tab_add (N_GUI_TAB_PANEL *panel, const char *label)
 add a tab to the panel, returns tab index
 
N_GUI_TAB_PANELn_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
 
void n_gui_tab_free (N_GUI_TAB_PANEL **panel)
 free a tab panel (does not destroy the N_GUI widgets)
 
int n_gui_tab_get_active (N_GUI_TAB_PANEL *panel)
 get the active tab index
 
void n_gui_tab_set_active (N_GUI_TAB_PANEL *panel, int index)
 set the active tab (toggles buttons, opens/closes content windows)
 
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
 
const char * n_gui_textarea_get_text (N_GUI_CTX *ctx, int widget_id)
 get text area content
 
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)
 
void n_gui_textarea_scroll_to_bottom (N_GUI_CTX *ctx, int widget_id)
 scroll a multiline textarea to the bottom
 
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
 
void n_gui_textarea_set_bitmap (N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg)
 set optional background bitmap on a textarea widget.
 
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.
 
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)
 
void n_gui_textarea_set_text (N_GUI_CTX *ctx, int widget_id, const char *text)
 set text area content
 
void n_gui_toggle_window (N_GUI_CTX *ctx, int window_id)
 toggle window visibility (show/hide)
 
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
 
N_GUI_TREEn_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
 
void n_gui_tree_free (N_GUI_TREE **tree)
 free a tree view (does not destroy the N_GUI listbox)
 
void n_gui_tree_rebuild (N_GUI_TREE *tree)
 rebuild the listbox to reflect current tree state
 
void n_gui_tree_toggle_expand (N_GUI_TREE *tree, int node_index)
 toggle expand/collapse of a node
 
void n_gui_update_transform (N_GUI_CTX *ctx)
 recalculate scale and offset from virtual canvas to display.
 
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 world)
 
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)
 
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
 
int n_gui_window_get_flags (N_GUI_CTX *ctx, int window_id)
 get feature flags of a window
 
int n_gui_window_get_resize_policy (N_GUI_CTX *ctx, int window_id)
 get per-window resize policy
 
int n_gui_window_get_zorder (N_GUI_CTX *ctx, int window_id)
 get window z-order mode
 
int n_gui_window_get_zvalue (N_GUI_CTX *ctx, int window_id)
 get window z-value (for N_GUI_ZORDER_FIXED mode)
 
int n_gui_window_is_open (N_GUI_CTX *ctx, int window_id)
 check if window is visible
 
void n_gui_window_set_autofit (N_GUI_CTX *ctx, int window_id, int autofit_flags, float border)
 configure auto-fit behavior for a dialog window
 
void n_gui_window_set_bitmaps (N_GUI_CTX *ctx, int window_id, ALLEGRO_BITMAP *bg, ALLEGRO_BITMAP *titlebar, int bg_scale_mode)
 set optional bitmap overlays on a window's body and titlebar.
 
void n_gui_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, ...)
 
void n_gui_window_set_resize_policy (N_GUI_CTX *ctx, int window_id, int policy)
 set per-window resize policy (N_GUI_WIN_RESIZE_NONE / _MOVE / _SCALE).
 
void n_gui_window_set_zorder (N_GUI_CTX *ctx, int window_id, int z_mode, int z_value)
 set window z-order mode and value
 
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.
 

Detailed Description

Bitmap Skinning

All widgets support optional bitmap overlays for visual customization. By default, every bitmap pointer is NULL and the standard color theme is used. To skin a widget element, call the corresponding _set_bitmaps() function after widget creation.

Bitmaps are NOT owned by N_GUI — the caller is responsible for loading and destroying them. N_GUI only stores the pointer.

Fallback Chain

For widgets with per-state bitmaps (normal/hover/active):

Supported Widgets

JSON Theme

Bitmap assignments are programmatic (via setter functions), not part of the JSON theme file. The JSON theme remains the color/layout fallback.


Data Structure Documentation

◆ N_GUI_BUTTON_DATA

struct N_GUI_BUTTON_DATA

button specific data

Definition at line 295 of file n_gui.h.

+ Collaboration diagram for N_GUI_BUTTON_DATA:

Data Fields

ALLEGRO_BITMAP * bitmap
 optional bitmap for the button (NULL = color theme)
 
ALLEGRO_BITMAP * bitmap_active
 optional bitmap for active/pressed state
 
ALLEGRO_BITMAP * bitmap_hover
 optional bitmap for hover state
 
int key_focus_only
 if 1, keycode fires only when the button itself or a source widget has focus.
 
int key_modifiers
 required modifier key flags for the keybind (0 = no modifier requirement, matches any modifier state for backward compatibility).
 
int key_sources [8]
 widget IDs that can trigger this focused key binding.
 
int keycode
 bound keyboard keycode (0 = none).
 
char label [128]
 label displayed on the button
 
void(* on_click )(int widget_id, void *user_data)
 callback on click (widget_id passed)
 
int shape
 shape type: N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, N_GUI_SHAPE_BITMAP
 
int toggle_mode
 toggle mode: 0 = momentary (default), 1 = toggle (stays clicked/unclicked)
 
int toggled
 toggle state: 0 = off/unclicked, 1 = on/clicked (only used when toggle_mode=1)
 
void * user_data
 user data for callback
 

Field Documentation

◆ bitmap

ALLEGRO_BITMAP* N_GUI_BUTTON_DATA::bitmap

optional bitmap for the button (NULL = color theme)

Definition at line 299 of file n_gui.h.

Referenced by _draw_button(), n_gui_add_button(), and n_gui_add_button_bitmap().

◆ bitmap_active

ALLEGRO_BITMAP* N_GUI_BUTTON_DATA::bitmap_active

optional bitmap for active/pressed state

Definition at line 303 of file n_gui.h.

Referenced by _draw_button(), n_gui_add_button(), and n_gui_add_button_bitmap().

◆ bitmap_hover

ALLEGRO_BITMAP* N_GUI_BUTTON_DATA::bitmap_hover

optional bitmap for hover state

Definition at line 301 of file n_gui.h.

Referenced by _draw_button(), n_gui_add_button(), and n_gui_add_button_bitmap().

◆ key_focus_only

int N_GUI_BUTTON_DATA::key_focus_only

if 1, keycode fires only when the button itself or a source widget has focus.

if 0 (default), keycode fires globally when no interactive widget has focus.

Definition at line 321 of file n_gui.h.

Referenced by n_gui_button_set_keycode_focused(), and n_gui_process_event().

◆ key_modifiers

int N_GUI_BUTTON_DATA::key_modifiers

required modifier key flags for the keybind (0 = no modifier requirement, matches any modifier state for backward compatibility).

Use ALLEGRO_KEYMOD_SHIFT, ALLEGRO_KEYMOD_CTRL, ALLEGRO_KEYMOD_ALT, ALLEGRO_KEYMOD_ALTGR ORed together. When non-zero, only the specified modifier combination triggers the keybind (exact match on N_GUI_KEY_MOD_MASK bits).

Definition at line 318 of file n_gui.h.

Referenced by n_gui_add_button(), n_gui_button_set_keycode(), n_gui_button_set_keycode_focused(), and n_gui_process_event().

◆ key_sources

int N_GUI_BUTTON_DATA::key_sources[8]

widget IDs that can trigger this focused key binding.

Terminated by -1. Only used when key_focus_only == 1. Up to N_GUI_KEY_SOURCES_MAX entries.

Definition at line 324 of file n_gui.h.

Referenced by n_gui_button_set_keycode_focused(), and n_gui_process_event().

◆ keycode

int N_GUI_BUTTON_DATA::keycode

bound keyboard keycode (0 = none).

When this key is pressed and no text input widget has focus, the button's on_click callback is triggered.

Definition at line 312 of file n_gui.h.

Referenced by n_gui_add_button(), n_gui_button_set_keycode(), n_gui_button_set_keycode_focused(), and n_gui_process_event().

◆ label

char N_GUI_BUTTON_DATA::label[128]

label displayed on the button

Definition at line 297 of file n_gui.h.

Referenced by _draw_button(), and n_gui_add_button().

◆ on_click

void(* N_GUI_BUTTON_DATA::on_click) (int widget_id, void *user_data)

callback on click (widget_id passed)

Definition at line 326 of file n_gui.h.

Referenced by n_gui_add_button(), and n_gui_process_event().

◆ shape

int N_GUI_BUTTON_DATA::shape

shape type: N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, N_GUI_SHAPE_BITMAP

Definition at line 305 of file n_gui.h.

Referenced by _draw_button(), and n_gui_add_button().

◆ toggle_mode

int N_GUI_BUTTON_DATA::toggle_mode

toggle mode: 0 = momentary (default), 1 = toggle (stays clicked/unclicked)

Definition at line 307 of file n_gui.h.

Referenced by _draw_button(), n_gui_add_button(), n_gui_add_toggle_button(), n_gui_button_set_toggle_mode(), and n_gui_process_event().

◆ toggled

int N_GUI_BUTTON_DATA::toggled

toggle state: 0 = off/unclicked, 1 = on/clicked (only used when toggle_mode=1)

Definition at line 309 of file n_gui.h.

Referenced by _draw_button(), n_gui_add_button(), n_gui_add_toggle_button(), n_gui_button_set_toggle_mode(), and n_gui_process_event().

◆ user_data

void* N_GUI_BUTTON_DATA::user_data

user data for callback

Definition at line 328 of file n_gui.h.

Referenced by n_gui_add_button(), and n_gui_process_event().

◆ N_GUI_CHECKBOX_DATA

struct N_GUI_CHECKBOX_DATA

checkbox specific data

Definition at line 399 of file n_gui.h.

+ Collaboration diagram for N_GUI_CHECKBOX_DATA:

Data Fields

ALLEGRO_BITMAP * box_bitmap
 optional bitmap for the checkbox square, unchecked state (NULL = color theme)
 
ALLEGRO_BITMAP * box_checked_bitmap
 optional bitmap for the checkbox square, checked state (NULL = color theme)
 
ALLEGRO_BITMAP * box_hover_bitmap
 optional bitmap for the checkbox square on hover (NULL = fallback to box_bitmap/box_checked_bitmap)
 
int checked
 checked state
 
char label [128]
 label displayed next to the checkbox
 
void(* on_toggle )(int widget_id, int checked, void *user_data)
 callback on toggle
 
void * user_data
 user data for callback
 

Field Documentation

◆ box_bitmap

ALLEGRO_BITMAP* N_GUI_CHECKBOX_DATA::box_bitmap

optional bitmap for the checkbox square, unchecked state (NULL = color theme)

Definition at line 405 of file n_gui.h.

Referenced by _draw_checkbox(), and n_gui_checkbox_set_bitmaps().

◆ box_checked_bitmap

ALLEGRO_BITMAP* N_GUI_CHECKBOX_DATA::box_checked_bitmap

optional bitmap for the checkbox square, checked state (NULL = color theme)

Definition at line 407 of file n_gui.h.

Referenced by _draw_checkbox(), and n_gui_checkbox_set_bitmaps().

◆ box_hover_bitmap

ALLEGRO_BITMAP* N_GUI_CHECKBOX_DATA::box_hover_bitmap

optional bitmap for the checkbox square on hover (NULL = fallback to box_bitmap/box_checked_bitmap)

Definition at line 409 of file n_gui.h.

Referenced by _draw_checkbox(), and n_gui_checkbox_set_bitmaps().

◆ checked

int N_GUI_CHECKBOX_DATA::checked

checked state

Definition at line 403 of file n_gui.h.

Referenced by _draw_checkbox(), n_gui_add_checkbox(), and n_gui_process_event().

◆ label

char N_GUI_CHECKBOX_DATA::label[128]

label displayed next to the checkbox

Definition at line 401 of file n_gui.h.

Referenced by _draw_checkbox(), and n_gui_add_checkbox().

◆ on_toggle

void(* N_GUI_CHECKBOX_DATA::on_toggle) (int widget_id, int checked, void *user_data)

callback on toggle

Definition at line 411 of file n_gui.h.

Referenced by n_gui_add_checkbox(), and n_gui_process_event().

◆ user_data

void* N_GUI_CHECKBOX_DATA::user_data

user data for callback

Definition at line 413 of file n_gui.h.

Referenced by n_gui_add_checkbox(), and n_gui_process_event().

◆ N_GUI_COMBOBOX_DATA

struct N_GUI_COMBOBOX_DATA

combo box specific data

Definition at line 507 of file n_gui.h.

+ Collaboration diagram for N_GUI_COMBOBOX_DATA:

Data Fields

ALLEGRO_BITMAP * bg_bitmap
 optional bitmap for the combobox background (NULL = color theme)
 
int flags
 bitmask of N_GUI_COMBOBOX_* flags
 
int is_open
 is dropdown currently open
 
ALLEGRO_BITMAP * item_bg_bitmap
 optional bitmap for per-item background, normal state (NULL = color theme)
 
float item_height
 item height in dropdown
 
ALLEGRO_BITMAP * item_selected_bitmap
 optional bitmap for per-item background, selected/highlighted (NULL = color theme)
 
N_GUI_LISTITEMitems
 dynamic array of items
 
size_t items_capacity
 allocated capacity
 
int max_visible
 max visible items in dropdown
 
size_t nb_items
 number of items
 
void(* on_select )(int widget_id, int index, void *user_data)
 callback on selection change (widget_id, selected_index, user_data)
 
int scroll_offset
 scroll offset in dropdown
 
int selected_index
 currently selected index (-1 = none)
 
void * user_data
 user data for callback
 

Field Documentation

◆ bg_bitmap

ALLEGRO_BITMAP* N_GUI_COMBOBOX_DATA::bg_bitmap

optional bitmap for the combobox background (NULL = color theme)

Definition at line 525 of file n_gui.h.

Referenced by _draw_combobox(), _draw_combobox_dropdown(), and n_gui_combobox_set_bitmaps().

◆ flags

int N_GUI_COMBOBOX_DATA::flags

bitmask of N_GUI_COMBOBOX_* flags

Definition at line 535 of file n_gui.h.

Referenced by _draw_combobox_dropdown(), n_gui_add_combobox(), n_gui_combobox_set_flags(), and n_gui_process_event().

◆ is_open

int N_GUI_COMBOBOX_DATA::is_open

is dropdown currently open

Definition at line 517 of file n_gui.h.

Referenced by _draw_combobox_dropdown(), n_gui_add_combobox(), n_gui_combobox_clear(), and n_gui_process_event().

◆ item_bg_bitmap

ALLEGRO_BITMAP* N_GUI_COMBOBOX_DATA::item_bg_bitmap

optional bitmap for per-item background, normal state (NULL = color theme)

Definition at line 527 of file n_gui.h.

Referenced by _draw_combobox_dropdown(), and n_gui_combobox_set_bitmaps().

◆ item_height

float N_GUI_COMBOBOX_DATA::item_height

item height in dropdown

Definition at line 521 of file n_gui.h.

Referenced by _draw_combobox_dropdown(), n_gui_add_combobox(), and n_gui_process_event().

◆ item_selected_bitmap

ALLEGRO_BITMAP* N_GUI_COMBOBOX_DATA::item_selected_bitmap

optional bitmap for per-item background, selected/highlighted (NULL = color theme)

Definition at line 529 of file n_gui.h.

Referenced by _draw_combobox_dropdown(), and n_gui_combobox_set_bitmaps().

◆ items

N_GUI_LISTITEM* N_GUI_COMBOBOX_DATA::items

◆ items_capacity

size_t N_GUI_COMBOBOX_DATA::items_capacity

allocated capacity

Definition at line 513 of file n_gui.h.

Referenced by n_gui_add_combobox(), and n_gui_combobox_add_item().

◆ max_visible

int N_GUI_COMBOBOX_DATA::max_visible

max visible items in dropdown

Definition at line 523 of file n_gui.h.

Referenced by _draw_combobox_dropdown(), n_gui_add_combobox(), and n_gui_process_event().

◆ nb_items

size_t N_GUI_COMBOBOX_DATA::nb_items

◆ on_select

void(* N_GUI_COMBOBOX_DATA::on_select) (int widget_id, int index, void *user_data)

callback on selection change (widget_id, selected_index, user_data)

Definition at line 531 of file n_gui.h.

Referenced by n_gui_add_combobox(), and n_gui_process_event().

◆ scroll_offset

int N_GUI_COMBOBOX_DATA::scroll_offset

scroll offset in dropdown

Definition at line 519 of file n_gui.h.

Referenced by _draw_combobox_dropdown(), n_gui_add_combobox(), n_gui_combobox_clear(), and n_gui_process_event().

◆ selected_index

int N_GUI_COMBOBOX_DATA::selected_index

currently selected index (-1 = none)

Definition at line 515 of file n_gui.h.

Referenced by _draw_combobox(), _draw_combobox_dropdown(), n_gui_add_combobox(), n_gui_combobox_clear(), n_gui_combobox_set_selected(), and n_gui_process_event().

◆ user_data

void* N_GUI_COMBOBOX_DATA::user_data

user data for callback

Definition at line 533 of file n_gui.h.

Referenced by n_gui_add_combobox(), and n_gui_process_event().

◆ N_GUI_CTX

struct N_GUI_CTX

The top-level GUI context that holds all windows.

Examples
ex_gui.c, ex_gui_dictionary.c, ex_gui_isometric.c, ex_gui_network.c, and ex_gui_particles.c.

Definition at line 882 of file n_gui.h.

+ Collaboration diagram for N_GUI_CTX:
Data Fields
ALLEGRO_FONT * default_font default font (must be set before adding widgets)
N_GUI_THEME default_theme default theme (applied to new widgets/windows)
ALLEGRO_DISPLAY * display display pointer for clipboard operations (set via n_gui_set_display)
float display_h display/viewport height
float display_w display/viewport width (set via n_gui_set_display_size)
float dpi_scale DPI scale factor (1.0 = normal, 1.25 = 125%, 2.0 = HiDPI, etc.)
int focused_widget_id id of the widget that currently has focus, or -1
int global_hscroll_drag 1 if global scrollbar horizontal thumb is being dragged
float global_scroll_x global horizontal scroll offset (when GUI exceeds display)
float global_scroll_y global vertical scroll offset (when GUI exceeds display)
int global_vscroll_drag 1 if global scrollbar vertical thumb is being dragged
float gui_bounds_h total bounding box height of all windows (computed internally)
float gui_bounds_w total bounding box width of all windows (computed internally)
float gui_offset_x horizontal letterbox offset for virtual canvas
float gui_offset_y vertical letterbox offset for virtual canvas
float gui_scale computed uniform scale factor for virtual canvas
int mouse_b1 mouse button 1 state
int mouse_b1_prev previous mouse button 1 state
int mouse_x mouse state tracking
int mouse_y mouse state tracking
int next_widget_id next widget id to assign
int next_window_id next window id to assign
int open_combobox_id id of the combobox whose dropdown is currently open, or -1
int open_dropmenu_id id of the dropdown menu whose panel is currently open, or -1
float ref_display_h reference display height at the time normalized values were last captured
float ref_display_w reference display width at the time normalized values were last captured
int resize_mode context resize mode: N_GUI_RESIZE_VIRTUAL or N_GUI_RESIZE_ADAPTIVE
int scrollbar_drag_widget_id id of the widget whose scrollbar is being dragged, or -1
int selected_label_id id of the label widget with the most recent text selection, or -1
N_GUI_STYLE style configurable style (sizes, colours, paddings)
float virtual_h virtual canvas height (0 = disabled / identity transform)
float virtual_w virtual canvas width (0 = disabled / identity transform)
HASH_TABLE * widgets_by_id hash table for fast widget lookup by id
LIST * windows ordered list of N_GUI_WINDOW* (back to front)

◆ N_GUI_DROPMENU_DATA

struct N_GUI_DROPMENU_DATA

dropdown menu specific data

Definition at line 585 of file n_gui.h.

+ Collaboration diagram for N_GUI_DROPMENU_DATA:

Data Fields

N_GUI_DROPMENU_ENTRYentries
 dynamic array of entries
 
size_t entries_capacity
 allocated capacity
 
int is_open
 is the menu currently open
 
float item_height
 item height
 
ALLEGRO_BITMAP * item_hover_bitmap
 optional bitmap for the hovered entry background (NULL = color theme)
 
char label [128]
 menu label (shown on the button)
 
int max_visible
 max visible items
 
size_t nb_entries
 number of entries
 
void(* on_open )(int widget_id, void *user_data)
 callback to rebuild dynamic entries each time the menu is opened.
 
void * on_open_user_data
 user data for on_open callback
 
ALLEGRO_BITMAP * panel_bitmap
 optional bitmap for the dropdown panel background (NULL = color theme)
 
int scroll_offset
 scroll offset
 

Field Documentation

◆ entries

◆ entries_capacity

size_t N_GUI_DROPMENU_DATA::entries_capacity

allocated capacity

Definition at line 593 of file n_gui.h.

Referenced by n_gui_add_dropmenu(), and n_gui_dropmenu_add_entry().

◆ is_open

int N_GUI_DROPMENU_DATA::is_open

is the menu currently open

Definition at line 595 of file n_gui.h.

Referenced by _draw_dropmenu(), _draw_dropmenu_panel(), n_gui_add_dropmenu(), and n_gui_process_event().

◆ item_height

float N_GUI_DROPMENU_DATA::item_height

item height

Definition at line 601 of file n_gui.h.

Referenced by _draw_dropmenu_panel(), n_gui_add_dropmenu(), and n_gui_process_event().

◆ item_hover_bitmap

ALLEGRO_BITMAP* N_GUI_DROPMENU_DATA::item_hover_bitmap

optional bitmap for the hovered entry background (NULL = color theme)

Definition at line 605 of file n_gui.h.

Referenced by _draw_dropmenu_panel(), and n_gui_dropmenu_set_bitmaps().

◆ label

char N_GUI_DROPMENU_DATA::label[128]

menu label (shown on the button)

Definition at line 587 of file n_gui.h.

Referenced by _draw_dropmenu(), and n_gui_add_dropmenu().

◆ max_visible

int N_GUI_DROPMENU_DATA::max_visible

max visible items

Definition at line 599 of file n_gui.h.

Referenced by _draw_dropmenu_panel(), n_gui_add_dropmenu(), n_gui_dropmenu_clear_dynamic(), and n_gui_process_event().

◆ nb_entries

◆ on_open

void(* N_GUI_DROPMENU_DATA::on_open) (int widget_id, void *user_data)

callback to rebuild dynamic entries each time the menu is opened.

signature: void rebuild(int widget_id, void* user_data) The callback should call n_gui_dropmenu_clear_dynamic() then add dynamic entries.

Definition at line 609 of file n_gui.h.

Referenced by n_gui_add_dropmenu(), and n_gui_process_event().

◆ on_open_user_data

void* N_GUI_DROPMENU_DATA::on_open_user_data

user data for on_open callback

Definition at line 611 of file n_gui.h.

Referenced by n_gui_add_dropmenu(), and n_gui_process_event().

◆ panel_bitmap

ALLEGRO_BITMAP* N_GUI_DROPMENU_DATA::panel_bitmap

optional bitmap for the dropdown panel background (NULL = color theme)

Definition at line 603 of file n_gui.h.

Referenced by _draw_dropmenu_panel(), and n_gui_dropmenu_set_bitmaps().

◆ scroll_offset

int N_GUI_DROPMENU_DATA::scroll_offset

◆ N_GUI_DROPMENU_ENTRY

struct N_GUI_DROPMENU_ENTRY

A single entry in a dropdown menu (static or dynamic)

Definition at line 571 of file n_gui.h.

+ Collaboration diagram for N_GUI_DROPMENU_ENTRY:

Data Fields

int is_dynamic
 is this entry dynamic (rebuilt via callback each time menu opens)
 
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)
 
int tag
 user-defined tag for the entry (e.g.
 
char text [128]
 display text
 
void * user_data
 user data for callback
 

Field Documentation

◆ is_dynamic

int N_GUI_DROPMENU_ENTRY::is_dynamic

is this entry dynamic (rebuilt via callback each time menu opens)

Definition at line 575 of file n_gui.h.

Referenced by n_gui_dropmenu_add_dynamic_entry(), n_gui_dropmenu_add_entry(), and n_gui_dropmenu_clear_dynamic().

◆ on_click

void(* N_GUI_DROPMENU_ENTRY::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 at line 579 of file n_gui.h.

Referenced by n_gui_dropmenu_add_entry(), and n_gui_process_event().

◆ tag

int N_GUI_DROPMENU_ENTRY::tag

user-defined tag for the entry (e.g.

a window id)

Definition at line 577 of file n_gui.h.

Referenced by n_gui_dropmenu_add_entry(), and n_gui_process_event().

◆ text

char N_GUI_DROPMENU_ENTRY::text[128]

display text

Definition at line 573 of file n_gui.h.

Referenced by _draw_dropmenu_panel(), n_gui_dropmenu_add_entry(), and n_gui_dropmenu_set_entry_text().

◆ user_data

void* N_GUI_DROPMENU_ENTRY::user_data

user data for callback

Definition at line 581 of file n_gui.h.

Referenced by n_gui_dropmenu_add_entry(), and n_gui_process_event().

◆ N_GUI_IMAGE_DATA

struct N_GUI_IMAGE_DATA

image widget specific data

Definition at line 539 of file n_gui.h.

+ Collaboration diagram for N_GUI_IMAGE_DATA:
Data Fields
ALLEGRO_BITMAP * bitmap bitmap to display (not owned, not freed)
int scale_mode scale mode: N_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, N_GUI_IMAGE_CENTER

◆ N_GUI_KV_ROW

struct N_GUI_KV_ROW

a single row in the KV table

Definition at line 1492 of file n_gui.h.

+ Collaboration diagram for N_GUI_KV_ROW:
Data Fields
int active 1 if active, 0 if removed
int desc_id textarea widget ID for the description
int enabled_id checkbox widget ID for the enabled toggle
int key_id textarea widget ID for the key
int remove_id button widget ID for the remove action
int value_id textarea widget ID for the value

◆ N_GUI_KVTABLE

struct N_GUI_KVTABLE

key-value table built from textareas, checkboxes, and buttons

Definition at line 1502 of file n_gui.h.

+ Collaboration diagram for N_GUI_KVTABLE:

Data Fields

int btn_add
 button widget ID for "+" add row
 
N_GUI_CTXctx
 GUI context.
 
float header_height
 height of the column header row
 
int lbl_desc
 label widget ID for "Description" header
 
int lbl_enabled
 label widget ID for "On" header
 
int lbl_key
 label widget ID for "Key" header
 
int lbl_value
 label widget ID for "Value" header
 
int nb_active
 active row count
 
int nb_rows
 total rows (including removed)
 
void(* on_remove )(int, void *)
 callback on row removal
 
float padding
 horizontal padding
 
float row_height
 height of each row in pixels
 
N_GUI_KV_ROW rows [128]
 row storage
 
void * user_data
 user data for callback
 
int window_id
 parent window
 

Field Documentation

◆ btn_add

int N_GUI_KVTABLE::btn_add

button widget ID for "+" add row

Definition at line 1515 of file n_gui.h.

Referenced by _n_gui_kv_reposition(), and n_gui_kvtable_create().

◆ ctx

N_GUI_CTX* N_GUI_KVTABLE::ctx

GUI context.

Definition at line 1503 of file n_gui.h.

Referenced by _n_gui_kv_reposition(), n_gui_kvtable_add_row(), n_gui_kvtable_create(), and n_gui_kvtable_remove_row().

◆ header_height

float N_GUI_KVTABLE::header_height

height of the column header row

Definition at line 1510 of file n_gui.h.

Referenced by _n_gui_kv_reposition(), n_gui_kvtable_add_row(), and n_gui_kvtable_create().

◆ lbl_desc

int N_GUI_KVTABLE::lbl_desc

label widget ID for "Description" header

Definition at line 1513 of file n_gui.h.

Referenced by n_gui_kvtable_create().

◆ lbl_enabled

int N_GUI_KVTABLE::lbl_enabled

label widget ID for "On" header

Definition at line 1514 of file n_gui.h.

Referenced by n_gui_kvtable_create().

◆ lbl_key

int N_GUI_KVTABLE::lbl_key

label widget ID for "Key" header

Definition at line 1511 of file n_gui.h.

Referenced by n_gui_kvtable_create().

◆ lbl_value

int N_GUI_KVTABLE::lbl_value

label widget ID for "Value" header

Definition at line 1512 of file n_gui.h.

Referenced by n_gui_kvtable_create().

◆ nb_active

int N_GUI_KVTABLE::nb_active

active row count

Definition at line 1507 of file n_gui.h.

Referenced by n_gui_kvtable_add_row(), n_gui_kvtable_create(), n_gui_kvtable_get_count(), and n_gui_kvtable_remove_row().

◆ nb_rows

int N_GUI_KVTABLE::nb_rows

total rows (including removed)

Definition at line 1506 of file n_gui.h.

Referenced by _n_gui_kv_remove_clicked(), _n_gui_kv_reposition(), n_gui_kvtable_add_row(), n_gui_kvtable_create(), and n_gui_kvtable_remove_row().

◆ on_remove

void(* N_GUI_KVTABLE::on_remove) (int, void *)

callback on row removal

Definition at line 1516 of file n_gui.h.

Referenced by _n_gui_kv_remove_clicked(), and n_gui_kvtable_create().

◆ padding

float N_GUI_KVTABLE::padding

horizontal padding

Definition at line 1509 of file n_gui.h.

Referenced by _n_gui_kv_reposition(), n_gui_kvtable_add_row(), and n_gui_kvtable_create().

◆ row_height

float N_GUI_KVTABLE::row_height

height of each row in pixels

Definition at line 1508 of file n_gui.h.

Referenced by _n_gui_kv_reposition(), n_gui_kvtable_add_row(), and n_gui_kvtable_create().

◆ rows

N_GUI_KV_ROW N_GUI_KVTABLE::rows[128]

◆ user_data

void* N_GUI_KVTABLE::user_data

user data for callback

Definition at line 1517 of file n_gui.h.

Referenced by _n_gui_kv_remove_clicked(), and n_gui_kvtable_create().

◆ window_id

int N_GUI_KVTABLE::window_id

parent window

Definition at line 1504 of file n_gui.h.

Referenced by n_gui_kvtable_add_row(), and n_gui_kvtable_create().

◆ N_GUI_LABEL_DATA

struct N_GUI_LABEL_DATA

static text label specific data

Definition at line 547 of file n_gui.h.

+ Collaboration diagram for N_GUI_LABEL_DATA:

Data Fields

int align
 text alignment: N_GUI_ALIGN_LEFT, N_GUI_ALIGN_CENTER, N_GUI_ALIGN_RIGHT
 
ALLEGRO_BITMAP * bg_bitmap
 optional bitmap for the label background (NULL = no background)
 
char link [4096]
 optional hyperlink URL (empty string = no link)
 
void(* on_link_click )(int widget_id, const char *link, void *user_data)
 callback when link is clicked (widget_id, link_url, user_data)
 
float scroll_y
 vertical scroll offset for overflowing text (pixels)
 
int sel_dragging
 1 if mouse is actively dragging to select text
 
int sel_end
 selection end byte offset (-1 = no selection)
 
int sel_start
 selection start byte offset (-1 = no selection)
 
char text [4096]
 text to display
 
void * user_data
 user data for callback
 

Field Documentation

◆ align

int N_GUI_LABEL_DATA::align

text alignment: N_GUI_ALIGN_LEFT, N_GUI_ALIGN_CENTER, N_GUI_ALIGN_RIGHT

Definition at line 553 of file n_gui.h.

Referenced by _draw_label(), _label_text_origin_x(), _window_update_content_size(), n_gui_add_label(), and n_gui_process_event().

◆ bg_bitmap

ALLEGRO_BITMAP* N_GUI_LABEL_DATA::bg_bitmap

optional bitmap for the label background (NULL = no background)

Definition at line 563 of file n_gui.h.

Referenced by _draw_label().

◆ link

char N_GUI_LABEL_DATA::link[4096]

optional hyperlink URL (empty string = no link)

Definition at line 551 of file n_gui.h.

Referenced by _draw_label(), n_gui_add_label(), n_gui_add_label_link(), n_gui_label_set_link(), and n_gui_process_event().

◆ on_link_click

void(* N_GUI_LABEL_DATA::on_link_click) (int widget_id, const char *link, void *user_data)

callback when link is clicked (widget_id, link_url, user_data)

Definition at line 565 of file n_gui.h.

Referenced by n_gui_add_label(), n_gui_add_label_link(), and n_gui_process_event().

◆ scroll_y

float N_GUI_LABEL_DATA::scroll_y

vertical scroll offset for overflowing text (pixels)

Definition at line 555 of file n_gui.h.

Referenced by _draw_label(), n_gui_add_label(), and n_gui_process_event().

◆ sel_dragging

int N_GUI_LABEL_DATA::sel_dragging

1 if mouse is actively dragging to select text

Definition at line 561 of file n_gui.h.

Referenced by n_gui_add_label(), and n_gui_process_event().

◆ sel_end

int N_GUI_LABEL_DATA::sel_end

selection end byte offset (-1 = no selection)

Definition at line 559 of file n_gui.h.

Referenced by _draw_label(), n_gui_add_label(), and n_gui_process_event().

◆ sel_start

int N_GUI_LABEL_DATA::sel_start

selection start byte offset (-1 = no selection)

Definition at line 557 of file n_gui.h.

Referenced by _draw_label(), n_gui_add_label(), and n_gui_process_event().

◆ text

char N_GUI_LABEL_DATA::text[4096]

◆ user_data

void* N_GUI_LABEL_DATA::user_data

user data for callback

Definition at line 567 of file n_gui.h.

Referenced by n_gui_add_label(), n_gui_add_label_link(), and n_gui_process_event().

◆ N_GUI_LISTBOX_DATA

struct N_GUI_LISTBOX_DATA

listbox specific data

Definition at line 451 of file n_gui.h.

+ Collaboration diagram for N_GUI_LISTBOX_DATA:

Data Fields

ALLEGRO_BITMAP * bg_bitmap
 optional bitmap for the listbox background (NULL = color theme)
 
ALLEGRO_BITMAP * item_bg_bitmap
 optional bitmap for per-item background, normal state (NULL = color theme)
 
float item_height
 item height in pixels
 
ALLEGRO_BITMAP * item_selected_bitmap
 optional bitmap for per-item background, selected/highlighted (NULL = color theme)
 
N_GUI_LISTITEMitems
 dynamic array of items
 
size_t items_capacity
 allocated capacity
 
size_t nb_items
 number of items
 
void(* on_select )(int widget_id, int index, int selected, void *user_data)
 callback on selection change (widget_id, item_index, selected, user_data)
 
int scroll_offset
 scroll offset in items
 
int selection_mode
 selection mode: N_GUI_SELECT_NONE, N_GUI_SELECT_SINGLE, N_GUI_SELECT_MULTIPLE
 
void * user_data
 user data for callback
 

Field Documentation

◆ bg_bitmap

ALLEGRO_BITMAP* N_GUI_LISTBOX_DATA::bg_bitmap

optional bitmap for the listbox background (NULL = color theme)

Definition at line 465 of file n_gui.h.

Referenced by _draw_listbox(), and n_gui_listbox_set_bitmaps().

◆ item_bg_bitmap

ALLEGRO_BITMAP* N_GUI_LISTBOX_DATA::item_bg_bitmap

optional bitmap for per-item background, normal state (NULL = color theme)

Definition at line 467 of file n_gui.h.

Referenced by _draw_listbox(), and n_gui_listbox_set_bitmaps().

◆ item_height

float N_GUI_LISTBOX_DATA::item_height

item height in pixels

Definition at line 463 of file n_gui.h.

Referenced by _draw_listbox(), n_gui_add_listbox(), n_gui_listbox_set_scroll_offset(), and n_gui_process_event().

◆ item_selected_bitmap

ALLEGRO_BITMAP* N_GUI_LISTBOX_DATA::item_selected_bitmap

optional bitmap for per-item background, selected/highlighted (NULL = color theme)

Definition at line 469 of file n_gui.h.

Referenced by _draw_listbox(), and n_gui_listbox_set_bitmaps().

◆ items

◆ items_capacity

size_t N_GUI_LISTBOX_DATA::items_capacity

allocated capacity

Definition at line 457 of file n_gui.h.

Referenced by n_gui_add_listbox(), and n_gui_listbox_add_item().

◆ nb_items

◆ on_select

void(* N_GUI_LISTBOX_DATA::on_select) (int widget_id, int index, int selected, void *user_data)

callback on selection change (widget_id, item_index, selected, user_data)

Definition at line 471 of file n_gui.h.

Referenced by n_gui_add_listbox(), and n_gui_process_event().

◆ scroll_offset

int N_GUI_LISTBOX_DATA::scroll_offset

◆ selection_mode

int N_GUI_LISTBOX_DATA::selection_mode

selection mode: N_GUI_SELECT_NONE, N_GUI_SELECT_SINGLE, N_GUI_SELECT_MULTIPLE

Definition at line 459 of file n_gui.h.

Referenced by n_gui_add_listbox(), n_gui_listbox_set_selected(), and n_gui_process_event().

◆ user_data

void* N_GUI_LISTBOX_DATA::user_data

user data for callback

Definition at line 473 of file n_gui.h.

Referenced by n_gui_add_listbox(), and n_gui_process_event().

◆ N_GUI_LISTITEM

struct N_GUI_LISTITEM

a single item in a list/radio/combo widget

Definition at line 443 of file n_gui.h.

+ Collaboration diagram for N_GUI_LISTITEM:
Data Fields
int selected selection state (for listbox)
char text[128] item display text

◆ N_GUI_RADIOLIST_DATA

struct N_GUI_RADIOLIST_DATA

radio list specific data

Definition at line 477 of file n_gui.h.

+ Collaboration diagram for N_GUI_RADIOLIST_DATA:

Data Fields

ALLEGRO_BITMAP * bg_bitmap
 optional bitmap for the radiolist background (NULL = color theme)
 
ALLEGRO_BITMAP * item_bg_bitmap
 optional bitmap for per-item background, normal state (NULL = color theme)
 
float item_height
 item height in pixels
 
ALLEGRO_BITMAP * item_selected_bitmap
 optional bitmap for per-item background, selected/highlighted (NULL = color theme)
 
N_GUI_LISTITEMitems
 dynamic array of items
 
size_t items_capacity
 allocated capacity
 
size_t nb_items
 number of items
 
void(* on_select )(int widget_id, int index, void *user_data)
 callback on selection change (widget_id, selected_index, user_data)
 
int scroll_offset
 scroll offset in items
 
int selected_index
 currently selected index (-1 = none)
 
void * user_data
 user data for callback
 

Field Documentation

◆ bg_bitmap

ALLEGRO_BITMAP* N_GUI_RADIOLIST_DATA::bg_bitmap

optional bitmap for the radiolist background (NULL = color theme)

Definition at line 491 of file n_gui.h.

Referenced by _draw_radiolist(), and n_gui_radiolist_set_bitmaps().

◆ item_bg_bitmap

ALLEGRO_BITMAP* N_GUI_RADIOLIST_DATA::item_bg_bitmap

optional bitmap for per-item background, normal state (NULL = color theme)

Definition at line 493 of file n_gui.h.

Referenced by _draw_radiolist(), and n_gui_radiolist_set_bitmaps().

◆ item_height

float N_GUI_RADIOLIST_DATA::item_height

item height in pixels

Definition at line 489 of file n_gui.h.

Referenced by _draw_radiolist(), n_gui_add_radiolist(), and n_gui_process_event().

◆ item_selected_bitmap

ALLEGRO_BITMAP* N_GUI_RADIOLIST_DATA::item_selected_bitmap

optional bitmap for per-item background, selected/highlighted (NULL = color theme)

Definition at line 495 of file n_gui.h.

Referenced by _draw_radiolist(), and n_gui_radiolist_set_bitmaps().

◆ items

N_GUI_LISTITEM* N_GUI_RADIOLIST_DATA::items

dynamic array of items

Definition at line 479 of file n_gui.h.

Referenced by _destroy_widget(), _draw_radiolist(), n_gui_add_radiolist(), and n_gui_radiolist_add_item().

◆ items_capacity

size_t N_GUI_RADIOLIST_DATA::items_capacity

allocated capacity

Definition at line 483 of file n_gui.h.

Referenced by n_gui_add_radiolist(), and n_gui_radiolist_add_item().

◆ nb_items

size_t N_GUI_RADIOLIST_DATA::nb_items

◆ on_select

void(* N_GUI_RADIOLIST_DATA::on_select) (int widget_id, int index, void *user_data)

callback on selection change (widget_id, selected_index, user_data)

Definition at line 497 of file n_gui.h.

Referenced by n_gui_add_radiolist(), and n_gui_process_event().

◆ scroll_offset

int N_GUI_RADIOLIST_DATA::scroll_offset

scroll offset in items

Definition at line 487 of file n_gui.h.

Referenced by _draw_radiolist(), n_gui_add_radiolist(), n_gui_process_event(), and n_gui_radiolist_clear().

◆ selected_index

int N_GUI_RADIOLIST_DATA::selected_index

currently selected index (-1 = none)

Definition at line 485 of file n_gui.h.

Referenced by _draw_radiolist(), n_gui_add_radiolist(), n_gui_process_event(), n_gui_radiolist_clear(), and n_gui_radiolist_set_selected().

◆ user_data

void* N_GUI_RADIOLIST_DATA::user_data

user data for callback

Definition at line 499 of file n_gui.h.

Referenced by n_gui_add_radiolist(), and n_gui_process_event().

◆ N_GUI_SCROLLBAR_DATA

struct N_GUI_SCROLLBAR_DATA

scrollbar specific data

Definition at line 417 of file n_gui.h.

+ Collaboration diagram for N_GUI_SCROLLBAR_DATA:

Data Fields

double content_size
 total content size
 
void(* on_scroll )(int widget_id, double scroll_pos, void *user_data)
 callback on scroll
 
int orientation
 orientation: N_GUI_SCROLLBAR_H or N_GUI_SCROLLBAR_V
 
double scroll_pos
 current scroll position
 
int shape
 shape type: N_GUI_SHAPE_RECT or N_GUI_SHAPE_ROUNDED
 
ALLEGRO_BITMAP * thumb_active_bitmap
 optional bitmap for the thumb while dragging (NULL = fallback to thumb_bitmap)
 
ALLEGRO_BITMAP * thumb_bitmap
 optional bitmap for the thumb/handle, normal state (NULL = color theme)
 
ALLEGRO_BITMAP * thumb_hover_bitmap
 optional bitmap for the thumb on hover (NULL = fallback to thumb_bitmap)
 
ALLEGRO_BITMAP * track_bitmap
 optional bitmap for the scrollbar track background (NULL = color theme)
 
void * user_data
 user data for callback
 
double viewport_size
 visible viewport size
 

Field Documentation

◆ content_size

double N_GUI_SCROLLBAR_DATA::content_size

◆ on_scroll

void(* N_GUI_SCROLLBAR_DATA::on_scroll) (int widget_id, double scroll_pos, void *user_data)

callback on scroll

Definition at line 437 of file n_gui.h.

Referenced by _scrollbar_update_from_mouse(), n_gui_add_scrollbar(), and n_gui_process_event().

◆ orientation

int N_GUI_SCROLLBAR_DATA::orientation

orientation: N_GUI_SCROLLBAR_H or N_GUI_SCROLLBAR_V

Definition at line 419 of file n_gui.h.

Referenced by _draw_scrollbar(), _scrollbar_update_from_mouse(), n_gui_add_scrollbar(), and n_gui_process_event().

◆ scroll_pos

double N_GUI_SCROLLBAR_DATA::scroll_pos

◆ shape

int N_GUI_SCROLLBAR_DATA::shape

shape type: N_GUI_SHAPE_RECT or N_GUI_SHAPE_ROUNDED

Definition at line 427 of file n_gui.h.

Referenced by _draw_scrollbar(), and n_gui_add_scrollbar().

◆ thumb_active_bitmap

ALLEGRO_BITMAP* N_GUI_SCROLLBAR_DATA::thumb_active_bitmap

optional bitmap for the thumb while dragging (NULL = fallback to thumb_bitmap)

Definition at line 435 of file n_gui.h.

Referenced by _draw_scrollbar(), and n_gui_scrollbar_set_bitmaps().

◆ thumb_bitmap

ALLEGRO_BITMAP* N_GUI_SCROLLBAR_DATA::thumb_bitmap

optional bitmap for the thumb/handle, normal state (NULL = color theme)

Definition at line 431 of file n_gui.h.

Referenced by _draw_scrollbar(), and n_gui_scrollbar_set_bitmaps().

◆ thumb_hover_bitmap

ALLEGRO_BITMAP* N_GUI_SCROLLBAR_DATA::thumb_hover_bitmap

optional bitmap for the thumb on hover (NULL = fallback to thumb_bitmap)

Definition at line 433 of file n_gui.h.

Referenced by _draw_scrollbar(), and n_gui_scrollbar_set_bitmaps().

◆ track_bitmap

ALLEGRO_BITMAP* N_GUI_SCROLLBAR_DATA::track_bitmap

optional bitmap for the scrollbar track background (NULL = color theme)

Definition at line 429 of file n_gui.h.

Referenced by _draw_scrollbar(), and n_gui_scrollbar_set_bitmaps().

◆ user_data

void* N_GUI_SCROLLBAR_DATA::user_data

user data for callback

Definition at line 439 of file n_gui.h.

Referenced by _scrollbar_update_from_mouse(), n_gui_add_scrollbar(), and n_gui_process_event().

◆ viewport_size

double N_GUI_SCROLLBAR_DATA::viewport_size

◆ N_GUI_SLIDER_DATA

struct N_GUI_SLIDER_DATA

slider specific data

Definition at line 332 of file n_gui.h.

+ Collaboration diagram for N_GUI_SLIDER_DATA:

Data Fields

ALLEGRO_BITMAP * fill_bitmap
 optional bitmap for the filled portion of the track (NULL = color theme)
 
ALLEGRO_BITMAP * handle_active_bitmap
 optional bitmap for the handle while dragging (NULL = fallback to handle_bitmap)
 
ALLEGRO_BITMAP * handle_bitmap
 optional bitmap for the draggable handle, normal state (NULL = color theme)
 
ALLEGRO_BITMAP * handle_hover_bitmap
 optional bitmap for the handle on hover (NULL = fallback to handle_bitmap)
 
double max_val
 maximum value
 
double min_val
 minimum value
 
int mode
 mode: N_GUI_SLIDER_VALUE or N_GUI_SLIDER_PERCENT
 
void(* on_change )(int widget_id, double value, void *user_data)
 callback on value change
 
int orientation
 orientation: N_GUI_SLIDER_H or N_GUI_SLIDER_V
 
double step
 step increment (0 is treated as 1).
 
ALLEGRO_BITMAP * track_bitmap
 optional bitmap for the track/rail background (NULL = color theme)
 
void * user_data
 user data for callback
 
double value
 current value (always snapped to step)
 

Field Documentation

◆ fill_bitmap

ALLEGRO_BITMAP* N_GUI_SLIDER_DATA::fill_bitmap

optional bitmap for the filled portion of the track (NULL = color theme)

Definition at line 348 of file n_gui.h.

Referenced by _draw_slider(), and n_gui_slider_set_bitmaps().

◆ handle_active_bitmap

ALLEGRO_BITMAP* N_GUI_SLIDER_DATA::handle_active_bitmap

optional bitmap for the handle while dragging (NULL = fallback to handle_bitmap)

Definition at line 354 of file n_gui.h.

Referenced by _draw_slider(), and n_gui_slider_set_bitmaps().

◆ handle_bitmap

ALLEGRO_BITMAP* N_GUI_SLIDER_DATA::handle_bitmap

optional bitmap for the draggable handle, normal state (NULL = color theme)

Definition at line 350 of file n_gui.h.

Referenced by _draw_slider(), and n_gui_slider_set_bitmaps().

◆ handle_hover_bitmap

ALLEGRO_BITMAP* N_GUI_SLIDER_DATA::handle_hover_bitmap

optional bitmap for the handle on hover (NULL = fallback to handle_bitmap)

Definition at line 352 of file n_gui.h.

Referenced by _draw_slider(), and n_gui_slider_set_bitmaps().

◆ max_val

double N_GUI_SLIDER_DATA::max_val

◆ min_val

double N_GUI_SLIDER_DATA::min_val

◆ mode

int N_GUI_SLIDER_DATA::mode

mode: N_GUI_SLIDER_VALUE or N_GUI_SLIDER_PERCENT

Definition at line 342 of file n_gui.h.

Referenced by _draw_slider(), and n_gui_add_slider().

◆ on_change

void(* N_GUI_SLIDER_DATA::on_change) (int widget_id, double value, void *user_data)

callback on value change

Definition at line 356 of file n_gui.h.

Referenced by _slider_update_from_mouse(), n_gui_add_slider(), and n_gui_process_event().

◆ orientation

int N_GUI_SLIDER_DATA::orientation

orientation: N_GUI_SLIDER_H or N_GUI_SLIDER_V

Definition at line 344 of file n_gui.h.

Referenced by _draw_slider(), _slider_update_from_mouse(), n_gui_add_slider(), and n_gui_process_event().

◆ step

double N_GUI_SLIDER_DATA::step

step increment (0 is treated as 1).

All values snap to nearest multiple of step from min_val.

Definition at line 340 of file n_gui.h.

Referenced by _slider_update_from_mouse(), n_gui_add_slider(), n_gui_process_event(), n_gui_slider_set_range(), n_gui_slider_set_step(), and n_gui_slider_set_value().

◆ track_bitmap

ALLEGRO_BITMAP* N_GUI_SLIDER_DATA::track_bitmap

optional bitmap for the track/rail background (NULL = color theme)

Definition at line 346 of file n_gui.h.

Referenced by _draw_slider(), and n_gui_slider_set_bitmaps().

◆ user_data

void* N_GUI_SLIDER_DATA::user_data

user data for callback

Definition at line 358 of file n_gui.h.

Referenced by _slider_update_from_mouse(), n_gui_add_slider(), and n_gui_process_event().

◆ value

double N_GUI_SLIDER_DATA::value

◆ N_GUI_STYLE

struct N_GUI_STYLE

Global style holding every configurable layout constant.

Initialised with sensible defaults by n_gui_default_style(). Can be serialised/deserialised to/from JSON with n_gui_style_to_json / n_gui_style_from_json.

Definition at line 731 of file n_gui.h.

+ Collaboration diagram for N_GUI_STYLE:
Data Fields
float checkbox_label_gap gap between box and label text
float checkbox_label_offset horizontal offset from box edge to label text
float checkbox_mark_margin checkmark inset from box edge
float checkbox_mark_thickness checkmark line thickness
float checkbox_max_size maximum box size
float combobox_max_dropdown_width maximum dropdown width for N_GUI_COMBOBOX_AUTO_WIDTH (0 = display width)
int combobox_max_visible default max visible items for combobox dropdown
float dropdown_arrow_half_h vertical half-extent of the arrow chevron
float dropdown_arrow_half_w horizontal half-extent of the arrow chevron
float dropdown_arrow_reserve horizontal space reserved for the arrow on the right
float dropdown_arrow_thickness arrow stroke thickness
float dropdown_border_thickness dropdown panel border thickness
int dropmenu_max_visible default max visible items for dropmenu panel
float global_scroll_step pixels per mouse wheel notch for global scroll
float global_scrollbar_border_thickness global thumb border thickness
float global_scrollbar_size global scrollbar track width/height
ALLEGRO_COLOR global_scrollbar_thumb_border_color global scrollbar thumb border colour
ALLEGRO_COLOR global_scrollbar_thumb_color global scrollbar thumb colour
float global_scrollbar_thumb_corner_r global thumb corner radius
float global_scrollbar_thumb_min global minimum thumb dimension
float global_scrollbar_thumb_padding global thumb inset from track edge
ALLEGRO_COLOR global_scrollbar_track_color global scrollbar track colour
ALLEGRO_COLOR grip_color grip line colour
float grip_line_thickness grip line thickness
float grip_size grip area size
float item_height_pad min padding added to font height for item height
float item_selection_inset item highlight inset from left/right edges
float item_text_padding text padding inside list/combo/dropmenu items
float label_padding horizontal padding each side
ALLEGRO_COLOR link_color_hover link colour (hover)
ALLEGRO_COLOR link_color_normal link colour (normal)
float link_underline_thickness link underline thickness
float listbox_default_item_height default item height for listbox
float min_win_h minimum window height (for resize)
float min_win_w minimum window width (for resize)
float radio_circle_border_thickness outer circle border thickness
float radio_circle_min_r minimum outer circle radius
float radio_inner_offset inner filled circle shrink from outer
float radio_label_gap gap between circle and label text
float radiolist_default_item_height default item height for radiolist
float scroll_step pixels per mouse wheel notch for window auto-scroll
float scrollbar_size scrollbar track width/height
ALLEGRO_COLOR scrollbar_thumb_color scrollbar thumb colour
float scrollbar_thumb_corner_r thumb corner radius
float scrollbar_thumb_min minimum thumb dimension
float scrollbar_thumb_padding thumb inset from track edge
ALLEGRO_COLOR scrollbar_track_color scrollbar track colour
float slider_handle_border_thickness handle border thickness
float slider_handle_edge_offset handle circle offset from edge
float slider_handle_min_r minimum handle circle radius
float slider_track_border_thickness track outline thickness
float slider_track_corner_r track corner radius
float slider_track_size track width (vertical) or height (horizontal)
float slider_value_label_offset gap between slider end and value label
float textarea_cursor_blink_period cursor blink period in seconds (full cycle on+off)
float textarea_cursor_width cursor width in pixels
float textarea_padding inner padding
float title_max_w_reserve pixels reserved right of title for truncation
float title_padding padding left of title text
float titlebar_h title bar height

◆ N_GUI_TAB_PANEL

struct N_GUI_TAB_PANEL

tab panel built from toggle buttons with content window management

Definition at line 1424 of file n_gui.h.

+ Collaboration diagram for N_GUI_TAB_PANEL:

Data Fields

int active_tab
 currently active tab index
 
float button_h
 height of each tab button
 
int button_ids [16]
 toggle button widget IDs
 
float button_w
 width of each tab button
 
int content_window_ids [16]
 content window IDs (-1 = none)
 
N_GUI_CTXctx
 GUI context.
 
int nb_tabs
 number of tabs
 
void(* on_tab_change )(int, void *)
 callback on tab switch (may be NULL)
 
int parent_window_id
 parent window for tab buttons
 
voiduser_data
 user data for callback
 
float x
 x origin of first tab button
 
float y
 y origin of tab button row
 

Field Documentation

◆ active_tab

int N_GUI_TAB_PANEL::active_tab

currently active tab index

Definition at line 1430 of file n_gui.h.

Referenced by n_gui_tab_add(), n_gui_tab_create(), n_gui_tab_get_active(), and n_gui_tab_set_active().

◆ button_h

float N_GUI_TAB_PANEL::button_h

height of each tab button

Definition at line 1434 of file n_gui.h.

Referenced by n_gui_tab_add(), and n_gui_tab_create().

◆ button_ids

int N_GUI_TAB_PANEL::button_ids[16]

toggle button widget IDs

Definition at line 1427 of file n_gui.h.

Referenced by _n_gui_tab_button_clicked(), n_gui_tab_add(), n_gui_tab_create(), and n_gui_tab_set_active().

◆ button_w

float N_GUI_TAB_PANEL::button_w

width of each tab button

Definition at line 1433 of file n_gui.h.

Referenced by n_gui_tab_add(), and n_gui_tab_create().

◆ content_window_ids

int N_GUI_TAB_PANEL::content_window_ids[16]

content window IDs (-1 = none)

Definition at line 1428 of file n_gui.h.

Referenced by n_gui_tab_create(), n_gui_tab_set_active(), and n_gui_tab_set_content_window().

◆ ctx

N_GUI_CTX* N_GUI_TAB_PANEL::ctx

GUI context.

Definition at line 1425 of file n_gui.h.

Referenced by n_gui_tab_add(), n_gui_tab_create(), and n_gui_tab_set_active().

◆ nb_tabs

int N_GUI_TAB_PANEL::nb_tabs

◆ on_tab_change

void(* N_GUI_TAB_PANEL::on_tab_change) (int, void *)

callback on tab switch (may be NULL)

Definition at line 1435 of file n_gui.h.

Referenced by _n_gui_tab_button_clicked(), and n_gui_tab_create().

◆ parent_window_id

int N_GUI_TAB_PANEL::parent_window_id

parent window for tab buttons

Definition at line 1426 of file n_gui.h.

Referenced by n_gui_tab_add(), and n_gui_tab_create().

◆ user_data

void* N_GUI_TAB_PANEL::user_data

user data for callback

Definition at line 1436 of file n_gui.h.

Referenced by _n_gui_tab_button_clicked(), and n_gui_tab_create().

◆ x

float N_GUI_TAB_PANEL::x

x origin of first tab button

Definition at line 1431 of file n_gui.h.

Referenced by n_gui_tab_add(), and n_gui_tab_create().

◆ y

float N_GUI_TAB_PANEL::y

y origin of tab button row

Definition at line 1432 of file n_gui.h.

Referenced by n_gui_tab_add(), and n_gui_tab_create().

◆ N_GUI_TEXT_DIMS

struct N_GUI_TEXT_DIMS

bounding box dimensions returned by n_gui_get_text_dims()

Definition at line 246 of file n_gui.h.

+ Collaboration diagram for N_GUI_TEXT_DIMS:
Data Fields
int h bounding box height in pixels
int w bounding box width in pixels
int x bounding box x offset from draw origin
int y bounding box y offset from draw origin

◆ N_GUI_TEXTAREA_DATA

struct N_GUI_TEXTAREA_DATA

text area specific data

Definition at line 362 of file n_gui.h.

+ Collaboration diagram for N_GUI_TEXTAREA_DATA:

Data Fields

ALLEGRO_BITMAP * bg_bitmap
 optional bitmap for the text area background (NULL = color theme)
 
size_t char_limit
 maximum character limit (0 = N_GUI_TEXT_MAX)
 
size_t cursor_pos
 cursor position in text
 
double cursor_time
 timestamp of last cursor activity (for blink reset)
 
char mask_char
 mask character for password fields (0 = no masking, e.g.
 
int multiline
 0 = single line, 1 = multiline
 
void(* on_change )(int widget_id, const char *text, void *user_data)
 callback on text change
 
int scroll_from_wheel
 set to 1 when scroll was changed by mouse wheel, cleared on key input
 
float scroll_x
 horizontal scroll offset for single-line text (pixels)
 
int scroll_y
 scroll offset for long text
 
size_t sel_end
 selection end position (tracks cursor during selection)
 
size_t sel_start
 selection anchor position (where shift-click/shift-arrow started).
 
char * text
 text content (dynamically allocated, text_alloc bytes)
 
size_t text_alloc
 allocated buffer size (char_limit + 1)
 
size_t text_len
 current text length
 
void * user_data
 user data for callback
 

Field Documentation

◆ bg_bitmap

ALLEGRO_BITMAP* N_GUI_TEXTAREA_DATA::bg_bitmap

optional bitmap for the text area background (NULL = color theme)

Definition at line 389 of file n_gui.h.

Referenced by _draw_textarea(), and n_gui_add_textarea().

◆ char_limit

size_t N_GUI_TEXTAREA_DATA::char_limit

maximum character limit (0 = N_GUI_TEXT_MAX)

Definition at line 370 of file n_gui.h.

Referenced by _textarea_handle_key(), n_gui_add_textarea(), and n_gui_textarea_set_text().

◆ cursor_pos

◆ cursor_time

double N_GUI_TEXTAREA_DATA::cursor_time

timestamp of last cursor activity (for blink reset)

Definition at line 387 of file n_gui.h.

Referenced by _draw_textarea(), _textarea_handle_key(), n_gui_add_textarea(), n_gui_process_event(), and n_gui_set_focus().

◆ mask_char

char N_GUI_TEXTAREA_DATA::mask_char

mask character for password fields (0 = no masking, e.g.

'*')

Definition at line 391 of file n_gui.h.

Referenced by _draw_textarea(), _textarea_pos_from_mouse(), and n_gui_add_textarea().

◆ multiline

int N_GUI_TEXTAREA_DATA::multiline

◆ on_change

void(* N_GUI_TEXTAREA_DATA::on_change) (int widget_id, const char *text, void *user_data)

callback on text change

Definition at line 393 of file n_gui.h.

Referenced by _textarea_delete_selection(), _textarea_handle_key(), and n_gui_add_textarea().

◆ scroll_from_wheel

int N_GUI_TEXTAREA_DATA::scroll_from_wheel

set to 1 when scroll was changed by mouse wheel, cleared on key input

Definition at line 385 of file n_gui.h.

Referenced by _draw_textarea(), _textarea_handle_key(), n_gui_process_event(), and n_gui_textarea_scroll_to_offset().

◆ scroll_x

float N_GUI_TEXTAREA_DATA::scroll_x

horizontal scroll offset for single-line text (pixels)

Definition at line 383 of file n_gui.h.

Referenced by _draw_textarea(), _textarea_pos_from_mouse(), n_gui_add_textarea(), and n_gui_textarea_set_text().

◆ scroll_y

int N_GUI_TEXTAREA_DATA::scroll_y

◆ sel_end

size_t N_GUI_TEXTAREA_DATA::sel_end

selection end position (tracks cursor during selection)

Definition at line 379 of file n_gui.h.

Referenced by _textarea_clear_selection(), _textarea_handle_key(), _textarea_has_selection(), _textarea_sel_range(), n_gui_add_textarea(), n_gui_process_event(), and n_gui_textarea_set_selection().

◆ sel_start

size_t N_GUI_TEXTAREA_DATA::sel_start

selection anchor position (where shift-click/shift-arrow started).

When sel_start == sel_end, no selection is active.

Definition at line 377 of file n_gui.h.

Referenced by _textarea_clear_selection(), _textarea_handle_key(), _textarea_has_selection(), _textarea_sel_range(), n_gui_add_textarea(), n_gui_process_event(), and n_gui_textarea_set_selection().

◆ text

◆ text_alloc

size_t N_GUI_TEXTAREA_DATA::text_alloc

allocated buffer size (char_limit + 1)

Definition at line 368 of file n_gui.h.

Referenced by n_gui_add_textarea().

◆ text_len

◆ user_data

void* N_GUI_TEXTAREA_DATA::user_data

user data for callback

Definition at line 395 of file n_gui.h.

Referenced by _textarea_delete_selection(), _textarea_handle_key(), and n_gui_add_textarea().

◆ N_GUI_THEME

struct N_GUI_THEME

Color theme for a widget.

Examples
ex_gui.c.

Definition at line 256 of file n_gui.h.

+ Collaboration diagram for N_GUI_THEME:
Data Fields
ALLEGRO_COLOR bg_active background active/pressed
ALLEGRO_COLOR bg_hover background hover
ALLEGRO_COLOR bg_normal background normal
ALLEGRO_COLOR border_active border active
ALLEGRO_COLOR border_hover border hover
ALLEGRO_COLOR border_normal border normal
float border_thickness border thickness
float corner_rx corner radius for rounded shapes
float corner_ry corner radius Y for rounded shapes
ALLEGRO_COLOR selection_color text selection highlight colour (semi-transparent recommended)
ALLEGRO_COLOR text_active text active
ALLEGRO_COLOR text_hover text hover
ALLEGRO_COLOR text_normal text normal

◆ N_GUI_TREE

struct N_GUI_TREE

tree view built from an N_GUI listbox

Definition at line 1466 of file n_gui.h.

+ Collaboration diagram for N_GUI_TREE:

Data Fields

N_GUI_CTXctx
 GUI context.
 
int listbox_id
 listbox widget ID
 
int nb_nodes
 number of nodes
 
int nb_visible
 number of visible rows
 
N_GUI_TREE_NODE nodes [512]
 node storage
 
void(* on_select )(int, void *)
 selection callback
 
void * user_data
 user data for callback
 
int visible_map [512]
 visible row to node index
 

Field Documentation

◆ ctx

N_GUI_CTX* N_GUI_TREE::ctx

GUI context.

Definition at line 1467 of file n_gui.h.

Referenced by n_gui_tree_create(), and n_gui_tree_rebuild().

◆ listbox_id

int N_GUI_TREE::listbox_id

listbox widget ID

Definition at line 1468 of file n_gui.h.

Referenced by n_gui_tree_create(), and n_gui_tree_rebuild().

◆ nb_nodes

int N_GUI_TREE::nb_nodes

◆ nb_visible

int N_GUI_TREE::nb_visible

number of visible rows

Definition at line 1472 of file n_gui.h.

Referenced by _n_gui_tree_listbox_selected(), n_gui_tree_create(), and n_gui_tree_rebuild().

◆ nodes

◆ on_select

void(* N_GUI_TREE::on_select) (int, void *)

selection callback

Definition at line 1473 of file n_gui.h.

Referenced by _n_gui_tree_listbox_selected(), and n_gui_tree_create().

◆ user_data

void* N_GUI_TREE::user_data

user data for callback

Definition at line 1474 of file n_gui.h.

Referenced by _n_gui_tree_listbox_selected(), and n_gui_tree_create().

◆ visible_map

int N_GUI_TREE::visible_map[512]

visible row to node index

Definition at line 1471 of file n_gui.h.

Referenced by _n_gui_tree_listbox_selected(), and n_gui_tree_rebuild().

◆ N_GUI_TREE_NODE

struct N_GUI_TREE_NODE

a single node in the tree view

Definition at line 1456 of file n_gui.h.

+ Collaboration diagram for N_GUI_TREE_NODE:
Data Fields
int depth depth in tree (0 = root)
int expanded 1 if expanded
int has_children 1 if node has children
char label[128] display text
int parent_index parent node index, or -1 for root
void * user_data user data for this node

◆ N_GUI_WIDGET

struct N_GUI_WIDGET

A single GUI widget.

Definition at line 617 of file n_gui.h.

+ Collaboration diagram for N_GUI_WIDGET:
Data Fields
void * data widget-specific data (union via void pointer)
int enabled enabled flag (1 = enabled, 0 = disabled: drawn dimmed and ignores input)
ALLEGRO_FONT * font font used by this widget (NULL = context default)
float h height
int id unique widget id
float norm_h normalized height (fraction of parent window h)
float norm_w normalized width (fraction of parent window w)
float norm_x normalized position x (fraction of parent window w, used for SCALE resize)
float norm_y normalized position y (fraction of parent window h, used for SCALE resize)
int state current state flags (N_GUI_STATE_*)
N_GUI_THEME theme color theme for this widget
int type widget type (N_GUI_TYPE_*)
int visible visibility flag
float w width
float x position x relative to parent window
float y position y relative to parent window

◆ N_GUI_WINDOW

struct N_GUI_WINDOW

A pseudo window that contains widgets.

Definition at line 655 of file n_gui.h.

+ Collaboration diagram for N_GUI_WINDOW:
Data Fields
float autofit_border padding/border around content for auto-fit (pixels, applied on each side)
int autofit_flags bitmask of N_GUI_AUTOFIT_* flags (0 = no auto-fitting)
float autofit_origin_x original insertion point x for N_GUI_AUTOFIT_CENTER (set by n_gui_window_set_autofit)
float autofit_origin_y original insertion point y for N_GUI_AUTOFIT_CENTER (set by n_gui_window_set_autofit)
ALLEGRO_BITMAP * bg_bitmap optional bitmap for the window body background (NULL = color fill)
int bg_scale_mode scale mode for bg_bitmap: N_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, or N_GUI_IMAGE_CENTER
float content_h total content height computed from widgets (internal)
float content_w total content width computed from widgets (internal)
float drag_ox drag offset x (internal)
float drag_oy drag offset y (internal)
int flags feature flags (N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_RESIZABLE, etc.)
ALLEGRO_FONT * font font for the title bar
float h window height
int id unique window id
float min_h minimum height
float min_w minimum width
float norm_h normalized height (fraction of reference display height, used in SCALE mode)
float norm_w normalized width (fraction of reference display width, used in SCALE mode)
float norm_x normalized position x (0.0–1.0 fraction of reference display width)
float norm_y normalized position y (0.0–1.0 fraction of reference display height)
int resize_policy per-window resize policy: N_GUI_WIN_RESIZE_NONE, _MOVE, or _SCALE
float scroll_x horizontal scroll offset for auto-scrollbar (pixels)
float scroll_y vertical scroll offset for auto-scrollbar (pixels)
int state state flags (N_GUI_WIN_*)
N_GUI_THEME theme color theme for this window chrome
char title[128] window title
ALLEGRO_BITMAP * titlebar_bitmap optional bitmap for the titlebar background (NULL = color fill)
float titlebar_h title bar height
float w window width
LIST * widgets list of N_GUI_WIDGET* contained in this window
float x position x on screen
float y position y on screen
int z_order z-order mode (N_GUI_ZORDER_NORMAL, _ALWAYS_ON_TOP, _ALWAYS_BEHIND, _FIXED)
int z_value z-value for N_GUI_ZORDER_FIXED mode (lower = behind, higher = on top)

Macro Definition Documentation

◆ N_GUI_ALIGN_CENTER

#define N_GUI_ALIGN_CENTER   1

center aligned text

Examples
ex_gui.c.

Definition at line 158 of file n_gui.h.

◆ N_GUI_ALIGN_JUSTIFIED

#define N_GUI_ALIGN_JUSTIFIED   3

justified text (spread words to fill width)

Examples
ex_gui.c, and ex_gui_dictionary.c.

Definition at line 162 of file n_gui.h.

◆ N_GUI_ALIGN_LEFT

#define N_GUI_ALIGN_LEFT   0

left aligned text

Examples
ex_gui.c, ex_gui_dictionary.c, ex_gui_isometric.c, ex_gui_network.c, and ex_gui_particles.c.

Definition at line 156 of file n_gui.h.

◆ N_GUI_ALIGN_RIGHT

#define N_GUI_ALIGN_RIGHT   2

right aligned text

Examples
ex_gui.c.

Definition at line 160 of file n_gui.h.

◆ N_GUI_AUTOFIT_CENTER

#define N_GUI_AUTOFIT_CENTER   16

center the window on its insertion point after auto-fit (overrides EXPAND_LEFT/EXPAND_UP for centering)

Examples
ex_gui.c.

Definition at line 226 of file n_gui.h.

◆ N_GUI_AUTOFIT_EXPAND_LEFT

#define N_GUI_AUTOFIT_EXPAND_LEFT   4

expand leftward instead of rightward when adjusting width

Definition at line 222 of file n_gui.h.

◆ N_GUI_AUTOFIT_EXPAND_UP

#define N_GUI_AUTOFIT_EXPAND_UP   8

expand upward instead of downward when adjusting height

Definition at line 224 of file n_gui.h.

◆ N_GUI_AUTOFIT_H

#define N_GUI_AUTOFIT_H   2

auto-adjust window height to content

Definition at line 218 of file n_gui.h.

◆ N_GUI_AUTOFIT_W

#define N_GUI_AUTOFIT_W   1

auto-adjust window width to content

Definition at line 216 of file n_gui.h.

◆ N_GUI_AUTOFIT_WH

#define N_GUI_AUTOFIT_WH   3

auto-adjust both width and height (convenience: W|H)

Examples
ex_gui.c.

Definition at line 220 of file n_gui.h.

◆ N_GUI_COMBOBOX_AUTO_WIDTH

#define N_GUI_COMBOBOX_AUTO_WIDTH   1

dropdown panel expands to fit the longest item text

Definition at line 504 of file n_gui.h.

◆ N_GUI_ID_MAX

#define N_GUI_ID_MAX   128

maximum length for widget id/name strings

Examples
ex_gui.c.

Definition at line 84 of file n_gui.h.

◆ N_GUI_IMAGE_CENTER

#define N_GUI_IMAGE_CENTER   2

draw at original size, centered

Examples
ex_gui.c.

Definition at line 152 of file n_gui.h.

◆ N_GUI_IMAGE_FIT

#define N_GUI_IMAGE_FIT   0

scale to fit within bounds, keep aspect ratio

Examples
ex_gui.c.

Definition at line 148 of file n_gui.h.

◆ N_GUI_IMAGE_STRETCH

#define N_GUI_IMAGE_STRETCH   1

stretch to fill bounds

Examples
ex_gui.c.

Definition at line 150 of file n_gui.h.

◆ N_GUI_KEY_MOD_MASK

#define N_GUI_KEY_MOD_MASK   (ALLEGRO_KEYMOD_SHIFT | ALLEGRO_KEYMOD_CTRL | ALLEGRO_KEYMOD_ALT | ALLEGRO_KEYMOD_ALTGR)

mask of supported modifier flags for button keybind matching

Definition at line 287 of file n_gui.h.

◆ N_GUI_KEY_SOURCES_MAX

#define N_GUI_KEY_SOURCES_MAX   8

maximum number of source widgets for a focused key binding

Definition at line 290 of file n_gui.h.

◆ N_GUI_KV_MAX

#define N_GUI_KV_MAX   128

maximum number of rows in a KV table

Definition at line 1489 of file n_gui.h.

◆ N_GUI_RESIZE_ADAPTIVE

#define N_GUI_RESIZE_ADAPTIVE   1

virtual size tracks display; windows adapt per their resize_policy

Examples
ex_gui.c.

Definition at line 204 of file n_gui.h.

◆ N_GUI_RESIZE_VIRTUAL

#define N_GUI_RESIZE_VIRTUAL   0

fixed virtual canvas with uniform scaling (default/existing behavior)

Definition at line 202 of file n_gui.h.

◆ N_GUI_SCROLLBAR_H

#define N_GUI_SCROLLBAR_H   0

horizontal scrollbar

Examples
ex_gui.c.

Definition at line 134 of file n_gui.h.

◆ N_GUI_SCROLLBAR_V

#define N_GUI_SCROLLBAR_V   1

vertical scrollbar

Examples
ex_gui.c.

Definition at line 136 of file n_gui.h.

◆ N_GUI_SELECT_MULTIPLE

#define N_GUI_SELECT_MULTIPLE   2

multiple item selection

Examples
ex_gui.c.

Definition at line 144 of file n_gui.h.

◆ N_GUI_SELECT_NONE

#define N_GUI_SELECT_NONE   0

no selection allowed (display only)

Examples
ex_gui_network.c.

Definition at line 140 of file n_gui.h.

◆ N_GUI_SELECT_SINGLE

#define N_GUI_SELECT_SINGLE   1

single item selection

Examples
ex_gui.c, ex_gui_dictionary.c, and ex_gui_isometric.c.

Definition at line 142 of file n_gui.h.

◆ N_GUI_SHAPE_BITMAP

#define N_GUI_SHAPE_BITMAP   2

bitmap-based rendering

Definition at line 118 of file n_gui.h.

◆ N_GUI_SHAPE_RECT

#define N_GUI_SHAPE_RECT   0

rectangle shape (default)

Examples
ex_gui.c.

Definition at line 114 of file n_gui.h.

◆ N_GUI_SHAPE_ROUNDED

#define N_GUI_SHAPE_ROUNDED   1

rounded rectangle shape

Examples
ex_gui.c, ex_gui_dictionary.c, ex_gui_isometric.c, and ex_gui_network.c.

Definition at line 116 of file n_gui.h.

◆ N_GUI_SLIDER_H

#define N_GUI_SLIDER_H   0

horizontal slider (default)

Definition at line 128 of file n_gui.h.

◆ N_GUI_SLIDER_PERCENT

#define N_GUI_SLIDER_PERCENT   1

slider uses 0-100 percentage

Examples
ex_gui.c.

Definition at line 124 of file n_gui.h.

◆ N_GUI_SLIDER_V

#define N_GUI_SLIDER_V   1

vertical slider

Definition at line 130 of file n_gui.h.

◆ N_GUI_SLIDER_VALUE

#define N_GUI_SLIDER_VALUE   0

slider uses raw start/end values

Examples
ex_gui.c, and ex_gui_isometric.c.

Definition at line 122 of file n_gui.h.

◆ N_GUI_STATE_ACTIVE

#define N_GUI_STATE_ACTIVE   2

widget is being pressed / dragged

Definition at line 170 of file n_gui.h.

◆ N_GUI_STATE_FOCUSED

#define N_GUI_STATE_FOCUSED   4

widget has keyboard focus

Definition at line 172 of file n_gui.h.

◆ N_GUI_STATE_HOVER

#define N_GUI_STATE_HOVER   1

mouse is hovering the widget

Definition at line 168 of file n_gui.h.

◆ N_GUI_STATE_IDLE

#define N_GUI_STATE_IDLE   0

widget is idle / normal state

Definition at line 166 of file n_gui.h.

◆ N_GUI_STATE_SCROLLBAR_DRAG

#define N_GUI_STATE_SCROLLBAR_DRAG   8

widget scrollbar is being dragged

Definition at line 174 of file n_gui.h.

◆ N_GUI_TAB_MAX

#define N_GUI_TAB_MAX   16

maximum number of tabs in a single tab panel

Definition at line 1421 of file n_gui.h.

◆ N_GUI_TEXT_MAX

#define N_GUI_TEXT_MAX   4096

maximum length for textarea content

Definition at line 86 of file n_gui.h.

◆ N_GUI_TREE_MAX

#define N_GUI_TREE_MAX   512

maximum number of nodes in a tree view

Definition at line 1453 of file n_gui.h.

◆ N_GUI_TYPE_BUTTON

#define N_GUI_TYPE_BUTTON   1

widget type: button

Definition at line 90 of file n_gui.h.

◆ N_GUI_TYPE_CHECKBOX

#define N_GUI_TYPE_CHECKBOX   4

widget type: checkbox

Definition at line 96 of file n_gui.h.

◆ N_GUI_TYPE_COMBOBOX

#define N_GUI_TYPE_COMBOBOX   8

widget type: combo box (dropdown)

Definition at line 104 of file n_gui.h.

◆ N_GUI_TYPE_DROPMENU

#define N_GUI_TYPE_DROPMENU   11

widget type: dropdown menu with static and dynamic entries

Definition at line 110 of file n_gui.h.

◆ N_GUI_TYPE_IMAGE

#define N_GUI_TYPE_IMAGE   9

widget type: image display

Definition at line 106 of file n_gui.h.

◆ N_GUI_TYPE_LABEL

#define N_GUI_TYPE_LABEL   10

widget type: static text label (with optional hyperlink)

Definition at line 108 of file n_gui.h.

◆ N_GUI_TYPE_LISTBOX

#define N_GUI_TYPE_LISTBOX   6

widget type: listbox (selectable list)

Definition at line 100 of file n_gui.h.

◆ N_GUI_TYPE_RADIOLIST

#define N_GUI_TYPE_RADIOLIST   7

widget type: radio list (single select radio buttons)

Definition at line 102 of file n_gui.h.

◆ N_GUI_TYPE_SCROLLBAR

#define N_GUI_TYPE_SCROLLBAR   5

widget type: scrollbar

Definition at line 98 of file n_gui.h.

◆ N_GUI_TYPE_SLIDER

#define N_GUI_TYPE_SLIDER   2

widget type: slider

Definition at line 92 of file n_gui.h.

◆ N_GUI_TYPE_TEXTAREA

#define N_GUI_TYPE_TEXTAREA   3

widget type: text area

Definition at line 94 of file n_gui.h.

◆ N_GUI_WIN_AUTO_SCROLLBAR

#define N_GUI_WIN_AUTO_SCROLLBAR   16

enable automatic scrollbars when content exceeds window size

Examples
ex_gui.c.

Definition at line 192 of file n_gui.h.

◆ N_GUI_WIN_DRAGGING

#define N_GUI_WIN_DRAGGING   4

window is being dragged

Definition at line 182 of file n_gui.h.

◆ N_GUI_WIN_FIXED_POSITION

#define N_GUI_WIN_FIXED_POSITION   64

disable window dragging (default:enable)

Examples
ex_gui.c, ex_gui_dictionary.c, and ex_gui_network.c.

Definition at line 196 of file n_gui.h.

◆ N_GUI_WIN_FRAMELESS

#define N_GUI_WIN_FRAMELESS   128

frameless window: no title bar drawn, drag via window body unless N_GUI_WIN_FIXED_POSITION is also set

Examples
ex_gui.c.

Definition at line 198 of file n_gui.h.

◆ N_GUI_WIN_HSCROLL_DRAG

#define N_GUI_WIN_HSCROLL_DRAG   32

window horizontal auto-scrollbar is being dragged

Definition at line 188 of file n_gui.h.

◆ N_GUI_WIN_MINIMISED

#define N_GUI_WIN_MINIMISED   2

window is minimised (title bar only)

Definition at line 180 of file n_gui.h.

◆ N_GUI_WIN_OPEN

#define N_GUI_WIN_OPEN   1

window is visible

Definition at line 178 of file n_gui.h.

◆ N_GUI_WIN_RESIZABLE

#define N_GUI_WIN_RESIZABLE   32

enable user-resizable window with a drag handle at bottom-right

Examples
ex_gui.c, and ex_gui_network.c.

Definition at line 194 of file n_gui.h.

◆ N_GUI_WIN_RESIZE_MOVE

#define N_GUI_WIN_RESIZE_MOVE   1

reposition proportionally, keep pixel size

Examples
ex_gui.c.

Definition at line 210 of file n_gui.h.

◆ N_GUI_WIN_RESIZE_NONE

#define N_GUI_WIN_RESIZE_NONE   0

no adaptation: absolute position and size unchanged

Examples
ex_gui.c.

Definition at line 208 of file n_gui.h.

◆ N_GUI_WIN_RESIZE_SCALE

#define N_GUI_WIN_RESIZE_SCALE   2

reposition AND resize proportionally, child widgets scale too

Examples
ex_gui.c.

Definition at line 212 of file n_gui.h.

◆ N_GUI_WIN_RESIZING

#define N_GUI_WIN_RESIZING   8

window is being resized

Definition at line 184 of file n_gui.h.

◆ N_GUI_WIN_VSCROLL_DRAG

#define N_GUI_WIN_VSCROLL_DRAG   16

window vertical auto-scrollbar is being dragged

Definition at line 186 of file n_gui.h.

◆ N_GUI_ZORDER_ALWAYS_BEHIND

#define N_GUI_ZORDER_ALWAYS_BEHIND   2

always drawn behind normal windows, cannot be raised above them

Definition at line 234 of file n_gui.h.

◆ N_GUI_ZORDER_ALWAYS_ON_TOP

#define N_GUI_ZORDER_ALWAYS_ON_TOP   1

always drawn on top of normal windows, cannot be lowered behind them

Definition at line 232 of file n_gui.h.

◆ N_GUI_ZORDER_FIXED

#define N_GUI_ZORDER_FIXED   3

fixed z-value: window is sorted within a dedicated group between ALWAYS_BEHIND and NORMAL windows.

The draw order of groups is: ALWAYS_BEHIND < FIXED < NORMAL < ALWAYS_ON_TOP. Within the FIXED group, windows are ordered by z_value (lower = drawn first / behind, higher = drawn last / on top). z_value has no effect on other z-order modes. Windows with the same z_value preserve their relative list order (stable sort).

Definition at line 241 of file n_gui.h.

◆ N_GUI_ZORDER_NORMAL

#define N_GUI_ZORDER_NORMAL   0

default z-order: window participates in normal raise/lower ordering

Definition at line 230 of file n_gui.h.

Function Documentation

◆ n_gui_add_button()

◆ n_gui_add_button_bitmap()

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(*)(int, void *)  on_click,
void *  user_data 
)

add a bitmap-based button widget

add a bitmap-based button widget

Returns
widget id, or -1 on error

Definition at line 1042 of file n_gui.c.

References N_GUI_BUTTON_DATA::bitmap, N_GUI_BUTTON_DATA::bitmap_active, N_GUI_BUTTON_DATA::bitmap_hover, N_GUI_WIDGET::data, n_gui_add_button(), n_gui_get_widget(), and N_GUI_SHAPE_BITMAP.

+ Here is the call graph for this function:

◆ n_gui_add_checkbox()

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(*)(int, int, void *)  on_toggle,
void *  user_data 
)

◆ n_gui_add_combobox()

◆ n_gui_add_dropmenu()

int n_gui_add_dropmenu ( N_GUI_CTX ctx,
int  window_id,
const char *  label,
float  x,
float  y,
float  w,
float  h,
void(*)(int, void *)  on_open,
void *  on_open_user_data 
)

add a dropdown menu widget (button that opens a menu panel with entries)

Parameters
ctxthe GUI context
window_idid of the parent window
labelbutton label text
xhorizontal position
yvertical position
wwidget width
hwidget height
on_opencallback invoked when the menu is opened (or NULL)
on_open_user_datauser data passed to on_open callback
Returns
widget id, or -1 on error

add a dropdown menu widget (button that opens a menu panel with entries)

Returns
widget id, or -1 on error

Definition at line 2237 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_WIDGET::data, N_GUI_STYLE::dropmenu_max_visible, N_GUI_DROPMENU_DATA::entries, N_GUI_DROPMENU_DATA::entries_capacity, Free, N_GUI_WIDGET::id, N_GUI_DROPMENU_DATA::is_open, N_GUI_DROPMENU_DATA::item_height, N_GUI_DROPMENU_DATA::label, list_push(), Malloc, N_GUI_DROPMENU_DATA::max_visible, n_gui_get_window(), N_GUI_ID_MAX, N_GUI_TYPE_DROPMENU, N_GUI_DROPMENU_DATA::nb_entries, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_DROPMENU_DATA::on_open, N_GUI_DROPMENU_DATA::on_open_user_data, N_GUI_DROPMENU_DATA::scroll_offset, N_GUI_CTX::style, and N_GUI_WINDOW::widgets.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_add_image()

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

add an image widget

Parameters
ctxthe GUI context
window_idid of the parent window
xhorizontal position
yvertical position
wwidget width
hwidget height
bitmapthe bitmap to display (not owned by the widget)
scale_modeN_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, or N_GUI_IMAGE_CENTER
Returns
widget id, or -1 on error

Definition at line 1468 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_WIDGET::data, Free, N_GUI_WIDGET::id, list_push(), Malloc, n_gui_get_window(), N_GUI_TYPE_IMAGE, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, and N_GUI_WINDOW::widgets.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_add_label()

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 
)

◆ n_gui_add_label_link()

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(*)(int, const char *, void *)  on_link_click,
void *  user_data 
)

add a text label with hyperlink

add a text label with hyperlink

Returns
widget id, or -1 on error

Definition at line 1538 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_LABEL_DATA::link, n_gui_add_label(), n_gui_get_widget(), N_GUI_TEXT_MAX, on_link_click(), N_GUI_LABEL_DATA::on_link_click, and N_GUI_LABEL_DATA::user_data.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_add_listbox()

int n_gui_add_listbox ( N_GUI_CTX ctx,
int  window_id,
float  x,
float  y,
float  w,
float  h,
int  selection_mode,
void(*)(int, int, int, void *)  on_select,
void *  user_data 
)

add a listbox widget

add a listbox widget

Parameters
ctxthe GUI context
window_idid of the parent window
xhorizontal position
yvertical position
wwidget width
hwidget height
selection_modeN_GUI_SELECT_NONE, N_GUI_SELECT_SINGLE, or N_GUI_SELECT_MULTIPLE
on_selectcallback invoked when an item is selected (or NULL)
user_datauser data passed to on_select callback
Returns
widget id, or -1 on error

Definition at line 1336 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_WIDGET::data, Free, N_GUI_WIDGET::id, N_GUI_LISTBOX_DATA::item_height, N_GUI_LISTBOX_DATA::items, N_GUI_LISTBOX_DATA::items_capacity, list_push(), N_GUI_STYLE::listbox_default_item_height, Malloc, n_gui_get_window(), N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_LISTBOX_DATA::on_select, N_GUI_LISTBOX_DATA::scroll_offset, N_GUI_LISTBOX_DATA::selection_mode, N_GUI_CTX::style, N_GUI_LISTBOX_DATA::user_data, and N_GUI_WINDOW::widgets.

Referenced by main(), main(), and n_gui_tree_create().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_add_radiolist()

int n_gui_add_radiolist ( N_GUI_CTX ctx,
int  window_id,
float  x,
float  y,
float  w,
float  h,
void(*)(int, int, void *)  on_select,
void *  user_data 
)

◆ n_gui_add_scrollbar()

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(*)(int, double, void *)  on_scroll,
void *  user_data 
)

◆ n_gui_add_slider()

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(*)(int, double, void *)  on_change,
void *  user_data 
)

◆ n_gui_add_textarea()

◆ n_gui_add_toggle_button()

int n_gui_add_toggle_button ( N_GUI_CTX ctx,
int  window_id,
const char *  label,
float  x,
float  y,
float  w,
float  h,
int  shape,
int  initial_state,
void(*)(int, void *)  on_click,
void *  user_data 
)

toggle button creation (returns widget id)

toggle button creation (returns widget id)

Parameters
ctxthe GUI context
window_idid of the parent window
labelbutton label text
xhorizontal position
yvertical position
wwidget width
hwidget height
shapebutton shape (N_GUI_SHAPE_*)
initial_state0 = off, 1 = on
on_clickcallback invoked on click (or NULL)
user_datauser data passed to on_click callback
Returns
widget id, or -1 on error

Definition at line 1070 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_add_button(), n_gui_get_widget(), N_GUI_BUTTON_DATA::toggle_mode, and N_GUI_BUTTON_DATA::toggled.

Referenced by main(), and n_gui_tab_add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_add_vslider()

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(*)(int, double, void *)  on_change,
void *  user_data 
)

add a vertical slider (same as n_gui_add_slider but oriented vertically)

add a vertical slider (same as n_gui_add_slider but oriented vertically)

Returns
widget id, or -1 on error

Definition at line 1200 of file n_gui.c.

References N_GUI_WIDGET::data, mode, n_gui_add_slider(), n_gui_get_widget(), and N_GUI_SLIDER_V.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_add_window()

int n_gui_add_window ( N_GUI_CTX ctx,
const char *  title,
float  x,
float  y,
float  w,
float  h 
)

◆ n_gui_add_window_auto()

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 adding all widgets)

add a window that sizes itself automatically to fit its widgets (call n_gui_window_autosize after adding all widgets)

Returns
the window id, or -1 on error

Definition at line 817 of file n_gui.c.

References N_GUI_STYLE::min_win_h, N_GUI_STYLE::min_win_w, n_gui_add_window(), and N_GUI_CTX::style.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_apply_adaptive_resize()

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 dimensions.

Called automatically from n_gui_set_display_size() when in ADAPTIVE mode, but can also be called manually.

apply adaptive resize: reposition/resize all windows according to their policies for the new display dimensions.

Called automatically from n_gui_set_display_size() when in ADAPTIVE mode, but can also be called manually.

Definition at line 5123 of file n_gui.c.

References __n_assert, N_GUI_WINDOW::flags, N_GUI_WIDGET::h, N_GUI_WINDOW::h, list_foreach, N_GUI_WINDOW::min_h, N_GUI_WINDOW::min_w, N_GUI_WIN_FRAMELESS, N_GUI_WIN_RESIZE_MOVE, N_GUI_WIN_RESIZE_NONE, N_GUI_WIN_RESIZE_SCALE, N_GUI_WIDGET::norm_h, N_GUI_WINDOW::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WINDOW::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WINDOW::norm_x, N_GUI_WIDGET::norm_y, N_GUI_WINDOW::norm_y, N_GUI_WINDOW::resize_policy, N_GUI_WIDGET::w, N_GUI_WINDOW::w, N_GUI_WINDOW::widgets, N_GUI_CTX::windows, N_GUI_WIDGET::x, N_GUI_WINDOW::x, N_GUI_WIDGET::y, and N_GUI_WINDOW::y.

Referenced by n_gui_set_display_size().

+ Here is the caller graph for this function:

◆ n_gui_button_is_toggled()

int n_gui_button_is_toggled ( N_GUI_CTX ctx,
int  widget_id 
)

check if button is toggled

check if button is toggled

Returns
1 if toggled on, 0 if off or not a toggle button

Definition at line 1086 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_BUTTON, and N_GUI_WIDGET::type.

Referenced by main(), on_ghost_toggle(), on_ghost_toggle(), on_grid_toggle(), on_grid_toggle(), on_height_toggle(), on_height_toggle(), on_player_toggle(), on_player_toggle(), on_smooth_toggle(), and on_smooth_toggle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_button_set_keycode()

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.

When the key is pressed (with matching modifiers) and no text input widget has focus, the button's on_click callback is triggered. Pass keycode 0 to unbind. Use ALLEGRO_KEY_* constants for the keycode. When modifiers is 0, any modifier state matches (no modifier requirement). When modifiers is non-zero, only an exact match of the specified modifiers (masked by N_GUI_KEY_MOD_MASK) triggers the keybind. Example: n_gui_button_set_keycode(ctx, id, ALLEGRO_KEY_A, ALLEGRO_KEYMOD_SHIFT | ALLEGRO_KEYMOD_CTRL)

Parameters
ctxGUI context
widget_idbutton widget id
keycodeALLEGRO_KEY_* constant, or 0 to unbind
modifiersALLEGRO_KEYMOD_* flags ORed together, or 0 for no requirement

bind a keyboard key with optional modifier requirements to a button.

When the key is pressed (with matching modifiers) and no text input widget has focus, the button's on_click callback is triggered (and toggle state flipped for toggle buttons). Pass keycode 0 to unbind. When modifiers is 0, any modifier state matches (no modifier requirement). When modifiers is non-zero, only an exact match triggers the keybind. Example: ALLEGRO_KEY_A with ALLEGRO_KEYMOD_SHIFT | ALLEGRO_KEYMOD_CTRL

Definition at line 1129 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_BUTTON_DATA::key_modifiers, N_GUI_BUTTON_DATA::keycode, n_gui_get_widget(), N_GUI_KEY_MOD_MASK, N_GUI_TYPE_BUTTON, and N_GUI_WIDGET::type.

Referenced by main(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_button_set_keycode_focused()

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.

Unlike n_gui_button_set_keycode (global), this binding triggers only when the button itself or one of the listed source widgets currently has focus. This allows e.g. ENTER in a URL textarea to trigger a Send button without interfering with ENTER in other textareas.

Parameters
ctxGUI context
widget_idbutton widget id
keycodeALLEGRO_KEY_* constant, or 0 to unbind
modifiersALLEGRO_KEYMOD_* flags ORed together, or 0 for no requirement
sourcesarray of widget IDs whose focus can trigger this binding
source_countnumber of entries in sources (max N_GUI_KEY_SOURCES_MAX)

bind a keyboard key to a button that fires only when specific widgets have focus.

Definition at line 1139 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_BUTTON_DATA::key_focus_only, N_GUI_BUTTON_DATA::key_modifiers, N_GUI_BUTTON_DATA::key_sources, N_GUI_BUTTON_DATA::keycode, n_gui_get_widget(), N_GUI_KEY_MOD_MASK, N_GUI_KEY_SOURCES_MAX, N_GUI_TYPE_BUTTON, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_button_set_toggle_mode()

void n_gui_button_set_toggle_mode ( N_GUI_CTX ctx,
int  widget_id,
int  toggle_mode 
)

set button toggle mode

set button toggle mode

Parameters
ctxthe GUI context
widget_idid of the target button widget
toggle_mode0 = momentary, 1 = toggle

Definition at line 1110 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_BUTTON, N_GUI_BUTTON_DATA::toggle_mode, N_GUI_BUTTON_DATA::toggled, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_button_set_toggled()

void n_gui_button_set_toggled ( N_GUI_CTX ctx,
int  widget_id,
int  toggled 
)

set button toggled state

set button toggled state

Definition at line 1097 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_BUTTON, and N_GUI_WIDGET::type.

Referenced by main(), n_gui_tab_set_active(), on_height_toggle(), on_player_toggle(), on_proj_select(), and on_proj_select().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_checkbox_is_checked()

int n_gui_checkbox_is_checked ( N_GUI_CTX ctx,
int  widget_id 
)

check if checkbox is checked

check if checkbox is checked

Parameters
ctxGUI context
widget_idid of the checkbox widget
Returns
1 if checked, 0 otherwise

Definition at line 1779 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_CHECKBOX, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_checkbox_set_bitmaps()

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.

Pass NULL for any bitmap you don't want to set.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional bitmap overlays on a checkbox widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2447 of file n_gui.c.

References N_GUI_CHECKBOX_DATA::box_bitmap, N_GUI_CHECKBOX_DATA::box_checked_bitmap, N_GUI_CHECKBOX_DATA::box_hover_bitmap, N_GUI_WIDGET::data, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_CHECKBOX, n_log, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_checkbox_set_checked()

void n_gui_checkbox_set_checked ( N_GUI_CTX ctx,
int  widget_id,
int  checked 
)

set checkbox checked state

set checkbox checked state

Parameters
ctxGUI context
widget_idid of the checkbox widget
checked1 to check, 0 to uncheck

Definition at line 1793 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_CHECKBOX, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_close_window()

void n_gui_close_window ( N_GUI_CTX ctx,
int  window_id 
)

close (hide) a window

close (hide) a window

Definition at line 646 of file n_gui.c.

References n_gui_get_window(), and N_GUI_WINDOW::state.

Referenced by main(), n_gui_tab_set_active(), and on_ghost_toggle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_combobox_add_item()

int n_gui_combobox_add_item ( N_GUI_CTX ctx,
int  widget_id,
const char *  text 
)

add an item to a combo box

Definition at line 2109 of file n_gui.c.

References _items_grow(), N_GUI_WIDGET::data, N_GUI_COMBOBOX_DATA::items, N_GUI_COMBOBOX_DATA::items_capacity, n_gui_get_widget(), N_GUI_ID_MAX, N_GUI_TYPE_COMBOBOX, N_GUI_COMBOBOX_DATA::nb_items, N_GUI_LISTITEM::selected, N_GUI_LISTITEM::text, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_combobox_clear()

void n_gui_combobox_clear ( N_GUI_CTX ctx,
int  widget_id 
)

remove all items from a combobox

remove all items from a combobox

Parameters
ctxGUI context
widget_idid of the combobox widget

Definition at line 2096 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_COMBOBOX_DATA::is_open, N_GUI_COMBOBOX_DATA::items, n_gui_get_widget(), N_GUI_TYPE_COMBOBOX, N_GUI_COMBOBOX_DATA::nb_items, N_GUI_COMBOBOX_DATA::scroll_offset, N_GUI_COMBOBOX_DATA::selected_index, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_combobox_get_selected()

int n_gui_combobox_get_selected ( N_GUI_CTX ctx,
int  widget_id 
)

get the selected item index

get the selected item index

Parameters
ctxGUI context
widget_idid of the combobox widget
Returns
index of the selected item, or -1 if none

Definition at line 2131 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_COMBOBOX, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_combobox_set_bitmaps()

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.

Pass NULL for any bitmap you don't want to set.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional bitmap overlays on a combobox widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2522 of file n_gui.c.

References N_GUI_COMBOBOX_DATA::bg_bitmap, N_GUI_WIDGET::data, N_GUI_COMBOBOX_DATA::item_bg_bitmap, N_GUI_COMBOBOX_DATA::item_selected_bitmap, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_COMBOBOX, n_log, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_combobox_set_flags()

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)

set combobox feature flags (bitmask of N_GUI_COMBOBOX_* values)

Parameters
ctxGUI context. Must not be NULL.
widget_idCombobox widget id.
flagsBitmask of N_GUI_COMBOBOX_* values.

Definition at line 1446 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, N_GUI_COMBOBOX_DATA::flags, n_gui_get_widget(), N_GUI_TYPE_COMBOBOX, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_combobox_set_selected()

void n_gui_combobox_set_selected ( N_GUI_CTX ctx,
int  widget_id,
int  index 
)

set the selected item index

set the selected item index

Parameters
ctxGUI context
widget_idid of the combobox widget
indexindex of the item to select, or -1 for none

Definition at line 2145 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_COMBOBOX, N_GUI_COMBOBOX_DATA::selected_index, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_default_style()

N_GUI_STYLE n_gui_default_style ( void  )

return the built-in default style

return the built-in default style

Definition at line 365 of file n_gui.c.

References N_GUI_STYLE::checkbox_label_gap, N_GUI_STYLE::checkbox_label_offset, N_GUI_STYLE::checkbox_mark_margin, N_GUI_STYLE::checkbox_mark_thickness, N_GUI_STYLE::checkbox_max_size, N_GUI_STYLE::combobox_max_dropdown_width, N_GUI_STYLE::combobox_max_visible, N_GUI_STYLE::dropdown_arrow_half_h, N_GUI_STYLE::dropdown_arrow_half_w, N_GUI_STYLE::dropdown_arrow_reserve, N_GUI_STYLE::dropdown_arrow_thickness, N_GUI_STYLE::dropdown_border_thickness, N_GUI_STYLE::dropmenu_max_visible, N_GUI_STYLE::global_scroll_step, N_GUI_STYLE::global_scrollbar_border_thickness, N_GUI_STYLE::global_scrollbar_size, N_GUI_STYLE::global_scrollbar_thumb_border_color, N_GUI_STYLE::global_scrollbar_thumb_color, N_GUI_STYLE::global_scrollbar_thumb_corner_r, N_GUI_STYLE::global_scrollbar_thumb_min, N_GUI_STYLE::global_scrollbar_thumb_padding, N_GUI_STYLE::global_scrollbar_track_color, N_GUI_STYLE::grip_color, N_GUI_STYLE::grip_line_thickness, N_GUI_STYLE::grip_size, N_GUI_STYLE::item_height_pad, N_GUI_STYLE::item_selection_inset, N_GUI_STYLE::item_text_padding, N_GUI_STYLE::label_padding, N_GUI_STYLE::link_color_hover, N_GUI_STYLE::link_color_normal, N_GUI_STYLE::link_underline_thickness, N_GUI_STYLE::listbox_default_item_height, N_GUI_STYLE::min_win_h, N_GUI_STYLE::min_win_w, N_GUI_STYLE::radio_circle_border_thickness, N_GUI_STYLE::radio_circle_min_r, N_GUI_STYLE::radio_inner_offset, N_GUI_STYLE::radio_label_gap, N_GUI_STYLE::radiolist_default_item_height, N_GUI_STYLE::scroll_step, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_color, N_GUI_STYLE::scrollbar_thumb_corner_r, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_STYLE::scrollbar_track_color, N_GUI_STYLE::slider_handle_border_thickness, N_GUI_STYLE::slider_handle_edge_offset, N_GUI_STYLE::slider_handle_min_r, N_GUI_STYLE::slider_track_border_thickness, N_GUI_STYLE::slider_track_corner_r, N_GUI_STYLE::slider_track_size, N_GUI_STYLE::slider_value_label_offset, N_GUI_STYLE::textarea_cursor_blink_period, N_GUI_STYLE::textarea_cursor_width, N_GUI_STYLE::textarea_padding, N_GUI_STYLE::title_max_w_reserve, N_GUI_STYLE::title_padding, and N_GUI_STYLE::titlebar_h.

Referenced by n_gui_new_ctx().

+ Here is the caller graph for this function:

◆ n_gui_default_theme()

N_GUI_THEME n_gui_default_theme ( void  )

◆ n_gui_destroy_ctx()

void n_gui_destroy_ctx ( N_GUI_CTX **  ctx)

destroy a GUI context and free all resources

destroy a GUI context and free all resources

Parameters
ctxpointer to the context pointer (set to NULL)

Definition at line 523 of file n_gui.c.

References __n_assert, destroy_ht(), Free, and list_destroy().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_detect_dpi_scale()

float n_gui_detect_dpi_scale ( N_GUI_CTX ctx,
ALLEGRO_DISPLAY *  display 
)

detect and apply DPI scale from the given allegro display.

Works on Linux (X11/Wayland), Windows, and Android. Returns the detected scale factor.

detect and apply DPI scale from the given allegro display.

Detection strategy (cross-platform):

  • Compare the physical pixel size (framebuffer) to the logical window size. On HiDPI displays these differ (e.g. a 1920-logical window may have a 3840-pixel framebuffer on a 2x Retina display).
  • On Android, al_get_display_option(ALLEGRO_DEFAULT_DISPLAY_ADAPTER) and the framebuffer/window ratio gives the density scale.
  • On Windows with per-monitor DPI awareness, the ratio reflects the OS scaling percentage (125% = 1.25, 150% = 1.5, etc.).
  • On Linux/X11/Wayland, the ratio picks up Xft.dpi or Wayland scale factor if Allegro was built with the appropriate backend.

If the framebuffer and window sizes are both reported identically (no HiDPI support from the Allegro build), the function falls back to 1.0.

Returns
the detected scale factor (also stored in ctx->dpi_scale)

Definition at line 5234 of file n_gui.c.

References __n_assert, display, and N_GUI_CTX::dpi_scale.

Referenced by main().

+ Here is the caller graph for this function:

◆ n_gui_draw()

void n_gui_draw ( N_GUI_CTX ctx)

◆ n_gui_dropmenu_add_dynamic_entry()

int n_gui_dropmenu_add_dynamic_entry ( N_GUI_CTX ctx,
int  widget_id,
const char *  text,
int  tag,
void(*)(int, int, int, void *)  on_click,
void *  user_data 
)

add a dynamic entry (rebuilt each time menu opens)

add a dynamic entry (rebuilt each time menu opens)

Returns
entry index, or -1 on error

Definition at line 2301 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::entries, N_GUI_DROPMENU_ENTRY::is_dynamic, LOG_ERR, n_gui_dropmenu_add_entry(), n_gui_get_widget(), and n_log.

Referenced by on_windows_menu_open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_dropmenu_add_entry()

int n_gui_dropmenu_add_entry ( N_GUI_CTX ctx,
int  widget_id,
const char *  text,
int  tag,
void(*)(int, int, int, void *)  on_click,
void *  user_data 
)

add a static entry to a dropdown menu

add a static entry to a dropdown menu

Returns
entry index, or -1 on error

Definition at line 2278 of file n_gui.c.

References _dropmenu_entries_grow(), N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::entries, N_GUI_DROPMENU_DATA::entries_capacity, N_GUI_DROPMENU_ENTRY::is_dynamic, n_gui_get_widget(), N_GUI_ID_MAX, N_GUI_TYPE_DROPMENU, N_GUI_DROPMENU_DATA::nb_entries, N_GUI_DROPMENU_ENTRY::on_click, N_GUI_DROPMENU_ENTRY::tag, N_GUI_DROPMENU_ENTRY::text, N_GUI_WIDGET::type, and N_GUI_DROPMENU_ENTRY::user_data.

Referenced by main(), and n_gui_dropmenu_add_dynamic_entry().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_dropmenu_clear()

void n_gui_dropmenu_clear ( N_GUI_CTX ctx,
int  widget_id 
)

remove all entries

remove all entries

Definition at line 2355 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DROPMENU, N_GUI_DROPMENU_DATA::nb_entries, N_GUI_DROPMENU_DATA::scroll_offset, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_dropmenu_clear_dynamic()

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)

remove all dynamic entries (call from on_open callback before re-adding)

Definition at line 2326 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::entries, N_GUI_DROPMENU_ENTRY::is_dynamic, N_GUI_DROPMENU_DATA::max_visible, n_gui_get_widget(), N_GUI_TYPE_DROPMENU, N_GUI_DROPMENU_DATA::nb_entries, N_GUI_DROPMENU_DATA::scroll_offset, and N_GUI_WIDGET::type.

Referenced by on_windows_menu_open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_dropmenu_get_count()

int n_gui_dropmenu_get_count ( N_GUI_CTX ctx,
int  widget_id 
)

get number of entries

get number of entries

Definition at line 2380 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DROPMENU, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_dropmenu_set_bitmaps()

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.

Pass NULL for any bitmap you don't want to set.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional bitmap overlays on a dropmenu widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2538 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::item_hover_bitmap, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_DROPMENU, n_log, N_GUI_DROPMENU_DATA::panel_bitmap, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_dropmenu_set_entry_text()

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

update text of an existing entry by index

Definition at line 2366 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::entries, n_gui_get_widget(), N_GUI_ID_MAX, N_GUI_TYPE_DROPMENU, N_GUI_DROPMENU_DATA::nb_entries, N_GUI_DROPMENU_ENTRY::text, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_get_dpi_scale()

float n_gui_get_dpi_scale ( const N_GUI_CTX ctx)

get current DPI scale factor

get current DPI scale factor

Definition at line 5210 of file n_gui.c.

References __n_assert, and N_GUI_CTX::dpi_scale.

◆ n_gui_get_resize_mode()

int n_gui_get_resize_mode ( N_GUI_CTX ctx)

get current resize mode

get current resize mode

Returns
N_GUI_RESIZE_VIRTUAL or N_GUI_RESIZE_ADAPTIVE

Definition at line 5071 of file n_gui.c.

References __n_assert, and N_GUI_CTX::resize_mode.

◆ n_gui_get_text_dims()

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.

Uses al_get_text_dimensions for accurate measurement including glyph overhangs.

Definition at line 58 of file n_gui.c.

References N_GUI_TEXT_DIMS::h, N_GUI_TEXT_DIMS::w, N_GUI_TEXT_DIMS::x, and N_GUI_TEXT_DIMS::y.

◆ n_gui_get_widget()

N_GUI_WIDGET * n_gui_get_widget ( N_GUI_CTX ctx,
int  widget_id 
)

get a widget by id

get a widget by id

Definition at line 1561 of file n_gui.c.

References __n_assert, ht_get_ptr(), key, and N_GUI_CTX::widgets_by_id.

Referenced by _draw_combobox_dropdown(), _draw_dropmenu_panel(), _n_gui_kv_reposition(), n_gui_add_button_bitmap(), n_gui_add_label_link(), n_gui_add_toggle_button(), n_gui_add_vslider(), n_gui_button_is_toggled(), n_gui_button_set_keycode(), n_gui_button_set_keycode_focused(), n_gui_button_set_toggle_mode(), n_gui_button_set_toggled(), n_gui_checkbox_is_checked(), n_gui_checkbox_set_bitmaps(), n_gui_checkbox_set_checked(), n_gui_combobox_add_item(), n_gui_combobox_clear(), n_gui_combobox_get_selected(), n_gui_combobox_set_bitmaps(), n_gui_combobox_set_flags(), n_gui_combobox_set_selected(), n_gui_dropmenu_add_dynamic_entry(), n_gui_dropmenu_add_entry(), n_gui_dropmenu_clear(), n_gui_dropmenu_clear_dynamic(), n_gui_dropmenu_get_count(), n_gui_dropmenu_set_bitmaps(), n_gui_dropmenu_set_entry_text(), n_gui_image_set_bitmap(), n_gui_is_widget_enabled(), n_gui_label_set_bitmap(), n_gui_label_set_link(), n_gui_label_set_text(), n_gui_listbox_add_item(), n_gui_listbox_clear(), n_gui_listbox_get_count(), n_gui_listbox_get_item_text(), n_gui_listbox_get_scroll_offset(), n_gui_listbox_get_selected(), n_gui_listbox_is_selected(), n_gui_listbox_remove_item(), n_gui_listbox_set_bitmaps(), n_gui_listbox_set_scroll_offset(), n_gui_listbox_set_selected(), n_gui_process_event(), n_gui_radiolist_add_item(), n_gui_radiolist_clear(), n_gui_radiolist_get_selected(), n_gui_radiolist_set_bitmaps(), n_gui_radiolist_set_selected(), n_gui_scrollbar_get_pos(), n_gui_scrollbar_set_bitmaps(), n_gui_scrollbar_set_pos(), n_gui_scrollbar_set_sizes(), n_gui_set_focus(), n_gui_set_widget_enabled(), n_gui_set_widget_theme(), n_gui_set_widget_visible(), n_gui_slider_get_value(), n_gui_slider_set_bitmaps(), n_gui_slider_set_range(), n_gui_slider_set_step(), n_gui_slider_set_value(), n_gui_textarea_get_text(), n_gui_textarea_get_text_length(), n_gui_textarea_scroll_to_bottom(), n_gui_textarea_scroll_to_offset(), n_gui_textarea_set_bitmap(), n_gui_textarea_set_mask_char(), n_gui_textarea_set_selection(), and n_gui_textarea_set_text().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_get_window()

◆ n_gui_image_set_bitmap()

void n_gui_image_set_bitmap ( N_GUI_CTX ctx,
int  widget_id,
ALLEGRO_BITMAP *  bitmap 
)

set the bitmap on an image widget

set the bitmap on an image widget

Parameters
ctxGUI context
widget_idid of the image widget
bitmappointer to the ALLEGRO_BITMAP to set

Definition at line 2163 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_IMAGE, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_is_widget_enabled()

int n_gui_is_widget_enabled ( N_GUI_CTX ctx,
int  widget_id 
)

check if a widget is enabled

check if a widget is enabled

Returns
1 if enabled, 0 if disabled

Definition at line 1601 of file n_gui.c.

References N_GUI_WIDGET::enabled, and n_gui_get_widget().

+ Here is the call graph for this function:

◆ n_gui_kvtable_add_row()

◆ n_gui_kvtable_create()

◆ n_gui_kvtable_free()

void n_gui_kvtable_free ( N_GUI_KVTABLE **  table)

free a KV table (does not destroy the N_GUI widgets)

Definition at line 8028 of file n_gui.c.

References FreeNoLog.

◆ n_gui_kvtable_get_count()

int n_gui_kvtable_get_count ( N_GUI_KVTABLE table)

get the number of active rows

Definition at line 8024 of file n_gui.c.

References N_GUI_KVTABLE::nb_active.

◆ n_gui_kvtable_remove_row()

void n_gui_kvtable_remove_row ( N_GUI_KVTABLE table,
int  row_index 
)

remove a row by index (hides widgets, marks inactive)

Definition at line 8010 of file n_gui.c.

References _n_gui_kv_reposition(), N_GUI_KV_ROW::active, N_GUI_KVTABLE::ctx, N_GUI_KV_ROW::desc_id, N_GUI_KV_ROW::enabled_id, N_GUI_KV_ROW::key_id, n_gui_set_widget_visible(), N_GUI_KVTABLE::nb_active, N_GUI_KVTABLE::nb_rows, N_GUI_KV_ROW::remove_id, N_GUI_KVTABLE::rows, and N_GUI_KV_ROW::value_id.

Referenced by _n_gui_kv_remove_clicked().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_label_set_bitmap()

void n_gui_label_set_bitmap ( N_GUI_CTX ctx,
int  widget_id,
ALLEGRO_BITMAP *  bg 
)

set optional background bitmap on a label widget.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional background bitmap on a label widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2553 of file n_gui.c.

References N_GUI_WIDGET::data, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_LABEL, n_log, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_label_set_link()

void n_gui_label_set_link ( N_GUI_CTX ctx,
int  widget_id,
const char *  link 
)

set label hyperlink URL

set label hyperlink URL

Parameters
ctxGUI context
widget_idid of the label widget
linkthe URL to set, or NULL to clear

Definition at line 2198 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_LABEL_DATA::link, n_gui_get_widget(), N_GUI_TEXT_MAX, N_GUI_TYPE_LABEL, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_label_set_text()

void n_gui_label_set_text ( N_GUI_CTX ctx,
int  widget_id,
const char *  text 
)

set label text content

set label text content

Parameters
ctxGUI context
widget_idid of the label widget
textthe text to set, or NULL to clear

Definition at line 2178 of file n_gui.c.

References _normalize_crlf(), N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TEXT_MAX, N_GUI_TYPE_LABEL, N_GUI_LABEL_DATA::text, and N_GUI_WIDGET::type.

Referenced by main(), main(), and update_definitions().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_listbox_add_item()

int n_gui_listbox_add_item ( N_GUI_CTX ctx,
int  widget_id,
const char *  text 
)

add an item to a listbox

add an item to a listbox

Parameters
ctxGUI context
widget_idid of the listbox widget
texttext of the item to add
Returns
index of the new item or -1 on error

Definition at line 1860 of file n_gui.c.

References _items_grow(), N_GUI_WIDGET::data, N_GUI_LISTBOX_DATA::items, N_GUI_LISTBOX_DATA::items_capacity, n_gui_get_widget(), N_GUI_ID_MAX, N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_LISTITEM::selected, N_GUI_LISTITEM::text, and N_GUI_WIDGET::type.

Referenced by chat_log_add(), main(), n_gui_tree_rebuild(), and update_completion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_listbox_clear()

void n_gui_listbox_clear ( N_GUI_CTX ctx,
int  widget_id 
)

clear all items from a listbox

clear all items from a listbox

Parameters
ctxGUI context
widget_idid of the listbox widget

Definition at line 1907 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_LISTBOX_DATA::scroll_offset, and N_GUI_WIDGET::type.

Referenced by n_gui_tree_rebuild(), refresh_clients_list(), and update_completion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_listbox_get_count()

int n_gui_listbox_get_count ( N_GUI_CTX ctx,
int  widget_id 
)

get number of items in a listbox

get number of items in a listbox

Parameters
ctxGUI context
widget_idid of the listbox widget
Returns
number of items

Definition at line 1922 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_listbox_get_item_text()

const char * n_gui_listbox_get_item_text ( N_GUI_CTX ctx,
int  widget_id,
int  index 
)

get item text by index

get item text by index

Parameters
ctxGUI context
widget_idid of the listbox widget
indexindex of the item
Returns
pointer to the item text, or empty string on error

Definition at line 1937 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_LISTBOX_DATA::items, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, N_GUI_LISTITEM::text, and N_GUI_WIDGET::type.

Referenced by on_completion_select().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_listbox_get_scroll_offset()

int n_gui_listbox_get_scroll_offset ( N_GUI_CTX ctx,
int  widget_id 
)

get the current scroll offset (in items)

Definition at line 2001 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::scroll_offset, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_listbox_get_selected()

int n_gui_listbox_get_selected ( N_GUI_CTX ctx,
int  widget_id 
)

get the first selected item index

get the first selected item index

Parameters
ctxGUI context
widget_idid of the listbox widget
Returns
index of the first selected item, or -1 if none

Definition at line 1954 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_LISTBOX_DATA::items, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_LISTITEM::selected, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_listbox_is_selected()

int n_gui_listbox_is_selected ( N_GUI_CTX ctx,
int  widget_id,
int  index 
)

check if an item is selected

check if an item is selected

Parameters
ctxGUI context
widget_idid of the listbox widget
indexindex of the item to check
Returns
1 if selected, 0 otherwise

Definition at line 1972 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_LISTBOX_DATA::items, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, N_GUI_LISTITEM::selected, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_listbox_remove_item()

int n_gui_listbox_remove_item ( N_GUI_CTX ctx,
int  widget_id,
int  index 
)

remove an item from a listbox by index

remove an item from a listbox by index

Parameters
ctxGUI context
widget_idid of the listbox widget
indexindex of the item to remove
Returns
0 on success, -1 on error

Definition at line 1883 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_LISTBOX_DATA::items, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_LISTBOX_DATA::scroll_offset, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_listbox_set_bitmaps()

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.

Pass NULL for any bitmap you don't want to set.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional bitmap overlays on a listbox widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2490 of file n_gui.c.

References N_GUI_LISTBOX_DATA::bg_bitmap, N_GUI_WIDGET::data, N_GUI_LISTBOX_DATA::item_bg_bitmap, N_GUI_LISTBOX_DATA::item_selected_bitmap, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, n_log, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_listbox_set_scroll_offset()

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 at line 2008 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_LISTBOX_DATA::item_height, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_LISTBOX_DATA::scroll_offset, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_listbox_set_selected()

void n_gui_listbox_set_selected ( N_GUI_CTX ctx,
int  widget_id,
int  index,
int  selected 
)

set item selection state

set item selection state

Parameters
ctxGUI context
widget_idid of the listbox widget
indexindex of the item
selected1 to select, 0 to deselect

Definition at line 1990 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_LISTBOX_DATA::items, n_gui_get_widget(), N_GUI_SELECT_SINGLE, N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_LISTITEM::selected, N_GUI_LISTBOX_DATA::selection_mode, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_load_theme_json()

int n_gui_load_theme_json ( N_GUI_CTX ctx,
const char *  filepath 
)

Load a JSON theme file and apply it to the context.

Returns 0 on success, -1 on error.

Load a JSON theme file and apply it to the context.

Parameters
ctxGUI context
filepathpath to the input JSON file
Returns
0 on success, -1 on error

Definition at line 7536 of file n_gui.c.

References __n_assert, _json_get_color(), _json_get_float(), _json_get_int(), N_GUI_THEME::bg_active, N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_THEME::border_hover, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_STYLE::checkbox_label_gap, N_GUI_STYLE::checkbox_label_offset, N_GUI_STYLE::checkbox_mark_margin, N_GUI_STYLE::checkbox_mark_thickness, N_GUI_STYLE::checkbox_max_size, N_GUI_STYLE::combobox_max_dropdown_width, N_GUI_STYLE::combobox_max_visible, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_CTX::default_theme, N_GUI_STYLE::dropdown_arrow_half_h, N_GUI_STYLE::dropdown_arrow_half_w, N_GUI_STYLE::dropdown_arrow_reserve, N_GUI_STYLE::dropdown_arrow_thickness, N_GUI_STYLE::dropdown_border_thickness, N_GUI_STYLE::dropmenu_max_visible, FreeNoLog, N_GUI_STYLE::global_scroll_step, N_GUI_STYLE::global_scrollbar_border_thickness, N_GUI_STYLE::global_scrollbar_size, N_GUI_STYLE::global_scrollbar_thumb_border_color, N_GUI_STYLE::global_scrollbar_thumb_color, N_GUI_STYLE::global_scrollbar_thumb_corner_r, N_GUI_STYLE::global_scrollbar_thumb_min, N_GUI_STYLE::global_scrollbar_thumb_padding, N_GUI_STYLE::global_scrollbar_track_color, N_GUI_STYLE::grip_color, N_GUI_STYLE::grip_line_thickness, N_GUI_STYLE::grip_size, N_GUI_STYLE::item_height_pad, N_GUI_STYLE::item_selection_inset, N_GUI_STYLE::item_text_padding, N_GUI_STYLE::label_padding, N_GUI_STYLE::link_color_hover, N_GUI_STYLE::link_color_normal, N_GUI_STYLE::link_underline_thickness, list_foreach, N_GUI_STYLE::listbox_default_item_height, Malloc, N_GUI_STYLE::min_win_h, N_GUI_STYLE::min_win_w, N_GUI_STYLE::radio_circle_border_thickness, N_GUI_STYLE::radio_circle_min_r, N_GUI_STYLE::radio_inner_offset, N_GUI_STYLE::radio_label_gap, N_GUI_STYLE::radiolist_default_item_height, N_GUI_STYLE::scroll_step, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_color, N_GUI_STYLE::scrollbar_thumb_corner_r, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_STYLE::scrollbar_track_color, N_GUI_THEME::selection_color, N_GUI_STYLE::slider_handle_border_thickness, N_GUI_STYLE::slider_handle_edge_offset, N_GUI_STYLE::slider_handle_min_r, N_GUI_STYLE::slider_track_border_thickness, N_GUI_STYLE::slider_track_corner_r, N_GUI_STYLE::slider_track_size, N_GUI_STYLE::slider_value_label_offset, N_GUI_CTX::style, N_GUI_THEME::text_active, N_GUI_THEME::text_hover, N_GUI_THEME::text_normal, N_GUI_STYLE::textarea_cursor_blink_period, N_GUI_STYLE::textarea_cursor_width, N_GUI_STYLE::textarea_padding, N_GUI_WIDGET::theme, N_GUI_WINDOW::theme, N_GUI_STYLE::title_max_w_reserve, N_GUI_STYLE::title_padding, N_GUI_STYLE::titlebar_h, N_GUI_WINDOW::widgets, and N_GUI_CTX::windows.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_lower_window()

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)

lower a window to the bottom of the stack (respects z-order constraints)

Only NORMAL windows can be lowered.

Definition at line 763 of file n_gui.c.

References __n_assert, _destroy_window(), _find_window_node(), _sort_windows_by_zorder(), LIST_NODE::destroy_func, list_unshift(), N_GUI_ZORDER_NORMAL, LIST_NODE::ptr, remove_list_node_f(), N_GUI_CTX::windows, and N_GUI_WINDOW::z_order.

+ Here is the call graph for this function:

◆ n_gui_make_theme()

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

create a custom theme from individual colors and properties

Parameters
bgbackground colour
bg_hoverbackground colour on hover
bg_activebackground colour when active
borderborder colour
border_hoverborder colour on hover
border_activeborder colour when active
texttext colour
text_hovertext colour on hover
text_activetext colour when active
border_thicknessborder thickness in pixels
corner_rxhorizontal corner radius
corner_ryvertical corner radius
Returns
configured N_GUI_THEME

Definition at line 328 of file n_gui.c.

References N_GUI_THEME::bg_active, N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_THEME::border_hover, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_THEME::selection_color, N_GUI_THEME::text_active, N_GUI_THEME::text_hover, and N_GUI_THEME::text_normal.

Referenced by main().

+ Here is the caller graph for this function:

◆ n_gui_minimize_window()

void n_gui_minimize_window ( N_GUI_CTX ctx,
int  window_id 
)

minimize a window (title bar only)

minimize a window (title bar only)

Definition at line 662 of file n_gui.c.

References n_gui_get_window(), N_GUI_WIN_MINIMISED, and N_GUI_WINDOW::state.

+ Here is the call graph for this function:

◆ n_gui_new_ctx()

◆ n_gui_open_window()

void n_gui_open_window ( N_GUI_CTX ctx,
int  window_id 
)

open (show) a window

open (show) a window

Definition at line 654 of file n_gui.c.

References n_gui_get_window(), N_GUI_WIN_OPEN, and N_GUI_WINDOW::state.

Referenced by main(), n_gui_tab_set_active(), and on_ghost_toggle().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_process_event()

int n_gui_process_event ( N_GUI_CTX ctx,
ALLEGRO_EVENT  event 
)

process an allegro event for the GUI

process an allegro event for the GUI

Parameters
ctxthe GUI context
eventthe allegro event to process
Returns
1 if the event was consumed by the GUI (mouse over a window/widget, active capture operation, keyboard input to focused widget, etc.), 0 if the event was not handled by the GUI and can be processed by the application (e.g. game logic).

Definition at line 5767 of file n_gui.c.

References __n_assert, _clamp(), _compute_gui_bounds(), _find_focused_window(), _find_widget_window(), _is_focusable_type(), _justified_char_at_pos(), _label_char_at_x(), _label_content_height(), _label_text_origin_x(), _n_gui_window_capture_normalized(), _point_in_rect(), _scrollbar_calc_scroll(), _scrollbar_calc_scroll_int(), _scrollbar_update_from_mouse(), _slider_snap_value(), _slider_update_from_mouse(), _text_w(), _textarea_content_height(), _textarea_handle_key(), _textarea_pos_from_mouse(), _win_tbh(), _window_update_content_size(), N_GUI_LABEL_DATA::align, N_GUI_CHECKBOX_DATA::checked, N_GUI_STYLE::combobox_max_dropdown_width, N_GUI_WINDOW::content_h, N_GUI_SCROLLBAR_DATA::content_size, N_GUI_WINDOW::content_w, N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_TEXTAREA_DATA::cursor_time, N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_CTX::display, N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_WINDOW::drag_ox, N_GUI_WINDOW::drag_oy, N_GUI_WIDGET::enabled, LIST::end, N_GUI_DROPMENU_DATA::entries, N_GUI_COMBOBOX_DATA::flags, N_GUI_WINDOW::flags, N_GUI_CTX::focused_widget_id, N_GUI_WIDGET::font, N_GUI_CTX::global_hscroll_drag, N_GUI_STYLE::global_scroll_step, N_GUI_CTX::global_scroll_x, N_GUI_CTX::global_scroll_y, N_GUI_STYLE::global_scrollbar_size, N_GUI_STYLE::global_scrollbar_thumb_min, N_GUI_CTX::global_vscroll_drag, N_GUI_STYLE::grip_size, N_GUI_CTX::gui_bounds_h, N_GUI_CTX::gui_bounds_w, N_GUI_CTX::gui_offset_x, N_GUI_CTX::gui_offset_y, N_GUI_CTX::gui_scale, N_GUI_WIDGET::h, N_GUI_WINDOW::h, N_GUI_WIDGET::id, N_GUI_WINDOW::id, N_GUI_COMBOBOX_DATA::is_open, N_GUI_DROPMENU_DATA::is_open, N_GUI_LISTBOX_DATA::item_height, N_GUI_RADIOLIST_DATA::item_height, N_GUI_COMBOBOX_DATA::item_height, N_GUI_DROPMENU_DATA::item_height, N_GUI_STYLE::item_height_pad, N_GUI_STYLE::item_text_padding, N_GUI_LISTBOX_DATA::items, N_GUI_COMBOBOX_DATA::items, N_GUI_BUTTON_DATA::key_focus_only, N_GUI_BUTTON_DATA::key_modifiers, N_GUI_BUTTON_DATA::key_sources, N_GUI_BUTTON_DATA::keycode, N_GUI_STYLE::label_padding, N_GUI_LABEL_DATA::link, list_foreach, N_GUI_SLIDER_DATA::max_val, N_GUI_COMBOBOX_DATA::max_visible, N_GUI_DROPMENU_DATA::max_visible, N_GUI_WINDOW::min_h, N_GUI_SLIDER_DATA::min_val, N_GUI_WINDOW::min_w, N_GUI_CTX::mouse_b1, N_GUI_CTX::mouse_b1_prev, N_GUI_CTX::mouse_x, N_GUI_CTX::mouse_y, N_GUI_TEXTAREA_DATA::multiline, N_GUI_ALIGN_JUSTIFIED, N_GUI_COMBOBOX_AUTO_WIDTH, n_gui_get_widget(), n_gui_get_window(), N_GUI_KEY_MOD_MASK, N_GUI_KEY_SOURCES_MAX, n_gui_raise_window(), N_GUI_RESIZE_ADAPTIVE, N_GUI_SCROLLBAR_V, N_GUI_SELECT_MULTIPLE, N_GUI_SELECT_NONE, N_GUI_SELECT_SINGLE, n_gui_set_focus(), N_GUI_SLIDER_H, N_GUI_STATE_ACTIVE, N_GUI_STATE_FOCUSED, N_GUI_STATE_HOVER, N_GUI_TEXT_MAX, N_GUI_TYPE_BUTTON, N_GUI_TYPE_CHECKBOX, N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_DROPMENU, N_GUI_TYPE_LABEL, N_GUI_TYPE_LISTBOX, N_GUI_TYPE_RADIOLIST, N_GUI_TYPE_SCROLLBAR, N_GUI_TYPE_SLIDER, N_GUI_TYPE_TEXTAREA, N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_DRAGGING, N_GUI_WIN_FIXED_POSITION, N_GUI_WIN_FRAMELESS, N_GUI_WIN_HSCROLL_DRAG, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WIN_RESIZABLE, N_GUI_WIN_RESIZING, N_GUI_WIN_VSCROLL_DRAG, N_GUI_DROPMENU_DATA::nb_entries, N_GUI_LISTBOX_DATA::nb_items, N_GUI_RADIOLIST_DATA::nb_items, N_GUI_COMBOBOX_DATA::nb_items, LIST::nb_items, N_GUI_SLIDER_DATA::on_change, N_GUI_DROPMENU_ENTRY::on_click, N_GUI_BUTTON_DATA::on_click, N_GUI_LABEL_DATA::on_link_click, N_GUI_DROPMENU_DATA::on_open, N_GUI_DROPMENU_DATA::on_open_user_data, N_GUI_SCROLLBAR_DATA::on_scroll, N_GUI_LISTBOX_DATA::on_select, N_GUI_RADIOLIST_DATA::on_select, N_GUI_COMBOBOX_DATA::on_select, N_GUI_CHECKBOX_DATA::on_toggle, N_GUI_CTX::open_combobox_id, N_GUI_CTX::open_dropmenu_id, N_GUI_SLIDER_DATA::orientation, N_GUI_SCROLLBAR_DATA::orientation, LIST_NODE::ptr, N_GUI_CTX::resize_mode, N_GUI_TEXTAREA_DATA::scroll_from_wheel, N_GUI_LISTBOX_DATA::scroll_offset, N_GUI_RADIOLIST_DATA::scroll_offset, N_GUI_COMBOBOX_DATA::scroll_offset, N_GUI_DROPMENU_DATA::scroll_offset, N_GUI_SCROLLBAR_DATA::scroll_pos, N_GUI_STYLE::scroll_step, N_GUI_WINDOW::scroll_x, N_GUI_TEXTAREA_DATA::scroll_y, N_GUI_LABEL_DATA::scroll_y, N_GUI_WINDOW::scroll_y, N_GUI_CTX::scrollbar_drag_widget_id, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_LABEL_DATA::sel_dragging, N_GUI_TEXTAREA_DATA::sel_end, N_GUI_LABEL_DATA::sel_end, N_GUI_TEXTAREA_DATA::sel_start, N_GUI_LABEL_DATA::sel_start, N_GUI_LISTITEM::selected, N_GUI_RADIOLIST_DATA::selected_index, N_GUI_COMBOBOX_DATA::selected_index, N_GUI_CTX::selected_label_id, N_GUI_LISTBOX_DATA::selection_mode, N_GUI_WIDGET::state, N_GUI_WINDOW::state, N_GUI_SLIDER_DATA::step, N_GUI_CTX::style, N_GUI_DROPMENU_ENTRY::tag, N_GUI_LISTITEM::text, N_GUI_LABEL_DATA::text, N_GUI_STYLE::textarea_padding, N_GUI_STYLE::title_max_w_reserve, N_GUI_BUTTON_DATA::toggle_mode, N_GUI_BUTTON_DATA::toggled, N_GUI_WIDGET::type, N_GUI_BUTTON_DATA::user_data, N_GUI_SLIDER_DATA::user_data, N_GUI_CHECKBOX_DATA::user_data, N_GUI_SCROLLBAR_DATA::user_data, N_GUI_LISTBOX_DATA::user_data, N_GUI_RADIOLIST_DATA::user_data, N_GUI_COMBOBOX_DATA::user_data, N_GUI_LABEL_DATA::user_data, N_GUI_DROPMENU_ENTRY::user_data, N_GUI_SLIDER_DATA::value, N_GUI_SCROLLBAR_DATA::viewport_size, N_GUI_CTX::virtual_h, N_GUI_CTX::virtual_w, N_GUI_WIDGET::visible, N_GUI_WIDGET::w, N_GUI_WINDOW::w, N_GUI_WINDOW::widgets, N_GUI_CTX::windows, N_GUI_WIDGET::x, N_GUI_WINDOW::x, N_GUI_WIDGET::y, and N_GUI_WINDOW::y.

Referenced by main(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_radiolist_add_item()

int n_gui_radiolist_add_item ( N_GUI_CTX ctx,
int  widget_id,
const char *  text 
)

add an item to a radio list

add an item to a radio list

Parameters
ctxGUI context
widget_idid of the radiolist widget
texttext of the item to add
Returns
index of the new item or -1 on error

Definition at line 2028 of file n_gui.c.

References _items_grow(), N_GUI_WIDGET::data, N_GUI_RADIOLIST_DATA::items, N_GUI_RADIOLIST_DATA::items_capacity, n_gui_get_widget(), N_GUI_ID_MAX, N_GUI_TYPE_RADIOLIST, N_GUI_RADIOLIST_DATA::nb_items, N_GUI_LISTITEM::selected, N_GUI_LISTITEM::text, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_radiolist_clear()

void n_gui_radiolist_clear ( N_GUI_CTX ctx,
int  widget_id 
)

remove all items from a radio list

remove all items from a radio list

Parameters
ctxGUI context
widget_idid of the radiolist widget

Definition at line 2049 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_RADIOLIST, N_GUI_RADIOLIST_DATA::nb_items, N_GUI_RADIOLIST_DATA::scroll_offset, N_GUI_RADIOLIST_DATA::selected_index, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_radiolist_get_selected()

int n_gui_radiolist_get_selected ( N_GUI_CTX ctx,
int  widget_id 
)

get the selected item index

get the selected item index

Parameters
ctxGUI context
widget_idid of the radiolist widget
Returns
index of the selected item, or -1 if none

Definition at line 2065 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_RADIOLIST, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_radiolist_set_bitmaps()

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.

Pass NULL for any bitmap you don't want to set.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional bitmap overlays on a radiolist widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2506 of file n_gui.c.

References N_GUI_RADIOLIST_DATA::bg_bitmap, N_GUI_WIDGET::data, N_GUI_RADIOLIST_DATA::item_bg_bitmap, N_GUI_RADIOLIST_DATA::item_selected_bitmap, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_RADIOLIST, n_log, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_radiolist_set_selected()

void n_gui_radiolist_set_selected ( N_GUI_CTX ctx,
int  widget_id,
int  index 
)

set the selected item index

set the selected item index

Parameters
ctxGUI context
widget_idid of the radiolist widget
indexindex of the item to select, or -1 for none

Definition at line 2079 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_RADIOLIST, N_GUI_RADIOLIST_DATA::selected_index, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_raise_window()

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)

raise a window to the top of the stack (respects z-order constraints)

Respects z-order constraints: ALWAYS_BEHIND and FIXED windows are not moved. After raising, the window list is re-sorted.

Definition at line 745 of file n_gui.c.

References __n_assert, _destroy_window(), _find_window_node(), _sort_windows_by_zorder(), LIST_NODE::destroy_func, list_push(), N_GUI_ZORDER_NORMAL, LIST_NODE::ptr, remove_list_node_f(), N_GUI_CTX::windows, and N_GUI_WINDOW::z_order.

Referenced by n_gui_process_event(), and n_gui_set_focus().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_save_theme_json()

int n_gui_save_theme_json ( N_GUI_CTX ctx,
const char *  filepath 
)

Save the full theme (default_theme + style) to a JSON file.

Returns 0 on success, -1 on error.

Save the full theme (default_theme + style) to a JSON file.

Parameters
ctxGUI context
filepathpath to the output JSON file
Returns
0 on success, -1 on error

Definition at line 7413 of file n_gui.c.

References __n_assert, _json_add_color(), N_GUI_THEME::bg_active, N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_THEME::border_hover, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_STYLE::checkbox_label_gap, N_GUI_STYLE::checkbox_label_offset, N_GUI_STYLE::checkbox_mark_margin, N_GUI_STYLE::checkbox_mark_thickness, N_GUI_STYLE::checkbox_max_size, N_GUI_STYLE::combobox_max_dropdown_width, N_GUI_STYLE::combobox_max_visible, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_CTX::default_theme, N_GUI_STYLE::dropdown_arrow_half_h, N_GUI_STYLE::dropdown_arrow_half_w, N_GUI_STYLE::dropdown_arrow_reserve, N_GUI_STYLE::dropdown_arrow_thickness, N_GUI_STYLE::dropdown_border_thickness, N_GUI_STYLE::dropmenu_max_visible, N_GUI_STYLE::global_scroll_step, N_GUI_STYLE::global_scrollbar_border_thickness, N_GUI_STYLE::global_scrollbar_size, N_GUI_STYLE::global_scrollbar_thumb_border_color, N_GUI_STYLE::global_scrollbar_thumb_color, N_GUI_STYLE::global_scrollbar_thumb_corner_r, N_GUI_STYLE::global_scrollbar_thumb_min, N_GUI_STYLE::global_scrollbar_thumb_padding, N_GUI_STYLE::global_scrollbar_track_color, N_GUI_STYLE::grip_color, N_GUI_STYLE::grip_line_thickness, N_GUI_STYLE::grip_size, N_GUI_STYLE::item_height_pad, N_GUI_STYLE::item_selection_inset, N_GUI_STYLE::item_text_padding, N_GUI_STYLE::label_padding, N_GUI_STYLE::link_color_hover, N_GUI_STYLE::link_color_normal, N_GUI_STYLE::link_underline_thickness, N_GUI_STYLE::listbox_default_item_height, N_GUI_STYLE::min_win_h, N_GUI_STYLE::min_win_w, N_GUI_STYLE::radio_circle_border_thickness, N_GUI_STYLE::radio_circle_min_r, N_GUI_STYLE::radio_inner_offset, N_GUI_STYLE::radio_label_gap, N_GUI_STYLE::radiolist_default_item_height, N_GUI_STYLE::scroll_step, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_color, N_GUI_STYLE::scrollbar_thumb_corner_r, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_STYLE::scrollbar_track_color, N_GUI_THEME::selection_color, N_GUI_STYLE::slider_handle_border_thickness, N_GUI_STYLE::slider_handle_edge_offset, N_GUI_STYLE::slider_handle_min_r, N_GUI_STYLE::slider_track_border_thickness, N_GUI_STYLE::slider_track_corner_r, N_GUI_STYLE::slider_track_size, N_GUI_STYLE::slider_value_label_offset, N_GUI_CTX::style, N_GUI_THEME::text_active, N_GUI_THEME::text_hover, N_GUI_THEME::text_normal, N_GUI_STYLE::textarea_cursor_blink_period, N_GUI_STYLE::textarea_cursor_width, N_GUI_STYLE::textarea_padding, N_GUI_STYLE::title_max_w_reserve, N_GUI_STYLE::title_padding, and N_GUI_STYLE::titlebar_h.

+ Here is the call graph for this function:

◆ n_gui_screen_to_virtual()

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.

If virtual canvas is disabled, outputs equal inputs.

Parameters
ctxGUI context
sxscreen X (physical pixels)
syscreen Y (physical pixels)
vxoutput virtual X (may be NULL)
vyoutput virtual Y (may be NULL)

convert physical screen coordinates to virtual canvas coordinates.

If virtual canvas is disabled (virtual_w/virtual_h == 0), outputs equal inputs.

Definition at line 5019 of file n_gui.c.

References __n_assert, N_GUI_CTX::gui_offset_x, N_GUI_CTX::gui_offset_y, N_GUI_CTX::gui_scale, N_GUI_CTX::virtual_h, and N_GUI_CTX::virtual_w.

Referenced by main().

+ Here is the caller graph for this function:

◆ n_gui_scrollbar_get_pos()

double n_gui_scrollbar_get_pos ( N_GUI_CTX ctx,
int  widget_id 
)

get scrollbar position

get scrollbar position

Parameters
ctxGUI context
widget_idid of the scrollbar widget
Returns
current scroll position

Definition at line 1808 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SCROLLBAR, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_scrollbar_set_bitmaps()

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.

Pass NULL for any bitmap you don't want to set.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional bitmap overlays on a scrollbar widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2430 of file n_gui.c.

References N_GUI_WIDGET::data, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_SCROLLBAR, n_log, N_GUI_SCROLLBAR_DATA::thumb_active_bitmap, N_GUI_SCROLLBAR_DATA::thumb_bitmap, N_GUI_SCROLLBAR_DATA::thumb_hover_bitmap, N_GUI_SCROLLBAR_DATA::track_bitmap, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_scrollbar_set_pos()

void n_gui_scrollbar_set_pos ( N_GUI_CTX ctx,
int  widget_id,
double  pos 
)

set scrollbar position

set scrollbar position

Parameters
ctxGUI context
widget_idid of the scrollbar widget
posnew scroll position

Definition at line 1822 of file n_gui.c.

References _clamp(), N_GUI_SCROLLBAR_DATA::content_size, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SCROLLBAR, N_GUI_SCROLLBAR_DATA::scroll_pos, N_GUI_WIDGET::type, and N_GUI_SCROLLBAR_DATA::viewport_size.

+ Here is the call graph for this function:

◆ n_gui_scrollbar_set_sizes()

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

set scrollbar content and viewport sizes

Parameters
ctxGUI context
widget_idid of the scrollbar widget
content_sizetotal size of the content
viewport_sizevisible viewport size

Definition at line 1839 of file n_gui.c.

References _clamp(), N_GUI_SCROLLBAR_DATA::content_size, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SCROLLBAR, N_GUI_SCROLLBAR_DATA::scroll_pos, N_GUI_WIDGET::type, and N_GUI_SCROLLBAR_DATA::viewport_size.

+ Here is the call graph for this function:

◆ n_gui_set_display()

void n_gui_set_display ( N_GUI_CTX ctx,
ALLEGRO_DISPLAY *  display 
)

set the display pointer for clipboard operations (copy/paste)

set the display pointer for clipboard operations (copy/paste)

Definition at line 5192 of file n_gui.c.

References __n_assert, display, and N_GUI_CTX::display.

Referenced by main().

+ Here is the caller graph for this function:

◆ n_gui_set_display_size()

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.

Call this on startup and whenever the display is resized. When virtual canvas is enabled, also updates the virtual-to-display transform.

set the display (viewport) size so global scrollbars can be computed.

Call on startup and whenever ALLEGRO_EVENT_DISPLAY_RESIZE is received. When virtual canvas is enabled, also recalculates the virtual-to-display transform.

Definition at line 5176 of file n_gui.c.

References __n_assert, N_GUI_CTX::display_h, N_GUI_CTX::display_w, n_gui_apply_adaptive_resize(), N_GUI_RESIZE_ADAPTIVE, n_gui_update_transform(), N_GUI_CTX::resize_mode, N_GUI_CTX::virtual_h, and N_GUI_CTX::virtual_w.

Referenced by main(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_set_dpi_scale()

void n_gui_set_dpi_scale ( N_GUI_CTX ctx,
float  scale 
)

set DPI scale factor manually (default is 1.0).

Affects global scrollbar rendering and can be queried by the application.

set DPI scale factor manually (default is 1.0).

Definition at line 5200 of file n_gui.c.

References __n_assert, and N_GUI_CTX::dpi_scale.

◆ n_gui_set_focus()

void n_gui_set_focus ( N_GUI_CTX ctx,
int  widget_id 
)

set keyboard focus to a specific widget (-1 to clear focus)

Parameters
ctxthe GUI context
widget_idthe widget to focus (-1 to clear focus)

set keyboard focus to a specific widget (-1 to clear focus)

Pass widget_id = -1 to clear focus. If the widget is a textarea, resets cursor blink timer. Raises the parent window if it exists and is open.

Definition at line 1613 of file n_gui.c.

References __n_assert, N_GUI_TEXTAREA_DATA::cursor_time, N_GUI_WIDGET::data, N_GUI_CTX::focused_widget_id, N_GUI_WIDGET::id, N_GUI_WINDOW::id, list_foreach, LOG_ERR, n_gui_get_widget(), n_gui_raise_window(), N_GUI_STATE_FOCUSED, N_GUI_TYPE_TEXTAREA, N_GUI_WIN_OPEN, n_log, N_GUI_WIDGET::state, N_GUI_WINDOW::state, N_GUI_WIDGET::type, N_GUI_WINDOW::widgets, and N_GUI_CTX::windows.

Referenced by main(), and n_gui_process_event().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_set_resize_mode()

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

set context-level resize mode: N_GUI_RESIZE_VIRTUAL (default) or N_GUI_RESIZE_ADAPTIVE

When switching to ADAPTIVE, the virtual canvas is disabled and normalized coordinates are captured for all existing windows.

Definition at line 5042 of file n_gui.c.

References __n_assert, _n_gui_window_capture_normalized(), N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_CTX::gui_offset_x, N_GUI_CTX::gui_offset_y, N_GUI_CTX::gui_scale, list_foreach, mode, N_GUI_RESIZE_ADAPTIVE, N_GUI_CTX::ref_display_h, N_GUI_CTX::ref_display_w, N_GUI_CTX::resize_mode, N_GUI_CTX::virtual_h, N_GUI_CTX::virtual_w, and N_GUI_CTX::windows.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_set_virtual_size()

void n_gui_set_virtual_size ( N_GUI_CTX ctx,
float  w,
float  h 
)

set the virtual canvas size for resolution-independent scaling.

When set (w > 0 && h > 0), all widget coordinates are in virtual space. An ALLEGRO_TRANSFORM is applied during draw and mouse input is reverse- transformed automatically. Pass (0, 0) to disable (identity transform). This is opt-in: the virtual canvas is enabled only when both w and h are > 0, and disabled when both are 0 (legacy behaviour).

set the virtual canvas size for resolution-independent scaling.

When enabled (w > 0 && h > 0), all widget coordinates are treated as virtual pixels. An ALLEGRO_TRANSFORM is applied in n_gui_draw() and mouse input is reverse-transformed in n_gui_process_event(). Pass (0, 0) to disable (identity transform, legacy behaviour).

Definition at line 4974 of file n_gui.c.

References __n_assert, LOG_ERR, n_gui_update_transform(), n_log, N_GUI_CTX::virtual_h, and N_GUI_CTX::virtual_w.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_set_widget_enabled()

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)

set widget enabled state (0 = disabled: drawn dimmed and ignores all input)

Disabled widgets are drawn dimmed and ignore all mouse/keyboard input.

Definition at line 1592 of file n_gui.c.

References N_GUI_WIDGET::enabled, and n_gui_get_widget().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_set_widget_theme()

void n_gui_set_widget_theme ( N_GUI_CTX ctx,
int  widget_id,
N_GUI_THEME  theme 
)

set the theme on a widget

set the theme on a widget

Definition at line 1575 of file n_gui.c.

References n_gui_get_widget(), and N_GUI_WIDGET::theme.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_set_widget_visible()

void n_gui_set_widget_visible ( N_GUI_CTX ctx,
int  widget_id,
int  visible 
)

set widget visibility

set widget visibility

Definition at line 1583 of file n_gui.c.

References n_gui_get_widget(), and N_GUI_WIDGET::visible.

Referenced by main(), and n_gui_kvtable_remove_row().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_slider_get_value()

double n_gui_slider_get_value ( N_GUI_CTX ctx,
int  widget_id 
)

get slider current value

get slider current value

Parameters
ctxGUI context
widget_idid of the slider widget
Returns
current slider value

Definition at line 1667 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SLIDER, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_slider_set_bitmaps()

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.

Pass NULL for any bitmap you don't want to set.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional bitmap overlays on a slider widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2412 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_SLIDER_DATA::fill_bitmap, N_GUI_SLIDER_DATA::handle_active_bitmap, N_GUI_SLIDER_DATA::handle_bitmap, N_GUI_SLIDER_DATA::handle_hover_bitmap, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_SLIDER, n_log, N_GUI_SLIDER_DATA::track_bitmap, and N_GUI_WIDGET::type.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_slider_set_range()

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

Parameters
ctxGUI context
widget_idid of the slider widget
min_valnew minimum value
max_valnew maximum value

Definition at line 1699 of file n_gui.c.

References _clamp(), _slider_snap_value(), N_GUI_WIDGET::data, N_GUI_SLIDER_DATA::max_val, N_GUI_SLIDER_DATA::min_val, n_gui_get_widget(), N_GUI_TYPE_SLIDER, N_GUI_SLIDER_DATA::step, N_GUI_WIDGET::type, and N_GUI_SLIDER_DATA::value.

+ Here is the call graph for this function:

◆ n_gui_slider_set_step()

void n_gui_slider_set_step ( N_GUI_CTX ctx,
int  widget_id,
double  step 
)

set slider step increment (0 is treated as 1).

Value is re-snapped.

set slider step increment (0 is treated as 1).

0 means continuous (no snapping). When step > 0, the current value is immediately snapped.

Parameters
ctxGUI context
widget_idid of the slider widget
stepstep increment (0 = continuous)

Definition at line 1719 of file n_gui.c.

References _slider_snap_value(), N_GUI_WIDGET::data, N_GUI_SLIDER_DATA::max_val, N_GUI_SLIDER_DATA::min_val, n_gui_get_widget(), N_GUI_TYPE_SLIDER, N_GUI_SLIDER_DATA::step, N_GUI_WIDGET::type, and N_GUI_SLIDER_DATA::value.

+ Here is the call graph for this function:

◆ n_gui_slider_set_value()

void n_gui_slider_set_value ( N_GUI_CTX ctx,
int  widget_id,
double  value 
)

set slider value

set slider value

Parameters
ctxGUI context
widget_idid of the slider widget
valuenew value to set

Definition at line 1681 of file n_gui.c.

References _clamp(), _slider_snap_value(), N_GUI_WIDGET::data, N_GUI_SLIDER_DATA::max_val, N_GUI_SLIDER_DATA::min_val, n_gui_get_widget(), N_GUI_TYPE_SLIDER, N_GUI_SLIDER_DATA::step, N_GUI_WIDGET::type, and N_GUI_SLIDER_DATA::value.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_tab_add()

◆ n_gui_tab_create()

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(*)(int, void *)  on_tab_change,
void *  user_data 
)

◆ n_gui_tab_free()

void n_gui_tab_free ( N_GUI_TAB_PANEL **  panel)

free a tab panel (does not destroy the N_GUI widgets)

Definition at line 7780 of file n_gui.c.

References FreeNoLog.

◆ n_gui_tab_get_active()

int n_gui_tab_get_active ( N_GUI_TAB_PANEL panel)

get the active tab index

Definition at line 7776 of file n_gui.c.

References N_GUI_TAB_PANEL::active_tab.

◆ n_gui_tab_set_active()

void n_gui_tab_set_active ( N_GUI_TAB_PANEL panel,
int  index 
)

set the active tab (toggles buttons, opens/closes content windows)

Definition at line 7762 of file n_gui.c.

References N_GUI_TAB_PANEL::active_tab, N_GUI_TAB_PANEL::button_ids, N_GUI_TAB_PANEL::content_window_ids, N_GUI_TAB_PANEL::ctx, n_gui_button_set_toggled(), n_gui_close_window(), n_gui_open_window(), and N_GUI_TAB_PANEL::nb_tabs.

Referenced by _n_gui_tab_button_clicked().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_tab_set_content_window()

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 at line 7757 of file n_gui.c.

References N_GUI_TAB_PANEL::content_window_ids, and N_GUI_TAB_PANEL::nb_tabs.

◆ n_gui_textarea_get_text()

const char * n_gui_textarea_get_text ( N_GUI_CTX ctx,
int  widget_id 
)

get text area content

get text area content

Parameters
ctxGUI context
widget_idid of the textarea widget
Returns
pointer to the text content

Definition at line 1738 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, and N_GUI_WIDGET::type.

Referenced by on_send_click().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_textarea_get_text_length()

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)

return the current text length in bytes (0 if widget is invalid)

Parameters
ctxGUI context
widget_idid of the textarea widget
Returns
text length in bytes, or 0 if widget is invalid

Definition at line 2910 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, N_GUI_TEXTAREA_DATA::text_len, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_textarea_scroll_to_bottom()

void n_gui_textarea_scroll_to_bottom ( N_GUI_CTX ctx,
int  widget_id 
)

scroll a multiline textarea to the bottom

Parameters
ctxGUI context
widget_idid of the textarea widget

Definition at line 2810 of file n_gui.c.

References _textarea_content_height(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_TEXTAREA_DATA::multiline, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, N_GUI_TEXTAREA_DATA::scroll_y, N_GUI_CTX::style, N_GUI_TEXTAREA_DATA::text_len, N_GUI_STYLE::textarea_padding, N_GUI_WIDGET::type, and N_GUI_WIDGET::w.

+ Here is the call graph for this function:

◆ n_gui_textarea_scroll_to_offset()

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

Parameters
ctxGUI context
widget_idid of the textarea widget
byte_offsetbyte offset in text to center on screen

Definition at line 2849 of file n_gui.c.

References _text_w(), _textarea_content_height(), _utf8_char_len(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_TEXTAREA_DATA::multiline, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, N_GUI_TEXTAREA_DATA::scroll_from_wheel, N_GUI_TEXTAREA_DATA::scroll_y, N_GUI_STYLE::scrollbar_size, N_GUI_CTX::style, N_GUI_TEXTAREA_DATA::text, N_GUI_TEXTAREA_DATA::text_len, N_GUI_STYLE::textarea_padding, N_GUI_WIDGET::type, and N_GUI_WIDGET::w.

+ Here is the call graph for this function:

◆ n_gui_textarea_set_bitmap()

void n_gui_textarea_set_bitmap ( N_GUI_CTX ctx,
int  widget_id,
ALLEGRO_BITMAP *  bg 
)

set optional background bitmap on a textarea widget.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the widget's lifetime and destroy them after the GUI context is destroyed.

set optional background bitmap on a textarea widget.

Note
Bitmaps are NOT owned by N_GUI.

Definition at line 2463 of file n_gui.c.

References N_GUI_WIDGET::data, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, n_log, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_textarea_set_mask_char()

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.

'*'). Set to '\0' to disable masking. Only affects single-line textareas.

Parameters
ctxthe GUI context
widget_idid of the textarea widget

set a mask character for password-style input (e.g.

Parameters
maskThe character to display instead of actual text (e.g. '*'). Set to '\0' to disable masking.

Definition at line 2477 of file n_gui.c.

References N_GUI_WIDGET::data, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, n_log, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_textarea_set_selection()

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)

Parameters
ctxGUI context
widget_idid of the textarea widget
startselection start byte offset
endselection end byte offset

Definition at line 2832 of file n_gui.c.

References N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, N_GUI_TEXTAREA_DATA::sel_end, N_GUI_TEXTAREA_DATA::sel_start, N_GUI_TEXTAREA_DATA::text_len, and N_GUI_WIDGET::type.

+ Here is the call graph for this function:

◆ n_gui_textarea_set_text()

void n_gui_textarea_set_text ( N_GUI_CTX ctx,
int  widget_id,
const char *  text 
)

set text area content

set text area content

Parameters
ctxGUI context
widget_idid of the textarea widget
textthe text to set, or NULL to clear

Definition at line 1752 of file n_gui.c.

References _normalize_crlf(), N_GUI_TEXTAREA_DATA::char_limit, N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, N_GUI_TEXTAREA_DATA::scroll_x, N_GUI_TEXTAREA_DATA::text, N_GUI_TEXTAREA_DATA::text_len, and N_GUI_WIDGET::type.

Referenced by main(), n_gui_kvtable_add_row(), on_clear_click(), on_completion_select(), and on_send_click().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_toggle_window()

void n_gui_toggle_window ( N_GUI_CTX ctx,
int  window_id 
)

toggle window visibility (show/hide)

toggle window visibility (show/hide)

Definition at line 825 of file n_gui.c.

References n_gui_get_window(), N_GUI_WIN_OPEN, and N_GUI_WINDOW::state.

Referenced by on_window_toggle_click().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_tree_add_node()

int n_gui_tree_add_node ( N_GUI_TREE tree,
const char *  label,
int  parent_index,
void *  user_data 
)

◆ n_gui_tree_create()

N_GUI_TREE * n_gui_tree_create ( N_GUI_CTX ctx,
int  window_id,
float  x,
float  y,
float  w,
float  h,
void(*)(int, void *)  on_select,
void *  user_data 
)

create a tree view in an existing window

Definition at line 7799 of file n_gui.c.

References _n_gui_tree_listbox_selected(), N_GUI_TREE::ctx, FreeNoLog, N_GUI_TREE::listbox_id, Malloc, n_gui_add_listbox(), N_GUI_SELECT_SINGLE, N_GUI_TREE::nb_nodes, N_GUI_TREE::nb_visible, N_GUI_TREE::on_select, and N_GUI_TREE::user_data.

+ Here is the call graph for this function:

◆ n_gui_tree_free()

void n_gui_tree_free ( N_GUI_TREE **  tree)

free a tree view (does not destroy the N_GUI listbox)

Definition at line 7878 of file n_gui.c.

References FreeNoLog.

◆ n_gui_tree_rebuild()

void n_gui_tree_rebuild ( N_GUI_TREE tree)

◆ n_gui_tree_toggle_expand()

void n_gui_tree_toggle_expand ( N_GUI_TREE tree,
int  node_index 
)

toggle expand/collapse of a node

Definition at line 7848 of file n_gui.c.

References N_GUI_TREE_NODE::expanded, N_GUI_TREE_NODE::has_children, n_gui_tree_rebuild(), N_GUI_TREE::nb_nodes, and N_GUI_TREE::nodes.

Referenced by _n_gui_tree_listbox_selected().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_update_transform()

void n_gui_update_transform ( N_GUI_CTX ctx)

recalculate scale and offset from virtual canvas to display.

Called automatically by n_gui_set_display_size when virtual canvas is set. You should not normally need to call this directly.

recalculate scale and offset from virtual canvas to display.

Uses uniform (aspect-preserving) scaling with centred letterboxing, identical to the approach used by BlockBlaster's update_view_offset(). Called automatically by n_gui_set_display_size() when virtual canvas is set.

Definition at line 4992 of file n_gui.c.

References __n_assert, N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_CTX::gui_offset_x, N_GUI_CTX::gui_offset_y, N_GUI_CTX::gui_scale, N_GUI_CTX::virtual_h, and N_GUI_CTX::virtual_w.

Referenced by n_gui_set_display_size(), and n_gui_set_virtual_size().

+ Here is the caller graph for this function:

◆ n_gui_wants_mouse()

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 world)

check if the mouse is currently over any open GUI window (use to prevent click-through to the game world)

Use this to prevent mouse clicks from passing through the GUI to the game.

Parameters
ctxthe GUI context
Returns
1 if the mouse is over a GUI window, 0 otherwise

Definition at line 7344 of file n_gui.c.

References __n_assert, _point_in_rect(), _win_tbh(), N_GUI_CTX::gui_offset_x, N_GUI_CTX::gui_offset_y, N_GUI_CTX::gui_scale, N_GUI_WINDOW::h, list_foreach, N_GUI_CTX::mouse_x, N_GUI_CTX::mouse_y, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WINDOW::state, N_GUI_CTX::virtual_h, N_GUI_CTX::virtual_w, N_GUI_WINDOW::w, N_GUI_CTX::windows, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_window_apply_autofit()

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)

Parameters
ctxthe GUI context
window_idthe window to recalculate

trigger auto-fit recalculation for a window (call after adding/removing/resizing widgets)

Computes content bounding box from visible widgets and adjusts window dimensions based on autofit_flags and autofit_border.

Definition at line 910 of file n_gui.c.

References __n_assert, _win_tbh(), N_GUI_WINDOW::autofit_border, N_GUI_WINDOW::autofit_flags, N_GUI_WINDOW::autofit_origin_x, N_GUI_WINDOW::autofit_origin_y, N_GUI_WINDOW::content_h, N_GUI_WINDOW::content_w, N_GUI_WIDGET::h, N_GUI_WINDOW::h, list_foreach, N_GUI_WINDOW::min_h, N_GUI_WINDOW::min_w, N_GUI_AUTOFIT_CENTER, N_GUI_AUTOFIT_EXPAND_LEFT, N_GUI_AUTOFIT_EXPAND_UP, N_GUI_AUTOFIT_H, N_GUI_AUTOFIT_W, n_gui_get_window(), N_GUI_WIDGET::visible, N_GUI_WIDGET::w, N_GUI_WINDOW::w, N_GUI_WINDOW::widgets, N_GUI_WIDGET::x, N_GUI_WINDOW::x, N_GUI_WIDGET::y, and N_GUI_WINDOW::y.

Referenced by main(), and n_gui_draw().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_window_autosize()

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

recompute and apply minimum-fit size for a window based on its current widgets

Adds padding around the furthest widget extents.

Definition at line 862 of file n_gui.c.

References _win_tbh(), N_GUI_WIDGET::h, N_GUI_WINDOW::h, list_foreach, N_GUI_WINDOW::min_h, N_GUI_WINDOW::min_w, n_gui_get_window(), N_GUI_WIDGET::w, N_GUI_WINDOW::w, N_GUI_WINDOW::widgets, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_window_get_flags()

int n_gui_window_get_flags ( N_GUI_CTX ctx,
int  window_id 
)

get feature flags of a window

get feature flags of a window

Returns
the flags, or 0

Definition at line 852 of file n_gui.c.

References N_GUI_WINDOW::flags, and n_gui_get_window().

+ Here is the call graph for this function:

◆ n_gui_window_get_resize_policy()

int n_gui_window_get_resize_policy ( N_GUI_CTX ctx,
int  window_id 
)

get per-window resize policy

get per-window resize policy

Returns
N_GUI_WIN_RESIZE_NONE, _MOVE, or _SCALE

Definition at line 5094 of file n_gui.c.

References __n_assert, n_gui_get_window(), and N_GUI_WINDOW::resize_policy.

+ Here is the call graph for this function:

◆ n_gui_window_get_zorder()

int n_gui_window_get_zorder ( N_GUI_CTX ctx,
int  window_id 
)

get window z-order mode

get window z-order mode

Definition at line 796 of file n_gui.c.

References __n_assert, n_gui_get_window(), N_GUI_ZORDER_NORMAL, and N_GUI_WINDOW::z_order.

+ Here is the call graph for this function:

◆ n_gui_window_get_zvalue()

int n_gui_window_get_zvalue ( N_GUI_CTX ctx,
int  window_id 
)

get window z-value (for N_GUI_ZORDER_FIXED mode)

get window z-value (for N_GUI_ZORDER_FIXED mode)

Definition at line 806 of file n_gui.c.

References __n_assert, n_gui_get_window(), and N_GUI_WINDOW::z_value.

+ Here is the call graph for this function:

◆ n_gui_window_is_open()

int n_gui_window_is_open ( N_GUI_CTX ctx,
int  window_id 
)

check if window is visible

check if window is visible

Returns
1 if open, 0 if closed

Definition at line 834 of file n_gui.c.

References n_gui_get_window(), N_GUI_WIN_OPEN, and N_GUI_WINDOW::state.

Referenced by on_windows_menu_open().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_window_set_autofit()

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

Parameters
ctxthe GUI context
window_idthe window to configure
autofit_flagsbitmask of N_GUI_AUTOFIT_W, N_GUI_AUTOFIT_H, N_GUI_AUTOFIT_EXPAND_LEFT, N_GUI_AUTOFIT_EXPAND_UP
borderpadding in pixels between content bounding box and window edge (on each side)

configure auto-fit behavior for a dialog window

Store the flags and border value in the window struct.

Definition at line 891 of file n_gui.c.

References __n_assert, N_GUI_WINDOW::autofit_border, N_GUI_WINDOW::autofit_flags, N_GUI_WINDOW::autofit_origin_x, N_GUI_WINDOW::autofit_origin_y, LOG_ERR, n_gui_get_window(), n_log, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_window_set_bitmaps()

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.

Pass NULL for any bitmap you don't want to set.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the window's lifetime and destroy them after the GUI context is destroyed.
Parameters
ctxthe GUI context
window_idid of the target window
bgbody background bitmap (NULL = color fill)
titlebartitlebar background bitmap (NULL = color fill)
bg_scale_modescale mode for bg: N_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, or N_GUI_IMAGE_CENTER

set optional bitmap overlays on a window's body and titlebar.

Note
Bitmaps are NOT owned by N_GUI. The caller must keep them alive for the window's lifetime and destroy them after the GUI context is destroyed.

Definition at line 2397 of file n_gui.c.

References N_GUI_WINDOW::bg_bitmap, N_GUI_WINDOW::bg_scale_mode, LOG_WARNING, n_gui_get_window(), n_log, and N_GUI_WINDOW::titlebar_bitmap.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_window_set_flags()

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, ...)

Parameters
ctxthe GUI context
window_idid of the target window
flagsbitmask of N_GUI_WIN_* flags to set

set feature flags on a window (N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_RESIZABLE, ...)

Definition at line 843 of file n_gui.c.

References N_GUI_WINDOW::flags, and n_gui_get_window().

Referenced by main(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_window_set_resize_policy()

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).

Automatically captures normalized coordinates from the window's current position/size relative to the current display size.

set per-window resize policy (N_GUI_WIN_RESIZE_NONE / _MOVE / _SCALE).

Automatically captures normalized coordinates from the window's current position/size relative to the current display size.

Definition at line 5081 of file n_gui.c.

References __n_assert, _n_gui_window_capture_normalized(), n_gui_get_window(), and N_GUI_WINDOW::resize_policy.

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ n_gui_window_set_zorder()

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

Parameters
ctxthe GUI context
window_idthe window to configure
z_modeone of N_GUI_ZORDER_NORMAL, N_GUI_ZORDER_ALWAYS_ON_TOP, N_GUI_ZORDER_ALWAYS_BEHIND, N_GUI_ZORDER_FIXED
z_valuez-value for N_GUI_ZORDER_FIXED mode (lower = behind, higher = on top), ignored for other modes

set window z-order mode and value

Re-sorts the window list after changing.

Definition at line 779 of file n_gui.c.

References __n_assert, _sort_windows_by_zorder(), LOG_ERR, n_gui_get_window(), N_GUI_ZORDER_ALWAYS_BEHIND, N_GUI_ZORDER_ALWAYS_ON_TOP, N_GUI_ZORDER_FIXED, N_GUI_ZORDER_NORMAL, n_log, N_GUI_WINDOW::z_order, and N_GUI_WINDOW::z_value.

+ Here is the call graph for this function:

◆ n_gui_window_update_normalized()

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.

Call after programmatically moving/resizing a window if you want the new position to be the adaptive reference point.

recapture normalized coordinates for a window from its current absolute position/size.

Call after programmatically moving/resizing a window if you want the new position to be the adaptive reference point.

Definition at line 5107 of file n_gui.c.

References __n_assert, _n_gui_window_capture_normalized(), N_GUI_CTX::display_h, N_GUI_CTX::display_w, n_gui_get_window(), N_GUI_CTX::ref_display_h, and N_GUI_CTX::ref_display_w.

+ Here is the call graph for this function: