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_CUSTOM_DATA
 Owner-draw custom widget data: a paint callback, an optional mouse callback, and their user pointers. More...
struct  N_GUI_DATAGRID_COL
 one data grid column definition More...
struct  N_GUI_DATAGRID_DATA
 data grid specific data: a sortable column table 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_HEXVIEW_DATA
 hex viewer specific data: a read-only byte dump 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_MARKDOWNVIEW_DATA
 markdownview specific data. More...
struct  N_GUI_MOUSE_EVENT
 A mouse event handed to a custom widget, in the widget's own coordinates. More...
struct  N_GUI_PENDING_GEOM
 A saved window position retained for a window not yet created at load time (see N_GUI_CTX::pending_layout). More...
struct  N_GUI_PENDING_WIDGET
 Saved user-adjustable state for a keyed widget that did not exist when the layout was loaded (a lazily-created splitpane/datagrid). More...
struct  N_GUI_PROGRESSBAR_DATA
 Progress-bar widget data (display only). More...
struct  N_GUI_RADIOLIST_DATA
 radio list specific data More...
struct  N_GUI_SB_TRACK
 Where a scrollbar a widget draws inside itself was last painted, and whether the pointer is on it. More...
struct  N_GUI_SCROLLBAR_DATA
 scrollbar specific data More...
struct  N_GUI_SECTION
 a single foldable section: a clickable header plus the member widgets it shows/hides More...
struct  N_GUI_SECTIONLIST
 a vertical accordion of foldable sections inside one window; folding hides a section's widgets and re-stacks the rest, leaving the window's N_GUI_WIN_AUTO_SCROLLBAR to absorb any overflow More...
struct  N_GUI_SLIDER_DATA
 slider specific data More...
struct  N_GUI_SPLITPANE_DATA
 split pane specific data: a draggable divider between two regions More...
struct  N_GUI_STYLE
 Global style holding every configurable layout constant. More...
struct  N_GUI_SYNTAXVIEW_DATA
 syntax view specific data: read-only highlighted text More...
struct  N_GUI_TAB_PANEL
 tab panel built from toggle buttons with content window management More...
struct  N_GUI_TB_BUTTONS
 Titlebar button state for a window (minimize, maximize, close). 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_TREE_STATE
 A tree's view state, captured by path so it survives a rebuild that replaces every node (a reloaded model has new pointers and new indices). 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_COMBOBOX_EXPAND_UP   2
 dropdown panel opens upward (above the widget) instead of downward.
#define N_GUI_DETACH_NONE   0
 no option
#define N_GUI_DETACH_OWN_CHROME   4
 keep N_GUI's own window chrome instead of the window manager's: the native window is created frameless and the window keeps drawing its own title bar, so a detached window looks and skins exactly like the pop-up it came from.
#define N_GUI_DETACH_RESIZABLE   1
 the native window can be resized by the user through the OS window manager
#define N_GUI_DETACH_SCALE_CONTENT   2
 scale the window's widgets when the native window is resized by the user.
#define N_GUI_DROP_AFTER   2
#define N_GUI_DROP_BEFORE   0
 drop position relative to a tree row (drag-and-drop)
#define N_GUI_DROP_INTO   1
#define N_GUI_DROPMENU_EXPAND_UP   1
 dropdown panel opens upward (above the button) instead of downward.
#define N_GUI_GLOBAL_SCROLL_SLACK   0.5f
 how far, in pixels, the open windows may reach past the display before the global scrollbars appear: under half a pixel is a rounding error of a layout computed in floats, and hides nothing
#define N_GUI_GLYPH_ARROW_DOWN   2
 filled triangle pointing down
#define N_GUI_GLYPH_ARROW_LEFT   3
 filled triangle pointing left
#define N_GUI_GLYPH_ARROW_RIGHT   4
 filled triangle pointing right
#define N_GUI_GLYPH_ARROW_UP   1
 filled triangle pointing up
#define N_GUI_GLYPH_COPY   8
 two offset sheets: duplicate / copy
#define N_GUI_GLYPH_COUNT   9
 number of defined glyphs, for range checks
#define N_GUI_GLYPH_CROSS   7
 diagonal cross
#define N_GUI_GLYPH_MINUS   6
 minus sign
#define N_GUI_GLYPH_NONE   0
 no glyph: the button draws its text label (default)
#define N_GUI_GLYPH_PLUS   5
 plus sign
#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_MOUSE_DOWN   1
 custom widget mouse event: a press inside it, button 1 or 2
#define N_GUI_MOUSE_DRAG   4
 custom widget mouse event: the pointer moved with button 1 held after a press in it; reported outside the widget too, as a slider's drag is
#define N_GUI_MOUSE_MOVE   3
 custom widget mouse event: the pointer moved over it with no button held
#define N_GUI_MOUSE_UP   2
 custom widget mouse event: the release of a button 1 press that began in it, wherever the pointer is now
#define N_GUI_MOUSE_WHEEL   5
 custom widget mouse event: the wheel turned over it
#define N_GUI_PERSIST_MAX_COLS   64
 Maximum datagrid columns whose layout is persisted per widget.
#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_SECTION_WIDGETS_MAX   96
 maximum number of member widgets per section.
#define N_GUI_SECTIONLIST_MAX   16
 maximum number of foldable sections in a section list
#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_SPLIT_HORIZONTAL   1
 split pane: horizontal divider, regions are top and bottom
#define N_GUI_SPLIT_VERTICAL   0
 split pane: vertical divider, regions are left and right
#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_SUGGEST_MAX   64
 most completions a textarea's suggestion list keeps for one prefix.
#define N_GUI_SUGGEST_SEP_MAX   8
 longest separator set a suggestion-aware textarea takes, including the terminator
#define N_GUI_SUGGEST_VISIBLE   8
 most completions a suggestion panel shows at once.
#define N_GUI_SYNTAX_DIFF   6
 syntax view: unified diff highlighting (added, removed and hunk header lines, as produced by n_diff_to_unified).
#define N_GUI_SYNTAX_HTTP   1
 syntax view: HTTP message highlighting (request/status line and headers)
#define N_GUI_SYNTAX_JS   5
 syntax view: JavaScript highlighting (keywords, strings, numbers, comments)
#define N_GUI_SYNTAX_JSON   2
 syntax view: JSON highlighting (keys, strings, numbers, punctuation)
#define N_GUI_SYNTAX_PLAIN   0
 syntax view: no highlighting
#define N_GUI_SYNTAX_XML   3
 syntax view: XML/HTML highlighting (tags, attributes, quoted values, comments)
#define N_GUI_SYNTAX_YAML   4
 syntax view: YAML highlighting (keys, quoted values, list markers, comments)
#define N_GUI_TAB_MAX   16
 maximum number of tabs in a single tab panel
#define N_GUI_TB_BTN_CLOSE   3
 close titlebar button
#define N_GUI_TB_BTN_MAXIMIZE   2
 maximize/restore titlebar button
#define N_GUI_TB_BTN_MINIMIZE   1
 minimize titlebar button
#define N_GUI_TB_BTN_NONE   0
 no titlebar button
#define N_GUI_TEXT_MAX   4096
 maximum length for textarea content
#define N_GUI_TREE_MAX   2048
 maximum number of nodes in a tree view
#define N_GUI_TREE_PATH_MAX   1024
 maximum length of a node path (labels from the root, joined)
#define N_GUI_TREE_PATH_SEP   '\x1f'
 separator joining the labels of a node path.
#define N_GUI_TREE_STATE_MAX   512
 maximum number of expanded paths remembered by an N_GUI_TREE_STATE
#define N_GUI_TRUNCATE_END   0
 text too wide for its box is cut at the end, "Long senten...": the default, right for a sentence
#define N_GUI_TRUNCATE_PATH   2
 a path too wide for its box loses whole leading components, ".../photos/IMG_0001.CR3", and the file name only if it is wider than the box on its own; both '/' and '\' separate components
#define N_GUI_TRUNCATE_START   1
 text too wide for its box is cut at the start, "...ong sentence": for anything whose end is what tells it apart
#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_CUSTOM   17
 widget type: owner-draw custom widget (rendering delegated to a callback)
#define N_GUI_TYPE_DATAGRID   15
 widget type: sortable column data grid
#define N_GUI_TYPE_DROPMENU   11
 widget type: dropdown menu with static and dynamic entries
#define N_GUI_TYPE_HEXVIEW   13
 widget type: read-only hexadecimal byte viewer
#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_MARKDOWNVIEW   18
 widget type: read-only scrolling Markdown view
#define N_GUI_TYPE_PROGRESSBAR   16
 widget type: horizontal progress bar (display only)
#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_SPLITPANE   12
 widget type: split pane with a draggable divider between two regions
#define N_GUI_TYPE_SYNTAXVIEW   14
 widget type: read-only syntax-highlighted text view
#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_BTN_ALL   (N_GUI_WIN_BTN_MINIMIZE | N_GUI_WIN_BTN_MAXIMIZE | N_GUI_WIN_BTN_CLOSE)
 enable all three title bar buttons (minimize + maximize + close)
#define N_GUI_WIN_BTN_CLOSE   1024
 enable close button on the title bar
#define N_GUI_WIN_BTN_MAXIMIZE   512
 enable maximize/restore button on the title bar
#define N_GUI_WIN_BTN_MINIMIZE   256
 enable minimize button on the title bar
#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_HSCROLL_HOVER   256
 pointer is over the window's horizontal auto-scrollbar
#define N_GUI_WIN_MAXIMISED   64
 window is maximised (full display size)
#define N_GUI_WIN_MINIMISED   2
 window is minimised (title bar only)
#define N_GUI_WIN_NO_HSCROLL   2048
 with N_GUI_WIN_AUTO_SCROLLBAR, never show the horizontal scrollbar (vertical-only scrolling): content wider than the window is clipped instead of horizontally scrolled
#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_WIN_VSCROLL_HOVER   128
 pointer is over the window's vertical auto-scrollbar
#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
#define N_GUI_ZORDER_POPUP   4
 popup/modal dialogs: drawn above EVERYTHING including ALWAYS_ON_TOP windows.

Typedefs

typedef void(* N_GUI_CUSTOM_DRAW) (N_GUI_WIDGET *widget, float x, float y, ALLEGRO_FONT *font, void *user_data)
 Owner-draw callback for a custom widget (N_GUI_TYPE_CUSTOM).
typedef int(* N_GUI_CUSTOM_MOUSE) (int widget_id, const N_GUI_MOUSE_EVENT *ev, void *user_data)
 Mouse callback for a custom widget, set with n_gui_custom_set_mouse().
typedef void(* N_GUI_SUGGEST_FN) (const char *prefix, N_GUI_SUGGEST_SINK *sink, void *user_data)
 asked for the completions of what has been typed so far
typedef int(* n_gui_tree_on_drop_t) (int src_node, int dst_node, int position, void *user_data)
 drag-reorder drop callback.

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_custom (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, N_GUI_CUSTOM_DRAW draw, void *user_data)
 Add an owner-draw custom widget to a window.
int n_gui_add_datagrid (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, void(*on_select)(int, int, void *), void *user_data)
 add a sortable data grid; returns the widget id or -1
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_hexview (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h)
 add a read-only hex viewer; returns the widget id or -1
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_markdownview (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, const N_GUI_MD_FONTS *fonts)
 add a read-only scrolling Markdown view.
int n_gui_add_progressbar (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h)
 add a horizontal progress bar (display only); returns the widget id or -1
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_splitpane (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int orientation, float ratio, void(*on_change)(int, float, void *), void *user_data)
 add a split pane (draggable divider); returns the widget id or -1
int n_gui_add_syntaxview (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int mode)
 add a read-only syntax-highlighted text view; returns the widget id or -1
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_get_glyph (N_GUI_CTX *ctx, int widget_id)
 current glyph of a button, or N_GUI_GLYPH_NONE when it draws its label (also for a non-button widget)
const char * n_gui_button_get_label (N_GUI_CTX *ctx, int widget_id)
 What a button says.
int n_gui_button_is_toggled (N_GUI_CTX *ctx, int widget_id)
 check if button is toggled
void n_gui_button_set_glyph (N_GUI_CTX *ctx, int widget_id, int glyph)
 draw an N_GUI_GLYPH_* icon (primitives, in the button's text colour) instead of the label; N_GUI_GLYPH_NONE restores the label.
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_label (N_GUI_CTX *ctx, int widget_id, const char *label)
 replace the label text drawn on a button
void n_gui_button_set_state_bitmaps (N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *normal, ALLEGRO_BITMAP *hover, ALLEGRO_BITMAP *active)
 skin a button or toggle button with caller-owned per-state bitmaps (switches its shape to N_GUI_SHAPE_BITMAP; toggled-on renders active)
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
const char * n_gui_checkbox_get_label (N_GUI_CTX *ctx, int widget_id)
 What a checkbox says.
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_checkbox_set_label (N_GUI_CTX *ctx, int widget_id, const char *label)
 Replace the text drawn beside a checkbox.
void n_gui_close_menus (N_GUI_CTX *ctx)
 Put away any open combo box list or drop menu panel.
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_count (N_GUI_CTX *ctx, int widget_id)
 get the number of items in a combobox (0 if not a combobox).
const char * n_gui_combobox_get_item_text (N_GUI_CTX *ctx, int widget_id, int index)
 get the text of the combobox item at index ("" if out of range / not a combobox)
int n_gui_combobox_get_selected (N_GUI_CTX *ctx, int widget_id)
 get the selected item index
int n_gui_combobox_remove_item (N_GUI_CTX *ctx, int widget_id, int index)
 remove the item at index from a combobox.
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
int n_gui_count_detached (N_GUI_CTX *ctx)
 count the windows currently detached into native OS windows
void n_gui_custom_set_destroy (N_GUI_CTX *ctx, int widget_id, void(*destroy)(void *user_data))
 hand a custom widget's paint user pointer to the widget
void n_gui_custom_set_mouse (N_GUI_CTX *ctx, int widget_id, N_GUI_CUSTOM_MOUSE on_mouse, void *user_data)
 give a custom widget mouse input
int n_gui_datagrid_add_column (N_GUI_CTX *ctx, int widget_id, const char *title, float width)
 append a column with a header title and pixel width; returns the column index or -1
int n_gui_datagrid_add_row (N_GUI_CTX *ctx, int widget_id, const char **values)
 append a row of cell strings (values must have one entry per column); returns the row index or -1
void n_gui_datagrid_clear_row_color (N_GUI_CTX *ctx, int widget_id, int row)
 remove the background tint of data row row (it draws untinted again)
void n_gui_datagrid_clear_row_colors (N_GUI_CTX *ctx, int widget_id)
 remove every row background tint (the rows and cells are kept)
void n_gui_datagrid_clear_rows (N_GUI_CTX *ctx, int widget_id)
 remove all rows from a data grid (columns are kept)
void n_gui_datagrid_clear_selection (N_GUI_CTX *ctx, int widget_id)
 clear the entire selection (no row selected)
float n_gui_datagrid_columns_width (N_GUI_CTX *ctx, int widget_id)
 horizontal scroll offset in pixels (how far the columns are scrolled left when their total width exceeds the widget's pane), or 0.
int n_gui_datagrid_display_to_physical (N_GUI_CTX *ctx, int widget_id, int display_pos)
 physical column shown at display position display_pos, or -1 if out of range
const char * n_gui_datagrid_get_cell (N_GUI_CTX *ctx, int widget_id, int row, int col)
 get a cell string by row and column, or NULL if out of range
size_t n_gui_datagrid_get_column_count (N_GUI_CTX *ctx, int widget_id)
 number of columns in a data grid (physical), or 0
const char * n_gui_datagrid_get_column_title (N_GUI_CTX *ctx, int widget_id, int col)
 header title of physical column col, or "" if out of range
int n_gui_datagrid_get_column_visible (N_GUI_CTX *ctx, int widget_id, int col)
 whether physical column col is visible (1) or hidden (0); 0 if out of range
float n_gui_datagrid_get_column_width (N_GUI_CTX *ctx, int widget_id, int col)
 current pixel width of physical column col, or 0 if out of range
float n_gui_datagrid_get_h_scroll (N_GUI_CTX *ctx, int widget_id)
int n_gui_datagrid_get_row_color (N_GUI_CTX *ctx, int widget_id, int row, ALLEGRO_COLOR *out)
 report whether data row row carries a background tint (1) or not (0), and copy the tint into out when it does.
int n_gui_datagrid_get_row_count (N_GUI_CTX *ctx, int widget_id)
 get the number of rows in a data grid
int n_gui_datagrid_get_scroll_offset (N_GUI_CTX *ctx, int widget_id)
 first visible data row (the vertical scroll position), or 0.
int n_gui_datagrid_get_selected (N_GUI_CTX *ctx, int widget_id)
 get the selected row index, or -1 if none
size_t n_gui_datagrid_get_selected_rows (N_GUI_CTX *ctx, int widget_id, int *out, size_t max)
 fill out with the indices of the selected rows (ascending), up to max, and return the total number of selected rows.
int n_gui_datagrid_get_sort (N_GUI_CTX *ctx, int widget_id, int *col, int *dir)
 read back the sort a datagrid is currently showing.
int n_gui_datagrid_is_row_selected (N_GUI_CTX *ctx, int widget_id, int row)
 report whether a given data row is selected (1) or not (0)
void n_gui_datagrid_move_column (N_GUI_CTX *ctx, int widget_id, int from, int to)
 move the column at display position from to display position to, shifting the columns in between (reorders how columns are laid out; the cells and physical indices are unchanged)
void n_gui_datagrid_select_row (N_GUI_CTX *ctx, int widget_id, int row, int selected)
 select (1) or deselect (0) a single row in a multi-select grid programmatically (e.g.
void n_gui_datagrid_set_column_visible (N_GUI_CTX *ctx, int widget_id, int col, int visible)
 show (1) or hide (0) physical column col; hidden columns keep their cells but are skipped in the header and rows and closed up so no gap remains
void n_gui_datagrid_set_column_width (N_GUI_CTX *ctx, int widget_id, int col, float width)
 set the pixel width of physical column col (clamped to a small minimum)
void n_gui_datagrid_set_h_scroll (N_GUI_CTX *ctx, int widget_id, float px)
 set the horizontal scroll offset in pixels (clamped to >= 0; the draw path re-clamps to the live content width each frame, so a stale value after a rebuild is harmless).
void n_gui_datagrid_set_multiselect (N_GUI_CTX *ctx, int widget_id, int enabled)
 enable (1) or disable (0) multi-row selection.
void n_gui_datagrid_set_on_columns_changed (N_GUI_CTX *ctx, int widget_id, void(*cb)(int, void *))
 set the callback fired after the user drags a column border to resize it, so the host can persist the layout.
void n_gui_datagrid_set_on_context (N_GUI_CTX *ctx, int widget_id, void(*on_context)(int, int, int, int, void *))
 set the right-click context callback; fired (with the cursor x/y in GUI coordinates) when a data row is right-clicked, after selecting that row.
void n_gui_datagrid_set_row_color (N_GUI_CTX *ctx, int widget_id, int row, ALLEGRO_COLOR color)
 paint data row row with a background tint (a per-row highlight, e.g.
void n_gui_datagrid_set_scroll_offset (N_GUI_CTX *ctx, int widget_id, int offset)
 set the first visible data row (clamped to the row count); the draw path re-clamps to the live viewport each frame, so a stale offset after a rebuild is harmless.
void n_gui_datagrid_set_selected (N_GUI_CTX *ctx, int widget_id, int row)
 set the selected row index (fires the on_select callback).
void n_gui_datagrid_sort (N_GUI_CTX *ctx, int widget_id, int col, int dir)
 sort the rows by a column (dir 1 ascending, -1 descending)
N_GUI_STYLE n_gui_default_style (void)
 return the built-in default style
N_GUI_THEME n_gui_default_tb_btn_theme (void)
 return the built-in default theme for titlebar minimize/maximize buttons
N_GUI_THEME n_gui_default_tb_close_theme (void)
 return the built-in default theme for the titlebar close button (red hover/active)
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.
int n_gui_double_clicked_widget (const N_GUI_CTX *ctx)
 id of the widget the primary press just processed double clicked, or -1.
void n_gui_draw (N_GUI_CTX *ctx)
 draw all visible GUI windows and widgets
void n_gui_draw_detached (N_GUI_CTX *ctx)
 render and flip every detached window, and release the ones whose native window was closed.
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
int n_gui_dropmenu_is_open (N_GUI_CTX *ctx, int widget_id)
 is a dropdown menu's panel showing
float n_gui_dropmenu_panel_width (N_GUI_CTX *ctx, int widget_id)
 width the open panel needs to show its entries without truncation: the larger of the collapsed button width and the widest entry text (plus item padding on both sides and the scrollbar width when the entry count overflows the visible window).
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
void n_gui_dropmenu_set_flags (N_GUI_CTX *ctx, int widget_id, int flags)
 set dropmenu feature flags (bitmask of N_GUI_DROPMENU_* values)
void n_gui_dropmenu_set_label (N_GUI_CTX *ctx, int widget_id, const char *label)
 replace the button label shown on a dropmenu (NULL clears it)
int n_gui_dropmenu_set_open (N_GUI_CTX *ctx, int widget_id, int open)
 open or close a dropdown menu without anybody clicking its button.
int n_gui_focus_takes_key (const N_GUI_CTX *ctx, int keycode)
 Would the focused widget do something with this particular key.
void n_gui_focus_window (N_GUI_CTX *ctx, int window_id)
 give a window keyboard focus: raise it within its z-order group and focus its first focusable widget (clears focus if it has none)
int n_gui_get_cursor (N_GUI_CTX *ctx, ALLEGRO_MOUSE_CURSOR **custom)
 The cursor the GUI last applied to the display.
float n_gui_get_dpi_scale (const N_GUI_CTX *ctx)
 get current DPI scale factor
ALLEGRO_EVENT_QUEUE * n_gui_get_event_queue (N_GUI_CTX *ctx)
 get the event queue previously given to n_gui_set_event_queue (NULL if none)
int n_gui_get_focus (const N_GUI_CTX *ctx)
 Which widget has the keyboard, or -1 when none has.
int n_gui_get_key_modifiers (const N_GUI_CTX *ctx)
 the modifier keys held down now, as the GUI has seen them
int n_gui_get_resize_mode (N_GUI_CTX *ctx)
 get current resize mode
int n_gui_get_shape_mode (N_GUI_CTX *ctx)
 get the global widget shape (N_GUI_SHAPE_ROUNDED or N_GUI_SHAPE_RECT)
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.
int n_gui_get_topmost_open_window (const N_GUI_CTX *ctx)
 get the id of the frontmost open, non-minimized window (the last one in draw order), or -1 if no window is open.
N_GUI_WIDGET * n_gui_get_widget (N_GUI_CTX *ctx, int widget_id)
 get a widget by id
N_GUI_WINDOW * n_gui_get_window (N_GUI_CTX *ctx, int window_id)
 get a window by id
size_t n_gui_hexview_get_cursor (N_GUI_CTX *ctx, int widget_id)
 the byte offset the edit cursor sits on
const unsigned char * n_gui_hexview_get_data (N_GUI_CTX *ctx, int widget_id, size_t *len)
 borrow the bytes a hex view holds (valid until the next edit or set_data); *len receives the count.
size_t n_gui_hexview_get_length (N_GUI_CTX *ctx, int widget_id)
 get the number of bytes currently held by a hex viewer
void n_gui_hexview_set_cursor (N_GUI_CTX *ctx, int widget_id, size_t offset)
 move the edit cursor to a byte offset (clamped to the data length)
void n_gui_hexview_set_data (N_GUI_CTX *ctx, int widget_id, const unsigned char *data, size_t len)
 set (copy) the bytes shown by a hex viewer; data may be NULL to clear
void n_gui_hexview_set_editable (N_GUI_CTX *ctx, int widget_id, int editable)
 make a hex view editable (or read-only again)
void n_gui_hexview_set_on_change (N_GUI_CTX *ctx, int widget_id, void(*on_change)(int, const unsigned char *, size_t, void *), void *user_data)
 set the callback fired after each edit (NULL to clear)
int n_gui_hovered_widget (const N_GUI_CTX *ctx)
 id of the widget currently under the mouse pointer (hover/active flag, maintained by n_gui_process_event; front-most open window wins), or -1.
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
void n_gui_kvtable_clear (N_GUI_KVTABLE *table)
 remove every row at once.
N_GUI_KVTABLE * n_gui_kvtable_create (N_GUI_CTX *ctx, int window_id, float row_height, float padding, void(*on_remove)(int, void *), void *user_data)
 create a KV table in an existing window
int n_gui_kvtable_duplicate_row (N_GUI_KVTABLE *table, int row_index)
 insert a copy of the row at row_index directly after it.
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 (const N_GUI_KVTABLE *table)
 get the number of active rows
int n_gui_kvtable_move_row (N_GUI_KVTABLE *table, int row_index, int direction)
 move the row at row_index one position up (direction < 0) or down (direction > 0) among the ACTIVE rows, by swapping their contents.
void n_gui_kvtable_relayout (N_GUI_KVTABLE *table)
 re-apply layout to all KV table widgets (positions, sizes, normalized coords).
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_kvtable_set_columns (N_GUI_KVTABLE *table, int show_value, int show_desc, int show_enabled)
 choose which optional columns are shown: Value, Description, and the enabled checkbox.
void n_gui_kvtable_set_placeholders (N_GUI_KVTABLE *table, const char *key_hint, const char *value_hint)
 set the placeholder/hint text shown in each row's key (and value) textarea while it is empty.
void n_gui_kvtable_set_row_actions (N_GUI_KVTABLE *table, int enabled)
 show (1) or hide (0, the default) the per-row action buttons: move up, move down and duplicate, drawn as glyphs next to the remove button.
void n_gui_kvtable_set_top_offset (N_GUI_KVTABLE *table, float top_offset)
 reserve top_offset unscaled pixels above the header row so other widgets (a toolbar, a heading) can share the table's window without overlapping it.
int n_gui_label_fits (N_GUI_CTX *ctx, int widget_id, float *needed_w, float *needed_h)
 report whether a label's text is drawn in full inside its own box, and how big it would have to be to show all of it (out-params may be NULL)
const char * n_gui_label_get_text (N_GUI_CTX *ctx, int widget_id)
 What a label says now.
int n_gui_label_get_truncate (N_GUI_CTX *ctx, int widget_id)
 the label's truncate mode, N_GUI_TRUNCATE_END when it is not a label
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
void n_gui_label_set_truncate (N_GUI_CTX *ctx, int widget_id, int mode)
 choose where a label's text is shortened when it does not fit: N_GUI_TRUNCATE_END (the default), N_GUI_TRUNCATE_START or N_GUI_TRUNCATE_PATH.
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
float n_gui_listbox_content_width (N_GUI_CTX *ctx, int widget_id)
 width in pixels the widest item needs to be drawn in full (text padding included), or 0 for an empty list / non-listbox widget.
int n_gui_listbox_get_count (N_GUI_CTX *ctx, int widget_id)
 get number of items in a listbox
float n_gui_listbox_get_h_scroll (N_GUI_CTX *ctx, int widget_id)
 current horizontal scroll offset in pixels (0 = leftmost)
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_h_scroll (N_GUI_CTX *ctx, int widget_id, float px)
 set the horizontal scroll offset in pixels; clamped to >= 0 here and to the live content width by the draw path, so a stale value after a refill is harmless
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_layout_json (N_GUI_CTX *ctx, const char *filepath)
 Load a JSON window layout file and apply it to matching windows in the context.
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_mark_dirty (N_GUI_CTX *ctx)
 Mark the GUI as needing a redraw.
float n_gui_markdownview_content_height (N_GUI_CTX *ctx, int widget_id)
 the height of the whole document at the width it was last drawn at, or 0 before the first draw
float n_gui_markdownview_get_scroll (N_GUI_CTX *ctx, int widget_id)
 how far down the content the view is, in pixels
const char * n_gui_markdownview_get_text (N_GUI_CTX *ctx, int widget_id)
 the Markdown source, owned by the widget, or NULL
void n_gui_markdownview_scroll_to (N_GUI_CTX *ctx, int widget_id, float y)
 scroll to y pixels down the content, clamped to what there is
void n_gui_markdownview_set_fonts (N_GUI_CTX *ctx, int widget_id, const N_GUI_MD_FONTS *fonts)
 replace the faces; the new ones are borrowed on the same terms
void n_gui_markdownview_set_on_link (N_GUI_CTX *ctx, int widget_id, void(*on_link)(int widget_id, const char *url, void *user_data), void *user_data)
 call on_link when a link in the view is clicked (NULL to stop).
void n_gui_markdownview_set_text (N_GUI_CTX *ctx, int widget_id, const char *text)
 set the Markdown source (copied; NULL clears it).
N_GUI_MD_STYLE * n_gui_markdownview_style (N_GUI_CTX *ctx, int widget_id)
 the view's style, to read or to change in place, or NULL if there is no such widget.
void n_gui_maximize_window (N_GUI_CTX *ctx, int window_id)
 toggle maximised state (full display or restore to previous size)
int n_gui_menu_is_open (const N_GUI_CTX *ctx)
 Is a combo box's list or a drop menu's panel currently open.
void n_gui_minimize_window (N_GUI_CTX *ctx, int window_id)
 minimize a window (title bar only)
int n_gui_needs_redraw (N_GUI_CTX *ctx)
 Return non-zero if the GUI must be redrawn this frame, i.e.
N_GUI_CTX * n_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
float n_gui_progressbar_get_value (N_GUI_CTX *ctx, int widget_id)
 get the current progress fraction (0.0 on an invalid widget)
void n_gui_progressbar_set_text (N_GUI_CTX *ctx, int widget_id, const char *text)
 set the centered overlay text (NULL or "" clears it)
void n_gui_progressbar_set_value (N_GUI_CTX *ctx, int widget_id, float value)
 set the progress fraction (clamped to 0.0 .
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)
void n_gui_reset_all_widget_themes (N_GUI_CTX *ctx)
 reset all widget and window themes to ctx->default_theme
void n_gui_restore_window (N_GUI_CTX *ctx, int window_id)
 restore a minimised window to its full size
int n_gui_save_layout_json (N_GUI_CTX *ctx, const char *filepath)
 Save the geometry + persistent state of every window in the context to a JSON file.
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_scrollbar_set_wheel_step (N_GUI_CTX *ctx, int widget_id, double step)
 set how far one wheel notch moves a scrollbar, in its content units: 1 for a list whose content is counted in rows moves it a row a notch.
int n_gui_sectionlist_add_section (N_GUI_SECTIONLIST *sl, const char *title, float header_y, int folded)
 add a section with a header button at header_y (members added next are captured relative to it); returns the section index or -1
int n_gui_sectionlist_add_widget (N_GUI_SECTIONLIST *sl, int section_index, int widget_id)
 register an existing widget as a member of a section (captures its current y as the fold offset).
float n_gui_sectionlist_content_height (const N_GUI_SECTIONLIST *sl)
 total content height in pixels under the current fold state, for sizing/scrolling the host window
N_GUI_SECTIONLIST * n_gui_sectionlist_create (N_GUI_CTX *ctx, int window_id, float x, float y0, float width, float header_h, float gap, void(*on_toggle)(int, int, void *), void *user_data)
 create an empty section list anchored at (x,y0) in window_id; sections stack downward from y0
void n_gui_sectionlist_free (N_GUI_SECTIONLIST **sl)
 free the section list (does not destroy the N_GUI widgets or window)
int n_gui_sectionlist_get_count (const N_GUI_SECTIONLIST *sl)
 number of sections in the list
int n_gui_sectionlist_get_order (const N_GUI_SECTIONLIST *sl, int position)
 The section stacked at a position.
int n_gui_sectionlist_is_folded (const N_GUI_SECTIONLIST *sl, int section_index)
 query a section's folded state (1 = folded, 0 = expanded)
int n_gui_sectionlist_is_section_hidden (const N_GUI_SECTIONLIST *sl, int section_index)
 Is a section left out of the stack.
void n_gui_sectionlist_relayout (N_GUI_SECTIONLIST *sl)
 re-stack all sections from y0 by current fold state: hide folded members, show and reposition expanded ones
void n_gui_sectionlist_set_first_inset (N_GUI_SECTIONLIST *sl, float inset)
 set a left inset applied to the FIRST section's header only, so a caller can place a button before it on the same row; relayout re-applies it
void n_gui_sectionlist_set_folded (N_GUI_SECTIONLIST *sl, int section_index, int folded)
 set a section's folded state and relayout; does NOT fire on_toggle (for programmatic restore)
void n_gui_sectionlist_set_geometry (N_GUI_SECTIONLIST *sl, float x, float y0, float width, float header_h, float gap)
 restate where the list stacks from, how wide its headers are and the two heights it stacks with, for a caller whose window is resized or whose interface scale changes after the list was made.
void n_gui_sectionlist_set_order (N_GUI_SECTIONLIST *sl, const int *order, int count)
 Stack the sections in another order.
void n_gui_sectionlist_set_section_hidden (N_GUI_SECTIONLIST *sl, int section_index, int hidden)
 Leave a whole section out of the stack, header and members, or put it back.
void n_gui_sectionlist_set_widget_hidden (N_GUI_SECTIONLIST *sl, int section_index, int widget_id, int hidden)
 keep a member hidden whatever the fold state, and leave it out of the section's height.
void n_gui_sectionlist_set_widget_offset (N_GUI_SECTIONLIST *sl, int section_index, int widget_id, float dy)
 state a member's y offset from the section's content top, for a caller that computes its own layout and recomputes it when the window is resized.
void n_gui_set_cursor (N_GUI_CTX *ctx, int system_shape, ALLEGRO_MOUSE_CURSOR *custom)
 Say which mouse cursor the application wants.
int n_gui_set_default_font (N_GUI_CTX *ctx, ALLEGRO_FONT *font)
 Replace the context's default font, keeping every widget and its state.
void n_gui_set_default_theme (N_GUI_CTX *ctx, N_GUI_THEME theme)
 Set the default theme on a context and sync scrollbar style colors.
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_double_click_radius (N_GUI_CTX *ctx, int pixels)
 how far the pointer may move between the two presses, in pixels (default 4)
void n_gui_set_double_click_time (N_GUI_CTX *ctx, double seconds)
 how long after a press a second one still counts, in seconds (default 0.4)
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_event_queue (N_GUI_CTX *ctx, ALLEGRO_EVENT_QUEUE *queue)
 give the context the event queue it registers native window event sources into
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_shape_mode (N_GUI_CTX *ctx, int shape_mode)
 set the global widget shape (N_GUI_SHAPE_ROUNDED for a round GUI, else square)
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_tooltip (N_GUI_CTX *ctx, int widget_id, const char *text)
 set (or clear with "" / NULL) the tooltip text shown after the pointer rests on a widget.
void n_gui_set_widget_visible (N_GUI_CTX *ctx, int widget_id, int visible)
 set widget visibility
int n_gui_slider_get_default (N_GUI_CTX *ctx, int widget_id, double *value)
 A slider's default, as n_gui_slider_set_default() gave it.
double n_gui_slider_get_key_step (N_GUI_CTX *ctx, int widget_id)
 get the arrow key and wheel increment actually in use for a slider
double n_gui_slider_get_value (N_GUI_CTX *ctx, int widget_id)
 get slider current value
int n_gui_slider_handle_pos (N_GUI_CTX *ctx, int widget_id, float *pos, float *radius)
 Where a slider's handle is drawn and how big it is.
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_default (N_GUI_CTX *ctx, int widget_id, double value)
 Give a slider a default value, which a double click on it puts back.
void n_gui_slider_set_key_step (N_GUI_CTX *ctx, int widget_id, double step)
 set how far one arrow key press or wheel notch moves a slider, without snapping its drag
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
void n_gui_slider_set_value_format (N_GUI_CTX *ctx, int widget_id, const char *fmt)
 Override the built-in value readout's printf format string.
void n_gui_slider_set_value_visible (N_GUI_CTX *ctx, int widget_id, int visible)
 Toggle the built-in value label.
float n_gui_slider_value_width (N_GUI_CTX *ctx, int widget_id)
 width in pixels a slider's built-in readout needs beside it, the gap between track and text included.
int n_gui_splitpane_at (N_GUI_CTX *ctx, float x, float y)
 report the split pane whose divider band is under a point, or -1.
float n_gui_splitpane_band (N_GUI_CTX *ctx, int widget_id)
 How far either side of a split pane's divider a press still counts as the divider's.
float n_gui_splitpane_get_ratio (N_GUI_CTX *ctx, int widget_id)
 get the current divider ratio (0..1), or 0.5 if the widget is invalid
void n_gui_splitpane_set_limits (N_GUI_CTX *ctx, int widget_id, float min_ratio, float max_ratio)
 set the minimum and maximum allowed divider ratio
void n_gui_splitpane_set_ratio (N_GUI_CTX *ctx, int widget_id, float ratio)
 set the divider ratio (clamped to the configured min/max)
int n_gui_suggest_add (N_GUI_SUGGEST_SINK *sink, const char *text)
 add one completion to a suggestion sink
float n_gui_syntaxview_content_width (N_GUI_CTX *ctx, int widget_id)
 pixel width the widest line of a syntax view needs, padding included
float n_gui_syntaxview_get_h_scroll (N_GUI_CTX *ctx, int widget_id)
 current horizontal scroll offset of a syntax view, in pixels.
int n_gui_syntaxview_get_line_count (N_GUI_CTX *ctx, int widget_id)
 get the number of text lines in a syntax view
char * n_gui_syntaxview_get_selected_text (N_GUI_CTX *ctx, int widget_id)
 copy of the currently selected text in a syntax view, or NULL when nothing is selected.
const char * n_gui_syntaxview_get_text (N_GUI_CTX *ctx, int widget_id)
 get the text shown by a syntax view (borrowed pointer, do not free; NULL if empty)
void n_gui_syntaxview_scroll_to_offset (N_GUI_CTX *ctx, int widget_id, int byte_offset)
 scroll a syntax view so the line holding the given byte offset is vertically centered, and horizontally so the offset itself is inside the visible width
void n_gui_syntaxview_select_all (N_GUI_CTX *ctx, int widget_id)
 select the entire text of a syntax view
void n_gui_syntaxview_set_h_scroll (N_GUI_CTX *ctx, int widget_id, float px)
 set the horizontal scroll offset of a syntax view, in pixels (clamped to the content width by the draw path)
void n_gui_syntaxview_set_mode (N_GUI_CTX *ctx, int widget_id, int mode)
 set the highlighting mode (N_GUI_SYNTAX_*) of a syntax view
void n_gui_syntaxview_set_selection (N_GUI_CTX *ctx, int widget_id, int start, int end)
 set the selection range (byte offsets into the text, clamped to its length); pass start == end to clear the selection
void n_gui_syntaxview_set_text (N_GUI_CTX *ctx, int widget_id, const char *text)
 set (copy) the text shown by a syntax view; text may be NULL to clear
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_PANEL * n_gui_tab_create (N_GUI_CTX *ctx, int window_id, float x, float y, float button_w, float button_h, void(*on_tab_change)(int, void *), void *user_data)
 create a tab panel in an existing window
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 (const N_GUI_TAB_PANEL *panel)
 get the active tab index
void n_gui_tab_relayout (N_GUI_TAB_PANEL *panel, float x, float y, float button_w, float button_h)
 move/resize the button row after creation (a host-owned or resizable layout); pass <= 0 for button_w / button_h to keep the current value.
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
int n_gui_text_shorten (ALLEGRO_FONT *font, const char *text, float max_w, int mode, char *out, size_t out_len)
 shorten text to fit max_w pixels in font, the way a label with truncate mode mode shows it: unchanged when it fits, otherwise with "..." at the end, at the start, or in place of whole leading path components (N_GUI_TRUNCATE_END, _START, _PATH).
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)
int n_gui_textarea_has_selection (N_GUI_CTX *ctx, int widget_id)
 is any text selected in a text area (0 for no selection or a bad id)
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_placeholder (N_GUI_CTX *ctx, int widget_id, const char *text)
 set placeholder/hint text for a textarea, shown dimmed while the field is empty and cleared from view as soon as the user types.
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_suggest (N_GUI_CTX *ctx, int widget_id, N_GUI_SUGGEST_FN fn, const char *separators, void *user_data)
 offer completions in a textarea
void n_gui_textarea_set_text (N_GUI_CTX *ctx, int widget_id, const char *text)
 set text area content
void n_gui_textarea_suggest_close (N_GUI_CTX *ctx, int widget_id)
 put a textarea's completion panel away
int n_gui_textarea_suggest_is_open (N_GUI_CTX *ctx, int widget_id)
 is a textarea's completion panel up
void n_gui_toggle_window (N_GUI_CTX *ctx, int window_id)
 toggle window visibility (show/hide)
int n_gui_tooltip_pending (N_GUI_CTX *ctx)
 tooltip phase: 0 = none (or tooltips disabled via style.tooltip_delay <= 0), 1 = arming (hosts with cached GUI renders must keep redrawing so the bubble can appear on time), 2 = shown (static - re-render once on the transition, then stop)
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
void n_gui_tree_clear (N_GUI_TREE *tree)
 remove all nodes and clear the backing listbox; tree object remains valid
N_GUI_TREE * n_gui_tree_create (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, void(*on_select)(int, void *), void *user_data)
 create a tree view in an existing window
void n_gui_tree_draw_overlay (N_GUI_TREE *tree)
 per-frame overlay drawing: draws the active drop-indicator on top of the listbox.
void n_gui_tree_expand (N_GUI_TREE *tree, int node_index)
 open a node, filling it first through the expand callback if it has not been; a node already open stays open.
int n_gui_tree_find_by_path (const N_GUI_TREE *tree, const char *path)
 index of the first node with the given path, or -1.
int n_gui_tree_find_by_user_data (const N_GUI_TREE *tree, const void *ptr)
 find the first node whose user_data pointer equals ptr, or -1.
void n_gui_tree_free (N_GUI_TREE **tree)
 free a tree view (does not destroy the N_GUI listbox)
int n_gui_tree_get_selection (N_GUI_TREE *tree)
 get the index of the currently selected node, or -1 when nothing is selected or the selection points at a hidden row
int n_gui_tree_node_path (const N_GUI_TREE *tree, int node_index, char *buf, size_t bufsz)
 write the path of a node (its label and its ancestors', joined by N_GUI_TREE_PATH_SEP) into buf.
void n_gui_tree_rebuild (N_GUI_TREE *tree)
 rebuild the listbox to reflect current tree state
void n_gui_tree_remove_node (N_GUI_TREE *tree, int node_index)
 remove a node and its entire subtree; remaining node indices are compacted (callers holding indices across the call must discard or re-resolve them)
void n_gui_tree_set_expand_callback (N_GUI_TREE *tree, void(*on_expand)(int node_index, void *user_data), void *user_data)
 set the callback that fills a node the first time it is opened, for a tree too large to build before it is shown: a folder tree reads a directory only when somebody opens it.
void n_gui_tree_set_expandable (N_GUI_TREE *tree, int node_index, int expandable)
 mark a node as openable before it has children, so it shows an expander and the expand callback fills it when it is opened
void n_gui_tree_set_label (N_GUI_TREE *tree, int node_index, const char *new_label)
 change the display label of a node
void n_gui_tree_set_on_drop (N_GUI_TREE *tree, n_gui_tree_on_drop_t on_drop, void *user_data)
 install (or clear, with NULL) a drag-reorder drop callback.
void n_gui_tree_set_selection (N_GUI_TREE *tree, int node_index)
 programmatically select a node; ancestors are expanded so the node is visible, and the listbox scrolls to reveal it.
void n_gui_tree_state_apply (N_GUI_TREE *tree, const N_GUI_TREE_STATE *state)
 re-expand, re-select and re-scroll a rebuilt tree from a saved state.
void n_gui_tree_state_free (N_GUI_TREE_STATE *state)
 release the strings owned by a saved state (safe on a zeroed struct)
int n_gui_tree_state_save (const N_GUI_TREE *tree, N_GUI_TREE_STATE *out)
 capture which nodes are expanded, which one is selected, and where the view is scrolled, all by path.
void n_gui_tree_tick (N_GUI_TREE *tree)
 per-frame poll: reads ctx->mouse_* to track drag state and fires the on_drop callback on release.
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)
int n_gui_was_double_click (const N_GUI_CTX *ctx, int widget_id)
 whether the press just processed double clicked this particular widget
const char * n_gui_widget_get_persist_key (N_GUI_CTX *ctx, int widget_id)
 Get a widget's persist key ("" when unset), or NULL when the widget is invalid.
int n_gui_widget_is_visible (N_GUI_CTX *ctx, int widget_id)
 Is a widget currently shown.
int n_gui_widget_screen_rect (N_GUI_CTX *ctx, int widget_id, float *x, float *y, float *w, float *h)
 Where a widget is on screen, rather than inside its window.
void n_gui_widget_set_persist_key (N_GUI_CTX *ctx, int widget_id, const char *key)
 Give a widget a stable key so its user-adjustable state (a splitpane's divider ratio, or a datagrid's column order/visibility/width) is persisted by n_gui_save_layout_json and restored by n_gui_load_layout_json.
void n_gui_widget_set_rect (N_GUI_CTX *ctx, int widget_id, float x, float y, float w, float h)
 move/resize a widget after creation, refreshing the normalized coordinates the resize passes read.
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)
int n_gui_window_attach (N_GUI_CTX *ctx, int window_id)
 return a detached window to being an in-display pop-up
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_button_rect (N_GUI_CTX *ctx, int window_id, int btn_type, float *x, float *y, float *w, float *h)
 Where one of a window's title bar buttons is, on screen.
int n_gui_window_detach (N_GUI_CTX *ctx, int window_id, int detach_flags)
 promote a pop-up window to a native OS window
int n_gui_window_find_button (N_GUI_CTX *ctx, int window_id, const char *label)
 Find the button in a window whose label is exactly this.
int n_gui_window_from_display (N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display)
 find the window detached into a given display
ALLEGRO_DISPLAY * n_gui_window_get_display (N_GUI_CTX *ctx, int window_id)
 get the native display backing a window, or NULL when it is a pop-up
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_detached (N_GUI_CTX *ctx, int window_id)
 check whether a window currently lives in a native OS window
int n_gui_window_is_maximised (N_GUI_CTX *ctx, int window_id)
 check if a window is currently maximised
int n_gui_window_is_minimised (N_GUI_CTX *ctx, int window_id)
 check if a window is currently minimised
int n_gui_window_is_open (N_GUI_CTX *ctx, int window_id)
 check if window is visible
int n_gui_window_native_is_hidden (N_GUI_CTX *ctx, int window_id)
 check whether a detached window's drawing is currently halted by the OS (Android surface loss) or the window manager has iconified it.
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_caption (N_GUI_CTX *ctx, int window_id, const char *caption)
 show a caption in a window's title bar in place of its title, for a title that carries live state ("Export - 3 photographs").
void n_gui_window_set_close_callback (N_GUI_CTX *ctx, int window_id, void(*on_close)(int, void *), void *user_data)
 set the close button callback for a window (NULL = default: hide window)
void n_gui_window_set_content_draw_callback (N_GUI_CTX *ctx, int window_id, void(*on_content_draw)(int, void *), void *user_data)
 set a content-draw callback for a window, invoked during n_gui_draw right after the window's own content is drawn (at the window's z-order)
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_maximize_callback (N_GUI_CTX *ctx, int window_id, void(*on_maximize)(int, void *), void *user_data)
 set the maximize button callback for a window (NULL = default: toggle maximised)
void n_gui_window_set_minimize_callback (N_GUI_CTX *ctx, int window_id, void(*on_minimize)(int, void *), void *user_data)
 set the minimize button callback for a window (NULL = default: toggle minimised)
int n_gui_window_set_native_icons (N_GUI_CTX *ctx, int window_id, ALLEGRO_BITMAP **icons, int num_icons)
 give a detached window's OS window a taskbar / title bar icon
void n_gui_window_set_rect (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h)
 move and resize a window at runtime, rescaling its child widgets from their normalized coordinates (what a split-pane divider drag or a collapsing panel needs, since the adaptive pass only runs on a display resize).
void n_gui_window_set_rect_axes (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h, int scale_x, int scale_y)
 n_gui_window_set_rect with per-axis reflow control.
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_tb_btn_theme (N_GUI_CTX *ctx, int window_id, N_GUI_THEME theme)
 set the theme for titlebar minimize/maximize buttons on a specific window
void n_gui_window_set_tb_button_bitmaps (N_GUI_CTX *ctx, int window_id, int btn_type, ALLEGRO_BITMAP *normal, ALLEGRO_BITMAP *hover, ALLEGRO_BITMAP *active)
 set optional bitmap overlays on a titlebar button
void n_gui_window_set_tb_close_theme (N_GUI_CTX *ctx, int window_id, N_GUI_THEME theme)
 set the theme for the titlebar close button on a specific window
void n_gui_window_set_wheel_scrollbar (N_GUI_CTX *ctx, int window_id, int scrollbar_id)
 make the wheel anywhere over a window move one of its scrollbars, for a window that scrolls its own rows with a scrollbar widget rather than with N_GUI_WIN_AUTO_SCROLLBAR (a fixed set of rows refilled from an offset).
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):

  • If the state-specific bitmap is NULL, the normal bitmap is used.
  • If the normal bitmap is also NULL, the color theme is used.

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 480 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 glyph NGUI_GLYPH* icon drawn centred in the button's text colour instead of the label (N_GUI_GLYPH_NONE, the default, draws the label).

Set with n_gui_button_set_glyph. The label is kept and is still a good place for a tooltip-free accessible name.

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

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

double key_press_until absolute al_get_time() deadline until which the button is rendered in its pressed (N_GUI_STATE_ACTIVE) visual state after a keybind trigger.

0.0 = no pending key-press flash.

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

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

char label[128] label displayed on the button
void(*)(int widget_id, void *user_data) on_click 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

◆ N_GUI_CHECKBOX_DATA

struct N_GUI_CHECKBOX_DATA

checkbox specific data

Definition at line 677 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(*)(int widget_id, int checked, void *user_data) on_toggle callback on toggle
void * user_data user data for callback

◆ N_GUI_COMBOBOX_DATA

struct N_GUI_COMBOBOX_DATA

combo box specific data

Examples
ex_gui_dropmenu.c.

Definition at line 952 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 highlight_index open-panel navigation cursor for the wheel and Up/Down keys (-1 = none).

While the dropdown is open, the wheel and arrow keys move this; hovering the panel sets it to the item under the pointer; Enter or a click commits it to selected_index. Reset to -1 when the panel closes.

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_LISTITEM * items 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(*)(int widget_id, int index, void *user_data) on_select 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

◆ N_GUI_CTX

struct N_GUI_CTX
Collaboration diagram for N_GUI_CTX:
Data Fields
ALLEGRO_DISPLAY * active_display display that last received input, used to pick the display for clipboard and mouse-cursor calls.

NULL falls back to N_GUI_CTX::display.

double anim_until deadline (al_get_time seconds) until which a transient animation is in progress (button key-press flash, tooltip reveal): n_gui_needs_redraw keeps returning non-zero until then.

0 when no timed animation is pending.

double click_time time of that press, from al_get_time()
int click_widget_id widget the previous primary press landed on, for double click detection (-1 = none yet)
int click_x pointer x at that press
int click_y pointer y at that press
ALLEGRO_MOUSE_CURSOR * cursor_custom the custom cursor currently applied to the display, or NULL when a system cursor is (cursor_shape then says which)
int cursor_shape system mouse cursor currently applied to the display (an ALLEGRO_SYSTEM_MOUSE_CURSOR_* value), so a horizontal-resize cursor is set over a datagrid column border and reset elsewhere without redundant calls
ALLEGRO_MOUSE_CURSOR * cursor_want_custom ... or a custom one, borrowed, which wins over the shape when set
int cursor_want_shape the cursor the application asked for with n_gui_set_cursor(), shown wherever the GUI has no cursor of its own to show: a system cursor (an ALLEGRO_SYSTEM_MOUSE_CURSOR_* value) ...
ALLEGRO_FONT * default_font default font.

Widgets resolve their font at DRAW time (wgt->font ? wgt->font : ctx->default_font), so this can be swapped after widgets exist – see n_gui_set_default_font().

N_GUI_THEME default_tb_btn_theme default theme for titlebar minimize/maximize buttons
N_GUI_THEME default_tb_close_theme default theme for titlebar close button
N_GUI_THEME default_theme default theme (applied to new widgets/windows)
int dirty non-zero when the GUI's appearance may have changed since the last n_gui_draw.

Set by widget/window creation, by input events that can change state, and by n_gui_mark_dirty; cleared at the end of n_gui_draw. Read via n_gui_needs_redraw so an event-driven host can skip drawing an unchanged, non-animating GUI. Initialised to 1 so the first frame draws.

ALLEGRO_DISPLAY * display display pointer for clipboard operations (set via n_gui_set_display)
float display_h display/viewport height
int display_size_set non-zero once n_gui_set_display_size() has been called.

Until then n_gui_draw() takes the display size from its target bitmap on every pass, so a caller who never sets it still gets tooltips, dropdowns and window clamps sized to the screen rather than to zero

int display_size_warned non-zero once the fallback above has logged that it is in use
float display_w display/viewport width (set via n_gui_set_display_size)
int double_click_radius how far the pointer may move between the two presses and still count, in pixels.

Without this a drag that happens to pause reads as a double click. n_gui_set_double_click_radius() sets it.

double double_click_time how long after a press a second one still counts as a double click, in seconds.

n_gui_set_double_click_time() sets it.

int double_clicked_widget_id widget the press just processed double clicked, or -1.

Valid until the next event is processed. Read with n_gui_double_clicked_widget().

float dpi_scale DPI scale factor (1.0 = normal, 1.25 = 125%, 2.0 = HiDPI, etc.).
ALLEGRO_EVENT_QUEUE * event_queue event queue the context registers native window event sources into (set via n_gui_set_event_queue).

Required by n_gui_window_detach.

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 held_modifier_keys the modifier keys held down, one bit per key (left and right apart, so letting go of one Ctrl while the other is held keeps Ctrl down), from the KEY_DOWN and KEY_UP events n_gui_process_event has seen.

Read through n_gui_get_key_modifiers().

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
int open_suggest_id id of the textarea whose completion panel is currently open, or -1.

One at a time, like the two above: the panel floats over everything and two of them would fight for the same keys.

ALLEGRO_DISPLAY * pass_display display the pass currently being processed or drawn belongs to: NULL for the host's main display (and for the headless case), or a detached window's native display.

Internal, maintained by n_gui_process_event and n_gui_draw / n_gui_draw_detached. A window takes part in the pass when its N_GUI_WINDOW::native equals this, so with no detached window every pass is the main one and behaviour is unchanged.

N_GUI_PENDING_GEOM * pending_layout layout entries for windows that did NOT exist when the saved layout was loaded (lazily-created panels).

n_gui_add_window applies the saved (x,y) to the first window created later with a matching title, giving cross-session position restore without eager-creating every window. Owned by the ctx; freed in n_gui_destroy_ctx.

int pending_layout_count number of valid entries in pending_layout
N_GUI_PENDING_WIDGET * pending_widgets saved widget state for keyed widgets that did NOT exist when the layout was loaded; n_gui_widget_set_persist_key applies the first matching entry (by owning window title + key) to the widget being keyed.

Owned by the ctx; freed in n_gui_destroy_ctx.

int pending_widgets_count number of valid entries in pending_widgets
int prev_over_win whether the pointer was over a window on the previous motion event, so a motion that leaves the GUI still forces one redraw to clear hover state.
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
int selected_syntaxview_id id of the syntax-view widget with the most recent text selection, or -1
N_GUI_STYLE style configurable style (sizes, colours, paddings)
int tooltip_anchor_x pointer x when the tooltip was last armed (movement re-arms)
int tooltip_anchor_y pointer y when the tooltip was last armed
double tooltip_armed_at time the tooltip hover was (re)armed, from al_get_time()
int tooltip_widget_id widget the pointer is resting on for tooltip purposes (-1 = none)
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_CUSTOM_DATA

struct N_GUI_CUSTOM_DATA

Owner-draw custom widget data: a paint callback, an optional mouse callback, and their user pointers.

Definition at line 1229 of file n_gui.h.

Collaboration diagram for N_GUI_CUSTOM_DATA:
Data Fields
void(*)(void *user_data) destroy called with user_data when the widget is destroyed, for a caller that hands its state to the widget (NULL = user_data is not owned)
N_GUI_CUSTOM_DRAW draw paint callback invoked during n_gui_draw (NULL = draw nothing)
void * mouse_user_data opaque user pointer handed back to on_mouse (not owned by n_gui)
N_GUI_CUSTOM_MOUSE on_mouse mouse callback (NULL = the widget takes no mouse input)
void * user_data opaque user pointer handed back to the callback (not owned by n_gui)

◆ N_GUI_DATAGRID_COL

struct N_GUI_DATAGRID_COL

one data grid column definition

Definition at line 845 of file n_gui.h.

Collaboration diagram for N_GUI_DATAGRID_COL:
Data Fields
char title[128] column header title
int visible 1 = drawn, 0 = hidden (kept in storage, skipped in the header and rows)
float width column width in pixels

◆ N_GUI_DATAGRID_DATA

struct N_GUI_DATAGRID_DATA

data grid specific data: a sortable column table

Definition at line 855 of file n_gui.h.

Collaboration diagram for N_GUI_DATAGRID_DATA:
Data Fields
int anchor_row anchor row for Shift-click range selection, or -1
char ** cells row-major cell strings (nb_rows * nb_cols owned char*)
size_t * col_order display order: display_pos -> physical column index (sized cols_cap), or NULL when the display order is still the identity
int col_resize_col physical column being resized by a header-border drag, or -1
float col_resize_w0 original width of the column at the start of a resize drag
float col_resize_x0 cursor x at the start of a column-resize drag
N_GUI_DATAGRID_COL * cols column definitions (physical/storage order; cells are indexed by these)
size_t cols_cap allocated column capacity
float h_scroll horizontal scroll offset in pixels: how far the columns are scrolled to the left when their total width exceeds the widget's pane.

0 = leftmost.

int h_scroll_dragging 1 while the user is dragging the horizontal scrollbar thumb (so the shared scrollbar-drag handler routes the drag to h_scroll, not the vertical scroll).
int multiselect 1 = multi-row selection enabled (Ctrl/Shift-click), 0 = single-select
size_t nb_cols number of columns
size_t nb_rows number of rows
void(*)(int widget_id, void *user_data) on_columns_changed callback fired after the user resizes a column by dragging its header border (widget_id, user_data), so the host can persist the new layout.

NULL disables it.

void(*)(int widget_id, int row, int x, int y, void *user_data) on_context callback on right-click over a data row, for a context menu (widget_id, row, x, y, user_data); x/y are the cursor position in GUI coordinates so the caller can place a popup there.

NULL disables it.

void(*)(int widget_id, int row, void *user_data) on_select callback on row selection (widget_id, row, user_data)
ALLEGRO_COLOR * row_color per-row background tint, sized rows_cap; NULL until a row color is set
unsigned char * row_has_color per-row tint flags (1 = row_color[row] is painted), sized rows_cap; NULL until a row color is set
unsigned char * row_sel per-row selection flags (1 = selected), sized rows_cap; NULL until needed
size_t rows_cap allocated row capacity (in rows)
int scroll_offset first visible data row
int selected_row selected data row (the primary / last-clicked row), or -1
int sort_col column index used for sorting, or -1
int sort_dir sort direction: 1 ascending, -1 descending
void * user_data user data for callback

◆ N_GUI_DROPMENU_DATA

struct N_GUI_DROPMENU_DATA

dropdown menu specific data

Examples
ex_gui_dropmenu.c.

Definition at line 1053 of file n_gui.h.

Collaboration diagram for N_GUI_DROPMENU_DATA:
Data Fields
N_GUI_DROPMENU_ENTRY * entries dynamic array of entries
size_t entries_capacity allocated capacity
int flags bitmask of N_GUI_DROPMENU_* flags
int highlight_index open-panel navigation cursor for the wheel and Up/Down keys (-1 = none).

While the menu is open, the wheel and arrow keys move this; hovering the panel sets it to the entry under the pointer; Enter or a click activates it. Reset to -1 when the panel closes.

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(*)(int widget_id, void *user_data) on_open 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.

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

◆ N_GUI_DROPMENU_ENTRY

struct N_GUI_DROPMENU_ENTRY

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

Definition at line 1033 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(*)(int widget_id, int entry_index, int tag, void *user_data) on_click callback when this entry is clicked (widget_id, entry_index, tag, user_data)
int tag user-defined tag for the entry (e.g.

a window id)

char text[128] display text
void * user_data user data for callback

◆ N_GUI_HEXVIEW_DATA

struct N_GUI_HEXVIEW_DATA

hex viewer specific data: a read-only byte dump

Definition at line 781 of file n_gui.h.

Collaboration diagram for N_GUI_HEXVIEW_DATA:
Data Fields
int bytes_per_row bytes shown per row
size_t cap bytes allocated (>= len; edits grow the buffer)
size_t cursor byte the cursor sits on (<= len)
unsigned char * data owned copy of the bytes, or NULL
int editable 1 when the bytes can be edited in place
size_t len number of bytes
int nibble which half of the cursor byte a typed hex digit lands in: 0 high, 1 low
void(*)(int widget_id, const unsigned char *data, size_t len, void *user_data) on_change called after any edit, with the new byte count
int scroll_offset first visible row
void * user_data opaque pointer handed back to on_change

◆ N_GUI_IMAGE_DATA

struct N_GUI_IMAGE_DATA

image widget specific data

Definition at line 989 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 3627 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 down_id button widget ID for the move-down action (row actions only)
int dup_id button widget ID for the duplicate action (row actions only)
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 up_id button widget ID for the move-up action (row actions only)
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.

The text columns are separated by draggable dividers (split panes spanning the table height), so the user can widen a column whose content overflows; the trailing checkbox/action/remove cluster keeps its fixed width

Examples
ex_gui_kvtable.c.

Definition at line 3643 of file n_gui.h.

Collaboration diagram for N_GUI_KVTABLE:
Data Fields
int btn_add button widget ID for "+" add row
float col_frac[3] width fraction of each visible text column over the text area, summing to 1; user-adjusted by the column dividers
N_GUI_CTX * ctx GUI context.
int frac_cols visible text column count col_frac was computed for; when it changes the fractions reset to equal widths
float header_height unscaled column-header row height
float init_win_h parent window height at create time
float init_win_w parent window width at create time
char * key_placeholder owned hint shown in each key textarea, or NULL
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(*)(int, void *) on_remove callback on row removal
float padding unscaled padding in pixels
float row_height unscaled row height in pixels
N_GUI_KV_ROW rows[128] row storage
int show_actions 1 to show the per-row move-up / move-down / duplicate buttons (default 0)
int show_desc 1 to show the Description column (default 1)
int show_enabled 1 to show the enabled-checkbox column (default 1)
int show_value 1 to show the Value column (default 1)
int split_a splitpane widget ID of the divider after the first text column, or -1
int split_b splitpane widget ID of the divider after the second text column, or -1
float top_offset unscaled y offset of the header row from the window top (default 0), to reserve space above the table for other widgets
void * user_data user data for callback
char * value_placeholder owned hint shown in each value textarea, or NULL
int window_id parent window

◆ N_GUI_LABEL_DATA

struct N_GUI_LABEL_DATA

static text label specific data

Definition at line 997 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(*)(int widget_id, const char *link, void *user_data) on_link_click 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
int truncate how text too wide for the label is shortened: N_GUI_TRUNCATE_END (the default), N_GUI_TRUNCATE_START or N_GUI_TRUNCATE_PATH.

Not used by N_GUI_ALIGN_JUSTIFIED, which wraps

void * user_data user data for callback

◆ N_GUI_LISTBOX_DATA

struct N_GUI_LISTBOX_DATA

listbox specific data

Definition at line 724 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)
float h_scroll horizontal scroll offset in pixels: how far the item text is scrolled to the left when the widest item is wider than the widget.

0 = leftmost. A horizontal scrollbar is drawn (and the text stops being truncated with an ellipsis) only while the content overflows.

int h_scroll_dragging 1 while the user is dragging the horizontal scrollbar thumb, so the shared scrollbar-drag handler routes the drag to h_scroll rather than to the vertical scroll position.
int hover_row index of the row the mouse is currently over, or -1.

Updated in the event loop when the widget gains N_GUI_STATE_HOVER; consumed by the draw path to paint a hover highlight.

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_LISTITEM * items dynamic array of items
size_t items_capacity allocated capacity
size_t nb_items number of items
void(*)(int widget_id, int index, int selected, void *user_data) on_select 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

◆ N_GUI_LISTITEM

struct N_GUI_LISTITEM

a single item in a list/radio/combo widget

Definition at line 576 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_MARKDOWNVIEW_DATA

struct N_GUI_MARKDOWNVIEW_DATA

markdownview specific data.

A read-only pane of rendered Markdown that scrolls vertically. There is no horizontal scroll and deliberately no way to ask for one: n_gui_md wraps everything it lays out, table cells included, so nothing ever overflows sideways.

Definition at line 1147 of file n_gui.h.

Collaboration diagram for N_GUI_MARKDOWNVIEW_DATA:
Data Fields
float content_h the height the whole document last measured at
int dirty set when the text, the faces or the style changed under a measure
N_GUI_MD_FONTS fonts the faces, borrowed: the caller owns them and they must outlive the widget, the same rule every ALLEGRO_BITMAP in this file follows
float measured_w the width it was measured at, so a resize re-measures and nothing else has to remember to
void(*)(int widget_id, const char *url, void *user_data) on_link called when a link is clicked, or NULL
float scroll_y how far down the content the view is, in pixels
N_GUI_MD_STYLE style colours and metrics, the caller's to change through n_gui_markdownview_style()
char * text the source, owned, NUL-terminated; never NULL after creation
int theme_derived 1 while the style is still the one derived from the widget's theme, so a palette change is followed; cleared the moment the caller asks for the style in order to change it
void * user_data user data for on_link

◆ N_GUI_MOUSE_EVENT

struct N_GUI_MOUSE_EVENT

A mouse event handed to a custom widget, in the widget's own coordinates.

Examples
ex_gui_custom_mouse.c.

Definition at line 1200 of file n_gui.h.

Collaboration diagram for N_GUI_MOUSE_EVENT:
Data Fields
int button 1 left, 2 right for DOWN; 1 for UP and DRAG; 0 otherwise
int dz wheel steps for WHEEL, positive away from the user; 0 otherwise
int modifiers the modifier keys held when the event came, ALLEGRO_KEYMOD_SHIFT, _CTRL, _ALT and _ALTGR ORed, as n_gui_get_key_modifiers() says.

Allegro's mouse events carry none, so this is what a custom widget reads to tell Ctrl+wheel from the wheel

int type N_GUI_MOUSE_DOWN, _UP, _MOVE, _DRAG or _WHEEL.
float x pointer x from the widget's left edge; outside 0..w during a DRAG
float y pointer y from the widget's top edge; outside 0..h during a DRAG

◆ N_GUI_PENDING_GEOM

struct N_GUI_PENDING_GEOM

A saved window position retained for a window not yet created at load time (see N_GUI_CTX::pending_layout).

Applied on first matching create.

Definition at line 1639 of file n_gui.h.

Collaboration diagram for N_GUI_PENDING_GEOM:
Data Fields
unsigned char consumed 1 once applied to a created window
float h saved height (display-scaled), 0 when absent
int state saved minimised/maximised bits, applied on create
char title[128] window title to match on
float w saved width (display-scaled), 0 when absent
float x saved x (already display-scaled)
float y saved y

◆ N_GUI_PENDING_WIDGET

struct N_GUI_PENDING_WIDGET

Saved user-adjustable state for a keyed widget that did not exist when the layout was loaded (a lazily-created splitpane/datagrid).

Applied on the first n_gui_widget_set_persist_key that matches the owning window title + key (consume-once), the widget-level analog of N_GUI_PENDING_GEOM.

Definition at line 1656 of file n_gui.h.

Collaboration diagram for N_GUI_PENDING_WIDGET:
Data Fields
unsigned char consumed 1 once applied
char key[128] widget persist key to match on
int kind N_GUI_TYPE_SPLITPANE or N_GUI_TYPE_DATAGRID.
int ncols column count (kind == DATAGRID)
int order[64] display position -> physical column
float ratio divider ratio (kind == SPLITPANE)
char title[128] owning window title to match on
int visible[64] per-physical-column visibility
float width[64] per-physical-column width

◆ N_GUI_PROGRESSBAR_DATA

struct N_GUI_PROGRESSBAR_DATA

Progress-bar widget data (display only).

Definition at line 1025 of file n_gui.h.

Collaboration diagram for N_GUI_PROGRESSBAR_DATA:
Data Fields
char text[4096] optional centered overlay text (empty string = none)
float value progress fraction, clamped to 0.0 .

. 1.0

◆ N_GUI_RADIOLIST_DATA

struct N_GUI_RADIOLIST_DATA

radio list specific data

Definition at line 917 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_LISTITEM * items dynamic array of items
size_t items_capacity allocated capacity
size_t nb_items number of items
void(*)(int widget_id, int index, void *user_data) on_select 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

◆ N_GUI_SB_TRACK

struct N_GUI_SB_TRACK

Where a scrollbar a widget draws inside itself was last painted, and whether the pointer is on it.

Such a bar is highlighted while the pointer is over the bar, and not otherwise: widget-level hover would be no answer, because the pointer is over a row or a cell far more often than over the bar, and keyboard focus is no answer either, because a widget with two bars has one focus and two bars to light with it.

Somebody therefore has to answer "is the pointer on this bar". The geometry is worked out by the paint, once per widget type, and the paint has no pointer position to test against; the event pass has the pointer and no geometry. So the paint records the rectangle here and the event pass hit-tests it. The answer is one frame old at worst, and that is a frame in which the pointer did not move.

Zero initialised with the widget, and a zero width or height means the bar was not painted, so it can never be hit.

Definition at line 463 of file n_gui.h.

Collaboration diagram for N_GUI_SB_TRACK:
Data Fields
float h height; zero when no bar was painted
int hovered non-zero while the pointer is inside the rectangle above, and while a drag that began inside it is still going
float w width; zero when no bar was painted
float x left edge, in the coordinates the paint drew in
float y top edge

◆ N_GUI_SCROLLBAR_DATA

struct N_GUI_SCROLLBAR_DATA

scrollbar specific data

Definition at line 695 of file n_gui.h.

Collaboration diagram for N_GUI_SCROLLBAR_DATA:
Data Fields
double content_size total content size
void(*)(int widget_id, double scroll_pos, void *user_data) on_scroll 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
double wheel_step how far one wheel notch moves it, in content units; 0 (the default) is a twentieth of the range.

Set by n_gui_scrollbar_set_wheel_step()

◆ N_GUI_SECTION

struct N_GUI_SECTION

a single foldable section: a clickable header plus the member widgets it shows/hides

Definition at line 3366 of file n_gui.h.

Collaboration diagram for N_GUI_SECTION:
Data Fields
int folded 1 = collapsed (members hidden), 0 = expanded
int header_id clickable header button widget id
float natural_h stacked height of the members when expanded, recomputed by n_gui_sectionlist_relayout() from the live offsets and heights
int nb_widgets number of member widgets
char title[64] section title (header label minus the fold glyph)
float widget_dy[96] each member's y offset from the section content top, captured at add time and settable with n_gui_sectionlist_set_widget_offset()
int widget_hidden[96] 1 = the caller keeps this member hidden whatever the fold state, and it does not count towards natural_h
int widget_ids[96] member widget ids

◆ N_GUI_SECTIONLIST

struct N_GUI_SECTIONLIST

a vertical accordion of foldable sections inside one window; folding hides a section's widgets and re-stacks the rest, leaving the window's N_GUI_WIN_AUTO_SCROLLBAR to absorb any overflow

Examples
ex_gui_sectionlist.c.

Definition at line 3380 of file n_gui.h.

Collaboration diagram for N_GUI_SECTIONLIST:
Data Fields
N_GUI_CTX * ctx GUI context.
float first_inset content-local left inset applied to the FIRST header only, so a button can sit before it on the same row (0 = none)
float gap vertical gap between rows
float header_h header button height
int nb_sections number of sections
void(*)(int, int, void *) on_toggle callback(section_index, folded, user_data) on a header click (may be NULL)
int order[16] display order: order[k] is the index of the section stacked k-th; indices themselves never change
int section_hidden[16] 1 = the whole section, header and members, is left out of the stack
N_GUI_SECTION sections[16] section storage
void * user_data user data for the callback
float width header width
int window_id window holding the headers and members
float x content-local x of every header and the layout origin
float y0 content-local y of the first header

◆ N_GUI_SLIDER_DATA

struct N_GUI_SLIDER_DATA

slider specific data

Definition at line 526 of file n_gui.h.

Collaboration diagram for N_GUI_SLIDER_DATA:
Data Fields
double default_value the value a double click puts back, when has_default is set
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)
int has_default non-zero once n_gui_slider_set_default() gave the slider a default, which a double click on it puts back
double key_step increment applied by the arrow keys and the mouse wheel, when it should differ from step.

0 falls back to step, and then to a twentieth of the range, which is what every slider did before this existed. Set via n_gui_slider_set_key_step().

double max_val maximum value
double min_val minimum value
int mode mode: N_GUI_SLIDER_VALUE or N_GUI_SLIDER_PERCENT
void(*)(int widget_id, double value, void *user_data) on_change 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).

All values snap to nearest multiple of step from min_val.

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)
char value_format[32] printf-style format string applied to the numeric value when the built-in readout draws.

Empty (first byte '\0') selects the legacy defaults: "%.1f" for VALUE mode, "%.0f%%" for PERCENT. Set via n_gui_slider_set_value_format().

int value_visible draw the built-in value label next to/below the handle.

Default 1 (on) for backward compatibility. Set to 0 when the consumer is already painting the value elsewhere (e.g. a status bar) to avoid the double-render gotcha.

◆ N_GUI_SPLITPANE_DATA

struct N_GUI_SPLITPANE_DATA

split pane specific data: a draggable divider between two regions

Definition at line 763 of file n_gui.h.

Collaboration diagram for N_GUI_SPLITPANE_DATA:
Data Fields
float divider divider thickness in pixels
float max_ratio upper clamp applied to ratio
float min_ratio lower clamp applied to ratio
void(*)(int widget_id, float ratio, void *user_data) on_change callback fired while the divider is dragged (widget_id, ratio, user_data)
int orientation N_GUI_SPLIT_VERTICAL or N_GUI_SPLIT_HORIZONTAL.
float ratio divider position as a fraction of the widget extent (0..1)
void * user_data user data for callback

◆ 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 1454 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
int shape_mode global widget shape override: N_GUI_SHAPE_ROUNDED forces a rounded GUI, N_GUI_SHAPE_RECT forces a square one, and -1 (default) leaves each widget on its own shape (the dropmenu button + panel still default to rounded).

Buttons and comboboxes follow this when it is set. The widgets with no shape of their own (textareas, checkboxes, a frameless window's body, the combobox dropdown) round ONLY when it is N_GUI_SHAPE_ROUNDED, and stay square otherwise. Toggle with n_gui_set_shape_mode() for a round/square GUI.

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 tb_btn_glyph_thickness line thickness for titlebar button glyphs
float tb_btn_right_margin right margin from window edge to rightmost button
float tb_btn_size titlebar button size (0 = auto: titlebar_h - 4)
float tb_btn_spacing gap between titlebar buttons
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
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
ALLEGRO_COLOR tooltip_bg tooltip bubble background color
ALLEGRO_COLOR tooltip_border tooltip bubble border color
float tooltip_delay inner padding

seconds the pointer must rest on a widget before its tooltip shows

ALLEGRO_COLOR tooltip_fg tooltip text color
float tooltip_max_w widest a tooltip bubble's text may get before it word-wraps, in pixels (0 = wrap only at the display edge).

Without a cap a long tooltip on a wide display renders as one line the width of the screen, which is readable but miserable to read; ~50 characters per line is not

◆ N_GUI_SYNTAXVIEW_DATA

struct N_GUI_SYNTAXVIEW_DATA

syntax view specific data: read-only highlighted text

Examples
ex_gui_syntaxview.c.

Definition at line 805 of file n_gui.h.

Collaboration diagram for N_GUI_SYNTAXVIEW_DATA:
Data Fields
float cached_content_w cached pixel width of the widest line, valid when width_valid
int cached_headers_end cached first blank-line index (HTTP headers end), or INT_MAX; valid when lines_valid
int cached_nb_lines cached line count (matches _text_line_count), valid when lines_valid
float h_scroll horizontal scroll offset in pixels: the view does not wrap, so a line wider than the widget is reached by panning rather than by folding
int h_scroll_dragging 1 while the horizontal scrollbar thumb is being dragged (so the shared scrollbar-drag handler routes the drag to h_scroll, not to the lines)
size_t len text length in bytes
int lines_valid 0 when cached_nb_lines / cached_headers_end are stale (rebuild on next use).

Zero-initialised so a freshly created widget rebuilds on first draw; set back to 0 by n_gui_syntaxview_set_text.

const ALLEGRO_FONT * metrics_font font cached_content_w was measured with (a text keeps its width only for as long as the font it was measured in stays the one in use)
int mode highlighting mode: N_GUI_SYNTAX_*
int scroll_offset first visible line
int sel_dragging 1 while a mouse drag is extending the selection, 0 otherwise
int sel_end selection end byte offset (tracks the cursor while a drag is in progress)
int sel_start selection start byte offset into text, or -1 when nothing is selected
char * text owned copy of the text, or NULL
int width_valid 0 when cached_content_w is stale.

Cleared by n_gui_syntaxview_set_text and whenever the widget is drawn with a font other than metrics_font.

◆ N_GUI_TAB_PANEL

struct N_GUI_TAB_PANEL

tab panel built from toggle buttons with content window management

Examples
ex_gui_window_rect.c.

Definition at line 3324 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_CTX * ctx GUI context.
int nb_tabs number of tabs
void(*)(int, void *) on_tab_change callback on tab switch (may be NULL)
int parent_window_id parent window for tab buttons
void * user_data user data for callback
float x x origin of first tab button
float y y origin of tab button row

◆ N_GUI_TB_BUTTONS

struct N_GUI_TB_BUTTONS

Titlebar button state for a window (minimize, maximize, close).

Definition at line 1246 of file n_gui.h.

Collaboration diagram for N_GUI_TB_BUTTONS:
Data Fields
N_GUI_THEME btn_theme theme for minimize and maximize buttons
ALLEGRO_BITMAP * close_active_bitmap optional bitmap for close button active state
ALLEGRO_BITMAP * close_bitmap optional bitmap for close button normal state (NULL = color theme)
ALLEGRO_BITMAP * close_hover_bitmap optional bitmap for close button hover state
N_GUI_THEME close_theme theme for close button (defaults to red hover/active)
int hovered which button is currently hovered (N_GUI_TB_BTN_*)
ALLEGRO_BITMAP * maximize_active_bitmap optional bitmap for maximize button active state
ALLEGRO_BITMAP * maximize_bitmap optional bitmap for maximize button normal state (NULL = color theme)
ALLEGRO_BITMAP * maximize_hover_bitmap optional bitmap for maximize button hover state
ALLEGRO_BITMAP * minimize_active_bitmap optional bitmap for minimize button active state
ALLEGRO_BITMAP * minimize_bitmap optional bitmap for minimize button normal state (NULL = color theme)
ALLEGRO_BITMAP * minimize_hover_bitmap optional bitmap for minimize button hover state
void(*)(int window_id, void *user_data) on_close callback on close button click (NULL = default: clear N_GUI_WIN_OPEN)
void * on_close_user_data user data for on_close callback
void(*)(int window_id, void *user_data) on_maximize callback on maximize button click (NULL = default: toggle N_GUI_WIN_MAXIMISED)
void * on_maximize_user_data user data for on_maximize callback
void(*)(int window_id, void *user_data) on_minimize callback on minimize button click (NULL = default: toggle N_GUI_WIN_MINIMISED)
void * on_minimize_user_data user data for on_minimize callback
int pressed which button is currently pressed (N_GUI_TB_BTN_*)
float restore_h saved height before maximise (for restore)
float restore_w saved width before maximise (for restore)
float restore_x saved x position before maximise (for restore)
float restore_y saved y position before maximise (for restore)

◆ N_GUI_TEXT_DIMS

struct N_GUI_TEXT_DIMS

bounding box dimensions returned by n_gui_get_text_dims()

Definition at line 374 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

Examples
ex_gui_placeholder.c.

Definition at line 616 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(*)(int widget_id, const char *text, void *user_data) on_change callback on text change
char * placeholder optional placeholder/hint text drawn dimmed while the field is empty (NULL = none); cleared from view as soon as any text is entered
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).

When sel_start == sel_end, no selection is active.

N_GUI_SUGGEST_FN suggest completion provider, NULL when the field offers none
int suggest_count how many of them
int suggest_highlight which one the keys and the pointer are on (-1 = none)
N_GUI_LISTITEM * suggest_items what the provider last answered, allocated on the first ask
int suggest_open the panel is up
char suggest_prefix[128] the word the answers are for, so the provider is asked once per word rather than once per key
int suggest_scroll first item the panel shows
char suggest_separators[8] characters that end a word, so a field holding a list completes the one the cursor is in rather than the whole line.

Empty means the whole content is one word.

void * suggest_user_data user data handed back to the provider
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

◆ N_GUI_THEME

struct N_GUI_THEME

Color theme for a widget.

Examples
ex_gui.c, ex_gui_button_keys.c, and ex_gui_round.c.

Definition at line 384 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

Examples
ex_gui_tree_lazy.c, ex_gui_tree_order.c, and ex_gui_tree_state.c.

Definition at line 3495 of file n_gui.h.

Collaboration diagram for N_GUI_TREE:
Data Fields
N_GUI_CTX * ctx GUI context.
int drag_active 1 once past threshold
int drag_armed_node pressed-but-not-yet-dragging
int drag_hover_node current hover node, or -1
float drag_press_x mouse x at press time
float drag_press_y mouse y at press time
int drag_source_node node being dragged, or -1
int drop_position N_GUI_DROP_BEFORE / INTO / AFTER.
void * drop_user_data user data for on_drop
void * expand_user_data user data for on_expand
int listbox_id listbox widget ID
int mouse_b1_prev previous frame's b1 state
int nb_nodes number of nodes
int nb_visible number of visible rows
N_GUI_TREE_NODE nodes[2048] node storage
n_gui_tree_on_drop_t on_drop drag-reorder state (managed by n_gui_tree_tick)

drop callback, or NULL

void(*)(int, void *) on_expand fills a node the first time it opens, or NULL
void(*)(int, void *) on_select selection callback
void * user_data user data for callback
int visible_map[2048] visible row to node index
int window_id owning window for coord math

◆ N_GUI_TREE_NODE

struct N_GUI_TREE_NODE

a single node in the tree view

Definition at line 3469 of file n_gui.h.

Collaboration diagram for N_GUI_TREE_NODE:
Data Fields
int depth depth in tree (0 = root)
int expandable 1 if the node can be opened before it has children: its children are added by the expand callback
int expanded 1 if expanded
int filled 1 once the expand callback has run for this node
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_TREE_STATE

struct N_GUI_TREE_STATE

A tree's view state, captured by path so it survives a rebuild that replaces every node (a reloaded model has new pointers and new indices).

Owns its strings: release with n_gui_tree_state_free.

Examples
ex_gui_tree_lazy.c, and ex_gui_tree_state.c.

Definition at line 3532 of file n_gui.h.

Collaboration diagram for N_GUI_TREE_STATE:
Data Fields
char * expanded[512] paths of the expanded nodes
float h_scroll horizontal scroll offset in pixels
int nb_expanded number of paths stored
int scroll_offset first visible row
char * selected path of the selected node, or NULL

◆ N_GUI_WIDGET

struct N_GUI_WIDGET
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)
char persist_key[128] optional stable key for persisting this widget's user-adjustable state (splitpane divider ratio, datagrid column order/visibility/width) across sessions inside the layout JSON.

"" (the default) = not persisted. Set with n_gui_widget_set_persist_key.

N_GUI_SB_TRACK sb_h and the horizontal one
N_GUI_SB_TRACK sb_v the vertical scrollbar this widget draws inside itself, if it draws one, so the pointer can be tested against the bar rather than against the whole widget
int state current state flags (N_GUI_STATE_*)
N_GUI_THEME theme color theme for this widget
char * tooltip owned tooltip text shown after the pointer rests on the widget (NULL = none); heap-allocated with no length cap so long tooltips are not truncated
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
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
char caption[128] what the title bar shows instead of the title when not empty, set by n_gui_window_set_caption(); never saved in a layout
float content_h total content height computed from widgets (internal)
float content_w total content width computed from widgets (internal)
int detach_flags options the window was detached with (N_GUI_DETACH_*), remembered so a close/open cycle and a restored layout can re-create the same native window
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
ALLEGRO_DISPLAY * native native OS window backing this pseudo-window, or NULL (the default) when the window is drawn as a pop-up inside the host's main display.

Set by n_gui_window_detach, cleared by n_gui_window_attach. Owned by the context: n_gui_destroy_ctx destroys any display still attached here.

int native_close_pending 1 when the native window must be released at the next safe point (an ALLEGRO_EVENT_DISPLAY_CLOSE arrived, or the window was closed while detached).

Destroying a display from inside event processing would leave already-queued events pointing at freed memory, so n_gui_draw_detached performs the actual release once the queue has been drained.

int native_drag_anchored 1 when the four native_drag_* fields hold a usable grab, that is when al_get_mouse_cursor_position worked.

0 falls the drag back to the display-local delta, which is all a platform without desktop cursor coordinates can offer.

int native_drag_cx desktop x of the mouse cursor when a native (N_GUI_DETACH_OWN_CHROME) title bar drag started.

Desktop coordinates are unaffected by the window moving, so the whole drag is expressed against this single grab point instead of accumulating display-local deltas.

int native_drag_cy desktop y of the mouse cursor at the drag grab (see native_drag_cx)
int native_drag_wx native window x at the drag grab, the move is native_drag_wx plus the desktop cursor travel since the grab
int native_drag_wy native window y at the drag grab (see native_drag_wx)
float native_h last known native window height (see native_w)
int native_halted 1 while the native window's drawing is halted.

Set on ALLEGRO_EVENT_DISPLAY_HALT_DRAWING and cleared on RESUME_DRAWING, both acknowledged to Allegro. n_gui_draw_detached skips a halted window: drawing into one is undefined, and on Android the OS has taken the surface away entirely.

int native_pos_x last known native window position on the desktop, applied when the native window is re-created.

INT_MIN means "unknown, let the OS place it".

int native_pos_y last known native window y position (see native_pos_x)
float native_w last known native window width, 0 until the window is first detached.

Tracked across resizes and persisted, so a re-created native window comes back at the size the user left it rather than at the pop-up's size.

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)
void(*)(int window_id, void *user_data) on_content_draw optional callback invoked during n_gui_draw immediately after this window's own content is drawn, at the window's z-order (NULL = none).

Lets a caller add custom immediate-mode rendering that is correctly occluded by any window drawn on top of this one.

void * on_content_draw_data user data passed to on_content_draw
int resize_policy per-window resize policy: N_GUI_WIN_RESIZE_NONE, _MOVE, or _SCALE
int saved_flags embedded feature flags saved by n_gui_window_detach (a detached window is forced frameless because the OS draws the title bar)
float saved_h embedded height saved by n_gui_window_detach, restored by n_gui_window_attach
float saved_w embedded width saved by n_gui_window_detach, restored by n_gui_window_attach
float saved_x embedded x saved by n_gui_window_detach, restored by n_gui_window_attach
float saved_y embedded y saved by n_gui_window_detach, restored by n_gui_window_attach
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_TB_BUTTONS tb_buttons titlebar button state (minimize, maximize, close)
N_GUI_THEME theme color theme for this window chrome
char title[128] window title.

Also the window's name for the saved layout, which matches windows by it, so it does not change once created

ALLEGRO_BITMAP * titlebar_bitmap optional bitmap for the titlebar background (NULL = color fill)
float titlebar_h title bar height
float w window width
int want_native 1 when the window should live in a native OS window: set by n_gui_window_detach and by a loaded layout, cleared by n_gui_window_attach.

n_gui_open_window re-creates the native window when this is set.

int wheel_scrollbar the scrollbar the wheel moves anywhere over the window when no widget under the pointer takes it, or -1 (the default) for none; set by n_gui_window_set_wheel_scrollbar()
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, and ex_gui_label_lines.c.

Definition at line 214 of file n_gui.h.

Referenced by _draw_label(), _label_effective_w(), _label_line_x(), _label_text_origin_x(), main(), and main().

◆ N_GUI_ALIGN_JUSTIFIED

#define N_GUI_ALIGN_JUSTIFIED   3

◆ N_GUI_ALIGN_LEFT

◆ N_GUI_ALIGN_RIGHT

#define N_GUI_ALIGN_RIGHT   2

right aligned text

Examples
ex_gui.c.

Definition at line 216 of file n_gui.h.

Referenced by _draw_label(), _label_effective_w(), _label_line_x(), _label_text_origin_x(), and main().

◆ 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 347 of file n_gui.h.

Referenced by main(), and n_gui_window_apply_autofit().

◆ N_GUI_AUTOFIT_EXPAND_LEFT

#define N_GUI_AUTOFIT_EXPAND_LEFT   4

expand leftward instead of rightward when adjusting width

Definition at line 343 of file n_gui.h.

Referenced by n_gui_window_apply_autofit().

◆ N_GUI_AUTOFIT_EXPAND_UP

#define N_GUI_AUTOFIT_EXPAND_UP   8

expand upward instead of downward when adjusting height

Definition at line 345 of file n_gui.h.

Referenced by n_gui_window_apply_autofit().

◆ N_GUI_AUTOFIT_H

#define N_GUI_AUTOFIT_H   2

auto-adjust window height to content

Definition at line 339 of file n_gui.h.

Referenced by n_gui_window_apply_autofit().

◆ N_GUI_AUTOFIT_W

#define N_GUI_AUTOFIT_W   1

auto-adjust window width to content

Definition at line 337 of file n_gui.h.

Referenced by n_gui_window_apply_autofit().

◆ 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 341 of file n_gui.h.

Referenced by main().

◆ N_GUI_COMBOBOX_AUTO_WIDTH

#define N_GUI_COMBOBOX_AUTO_WIDTH   1

dropdown panel expands to fit the longest item text

Definition at line 944 of file n_gui.h.

Referenced by _combobox_dropdown_width().

◆ N_GUI_COMBOBOX_EXPAND_UP

#define N_GUI_COMBOBOX_EXPAND_UP   2

dropdown panel opens upward (above the widget) instead of downward.

Useful for bottom-anchored comboboxes where the default downward panel would render off-screen. Without the flag, an auto-flip fallback still kicks in whenever the panel doesn't fit below and does fit above.

Definition at line 949 of file n_gui.h.

Referenced by _draw_combobox_dropdown(), and n_gui_process_event().

◆ N_GUI_DETACH_NONE

#define N_GUI_DETACH_NONE   0

no option

Definition at line 291 of file n_gui.h.

Referenced by n_gui_add_window(), and n_gui_load_layout_json().

◆ N_GUI_DETACH_OWN_CHROME

#define N_GUI_DETACH_OWN_CHROME   4

keep N_GUI's own window chrome instead of the window manager's: the native window is created frameless and the window keeps drawing its own title bar, so a detached window looks and skins exactly like the pop-up it came from.

Dragging the title bar moves the OS window, the resize grip resizes it, and the minimise / maximise / close buttons act on it.

Without this flag (the default) the OS supplies the title bar and all of the above is the window manager's job. Frameless windows are the less well trodden path on some window managers, which is why this is opt-in.

Examples
ex_gui_detach.c, and ex_gui_multiwin.c.

Definition at line 309 of file n_gui.h.

Referenced by _native_own_chrome(), main(), and n_gui_window_detach().

◆ N_GUI_DETACH_RESIZABLE

#define N_GUI_DETACH_RESIZABLE   1

the native window can be resized by the user through the OS window manager

Examples
ex_gui_detach.c, and ex_gui_multiwin.c.

Definition at line 293 of file n_gui.h.

Referenced by main(), and n_gui_window_detach().

◆ N_GUI_DETACH_SCALE_CONTENT

#define N_GUI_DETACH_SCALE_CONTENT   2

scale the window's widgets when the native window is resized by the user.

Requires N_GUI_DETACH_RESIZABLE and normalized widget coords, which n_gui_window_detach captures at detach time. Without it the widgets keep their pixel layout and the extra room is just empty space (or scrolled, when the window carries N_GUI_WIN_AUTO_SCROLLBAR).

Examples
ex_gui_detach.c.

Definition at line 299 of file n_gui.h.

Referenced by _n_gui_kv_apply_layout(), main(), and n_gui_process_event().

◆ N_GUI_DROP_AFTER

#define N_GUI_DROP_AFTER   2

Definition at line 3484 of file n_gui.h.

Referenced by _n_gui_tree_hit_row().

◆ N_GUI_DROP_BEFORE

#define N_GUI_DROP_BEFORE   0

drop position relative to a tree row (drag-and-drop)

Definition at line 3482 of file n_gui.h.

Referenced by _n_gui_tree_hit_row(), and n_gui_tree_draw_overlay().

◆ N_GUI_DROP_INTO

#define N_GUI_DROP_INTO   1

◆ N_GUI_DROPMENU_EXPAND_UP

#define N_GUI_DROPMENU_EXPAND_UP   1

dropdown panel opens upward (above the button) instead of downward.

Auto-flip fallback (pick direction based on available space) also kicks in whenever the panel doesn't fit below and does fit above.

Definition at line 1050 of file n_gui.h.

Referenced by _draw_dropmenu_panel(), and n_gui_process_event().

◆ N_GUI_GLOBAL_SCROLL_SLACK

#define N_GUI_GLOBAL_SCROLL_SLACK   0.5f

how far, in pixels, the open windows may reach past the display before the global scrollbars appear: under half a pixel is a rounding error of a layout computed in floats, and hides nothing

Definition at line 267 of file n_gui.h.

Referenced by _global_scroll_needs().

◆ N_GUI_GLYPH_ARROW_DOWN

#define N_GUI_GLYPH_ARROW_DOWN   2

filled triangle pointing down

Examples
ex_gui_glyph.c.

Definition at line 422 of file n_gui.h.

Referenced by _draw_glyph(), main(), and n_gui_kvtable_add_row().

◆ N_GUI_GLYPH_ARROW_LEFT

#define N_GUI_GLYPH_ARROW_LEFT   3

filled triangle pointing left

Definition at line 424 of file n_gui.h.

Referenced by _draw_glyph().

◆ N_GUI_GLYPH_ARROW_RIGHT

#define N_GUI_GLYPH_ARROW_RIGHT   4

filled triangle pointing right

Definition at line 426 of file n_gui.h.

Referenced by _draw_glyph().

◆ N_GUI_GLYPH_ARROW_UP

#define N_GUI_GLYPH_ARROW_UP   1

filled triangle pointing up

Examples
ex_gui_glyph.c.

Definition at line 420 of file n_gui.h.

Referenced by _draw_glyph(), main(), and n_gui_kvtable_add_row().

◆ N_GUI_GLYPH_COPY

#define N_GUI_GLYPH_COPY   8

two offset sheets: duplicate / copy

Examples
ex_gui_glyph.c.

Definition at line 434 of file n_gui.h.

Referenced by _draw_glyph(), main(), and n_gui_kvtable_add_row().

◆ N_GUI_GLYPH_COUNT

#define N_GUI_GLYPH_COUNT   9

number of defined glyphs, for range checks

Examples
ex_gui_glyph.c.

Definition at line 436 of file n_gui.h.

Referenced by main(), and n_gui_button_set_glyph().

◆ N_GUI_GLYPH_CROSS

#define N_GUI_GLYPH_CROSS   7

diagonal cross

Examples
ex_gui_glyph.c.

Definition at line 432 of file n_gui.h.

Referenced by _draw_glyph(), main(), n_gui_kvtable_add_row(), and n_gui_kvtable_set_row_actions().

◆ N_GUI_GLYPH_MINUS

#define N_GUI_GLYPH_MINUS   6

minus sign

Definition at line 430 of file n_gui.h.

Referenced by _draw_glyph().

◆ N_GUI_GLYPH_NONE

#define N_GUI_GLYPH_NONE   0

no glyph: the button draws its text label (default)

Examples
ex_gui_glyph.c, and ex_gui_kvtable.c.

Definition at line 418 of file n_gui.h.

Referenced by _draw_button(), main(), n_gui_add_button(), n_gui_button_get_glyph(), and n_gui_kvtable_set_row_actions().

◆ N_GUI_GLYPH_PLUS

#define N_GUI_GLYPH_PLUS   5

plus sign

Examples
ex_gui_glyph.c, and ex_gui_kvtable.c.

Definition at line 428 of file n_gui.h.

Referenced by _draw_glyph(), main(), and n_gui_kvtable_set_row_actions().

◆ N_GUI_ID_MAX

◆ N_GUI_IMAGE_CENTER

#define N_GUI_IMAGE_CENTER   2

draw at original size, centered

Examples
ex_gui.c.

Definition at line 208 of file n_gui.h.

Referenced by _draw_bitmap_scaled(), _draw_image(), and main().

◆ N_GUI_IMAGE_FIT

#define N_GUI_IMAGE_FIT   0

scale to fit within bounds, keep aspect ratio

Examples
ex_gui.c, and ex_gui_frameless_drag.c.

Definition at line 204 of file n_gui.h.

Referenced by main(), and main().

◆ N_GUI_IMAGE_STRETCH

#define N_GUI_IMAGE_STRETCH   1

stretch to fill bounds

Examples
ex_gui.c.

Definition at line 206 of file n_gui.h.

Referenced by _draw_bitmap_scaled(), _draw_image(), and main().

◆ 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 440 of file n_gui.h.

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

◆ 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 443 of file n_gui.h.

Referenced by n_gui_button_set_keycode_focused(), and n_gui_process_event().

◆ N_GUI_KV_MAX

#define N_GUI_KV_MAX   128

maximum number of rows in a KV table

Definition at line 3624 of file n_gui.h.

Referenced by _n_gui_kv_refresh_actions(), n_gui_kvtable_add_row(), n_gui_kvtable_duplicate_row(), and n_gui_kvtable_move_row().

◆ N_GUI_MOUSE_DOWN

#define N_GUI_MOUSE_DOWN   1

custom widget mouse event: a press inside it, button 1 or 2

Examples
ex_gui_custom_mouse.c.

Definition at line 1187 of file n_gui.h.

Referenced by _curve_mouse(), _grid_mouse(), _popup_mouse(), _wheel_mouse(), main(), and n_gui_process_event().

◆ N_GUI_MOUSE_DRAG

#define N_GUI_MOUSE_DRAG   4

custom widget mouse event: the pointer moved with button 1 held after a press in it; reported outside the widget too, as a slider's drag is

Examples
ex_gui_custom_mouse.c.

Definition at line 1195 of file n_gui.h.

Referenced by _curve_mouse(), _wheel_mouse(), main(), and n_gui_process_event().

◆ N_GUI_MOUSE_MOVE

#define N_GUI_MOUSE_MOVE   3

custom widget mouse event: the pointer moved over it with no button held

Examples
ex_gui_custom_mouse.c.

Definition at line 1192 of file n_gui.h.

Referenced by _popup_mouse(), main(), and n_gui_process_event().

◆ N_GUI_MOUSE_UP

#define N_GUI_MOUSE_UP   2

custom widget mouse event: the release of a button 1 press that began in it, wherever the pointer is now

Examples
ex_gui_custom_mouse.c.

Definition at line 1190 of file n_gui.h.

Referenced by _curve_mouse(), _popup_mouse(), _wheel_mouse(), main(), and n_gui_process_event().

◆ N_GUI_MOUSE_WHEEL

#define N_GUI_MOUSE_WHEEL   5

custom widget mouse event: the wheel turned over it

Examples
ex_gui_custom_mouse.c.

Definition at line 1197 of file n_gui.h.

Referenced by _grid_mouse(), main(), n_gui_process_event(), and on_mouse().

◆ N_GUI_PERSIST_MAX_COLS

#define N_GUI_PERSIST_MAX_COLS   64

Maximum datagrid columns whose layout is persisted per widget.

Definition at line 1650 of file n_gui.h.

Referenced by n_gui_load_layout_json(), and n_gui_save_layout_json().

◆ N_GUI_RESIZE_ADAPTIVE

#define N_GUI_RESIZE_ADAPTIVE   1

virtual size tracks display; windows adapt per their resize_policy

Examples
ex_gui.c, and ex_gui_kvtable.c.

Definition at line 325 of file n_gui.h.

Referenced by _n_gui_apply_display_size(), main(), main(), n_gui_add_window(), n_gui_maximize_window(), n_gui_process_event(), and n_gui_set_resize_mode().

◆ N_GUI_RESIZE_VIRTUAL

#define N_GUI_RESIZE_VIRTUAL   0

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

Definition at line 323 of file n_gui.h.

Referenced by n_gui_new_ctx().

◆ N_GUI_SCROLLBAR_H

#define N_GUI_SCROLLBAR_H   0

horizontal scrollbar

Examples
ex_gui.c.

Definition at line 190 of file n_gui.h.

Referenced by main().

◆ N_GUI_SCROLLBAR_V

#define N_GUI_SCROLLBAR_V   1

vertical scrollbar

Examples
ex_gui.c.

Definition at line 192 of file n_gui.h.

Referenced by _draw_scrollbar(), _scrollbar_update_from_mouse(), main(), n_gui_grid_new(), and n_gui_process_event().

◆ N_GUI_SECTION_WIDGETS_MAX

#define N_GUI_SECTION_WIDGETS_MAX   96

maximum number of member widgets per section.

48 until a panel built from a plugin's description outgrew it: six colour rows of five widgets, eight sliders of two and the rest came to 52, and the last four were dropped without a word, laid out at the top of the window.

Examples
ex_gui_sectionlist.c.

Definition at line 3363 of file n_gui.h.

Referenced by main(), and n_gui_sectionlist_add_widget().

◆ N_GUI_SECTIONLIST_MAX

#define N_GUI_SECTIONLIST_MAX   16

maximum number of foldable sections in a section list

Definition at line 3357 of file n_gui.h.

Referenced by n_gui_sectionlist_add_section(), and n_gui_sectionlist_set_order().

◆ N_GUI_SELECT_MULTIPLE

#define N_GUI_SELECT_MULTIPLE   2

multiple item selection

Examples
ex_gui.c.

Definition at line 200 of file n_gui.h.

Referenced by main(), and n_gui_process_event().

◆ N_GUI_SELECT_NONE

#define N_GUI_SELECT_NONE   0

no selection allowed (display only)

Examples
ex_gui_network.c.

Definition at line 196 of file n_gui.h.

Referenced by main(), and n_gui_process_event().

◆ N_GUI_SELECT_SINGLE

#define N_GUI_SELECT_SINGLE   1

◆ N_GUI_SHAPE_BITMAP

#define N_GUI_SHAPE_BITMAP   2

bitmap-based rendering

Definition at line 174 of file n_gui.h.

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

◆ N_GUI_SHAPE_RECT

◆ N_GUI_SHAPE_ROUNDED

◆ N_GUI_SLIDER_H

#define N_GUI_SLIDER_H   0

horizontal slider (default)

Definition at line 184 of file n_gui.h.

Referenced by n_gui_add_slider(), and n_gui_process_event().

◆ N_GUI_SLIDER_PERCENT

#define N_GUI_SLIDER_PERCENT   1

slider uses 0-100 percentage

Examples
ex_gui.c, and ex_gui_detach.c.

Definition at line 180 of file n_gui.h.

Referenced by _slider_value_text(), main(), main(), and n_gui_add_slider().

◆ N_GUI_SLIDER_V

#define N_GUI_SLIDER_V   1

◆ N_GUI_SLIDER_VALUE

#define N_GUI_SLIDER_VALUE   0

◆ N_GUI_SPLIT_HORIZONTAL

#define N_GUI_SPLIT_HORIZONTAL   1

split pane: horizontal divider, regions are top and bottom

Examples
ex_gui_layout_persist.c, and ex_gui_splitpane.c.

Definition at line 148 of file n_gui.h.

Referenced by main(), and n_gui_add_splitpane().

◆ N_GUI_SPLIT_VERTICAL

#define N_GUI_SPLIT_VERTICAL   0

◆ N_GUI_STATE_ACTIVE

◆ N_GUI_STATE_FOCUSED

#define N_GUI_STATE_FOCUSED   4

◆ N_GUI_STATE_HOVER

◆ N_GUI_STATE_IDLE

#define N_GUI_STATE_IDLE   0

◆ N_GUI_STATE_SCROLLBAR_DRAG

#define N_GUI_STATE_SCROLLBAR_DRAG   8

◆ N_GUI_SUGGEST_MAX

#define N_GUI_SUGGEST_MAX   64

most completions a textarea's suggestion list keeps for one prefix.

Past this the list is not a help, it is a second problem: the point of completion is to offer the few things that match, and a prefix matching more than this has not narrowed anything yet.

Definition at line 94 of file n_gui.h.

Referenced by _suggest_refresh(), and n_gui_suggest_add().

◆ N_GUI_SUGGEST_SEP_MAX

#define N_GUI_SUGGEST_SEP_MAX   8

longest separator set a suggestion-aware textarea takes, including the terminator

Definition at line 102 of file n_gui.h.

◆ N_GUI_SUGGEST_VISIBLE

#define N_GUI_SUGGEST_VISIBLE   8

most completions a suggestion panel shows at once.

The rest are reached with the arrow keys or the wheel, which scroll the window.

Definition at line 98 of file n_gui.h.

Referenced by _suggest_handle_key(), _suggest_panel_rect(), and n_gui_process_event().

◆ N_GUI_SYNTAX_DIFF

#define N_GUI_SYNTAX_DIFF   6

syntax view: unified diff highlighting (added, removed and hunk header lines, as produced by n_diff_to_unified).

Added and removed are semantic the way a status colour is, so they are fixed instead of theme derived and read the same on a light or a dark background.

Examples
ex_gui_syntaxview.c.

Definition at line 166 of file n_gui.h.

Referenced by _syntax_draw_line(), and main().

◆ N_GUI_SYNTAX_HTTP

#define N_GUI_SYNTAX_HTTP   1

syntax view: HTTP message highlighting (request/status line and headers)

Examples
ex_gui_syntaxview.c.

Definition at line 153 of file n_gui.h.

Referenced by _syntax_draw_line(), and main().

◆ N_GUI_SYNTAX_JS

#define N_GUI_SYNTAX_JS   5

syntax view: JavaScript highlighting (keywords, strings, numbers, comments)

Examples
ex_gui_syntaxview.c.

Definition at line 161 of file n_gui.h.

Referenced by _syntax_draw_line(), and main().

◆ N_GUI_SYNTAX_JSON

#define N_GUI_SYNTAX_JSON   2

syntax view: JSON highlighting (keys, strings, numbers, punctuation)

Examples
ex_gui_bench.c, and ex_gui_syntaxview.c.

Definition at line 155 of file n_gui.h.

Referenced by _syntax_draw_line(), build_syntaxview_window(), and main().

◆ N_GUI_SYNTAX_PLAIN

#define N_GUI_SYNTAX_PLAIN   0

syntax view: no highlighting

Examples
ex_gui_syntaxview.c.

Definition at line 151 of file n_gui.h.

Referenced by main().

◆ N_GUI_SYNTAX_XML

#define N_GUI_SYNTAX_XML   3

syntax view: XML/HTML highlighting (tags, attributes, quoted values, comments)

Examples
ex_gui_syntaxview.c.

Definition at line 157 of file n_gui.h.

Referenced by _syntax_draw_line(), and main().

◆ N_GUI_SYNTAX_YAML

#define N_GUI_SYNTAX_YAML   4

syntax view: YAML highlighting (keys, quoted values, list markers, comments)

Examples
ex_gui_syntaxview.c.

Definition at line 159 of file n_gui.h.

Referenced by _syntax_draw_line(), and main().

◆ N_GUI_TAB_MAX

#define N_GUI_TAB_MAX   16

maximum number of tabs in a single tab panel

Definition at line 3321 of file n_gui.h.

Referenced by n_gui_tab_add(), and n_gui_tab_create().

◆ N_GUI_TB_BTN_CLOSE

#define N_GUI_TB_BTN_CLOSE   3

close titlebar button

Examples
ex_gui.c.

Definition at line 319 of file n_gui.h.

Referenced by _draw_tb_buttons(), _tb_button_action(), _tb_button_rect(), main(), n_gui_process_event(), and n_gui_window_set_tb_button_bitmaps().

◆ N_GUI_TB_BTN_MAXIMIZE

#define N_GUI_TB_BTN_MAXIMIZE   2

maximize/restore titlebar button

Definition at line 317 of file n_gui.h.

Referenced by _draw_tb_buttons(), _tb_button_action(), _tb_button_rect(), n_gui_process_event(), and n_gui_window_set_tb_button_bitmaps().

◆ N_GUI_TB_BTN_MINIMIZE

#define N_GUI_TB_BTN_MINIMIZE   1

minimize titlebar button

Definition at line 315 of file n_gui.h.

Referenced by _draw_tb_buttons(), _tb_button_action(), _tb_button_rect(), n_gui_process_event(), and n_gui_window_set_tb_button_bitmaps().

◆ N_GUI_TB_BTN_NONE

#define N_GUI_TB_BTN_NONE   0

no titlebar button

Definition at line 313 of file n_gui.h.

Referenced by n_gui_process_event(), and n_gui_window_detach().

◆ N_GUI_TEXT_MAX

◆ N_GUI_TREE_MAX

#define N_GUI_TREE_MAX   2048

maximum number of nodes in a tree view

Definition at line 3466 of file n_gui.h.

Referenced by _n_gui_tree_emit(), n_gui_tree_add_node(), n_gui_tree_node_path(), and n_gui_tree_remove_node().

◆ N_GUI_TREE_PATH_MAX

#define N_GUI_TREE_PATH_MAX   1024

maximum length of a node path (labels from the root, joined)

Examples
ex_gui_tree_state.c.

Definition at line 3524 of file n_gui.h.

Referenced by main(), n_gui_tree_find_by_path(), n_gui_tree_state_apply(), and n_gui_tree_state_save().

◆ N_GUI_TREE_PATH_SEP

#define N_GUI_TREE_PATH_SEP   '\x1f'

separator joining the labels of a node path.

A unit separator cannot appear in a label, so a path can never be ambiguous

Definition at line 3527 of file n_gui.h.

Referenced by n_gui_tree_node_path().

◆ N_GUI_TREE_STATE_MAX

#define N_GUI_TREE_STATE_MAX   512

maximum number of expanded paths remembered by an N_GUI_TREE_STATE

Definition at line 3522 of file n_gui.h.

Referenced by n_gui_tree_state_save().

◆ N_GUI_TRUNCATE_END

#define N_GUI_TRUNCATE_END   0

text too wide for its box is cut at the end, "Long senten...": the default, right for a sentence

Examples
ex_gui_text_shorten.c.

Definition at line 222 of file n_gui.h.

Referenced by _draw_label_overflow(), main(), n_gui_label_get_truncate(), and n_gui_label_set_truncate().

◆ N_GUI_TRUNCATE_PATH

#define N_GUI_TRUNCATE_PATH   2

a path too wide for its box loses whole leading components, ".../photos/IMG_0001.CR3", and the file name only if it is wider than the box on its own; both '/' and '\' separate components

Examples
ex_gui_text_shorten.c.

Definition at line 229 of file n_gui.h.

Referenced by main(), n_gui_label_set_truncate(), and n_gui_text_shorten().

◆ N_GUI_TRUNCATE_START

#define N_GUI_TRUNCATE_START   1

text too wide for its box is cut at the start, "...ong sentence": for anything whose end is what tells it apart

Examples
ex_gui_text_shorten.c.

Definition at line 225 of file n_gui.h.

Referenced by main(), n_gui_label_set_truncate(), and n_gui_text_shorten().

◆ N_GUI_TYPE_BUTTON

◆ N_GUI_TYPE_CHECKBOX

◆ N_GUI_TYPE_COMBOBOX

◆ N_GUI_TYPE_CUSTOM

#define N_GUI_TYPE_CUSTOM   17

widget type: owner-draw custom widget (rendering delegated to a callback)

Examples
ex_gui_custom.c.

Definition at line 140 of file n_gui.h.

Referenced by _curve_of(), _custom_mouse(), _destroy_widget(), _draw_widget(), _grid_of(), _wheel_of(), main(), n_gui_add_custom(), n_gui_custom_set_destroy(), n_gui_custom_set_mouse(), and n_gui_process_event().

◆ N_GUI_TYPE_DATAGRID

◆ N_GUI_TYPE_DROPMENU

◆ N_GUI_TYPE_HEXVIEW

◆ N_GUI_TYPE_IMAGE

#define N_GUI_TYPE_IMAGE   9

widget type: image display

Definition at line 122 of file n_gui.h.

Referenced by _draw_widget(), _widget_took_press(), n_gui_add_image(), and n_gui_image_set_bitmap().

◆ N_GUI_TYPE_LABEL

◆ N_GUI_TYPE_LISTBOX

◆ N_GUI_TYPE_MARKDOWNVIEW

#define N_GUI_TYPE_MARKDOWNVIEW   18

widget type: read-only scrolling Markdown view

Definition at line 143 of file n_gui.h.

Referenced by _destroy_widget(), _draw_widget(), _is_focusable_type(), _markdownview_of(), n_gui_add_markdownview(), n_gui_focus_takes_key(), and n_gui_process_event().

◆ N_GUI_TYPE_PROGRESSBAR

#define N_GUI_TYPE_PROGRESSBAR   16

widget type: horizontal progress bar (display only)

Definition at line 137 of file n_gui.h.

Referenced by _draw_widget(), _widget_took_press(), n_gui_add_progressbar(), n_gui_progressbar_get_value(), n_gui_progressbar_set_text(), and n_gui_progressbar_set_value().

◆ N_GUI_TYPE_RADIOLIST

◆ N_GUI_TYPE_SCROLLBAR

◆ N_GUI_TYPE_SLIDER

◆ N_GUI_TYPE_SPLITPANE

◆ N_GUI_TYPE_SYNTAXVIEW

◆ N_GUI_TYPE_TEXTAREA

◆ 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 270 of file n_gui.h.

Referenced by _draw_window(), _win_auto_sb_rects(), _window_update_content_size(), main(), and n_gui_process_event().

◆ N_GUI_WIN_BTN_ALL

enable all three title bar buttons (minimize + maximize + close)

Examples
ex_gui_detach.c, and ex_gui_multiwin.c.

Definition at line 284 of file n_gui.h.

Referenced by build_panel(), and main().

◆ N_GUI_WIN_BTN_CLOSE

#define N_GUI_WIN_BTN_CLOSE   1024

enable close button on the title bar

Definition at line 282 of file n_gui.h.

Referenced by _tb_button_rect(), _tb_buttons_area_width(), and n_gui_color_picker_new().

◆ N_GUI_WIN_BTN_MAXIMIZE

#define N_GUI_WIN_BTN_MAXIMIZE   512

enable maximize/restore button on the title bar

Definition at line 280 of file n_gui.h.

Referenced by _tb_button_rect(), and _tb_buttons_area_width().

◆ N_GUI_WIN_BTN_MINIMIZE

#define N_GUI_WIN_BTN_MINIMIZE   256

enable minimize button on the title bar

Examples
ex_gui_detach.c.

Definition at line 278 of file n_gui.h.

Referenced by _tb_button_rect(), _tb_buttons_area_width(), and main().

◆ N_GUI_WIN_DRAGGING

#define N_GUI_WIN_DRAGGING   4

window is being dragged

Examples
ex_gui_multiwin.c.

Definition at line 249 of file n_gui.h.

Referenced by main(), n_gui_process_event(), and n_gui_window_detach().

◆ N_GUI_WIN_FIXED_POSITION

#define N_GUI_WIN_FIXED_POSITION   64

disable window dragging (default:enable)

Examples
ex_gui.c, ex_gui_checkbox_release.c, ex_gui_dictionary.c, ex_gui_listbox.c, ex_gui_network.c, ex_gui_round.c, and ex_gui_splitpane.c.

Definition at line 274 of file n_gui.h.

Referenced by _popup_make_window(), main(), main(), n_gui_process_event(), and run().

◆ N_GUI_WIN_FRAMELESS

◆ N_GUI_WIN_HSCROLL_DRAG

#define N_GUI_WIN_HSCROLL_DRAG   32

window horizontal auto-scrollbar is being dragged

Definition at line 255 of file n_gui.h.

Referenced by _draw_window(), n_gui_process_event(), and n_gui_window_detach().

◆ N_GUI_WIN_HSCROLL_HOVER

#define N_GUI_WIN_HSCROLL_HOVER   256

pointer is over the window's horizontal auto-scrollbar

Definition at line 261 of file n_gui.h.

Referenced by _draw_window(), n_gui_process_event(), and n_gui_window_detach().

◆ N_GUI_WIN_MAXIMISED

#define N_GUI_WIN_MAXIMISED   64

window is maximised (full display size)

Examples
ex_gui_multiwin.c.

Definition at line 257 of file n_gui.h.

Referenced by _draw_tb_buttons(), main(), n_gui_add_window(), n_gui_maximize_window(), n_gui_process_event(), n_gui_window_detach(), and n_gui_window_is_maximised().

◆ N_GUI_WIN_MINIMISED

◆ N_GUI_WIN_NO_HSCROLL

#define N_GUI_WIN_NO_HSCROLL   2048

with N_GUI_WIN_AUTO_SCROLLBAR, never show the horizontal scrollbar (vertical-only scrolling): content wider than the window is clipped instead of horizontally scrolled

Examples
ex_gui.c.

Definition at line 287 of file n_gui.h.

Referenced by _draw_window(), _win_auto_sb_rects(), and main().

◆ N_GUI_WIN_OPEN

◆ 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, ex_gui_detach.c, ex_gui_multiwin.c, and ex_gui_network.c.

Definition at line 272 of file n_gui.h.

Referenced by _draw_window(), _win_auto_sb_rects(), build_panel(), main(), main(), and n_gui_process_event().

◆ N_GUI_WIN_RESIZE_MOVE

#define N_GUI_WIN_RESIZE_MOVE   1

reposition proportionally, keep pixel size

Examples
ex_gui.c, and ex_gui_kvtable.c.

Definition at line 331 of file n_gui.h.

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

◆ 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 329 of file n_gui.h.

Referenced by main(), n_gui_add_window(), and n_gui_apply_adaptive_resize().

◆ N_GUI_WIN_RESIZE_SCALE

#define N_GUI_WIN_RESIZE_SCALE   2

reposition AND resize proportionally, child widgets scale too

Examples
ex_gui.c, and ex_gui_kvtable.c.

Definition at line 333 of file n_gui.h.

Referenced by _n_gui_kv_apply_layout(), _n_gui_window_capture_normalized(), main(), main(), and n_gui_apply_adaptive_resize().

◆ N_GUI_WIN_RESIZING

#define N_GUI_WIN_RESIZING   8

window is being resized

Examples
ex_gui_multiwin.c.

Definition at line 251 of file n_gui.h.

Referenced by main(), n_gui_process_event(), and n_gui_window_detach().

◆ N_GUI_WIN_VSCROLL_DRAG

#define N_GUI_WIN_VSCROLL_DRAG   16

window vertical auto-scrollbar is being dragged

Definition at line 253 of file n_gui.h.

Referenced by _draw_window(), n_gui_process_event(), and n_gui_window_detach().

◆ N_GUI_WIN_VSCROLL_HOVER

#define N_GUI_WIN_VSCROLL_HOVER   128

pointer is over the window's vertical auto-scrollbar

Definition at line 259 of file n_gui.h.

Referenced by _draw_window(), n_gui_process_event(), and n_gui_window_detach().

◆ 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 355 of file n_gui.h.

Referenced by _zorder_group(), and n_gui_window_set_zorder().

◆ 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 353 of file n_gui.h.

Referenced by _zorder_group(), and n_gui_window_set_zorder().

◆ 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 < POPUP. 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 362 of file n_gui.h.

Referenced by _zorder_group(), and n_gui_window_set_zorder().

◆ N_GUI_ZORDER_NORMAL

#define N_GUI_ZORDER_NORMAL   0

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

Definition at line 351 of file n_gui.h.

Referenced by n_gui_add_window(), n_gui_lower_window(), n_gui_raise_window(), n_gui_window_get_zorder(), and n_gui_window_set_zorder().

◆ N_GUI_ZORDER_POPUP

#define N_GUI_ZORDER_POPUP   4

popup/modal dialogs: drawn above EVERYTHING including ALWAYS_ON_TOP windows.

Use for transient attention-demanding windows (confirmations, invitations, NPC dialogs, loot/reward popups, context menus). Unlike ALWAYS_ON_TOP, POPUP windows ARE raisable (n_gui_raise_window / click-to-raise) WITHIN their group, so the most recently opened/clicked popup wins among popups while none of them can ever be covered by HUD furniture.

Examples
ex_gui_reentrant.c, and ex_gui_tooltip.c.

Definition at line 369 of file n_gui.h.

Referenced by _popup_make_window(), _zorder_group(), main(), n_gui_color_picker_new(), n_gui_raise_window(), and n_gui_window_set_zorder().

Typedef Documentation

◆ N_GUI_CUSTOM_DRAW

typedef void(* N_GUI_CUSTOM_DRAW) (N_GUI_WIDGET *widget, float x, float y, ALLEGRO_FONT *font, void *user_data)

Owner-draw callback for a custom widget (N_GUI_TYPE_CUSTOM).

Invoked during n_gui_draw with the widget's absolute top-left screen position. The callback renders anything it likes inside the rectangle [x, y, x + widget->w, y + widget->h] using Allegro drawing primitives.

Parameters
widgetthe custom widget being drawn (read its w, h, theme, state)
xabsolute screen x of the widget's top-left corner
yabsolute screen y of the widget's top-left corner
fontthe effective font (the widget's own font, or the context default)
user_datathe user pointer passed to n_gui_add_custom

Definition at line 1184 of file n_gui.h.

◆ N_GUI_CUSTOM_MOUSE

typedef int(* N_GUI_CUSTOM_MOUSE) (int widget_id, const N_GUI_MOUSE_EVENT *ev, void *user_data)

Mouse callback for a custom widget, set with n_gui_custom_set_mouse().

Parameters
widget_idthe custom widget
evthe event, valid during the call only
user_datathe pointer passed to n_gui_custom_set_mouse
Returns
non-zero when the widget used the event. For WHEEL, zero lets the window scroll instead; for DOWN, non-zero marks the event consumed. Ignored for the others.

Definition at line 1225 of file n_gui.h.

◆ N_GUI_SUGGEST_FN

typedef void(* N_GUI_SUGGEST_FN) (const char *prefix, N_GUI_SUGGEST_SINK *sink, void *user_data)

asked for the completions of what has been typed so far

Called while the pointer is not in the widget's own code: it runs from the key handler, once per change of the word under the cursor, and must not add, remove or retext any widget.

Parameters
prefixwhat has been typed of the word under the cursor. Never NULL and never empty: an empty word closes the list without asking.
sinkwhere the answers go, through n_gui_suggest_add()
user_datawhatever was passed to n_gui_textarea_set_suggest()

Definition at line 613 of file n_gui.h.

◆ n_gui_tree_on_drop_t

typedef int(* n_gui_tree_on_drop_t) (int src_node, int dst_node, int position, void *user_data)

drag-reorder drop callback.

Called when the user drags node src_node and releases the mouse over dst_node at position (N_GUI_DROP_BEFORE / INTO / AFTER). Return 1 to accept; the caller is responsible for mutating the underlying data model and rebuilding the tree. Return 0 to reject (widget clears its drag state silently).

Definition at line 3492 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(* on_click )(int, void *),
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 2762 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, h(), n_gui_add_button(), n_gui_get_widget(), N_GUI_SHAPE_BITMAP, and on_click().

Referenced by main().

Here is the call graph for this function:
Here is the caller 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(* on_toggle )(int, int, void *),
void * user_data )

add a checkbox widget.

A mouse press toggles it on RELEASE over the same box, like a button's click: a press that drags off it (a touch scroll starting on the box) changes nothing. Space on a focused box toggles at once.

add a checkbox widget.

Returns
widget id, or -1 on error

Definition at line 3207 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_CHECKBOX_DATA::checked, N_GUI_WIDGET::data, Free, h(), N_GUI_WIDGET::id, N_GUI_CHECKBOX_DATA::label, list_push(), Malloc, n_gui_get_window(), N_GUI_ID_MAX, N_GUI_TYPE_CHECKBOX, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_CHECKBOX_DATA::on_toggle, on_toggle(), N_GUI_CHECKBOX_DATA::user_data, and N_GUI_WINDOW::widgets.

Referenced by build_widgets_window(), main(), main(), n_gui_kvtable_add_row(), and run().

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

◆ n_gui_add_combobox()

◆ n_gui_add_custom()

int n_gui_add_custom ( N_GUI_CTX * ctx,
int window_id,
float x,
float y,
float w,
float h,
N_GUI_CUSTOM_DRAW draw,
void * user_data )

Add an owner-draw custom widget to a window.

The widget participates in the window layout, z-order, visibility, enable/ disable dimming, and resize like any other widget, but its interior is painted by draw during n_gui_draw. This is the general extension point for rendering a chart, a canvas, a custom editor, or any host-supplied content that no stock widget covers. Input is not routed to the widget (place stock widgets around it for interaction); the callback is paint-only.

Parameters
ctxthe GUI context
window_idthe window to add the widget to
xwidget x relative to the window
ywidget y relative to the window
wwidget width
hwidget height
drawthe paint callback (NULL draws nothing but reserves the space)
user_dataopaque pointer handed back to the callback (not owned by n_gui)
Returns
the new widget id, or -1 on error

Add an owner-draw custom widget to a window.

Definition at line 5698 of file n_gui.c.

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

Referenced by _popup_make_window(), main(), n_gui_color_picker_new(), n_gui_colorwheel_new(), n_gui_curve_new(), and n_gui_grid_new().

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

◆ n_gui_add_datagrid()

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

add a sortable data grid; returns the widget id or -1

add a sortable data grid; returns the widget id or -1

Parameters
ctxthe GUI context
window_idthe parent window id
xwidget x within the window content area
ywidget y within the window content area
wwidget width
hwidget height
on_selectcallback fired on row selection, or NULL
user_datauser data passed to on_select
Returns
widget id, or -1 on error

Definition at line 3460 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_DATAGRID_DATA::anchor_row, N_GUI_DATAGRID_DATA::cells, N_GUI_DATAGRID_DATA::col_order, N_GUI_DATAGRID_DATA::col_resize_col, N_GUI_DATAGRID_DATA::col_resize_w0, N_GUI_DATAGRID_DATA::col_resize_x0, N_GUI_DATAGRID_DATA::cols, N_GUI_DATAGRID_DATA::cols_cap, N_GUI_WIDGET::data, Free, h(), N_GUI_DATAGRID_DATA::h_scroll, N_GUI_DATAGRID_DATA::h_scroll_dragging, N_GUI_WIDGET::id, list_push(), Malloc, N_GUI_DATAGRID_DATA::multiselect, n_gui_get_window(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_DATAGRID_DATA::on_columns_changed, N_GUI_DATAGRID_DATA::on_context, N_GUI_DATAGRID_DATA::on_select, on_select(), N_GUI_DATAGRID_DATA::row_color, N_GUI_DATAGRID_DATA::row_has_color, N_GUI_DATAGRID_DATA::row_sel, N_GUI_DATAGRID_DATA::rows_cap, N_GUI_DATAGRID_DATA::scroll_offset, N_GUI_DATAGRID_DATA::selected_row, N_GUI_DATAGRID_DATA::sort_col, N_GUI_DATAGRID_DATA::sort_dir, N_GUI_DATAGRID_DATA::user_data, and N_GUI_WINDOW::widgets.

Referenced by build_datagrid_window(), build_window(), main(), and main().

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

◆ 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(* on_open )(int, void *),
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 6297 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, N_GUI_DROPMENU_DATA::flags, Free, h(), N_GUI_DROPMENU_DATA::highlight_index, N_GUI_WIDGET::id, N_GUI_DROPMENU_DATA::is_open, N_GUI_DROPMENU_DATA::item_height, N_GUI_DROPMENU_DATA::item_hover_bitmap, 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::panel_bitmap, N_GUI_DROPMENU_DATA::scroll_offset, N_GUI_CTX::style, and N_GUI_WINDOW::widgets.

Referenced by main(), and main().

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

◆ n_gui_add_hexview()

int n_gui_add_hexview ( N_GUI_CTX * ctx,
int window_id,
float x,
float y,
float w,
float h )

add a read-only hex viewer; returns the widget id or -1

add a read-only hex viewer; returns the widget id or -1

Parameters
ctxthe GUI context
window_idthe parent window id
xwidget x within the window content area
ywidget y within the window content area
wwidget width
hwidget height
Returns
widget id, or -1 on error

Definition at line 3372 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_HEXVIEW_DATA::bytes_per_row, N_GUI_HEXVIEW_DATA::data, N_GUI_WIDGET::data, Free, h(), N_GUI_WIDGET::id, N_GUI_HEXVIEW_DATA::len, list_push(), Malloc, n_gui_get_window(), N_GUI_TYPE_HEXVIEW, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_HEXVIEW_DATA::scroll_offset, 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 3610 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_WIDGET::data, Free, h(), 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(), and main().

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

◆ n_gui_add_label()

◆ 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(* on_link_click )(int, const char *, void *),
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 3680 of file n_gui.c.

References N_GUI_WIDGET::data, h(), N_GUI_LABEL_DATA::link, n_gui_add_label(), n_gui_get_widget(), N_GUI_TEXT_MAX, N_GUI_LABEL_DATA::on_link_click, on_link_click(), text(), 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(* on_select )(int, int, int, void *),
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 3285 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_WIDGET::data, Free, h(), N_GUI_LISTBOX_DATA::hover_row, 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, 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 build_widgets_window(), 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_markdownview()

int n_gui_add_markdownview ( N_GUI_CTX * ctx,
int window_id,
float x,
float y,
float w,
float h,
const N_GUI_MD_FONTS * fonts )

add a read-only scrolling Markdown view.

fonts is copied into the widget but the faces themselves are borrowed: the caller owns them, must keep them alive while the widget is, and destroys them after n_gui_destroy_ctx(), exactly as it does for a bitmap. Only fonts->regular has to be set; the rest fall back towards it.

The style starts derived from the widget's theme and keeps following it until the caller asks for it with n_gui_markdownview_style().

Returns
the widget id, or -1

Definition at line 5814 of file n_gui.c.

References __n_assert, _destroy_widget(), _markdownview_follow_theme(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_WIDGET::data, N_GUI_MARKDOWNVIEW_DATA::dirty, N_GUI_MARKDOWNVIEW_DATA::fonts, Free, h(), N_GUI_WIDGET::id, list_push(), Malloc, N_GUI_MARKDOWNVIEW_DATA::measured_w, n_gui_get_window(), N_GUI_TYPE_MARKDOWNVIEW, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_MARKDOWNVIEW_DATA::text, N_GUI_MARKDOWNVIEW_DATA::theme_derived, 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_progressbar()

int n_gui_add_progressbar ( N_GUI_CTX * ctx,
int window_id,
float x,
float y,
float w,
float h )

add a horizontal progress bar (display only); returns the widget id or -1

Definition at line 5636 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_WIDGET::enabled, Free, h(), N_GUI_WIDGET::id, list_push(), Malloc, n_gui_get_window(), N_GUI_TYPE_PROGRESSBAR, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_PROGRESSBAR_DATA::text, N_GUI_PROGRESSBAR_DATA::value, 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_radiolist()

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

◆ n_gui_add_splitpane()

int n_gui_add_splitpane ( N_GUI_CTX * ctx,
int window_id,
float x,
float y,
float w,
float h,
int orientation,
float ratio,
void(* on_change )(int, float, void *),
void * user_data )

add a split pane (draggable divider); returns the widget id or -1

add a split pane (draggable divider); returns the widget id or -1

Parameters
ctxthe GUI context
window_idthe parent window id
xwidget x within the window content area
ywidget y within the window content area
wwidget width
hwidget height
orientationN_GUI_SPLIT_VERTICAL or N_GUI_SPLIT_HORIZONTAL
ratioinitial divider position as a fraction (0..1)
on_changecallback fired while the divider is dragged, or NULL
user_datauser data passed to on_change
Returns
widget id, or -1 on error

Definition at line 3331 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_SPLITPANE_DATA::divider, Free, h(), N_GUI_WIDGET::id, list_push(), Malloc, N_GUI_SPLITPANE_DATA::max_ratio, N_GUI_SPLITPANE_DATA::min_ratio, n_gui_get_window(), N_GUI_SPLIT_HORIZONTAL, N_GUI_SPLIT_VERTICAL, N_GUI_TYPE_SPLITPANE, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_SPLITPANE_DATA::on_change, on_change(), N_GUI_SPLITPANE_DATA::orientation, N_GUI_SPLITPANE_DATA::ratio, N_GUI_SPLITPANE_DATA::user_data, and N_GUI_WINDOW::widgets.

Referenced by build_window(), main(), main(), and n_gui_kvtable_create().

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

◆ n_gui_add_syntaxview()

int n_gui_add_syntaxview ( N_GUI_CTX * ctx,
int window_id,
float x,
float y,
float w,
float h,
int mode )

add a read-only syntax-highlighted text view; returns the widget id or -1

add a read-only syntax-highlighted text view; returns the widget id or -1

Parameters
ctxthe GUI context
window_idthe parent window id
xwidget x within the window content area
ywidget y within the window content area
wwidget width
hwidget height
modehighlighting mode (N_GUI_SYNTAX_PLAIN, _HTTP, _JSON, _XML, _YAML, _JS or _DIFF)
Returns
widget id, or -1 on error

Definition at line 3410 of file n_gui.c.

References __n_assert, _destroy_widget(), _n_gui_widget_capture_normalized(), _new_widget(), _register_widget(), N_GUI_SYNTAXVIEW_DATA::cached_content_w, N_GUI_SYNTAXVIEW_DATA::cached_headers_end, N_GUI_SYNTAXVIEW_DATA::cached_nb_lines, N_GUI_WIDGET::data, Free, h(), N_GUI_SYNTAXVIEW_DATA::h_scroll, N_GUI_SYNTAXVIEW_DATA::h_scroll_dragging, N_GUI_WIDGET::id, N_GUI_SYNTAXVIEW_DATA::len, N_GUI_SYNTAXVIEW_DATA::lines_valid, list_push(), Malloc, N_GUI_SYNTAXVIEW_DATA::metrics_font, mode, N_GUI_SYNTAXVIEW_DATA::mode, n_gui_get_window(), N_GUI_TYPE_SYNTAXVIEW, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_SYNTAXVIEW_DATA::scroll_offset, N_GUI_SYNTAXVIEW_DATA::sel_dragging, N_GUI_SYNTAXVIEW_DATA::sel_end, N_GUI_SYNTAXVIEW_DATA::sel_start, N_GUI_SYNTAXVIEW_DATA::text, N_GUI_WINDOW::widgets, and N_GUI_SYNTAXVIEW_DATA::width_valid.

Referenced by build_syntaxview_window(), and main().

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

◆ 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(* on_click )(int, void *),
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 2790 of file n_gui.c.

References N_GUI_WIDGET::data, h(), n_gui_add_button(), n_gui_get_widget(), on_click(), 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(* on_change )(int, double, void *),
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 3148 of file n_gui.c.

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

Referenced by main(), and 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 )

add a window to the GUI context

add a window to the GUI context

Returns
the window id, or -1 on error

Definition at line 1277 of file n_gui.c.

References __n_assert, _destroy_window(), _n_gui_window_capture_normalized(), _sort_windows_by_zorder(), N_GUI_WINDOW::autofit_border, N_GUI_WINDOW::autofit_flags, N_GUI_WINDOW::autofit_origin_x, N_GUI_WINDOW::autofit_origin_y, N_GUI_TB_BUTTONS::btn_theme, N_GUI_TB_BUTTONS::close_theme, N_GUI_PENDING_GEOM::consumed, N_GUI_WINDOW::content_h, N_GUI_WINDOW::content_w, N_GUI_CTX::default_tb_btn_theme, N_GUI_CTX::default_tb_close_theme, N_GUI_CTX::default_theme, N_GUI_WINDOW::detach_flags, N_GUI_CTX::dirty, N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_WINDOW::drag_ox, N_GUI_WINDOW::drag_oy, N_GUI_WINDOW::flags, N_GUI_WINDOW::font, Free, h(), N_GUI_PENDING_GEOM::h, N_GUI_WINDOW::h, N_GUI_WINDOW::id, list_push(), LOG_ERR, Malloc, N_GUI_WINDOW::min_h, N_GUI_WINDOW::min_w, N_GUI_STYLE::min_win_h, N_GUI_STYLE::min_win_w, N_GUI_DETACH_NONE, N_GUI_ID_MAX, N_GUI_RESIZE_ADAPTIVE, N_GUI_WIN_MAXIMISED, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WIN_RESIZE_NONE, N_GUI_ZORDER_NORMAL, n_log, N_GUI_WINDOW::native, N_GUI_WINDOW::native_close_pending, N_GUI_WINDOW::native_drag_anchored, N_GUI_WINDOW::native_drag_cx, N_GUI_WINDOW::native_drag_cy, N_GUI_WINDOW::native_drag_wx, N_GUI_WINDOW::native_drag_wy, N_GUI_WINDOW::native_h, N_GUI_WINDOW::native_halted, N_GUI_WINDOW::native_pos_x, N_GUI_WINDOW::native_pos_y, N_GUI_WINDOW::native_w, new_generic_list(), N_GUI_CTX::next_window_id, N_GUI_WINDOW::norm_h, N_GUI_WINDOW::norm_w, N_GUI_WINDOW::norm_x, N_GUI_WINDOW::norm_y, N_GUI_CTX::pending_layout, N_GUI_CTX::pending_layout_count, N_GUI_CTX::resize_mode, N_GUI_WINDOW::resize_policy, N_GUI_WINDOW::saved_flags, N_GUI_WINDOW::saved_h, N_GUI_WINDOW::saved_w, N_GUI_WINDOW::saved_x, N_GUI_WINDOW::saved_y, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_PENDING_GEOM::state, N_GUI_WINDOW::state, N_GUI_CTX::style, N_GUI_WINDOW::tb_buttons, N_GUI_WINDOW::theme, N_GUI_PENDING_GEOM::title, N_GUI_WINDOW::title, N_GUI_STYLE::titlebar_h, N_GUI_WINDOW::titlebar_h, UNLIMITED_LIST_ITEMS, N_GUI_PENDING_GEOM::w, N_GUI_WINDOW::w, N_GUI_WINDOW::want_native, N_GUI_WINDOW::wheel_scrollbar, N_GUI_WINDOW::widgets, N_GUI_CTX::windows, N_GUI_PENDING_GEOM::x, N_GUI_WINDOW::x, N_GUI_PENDING_GEOM::y, N_GUI_WINDOW::y, N_GUI_WINDOW::z_order, and N_GUI_WINDOW::z_value.

Referenced by _popup_make_window(), build_datagrid_window(), build_panel(), build_syntaxview_window(), build_textarea_window(), build_widgets_window(), build_window(), main(), main(), main(), n_gui_add_window_auto(), n_gui_color_picker_new(), and run().

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

◆ 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 2489 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 12269 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_WINDOW::native, 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_apply_display_size().

Here is the caller graph for this function:

◆ n_gui_button_get_glyph()

int n_gui_button_get_glyph ( N_GUI_CTX * ctx,
int widget_id )

current glyph of a button, or N_GUI_GLYPH_NONE when it draws its label (also for a non-button widget)

current glyph of a button, or N_GUI_GLYPH_NONE when it draws its label (also for a non-button widget)

Parameters
ctxthe GUI context
widget_idthe button widget
Returns
the N_GUI_GLYPH_* value, or N_GUI_GLYPH_NONE when the button draws its label or the widget is not a button

Definition at line 2859 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_GLYPH_NONE, N_GUI_TYPE_BUTTON, 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_button_get_label()

const char * n_gui_button_get_label ( N_GUI_CTX * ctx,
int widget_id )

What a button says.

The counterpart n_gui_button_set_label() has never had. An application that sizes a row from its buttons' labels, or that wants to say in a log which button was pressed, had to keep its own copy of every label, which is a second place for them to go out of step with the widgets.

Parameters
ctxthe GUI context
widget_idthe button
Returns
The label, or NULL when the widget is not a button. Borrowed, and valid until the label is set again or the widget is destroyed.

Definition at line 2124 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_BUTTON, 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_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 2806 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_glyph()

void n_gui_button_set_glyph ( N_GUI_CTX * ctx,
int widget_id,
int glyph )

draw an N_GUI_GLYPH_* icon (primitives, in the button's text colour) instead of the label; N_GUI_GLYPH_NONE restores the label.

Out-of-range values and non-button widgets are ignored

draw an N_GUI_GLYPH_* icon (primitives, in the button's text colour) instead of the label; N_GUI_GLYPH_NONE restores the label.

The glyph is built from primitives in the button's text colour, so it needs no bitmap, follows the active theme, and stays crisp at any button size. Meant for the small square buttons where a label does not fit: a row of move-up / move-down / duplicate actions, arrow toolbars, close buttons.

The label is kept, so a caller can set both and switch back with N_GUI_GLYPH_NONE. Out-of-range glyph values and non-button widgets are ignored.

Parameters
ctxthe GUI context
widget_idthe button widget
glyphone of the N_GUI_GLYPH_* values

Definition at line 2843 of file n_gui.c.

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

Referenced by main(), n_gui_kvtable_add_row(), and n_gui_kvtable_set_row_actions().

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 3075 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 3085 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.

Referenced by main().

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

◆ n_gui_button_set_label()

void n_gui_button_set_label ( N_GUI_CTX * ctx,
int widget_id,
const char * label )

replace the label text drawn on a button

replace the label text drawn on a button

No-op on non-button widgets or NULL label.

Definition at line 2818 of file n_gui.c.

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

Referenced by _n_gui_sectionlist_set_header_label(), and refresh_buttons().

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

◆ n_gui_button_set_state_bitmaps()

void n_gui_button_set_state_bitmaps ( N_GUI_CTX * ctx,
int widget_id,
ALLEGRO_BITMAP * normal,
ALLEGRO_BITMAP * hover,
ALLEGRO_BITMAP * active )

skin a button or toggle button with caller-owned per-state bitmaps (switches its shape to N_GUI_SHAPE_BITMAP; toggled-on renders active)

skin a button or toggle button with caller-owned per-state bitmaps (switches its shape to N_GUI_SHAPE_BITMAP; toggled-on renders active)

Switches the button shape to N_GUI_SHAPE_BITMAP and assigns the three state bitmaps; a toggled-on toggle button renders active persistently (the draw path already maps toggled to the ACTIVE visual state). The bitmaps stay owned by the caller, exactly like n_gui_add_button_bitmap; the label keeps drawing on top, so pass "" at creation for icon-only buttons. No-op on non-button widgets.

Parameters
ctxthe GUI context
widget_idid of the target button widget
normalbitmap for the idle state
hoverbitmap for the hover state (NULL = normal)
activebitmap for the pressed / toggled-on state (NULL = normal)

Definition at line 3029 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_get_widget(), N_GUI_SHAPE_BITMAP, N_GUI_TYPE_BUTTON, N_GUI_BUTTON_DATA::shape, 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 3056 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 3043 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_get_label()

const char * n_gui_checkbox_get_label ( N_GUI_CTX * ctx,
int widget_id )

What a checkbox says.

Parameters
ctxthe GUI context
widget_idthe checkbox
Returns
The label, or NULL when the widget is not a checkbox. Borrowed, valid until the label is set again or the widget is destroyed.

Definition at line 4276 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_CHECKBOX, 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_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 4237 of file n_gui.c.

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

Referenced by _n_gui_kv_content_grab(), and main().

Here is the call graph for this function:
Here is the caller 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 6641 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 4251 of file n_gui.c.

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

Referenced by _n_gui_kv_content_put(), and n_gui_kvtable_add_row().

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

◆ n_gui_checkbox_set_label()

void n_gui_checkbox_set_label ( N_GUI_CTX * ctx,
int widget_id,
const char * label )

Replace the text drawn beside a checkbox.

For a pool of checkboxes shown for one thing at a time - the settings of whichever entry a list has selected - relabelled rather than destroyed and made again. Truncated to what the label holds.

Parameters
ctxthe GUI context
widget_idthe checkbox
labelthe new text; NULL is ignored

Definition at line 4261 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, N_GUI_CHECKBOX_DATA::label, n_gui_get_widget(), N_GUI_TYPE_CHECKBOX, 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_close_menus()

void n_gui_close_menus ( N_GUI_CTX * ctx)

Put away any open combo box list or drop menu panel.

An open list is drawn over whatever it covers and is dismissed by a press. An application that changes what is on screen without one - switching screens, closing a panel, reacting to a key - has to say so, or the list goes on painting over the thing that replaced it.

Parameters
ctxthe GUI context

Definition at line 2334 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, N_GUI_CTX::dirty, n_gui_get_widget(), N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_DROPMENU, N_GUI_CTX::open_combobox_id, N_GUI_CTX::open_dropmenu_id, 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 )

◆ 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 6012 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, text(), and N_GUI_WIDGET::type.

Referenced by add_once(), main(), main(), and 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 5998 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_COMBOBOX_DATA::highlight_index, 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_count()

int n_gui_combobox_get_count ( N_GUI_CTX * ctx,
int widget_id )

get the number of items in a combobox (0 if not a combobox).

With n_gui_combobox_get_item_text() a caller can walk the list it filled instead of keeping its own copy of it.

get the number of items in a combobox (0 if not a combobox).

Parameters
ctxGUI context
widget_idid of the combobox widget
Returns
number of items, 0 when it is not a combobox

Definition at line 6059 of file n_gui.c.

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

Referenced by add_once(), and main().

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

◆ n_gui_combobox_get_item_text()

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

get the text of the combobox item at index ("" if out of range / not a combobox)

Definition at line 6042 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_COMBOBOX_DATA::items, n_gui_get_widget(), N_GUI_TYPE_COMBOBOX, N_GUI_LISTITEM::text, and N_GUI_WIDGET::type.

Referenced by add_once(), and main().

Here is the call graph for this function:
Here is the caller 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 6034 of file n_gui.c.

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

Referenced by main(), and wheel_then_click().

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

◆ n_gui_combobox_remove_item()

int n_gui_combobox_remove_item ( N_GUI_CTX * ctx,
int widget_id,
int index )

remove the item at index from a combobox.

The selection and the open panel's highlight follow their item: one after it moves up with it, and one on the removed item is cleared (-1) rather than landing on its neighbour. Returns 0 on success, -1 on a bad index or widget.

remove the item at index from a combobox.

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

Definition at line 6087 of file n_gui.c.

References _combobox_index_after_remove(), N_GUI_WIDGET::data, N_GUI_COMBOBOX_DATA::highlight_index, 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.

Referenced by main().

Here is the call graph for this function:
Here is the caller 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 6732 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.

Referenced by main().

Here is the call graph for this function:
Here is the caller 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 3588 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 6116 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(), main(), and main().

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

◆ n_gui_count_detached()

int n_gui_count_detached ( N_GUI_CTX * ctx)

count the windows currently detached into native OS windows

count the windows currently detached into native OS windows

Definition at line 1843 of file n_gui.c.

References __n_assert, list_foreach, N_GUI_WINDOW::native, and N_GUI_CTX::windows.

Referenced by main(), and refresh_buttons().

Here is the caller graph for this function:

◆ n_gui_custom_set_destroy()

void n_gui_custom_set_destroy ( N_GUI_CTX * ctx,
int widget_id,
void(* destroy )(void *user_data) )

hand a custom widget's paint user pointer to the widget

By default n_gui does not own the pointer given to n_gui_add_custom(). A caller building a widget of its own on a custom widget, with state on the heap, sets a destroy function here and the state then lives exactly as long as the widget: it is called once, with that pointer, when the widget is destroyed, by n_gui_destroy_ctx() or otherwise.

Parameters
ctxthe GUI context
widget_ida widget made by n_gui_add_custom()
destroycalled with the paint user pointer; NULL gives up ownership
ctxthe GUI context
widget_ida widget made by n_gui_add_custom()
destroycalled with the paint user pointer; NULL gives up ownership

Definition at line 5745 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_CUSTOM, and N_GUI_WIDGET::type.

Referenced by main(), n_gui_colorwheel_new(), n_gui_curve_new(), and n_gui_grid_new().

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

◆ n_gui_custom_set_mouse()

void n_gui_custom_set_mouse ( N_GUI_CTX * ctx,
int widget_id,
N_GUI_CUSTOM_MOUSE on_mouse,
void * user_data )

give a custom widget mouse input

Without it a custom widget only paints. With it the widget is handed, in its own coordinates: a press inside it (DOWN, button 1 or 2), the pointer moving while button 1 is held after that press (DRAG, reported even when the pointer has left the widget, so a drag does not stop at its edge), the release that ends it (UP), the pointer moving over it with no button held (MOVE), and the wheel over it (WHEEL). A widget under another one, or in a window that is closed or not on the event's display, is not told.

Parameters
ctxthe GUI context
widget_ida widget made by n_gui_add_custom()
on_mousethe callback; NULL takes the input away again
user_dataopaque pointer handed back to it (not owned by n_gui)
ctxthe GUI context
widget_ida widget made by n_gui_add_custom()
on_mousethe callback; NULL takes the input away again
user_dataopaque pointer handed back to it (not owned by n_gui)

Definition at line 5730 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, N_GUI_CUSTOM_DATA::mouse_user_data, n_gui_get_widget(), N_GUI_TYPE_CUSTOM, N_GUI_CUSTOM_DATA::on_mouse, on_mouse(), and N_GUI_WIDGET::type.

Referenced by _popup_make_window(), main(), n_gui_colorwheel_new(), n_gui_curve_new(), n_gui_grid_new(), and n_gui_popup_free().

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

◆ n_gui_datagrid_add_column()

int n_gui_datagrid_add_column ( N_GUI_CTX * ctx,
int widget_id,
const char * title,
float width )

append a column with a header title and pixel width; returns the column index or -1

Definition at line 5153 of file n_gui.c.

References N_GUI_DATAGRID_DATA::col_order, N_GUI_DATAGRID_DATA::cols, N_GUI_DATAGRID_DATA::cols_cap, N_GUI_WIDGET::data, FreeNoLog, Malloc, n_gui_get_widget(), N_GUI_ID_MAX, N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_DATAGRID_COL::title, N_GUI_WIDGET::type, N_GUI_DATAGRID_COL::visible, and N_GUI_DATAGRID_COL::width.

Referenced by build_datagrid_window(), build_window(), main(), and main().

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

◆ n_gui_datagrid_add_row()

int n_gui_datagrid_add_row ( N_GUI_CTX * ctx,
int widget_id,
const char ** values )

append a row of cell strings (values must have one entry per column); returns the row index or -1

Definition at line 5210 of file n_gui.c.

References N_GUI_DATAGRID_DATA::cells, N_GUI_WIDGET::data, FreeNoLog, Malloc, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_DATAGRID_DATA::row_color, N_GUI_DATAGRID_DATA::row_has_color, N_GUI_DATAGRID_DATA::row_sel, N_GUI_DATAGRID_DATA::rows_cap, and N_GUI_WIDGET::type.

Referenced by build_datagrid_window(), fill_rows(), main(), and main().

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

◆ n_gui_datagrid_clear_row_color()

void n_gui_datagrid_clear_row_color ( N_GUI_CTX * ctx,
int widget_id,
int row )

remove the background tint of data row row (it draws untinted again)

Definition at line 5401 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_rows, row(), N_GUI_DATAGRID_DATA::row_has_color, 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_datagrid_clear_row_colors()

void n_gui_datagrid_clear_row_colors ( N_GUI_CTX * ctx,
int widget_id )

remove every row background tint (the rows and cells are kept)

Definition at line 5419 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::row_has_color, N_GUI_DATAGRID_DATA::rows_cap, 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_datagrid_clear_rows()

void n_gui_datagrid_clear_rows ( N_GUI_CTX * ctx,
int widget_id )

◆ n_gui_datagrid_clear_selection()

void n_gui_datagrid_clear_selection ( N_GUI_CTX * ctx,
int widget_id )

clear the entire selection (no row selected)

Definition at line 5366 of file n_gui.c.

References N_GUI_DATAGRID_DATA::anchor_row, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::row_sel, N_GUI_DATAGRID_DATA::rows_cap, N_GUI_DATAGRID_DATA::selected_row, 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_datagrid_columns_width()

float n_gui_datagrid_columns_width ( N_GUI_CTX * ctx,
int widget_id )

horizontal scroll offset in pixels (how far the columns are scrolled left when their total width exceeds the widget's pane), or 0.

Read it before a rebuild and pass it back to n_gui_datagrid_set_h_scroll to preserve the horizontal view across a clear/refill.

Total width the grid's VISIBLE columns need, including the left text padding the draw path adds — i.e. the width below which the grid grows a horizontal scrollbar. A host sizing a dialog from its own columns wants this plus style.scrollbar_size (the vertical scrollbar the grid shows once the rows overflow) plus its own margins; hardcoding a width narrower than the columns is what makes a dialog open already scrolled sideways. Returns 0 for a missing or non-datagrid widget.

Definition at line 5443 of file n_gui.c.

References _datagrid_phys(), N_GUI_DATAGRID_DATA::cols, N_GUI_WIDGET::data, N_GUI_STYLE::item_text_padding, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_CTX::style, N_GUI_WIDGET::type, N_GUI_DATAGRID_COL::visible, and N_GUI_DATAGRID_COL::width.

Referenced by main().

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

◆ n_gui_datagrid_display_to_physical()

int n_gui_datagrid_display_to_physical ( N_GUI_CTX * ctx,
int widget_id,
int display_pos )

physical column shown at display position display_pos, or -1 if out of range

Definition at line 5516 of file n_gui.c.

References _datagrid_data(), _datagrid_phys(), and N_GUI_DATAGRID_DATA::nb_cols.

Referenced by _datagrid_apply_columns(), main(), and n_gui_save_layout_json().

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

◆ n_gui_datagrid_get_cell()

const char * n_gui_datagrid_get_cell ( N_GUI_CTX * ctx,
int widget_id,
int row,
int col )

get a cell string by row and column, or NULL if out of range

Definition at line 5292 of file n_gui.c.

References N_GUI_DATAGRID_DATA::cells, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DATAGRID_DATA::nb_rows, row(), 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_datagrid_get_column_count()

size_t n_gui_datagrid_get_column_count ( N_GUI_CTX * ctx,
int widget_id )

number of columns in a data grid (physical), or 0

Definition at line 5481 of file n_gui.c.

References _datagrid_data(), and N_GUI_DATAGRID_DATA::nb_cols.

Referenced by _apply_pending_widget(), main(), and n_gui_save_layout_json().

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

◆ n_gui_datagrid_get_column_title()

const char * n_gui_datagrid_get_column_title ( N_GUI_CTX * ctx,
int widget_id,
int col )

header title of physical column col, or "" if out of range

Definition at line 5486 of file n_gui.c.

References _datagrid_data(), N_GUI_DATAGRID_DATA::cols, N_GUI_DATAGRID_DATA::nb_cols, and N_GUI_DATAGRID_COL::title.

Referenced by main().

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

◆ n_gui_datagrid_get_column_visible()

int n_gui_datagrid_get_column_visible ( N_GUI_CTX * ctx,
int widget_id,
int col )

whether physical column col is visible (1) or hidden (0); 0 if out of range

Definition at line 5498 of file n_gui.c.

References _datagrid_data(), N_GUI_DATAGRID_DATA::cols, N_GUI_DATAGRID_DATA::nb_cols, and N_GUI_DATAGRID_COL::visible.

Referenced by main(), and n_gui_save_layout_json().

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

◆ n_gui_datagrid_get_column_width()

float n_gui_datagrid_get_column_width ( N_GUI_CTX * ctx,
int widget_id,
int col )

current pixel width of physical column col, or 0 if out of range

Definition at line 5510 of file n_gui.c.

References _datagrid_data(), N_GUI_DATAGRID_DATA::cols, N_GUI_DATAGRID_DATA::nb_cols, and N_GUI_DATAGRID_COL::width.

Referenced by main(), and n_gui_save_layout_json().

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

◆ n_gui_datagrid_get_h_scroll()

float n_gui_datagrid_get_h_scroll ( N_GUI_CTX * ctx,
int widget_id )

Definition at line 5459 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, 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_datagrid_get_row_color()

int n_gui_datagrid_get_row_color ( N_GUI_CTX * ctx,
int widget_id,
int row,
ALLEGRO_COLOR * out )

report whether data row row carries a background tint (1) or not (0), and copy the tint into out when it does.

out may be NULL to just test.

Definition at line 5409 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_rows, row(), N_GUI_DATAGRID_DATA::row_color, N_GUI_DATAGRID_DATA::row_has_color, 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_datagrid_get_row_count()

int n_gui_datagrid_get_row_count ( N_GUI_CTX * ctx,
int widget_id )

get the number of rows in a data grid

Definition at line 5286 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, 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_datagrid_get_scroll_offset()

int n_gui_datagrid_get_scroll_offset ( N_GUI_CTX * ctx,
int widget_id )

first visible data row (the vertical scroll position), or 0.

Read it before a rebuild and pass it back to n_gui_datagrid_set_scroll_offset so an in-place edit that clears and refills the grid does not jump the view back to the top.

Definition at line 5426 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, 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_datagrid_get_selected()

int n_gui_datagrid_get_selected ( N_GUI_CTX * ctx,
int widget_id )

get the selected row index, or -1 if none

Definition at line 5300 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, 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_datagrid_get_selected_rows()

size_t n_gui_datagrid_get_selected_rows ( N_GUI_CTX * ctx,
int widget_id,
int * out,
size_t max )

fill out with the indices of the selected rows (ascending), up to max, and return the total number of selected rows.

With multi-select disabled this reports the single selected row. out may be NULL to just count.

Definition at line 5345 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_DATAGRID_DATA::multiselect, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_DATAGRID_DATA::row_sel, N_GUI_DATAGRID_DATA::selected_row, 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_datagrid_get_sort()

int n_gui_datagrid_get_sort ( N_GUI_CTX * ctx,
int widget_id,
int * col,
int * dir )

read back the sort a datagrid is currently showing.

n_gui_datagrid_clear_rows does NOT reset sort_col / sort_dir, and the header indicator is drawn from them, so a caller that rebuilds its rows leaves the header claiming an order the rows are no longer in. Without an accessor there was nothing to re-apply after the rebuild. Read the sort before clearing, re-apply it with n_gui_datagrid_sort after the rows are back, and the header stops lying.

Parameters
ctxThe GUI context.
widget_idThe datagrid.
colReceives the sorted column, or -1 when the grid is unsorted. May be NULL.
dirReceives 1 for ascending or -1 for descending. May be NULL.
Returns
TRUE when the widget is a datagrid, FALSE otherwise.

Definition at line 5542 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::sort_col, N_GUI_DATAGRID_DATA::sort_dir, 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_datagrid_is_row_selected()

int n_gui_datagrid_is_row_selected ( N_GUI_CTX * ctx,
int widget_id,
int row )

report whether a given data row is selected (1) or not (0)

Definition at line 5336 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_DATAGRID_DATA::multiselect, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_rows, row(), N_GUI_DATAGRID_DATA::row_sel, N_GUI_DATAGRID_DATA::selected_row, 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_datagrid_move_column()

void n_gui_datagrid_move_column ( N_GUI_CTX * ctx,
int widget_id,
int from,
int to )

move the column at display position from to display position to, shifting the columns in between (reorders how columns are laid out; the cells and physical indices are unchanged)

Definition at line 5522 of file n_gui.c.

References _datagrid_data(), N_GUI_DATAGRID_DATA::col_order, and N_GUI_DATAGRID_DATA::nb_cols.

Referenced by _datagrid_apply_columns(), and main().

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

◆ n_gui_datagrid_select_row()

void n_gui_datagrid_select_row ( N_GUI_CTX * ctx,
int widget_id,
int row,
int selected )

select (1) or deselect (0) a single row in a multi-select grid programmatically (e.g.

a select-all action); selecting also makes it the primary selected row

Definition at line 5375 of file n_gui.c.

References _datagrid_ensure_sel(), N_GUI_DATAGRID_DATA::anchor_row, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_rows, row(), N_GUI_DATAGRID_DATA::row_sel, N_GUI_DATAGRID_DATA::selected_row, 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_datagrid_set_column_visible()

void n_gui_datagrid_set_column_visible ( N_GUI_CTX * ctx,
int widget_id,
int col,
int visible )

show (1) or hide (0) physical column col; hidden columns keep their cells but are skipped in the header and rows and closed up so no gap remains

Definition at line 5492 of file n_gui.c.

References _datagrid_data(), N_GUI_DATAGRID_DATA::cols, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DATAGRID_COL::visible, and visible().

Referenced by _datagrid_apply_columns(), and main().

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

◆ n_gui_datagrid_set_column_width()

void n_gui_datagrid_set_column_width ( N_GUI_CTX * ctx,
int widget_id,
int col,
float width )

set the pixel width of physical column col (clamped to a small minimum)

Definition at line 5504 of file n_gui.c.

References _datagrid_data(), N_GUI_DATAGRID_DATA::cols, N_GUI_DATAGRID_DATA::nb_cols, and N_GUI_DATAGRID_COL::width.

Referenced by _datagrid_apply_columns(), and main().

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

◆ n_gui_datagrid_set_h_scroll()

void n_gui_datagrid_set_h_scroll ( N_GUI_CTX * ctx,
int widget_id,
float px )

set the horizontal scroll offset in pixels (clamped to >= 0; the draw path re-clamps to the live content width each frame, so a stale value after a rebuild is harmless).

Pairs with n_gui_datagrid_get_h_scroll.

Definition at line 5465 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, 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_datagrid_set_multiselect()

void n_gui_datagrid_set_multiselect ( N_GUI_CTX * ctx,
int widget_id,
int enabled )

enable (1) or disable (0) multi-row selection.

When enabled, a plain click selects one row, Ctrl-click toggles a row, and Shift-click selects the range from the anchor; all selected rows are highlighted. Single-select consumers are unaffected (the default is disabled).

Definition at line 5323 of file n_gui.c.

References _datagrid_ensure_sel(), N_GUI_DATAGRID_DATA::anchor_row, N_GUI_WIDGET::data, N_GUI_DATAGRID_DATA::multiselect, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::row_sel, N_GUI_DATAGRID_DATA::rows_cap, 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_datagrid_set_on_columns_changed()

void n_gui_datagrid_set_on_columns_changed ( N_GUI_CTX * ctx,
int widget_id,
void(* cb )(int, void *) )

set the callback fired after the user drags a column border to resize it, so the host can persist the layout.

Pass NULL to disable.

Definition at line 5537 of file n_gui.c.

References _datagrid_data(), and N_GUI_DATAGRID_DATA::on_columns_changed.

Referenced by main().

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

◆ n_gui_datagrid_set_on_context()

void n_gui_datagrid_set_on_context ( N_GUI_CTX * ctx,
int widget_id,
void(* on_context )(int, int, int, int, void *) )

set the right-click context callback; fired (with the cursor x/y in GUI coordinates) when a data row is right-clicked, after selecting that row.

The callback shares the data grid's user_data. Pass NULL to disable.

Definition at line 5317 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, 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_datagrid_set_row_color()

void n_gui_datagrid_set_row_color ( N_GUI_CTX * ctx,
int widget_id,
int row,
ALLEGRO_COLOR color )

paint data row row with a background tint (a per-row highlight, e.g.

a rule engine coloring matching entries). The tint is drawn under the cell text and follows the row through a sort; the selection is drawn over it as a darkening wash plus an active border so a tinted row still reads as selected. Cell text switches to black or white per the tint luminance so it stays legible. Row colors are dropped by n_gui_datagrid_clear_rows() along with the rows they belong to.

Definition at line 5391 of file n_gui.c.

References _datagrid_ensure_colors(), N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_rows, row(), N_GUI_DATAGRID_DATA::row_color, N_GUI_DATAGRID_DATA::row_has_color, 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_datagrid_set_scroll_offset()

void n_gui_datagrid_set_scroll_offset ( N_GUI_CTX * ctx,
int widget_id,
int offset )

set the first visible data row (clamped to the row count); the draw path re-clamps to the live viewport each frame, so a stale offset after a rebuild is harmless.

Pairs with n_gui_datagrid_get_scroll_offset to preserve the scroll position across a clear/refill.

Definition at line 5432 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_DATAGRID_DATA::scroll_offset, 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_datagrid_set_selected()

void n_gui_datagrid_set_selected ( N_GUI_CTX * ctx,
int widget_id,
int row )

set the selected row index (fires the on_select callback).

-1 clears the selection and fires nothing; a row past the end is ignored.

Definition at line 5306 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DATAGRID, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_DATAGRID_DATA::on_select, row(), N_GUI_DATAGRID_DATA::selected_row, N_GUI_WIDGET::type, and N_GUI_DATAGRID_DATA::user_data.

Referenced by main(), and main().

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

◆ n_gui_datagrid_sort()

void n_gui_datagrid_sort ( N_GUI_CTX * ctx,
int widget_id,
int col,
int dir )

◆ 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 949 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::shape_mode, 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::tb_btn_glyph_thickness, N_GUI_STYLE::tb_btn_right_margin, N_GUI_STYLE::tb_btn_size, N_GUI_STYLE::tb_btn_spacing, 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, N_GUI_STYLE::titlebar_h, N_GUI_STYLE::tooltip_bg, N_GUI_STYLE::tooltip_border, N_GUI_STYLE::tooltip_delay, N_GUI_STYLE::tooltip_fg, and N_GUI_STYLE::tooltip_max_w.

Referenced by n_gui_new_ctx().

Here is the caller graph for this function:

◆ n_gui_default_tb_btn_theme()

N_GUI_THEME n_gui_default_tb_btn_theme ( void )

return the built-in default theme for titlebar minimize/maximize buttons

return the built-in default theme for titlebar minimize/maximize buttons

Semi-transparent, blends with the titlebar background.

Definition at line 889 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 n_gui_default_tb_close_theme(), and n_gui_new_ctx().

Here is the caller graph for this function:

◆ n_gui_default_tb_close_theme()

N_GUI_THEME n_gui_default_tb_close_theme ( void )

return the built-in default theme for the titlebar close button (red hover/active)

return the built-in default theme for the titlebar close button (red hover/active)

Same as the btn theme but with red hover/active backgrounds.

Definition at line 912 of file n_gui.c.

References N_GUI_THEME::bg_active, N_GUI_THEME::bg_hover, and n_gui_default_tb_btn_theme().

Referenced by n_gui_new_ctx().

Here is the call graph for this function:
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 1209 of file n_gui.c.

References __n_assert, _release_native_window(), destroy_ht(), Free, FreeNoLog, list_destroy(), list_foreach, n_clipboard_destroy(), and N_GUI_WINDOW::native.

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

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 12420 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_double_clicked_widget()

int n_gui_double_clicked_widget ( const N_GUI_CTX * ctx)

id of the widget the primary press just processed double clicked, or -1.

Valid until the next event is processed. Two presses count when they land on the same widget inside n_gui_set_double_click_time() of each other and within n_gui_set_double_click_radius() pixels.

id of the widget the primary press just processed double clicked, or -1.

Valid until the next event goes through n_gui_process_event(). Two presses count as a double click when they land on the same widget, inside n_gui_set_double_click_time() of each other, and within n_gui_set_double_click_radius() pixels.

The radius matters as much as the interval. Without it a drag that happens to pause reads as a double click, which is the part hosts rolling their own leave out and then wonder why the gesture fires when it should not.

Parameters
ctxGUI context
Returns
the widget id, or -1 when the last event was not a double click

Definition at line 3753 of file n_gui.c.

References __n_assert, and N_GUI_CTX::double_clicked_widget_id.

Referenced by click_and_report(), and main().

Here is the caller graph for this function:

◆ n_gui_draw()

void n_gui_draw ( N_GUI_CTX * ctx)

◆ n_gui_draw_detached()

void n_gui_draw_detached ( N_GUI_CTX * ctx)

render and flip every detached window, and release the ones whose native window was closed.

Call once per frame, after the event queue has been drained. Restores the caller's target bitmap before returning, and does not touch the main display's backbuffer.

render and flip every detached window, and release the ones whose native window was closed.

Call once per frame, after the event queue has been drained: this is the safe point where a display whose close was requested is actually destroyed, so no already-queued event can name a freed display.

Each native window is drawn with an identity transform, the virtual canvas, global scroll and global scrollbars belong to the main display only. The caller's target bitmap is restored before returning.

Definition at line 11932 of file n_gui.c.

References __n_assert, _draw_combobox_dropdown(), _draw_dropmenu_panel(), _draw_textarea_suggest(), _draw_tooltip(), _draw_window(), _release_native_window(), N_GUI_WINDOW::autofit_flags, N_GUI_THEME::bg_normal, N_GUI_CTX::default_font, N_GUI_WINDOW::flags, N_GUI_WINDOW::h, N_GUI_WINDOW::id, list_foreach, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, n_gui_window_apply_autofit(), N_GUI_WINDOW::native, N_GUI_WINDOW::native_close_pending, N_GUI_WINDOW::native_halted, N_GUI_WINDOW::on_content_draw, N_GUI_WINDOW::on_content_draw_data, N_GUI_CTX::pass_display, pending, N_GUI_WINDOW::saved_flags, N_GUI_WINDOW::saved_h, N_GUI_WINDOW::saved_w, N_GUI_WINDOW::saved_x, N_GUI_WINDOW::saved_y, N_GUI_WINDOW::state, N_GUI_CTX::style, N_GUI_WINDOW::theme, N_GUI_WINDOW::w, N_GUI_WINDOW::want_native, 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_dropmenu_add_dynamic_entry()

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)

add a dynamic entry (rebuilt each time menu opens)

Returns
entry index, or -1 on error

Definition at line 6398 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(), n_log, on_click(), and text().

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(* on_click )(int, int, int, void *),
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 6375 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, on_click(), N_GUI_DROPMENU_ENTRY::tag, N_GUI_DROPMENU_ENTRY::text, text(), N_GUI_WIDGET::type, and N_GUI_DROPMENU_ENTRY::user_data.

Referenced by main(), 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 6452 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.

Referenced by main().

Here is the call graph for this function:
Here is the caller 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 6423 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 6477 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DROPMENU, 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_dropmenu_is_open()

int n_gui_dropmenu_is_open ( N_GUI_CTX * ctx,
int widget_id )

is a dropdown menu's panel showing

is a dropdown menu's panel showing

Parameters
ctxthe GUI context
widget_ida dropmenu widget
Returns
1 when its panel is open

Definition at line 6542 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_DROPMENU, 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_dropmenu_panel_width()

float n_gui_dropmenu_panel_width ( N_GUI_CTX * ctx,
int widget_id )

width the open panel needs to show its entries without truncation: the larger of the collapsed button width and the widest entry text (plus item padding on both sides and the scrollbar width when the entry count overflows the visible window).

Returns 0 for a non-dropmenu widget.

width the open panel needs to show its entries without truncation: the larger of the collapsed button width and the widest entry text (plus item padding on both sides and the scrollbar width when the entry count overflows the visible window).

The collapsed dropmenu button is often narrow (it only shows a short category label), but the floating panel must be wide enough that its entries read in full. This returns the larger of the button width and the widest entry text, padded by the item text padding on both sides and, when the entry count overflows the visible window, the scrollbar width. The draw and hit-test paths share it so the panel background, the clickable item area, and the scrollbar all use one width.

Parameters
ctxthe GUI context
widget_idthe dropmenu widget id
Returns
the panel width in pixels, or 0 for a non-dropmenu widget

Definition at line 6565 of file n_gui.c.

References _text_w(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_DROPMENU_DATA::entries, font, N_GUI_WIDGET::font, N_GUI_STYLE::item_text_padding, N_GUI_DROPMENU_DATA::max_visible, n_gui_get_widget(), N_GUI_TYPE_DROPMENU, N_GUI_DROPMENU_DATA::nb_entries, N_GUI_STYLE::scrollbar_size, N_GUI_CTX::style, N_GUI_DROPMENU_ENTRY::text, N_GUI_WIDGET::type, and N_GUI_WIDGET::w.

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

Here is the call graph for this function:
Here is the caller 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 6748 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.

Referenced by main().

Here is the call graph for this function:
Here is the caller 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 6463 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, text(), and N_GUI_WIDGET::type.

Here is the call graph for this function:

◆ n_gui_dropmenu_set_flags()

void n_gui_dropmenu_set_flags ( N_GUI_CTX * ctx,
int widget_id,
int flags )

set dropmenu feature flags (bitmask of N_GUI_DROPMENU_* values)

set dropmenu feature flags (bitmask of N_GUI_DROPMENU_* values)

Definition at line 6341 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::flags, 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_label()

void n_gui_dropmenu_set_label ( N_GUI_CTX * ctx,
int widget_id,
const char * label )

replace the button label shown on a dropmenu (NULL clears it)

replace the button label shown on a dropmenu (NULL clears it)

The label is the text drawn on the collapsed dropmenu button (before the arrow). Useful when a single dropmenu widget is reused to present different menus (a pooled toolbar category button, for instance). A NULL label clears it. The text is truncated to N_GUI_ID_MAX-1 bytes.

Parameters
ctxthe GUI context
widget_idthe dropmenu widget id
labelnew button label, or NULL to clear

Definition at line 6360 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::label, n_gui_get_widget(), N_GUI_TYPE_DROPMENU, 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_dropmenu_set_open()

int n_gui_dropmenu_set_open ( N_GUI_CTX * ctx,
int widget_id,
int open )

open or close a dropdown menu without anybody clicking its button.

The panel is positioned from the button's rectangle, so a caller wanting a menu somewhere else - a context menu at the pointer, say - moves the widget there with n_gui_widget_set_rect() first and may hide the button with n_gui_set_widget_visible(): the panel is drawn and hit tested from ctx->open_dropmenu_id rather than from the button's own visibility, so a hidden button still gives a working menu.

Opening does what a click on the button does: it closes any other open dropmenu or combobox, clears the highlight so nothing is pre-selected, and calls the on_open callback so dynamic entries are rebuilt. Closing a menu that is not the open one does nothing.

Parameters
ctxthe GUI context
widget_ida dropmenu widget
opennon-zero to open, zero to close
Returns
1 when the menu is open afterwards, 0 when it is not

open or close a dropdown menu without anybody clicking its button.

The same sequence the button's own press runs, so a menu opened this way behaves like one opened by hand: any other open dropmenu or combobox is closed first, nothing is pre-highlighted, and the on_open callback rebuilds the dynamic entries.

The panel is positioned from the button's rectangle and drawn from ctx->open_dropmenu_id, not from the button's visibility, so a caller that wants a context menu at the pointer can move the widget there and hide the button. The parameters are documented once, in n_gui.h.

Definition at line 6498 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::highlight_index, N_GUI_DROPMENU_DATA::is_open, LOG_ERR, n_gui_get_widget(), n_gui_mark_dirty(), N_GUI_TYPE_DROPMENU, n_log, N_GUI_DROPMENU_DATA::on_open, N_GUI_DROPMENU_DATA::on_open_user_data, N_GUI_CTX::open_combobox_id, N_GUI_CTX::open_dropmenu_id, N_GUI_DROPMENU_DATA::scroll_offset, 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_focus_takes_key()

int n_gui_focus_takes_key ( const N_GUI_CTX * ctx,
int keycode )

Would the focused widget do something with this particular key.

A text area takes every key, because every key is a character or an edit. A slider, a scrollbar, a list, a grid and an open menu take the keys that move through them - the arrows, Home, End, the page keys and Enter - and no others: a digit typed at a focused slider is not the slider's, and an application that binds digits should still get it.

A button, which has focus only from Tab, Shift+Tab, an arrow or n_gui_set_focus(), takes Enter and Space, which press it, and the four arrows, which move to the next or previous button of its window in reading order.

The key rather than the widget alone, because an application asking "does the focus want keys" has to answer "which key" to be useful. False when nothing is focused, or when what is focused is a label.

Parameters
ctxthe GUI context
keycodethe ALLEGRO_KEY_* code of the press
Returns
1 when the key belongs to the focused widget.

Definition at line 2284 of file n_gui.c.

References __n_assert, _button_takes_key(), _find_widget_const(), _key_navigates(), N_GUI_WIDGET::enabled, N_GUI_CTX::focused_widget_id, N_GUI_TYPE_BUTTON, N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_DATAGRID, N_GUI_TYPE_DROPMENU, N_GUI_TYPE_HEXVIEW, N_GUI_TYPE_LISTBOX, N_GUI_TYPE_MARKDOWNVIEW, N_GUI_TYPE_RADIOLIST, N_GUI_TYPE_SCROLLBAR, N_GUI_TYPE_SLIDER, N_GUI_TYPE_SYNTAXVIEW, N_GUI_TYPE_TEXTAREA, N_GUI_WIDGET::type, and N_GUI_WIDGET::visible.

Referenced by main().

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

◆ n_gui_focus_window()

void n_gui_focus_window ( N_GUI_CTX * ctx,
int window_id )

give a window keyboard focus: raise it within its z-order group and focus its first focusable widget (clears focus if it has none)

give a window keyboard focus: raise it within its z-order group and focus its first focusable widget (clears focus if it has none)

Raises the window within its z-order group (so it is drawn on top of its peers) and moves keyboard focus to its first focusable, visible, enabled widget. If the window has no focusable widget, focus is cleared so global key bindings still fire. Does nothing if the window id is unknown.

Definition at line 2381 of file n_gui.c.

References __n_assert, _is_focusable_type(), N_GUI_WIDGET::enabled, N_GUI_WIDGET::id, list_foreach, n_gui_get_window(), n_gui_raise_window(), n_gui_set_focus(), N_GUI_WIDGET::type, N_GUI_WIDGET::visible, and N_GUI_WINDOW::widgets.

Here is the call graph for this function:

◆ n_gui_get_cursor()

int n_gui_get_cursor ( N_GUI_CTX * ctx,
ALLEGRO_MOUSE_CURSOR ** custom )

The cursor the GUI last applied to the display.

What is showing, which is the application's cursor from n_gui_set_cursor() except where the GUI shows a resize cursor of its own. Recorded even without a display, so a headless test can read it.

Parameters
ctxthe GUI context
customreceives the custom cursor showing, or NULL when a system cursor is. May be NULL.
Returns
the ALLEGRO_SYSTEM_MOUSE_CURSOR_* value showing, meaningful when *custom is NULL; ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT for a NULL context

Definition at line 491 of file n_gui.c.

References N_GUI_CTX::cursor_custom, and N_GUI_CTX::cursor_shape.

Referenced by main().

Here is the caller 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 12396 of file n_gui.c.

References __n_assert, and N_GUI_CTX::dpi_scale.

◆ n_gui_get_event_queue()

ALLEGRO_EVENT_QUEUE * n_gui_get_event_queue ( N_GUI_CTX * ctx)

get the event queue previously given to n_gui_set_event_queue (NULL if none)

get the event queue previously given to n_gui_set_event_queue (NULL if none)

Definition at line 1595 of file n_gui.c.

References __n_assert, and N_GUI_CTX::event_queue.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_get_focus()

int n_gui_get_focus ( const N_GUI_CTX * ctx)

Which widget has the keyboard, or -1 when none has.

The counterpart n_gui_set_focus() has never had. An application with key bindings of its own has to know whether a key is meant for a widget before it acts on it: a digit typed into a search box is text, and the same digit with nothing focused is whatever the application says it is.

Parameters
ctxthe GUI context
Returns
The widget id, or -1.

Definition at line 2168 of file n_gui.c.

References __n_assert, and N_GUI_CTX::focused_widget_id.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_get_key_modifiers()

int n_gui_get_key_modifiers ( const N_GUI_CTX * ctx)

the modifier keys held down now, as the GUI has seen them

Allegro's mouse events do not say whether Ctrl or Shift is held, and asking the keyboard state reads the real keyboard, which an event a program made up itself (a test, a replay) never touched. The context follows instead the KEY_DOWN and KEY_UP events given to n_gui_process_event(), resyncs on each KEY_CHAR, which carries the modifiers, and forgets every key when the display loses the focus, since the key up of a key let go elsewhere is never seen.

A key event the program keeps from n_gui_process_event() is not seen; a program that handles some keys itself should still pass the modifier keys' own events through.

Parameters
ctxthe GUI context
Returns
ALLEGRO_KEYMOD_SHIFT, _CTRL, _ALT and _ALTGR ORed, 0 for none or a NULL ctx

Definition at line 13281 of file n_gui.c.

References _N_GUI_HELD_ALT, _N_GUI_HELD_ALTGR, _N_GUI_HELD_LCTRL, _N_GUI_HELD_LSHIFT, _N_GUI_HELD_RCTRL, _N_GUI_HELD_RSHIFT, and N_GUI_CTX::held_modifier_keys.

Referenced by _custom_mouse(), and main().

Here is the caller graph for this function:

◆ 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 12122 of file n_gui.c.

References __n_assert, and N_GUI_CTX::resize_mode.

◆ n_gui_get_shape_mode()

int n_gui_get_shape_mode ( N_GUI_CTX * ctx)

get the global widget shape (N_GUI_SHAPE_ROUNDED or N_GUI_SHAPE_RECT)

get the global widget shape (N_GUI_SHAPE_ROUNDED or N_GUI_SHAPE_RECT)

Parameters
ctxGUI context.
Returns
N_GUI_SHAPE_ROUNDED or N_GUI_SHAPE_RECT (rounded when ctx is NULL).

Definition at line 12371 of file n_gui.c.

References N_GUI_SHAPE_ROUNDED, N_GUI_STYLE::shape_mode, and N_GUI_CTX::style.

Referenced by main().

Here is the caller graph for this function:

◆ 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 106 of file n_gui.c.

References font, N_GUI_TEXT_DIMS::h, text(), N_GUI_TEXT_DIMS::w, N_GUI_TEXT_DIMS::x, and N_GUI_TEXT_DIMS::y.

Referenced by n_gui_slider_value_width().

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

◆ n_gui_get_topmost_open_window()

int n_gui_get_topmost_open_window ( const N_GUI_CTX * ctx)

get the id of the frontmost open, non-minimized window (the last one in draw order), or -1 if no window is open.

Because the window list is kept sorted by z-order group, this is the topmost window currently on screen.

get the id of the frontmost open, non-minimized window (the last one in draw order), or -1 if no window is open.

The window list is kept sorted by z-order group with the topmost group last, so the last open window in list order is the one drawn on top. Returns -1 when no window is open.

Definition at line 2361 of file n_gui.c.

References __n_assert, LIST::end, N_GUI_WINDOW::id, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, LIST_NODE::prev, N_GUI_WINDOW::state, and N_GUI_CTX::windows.

◆ 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 3701 of file n_gui.c.

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

Referenced by _clear_syntaxview_selection(), _curve_mouse(), _curve_of(), _datagrid_data(), _draw_combobox_dropdown(), _draw_dropmenu_panel(), _draw_textarea_suggest(), _draw_tooltip(), _grid_mouse(), _grid_of(), _markdownview_of(), _n_gui_kv_apply_layout(), _n_gui_tree_listbox_bounds(), _ngui_publish_primary_selection(), _splitpane_cursor_hover(), _suggest_refresh(), _wheel_mouse(), _wheel_of(), click_middle(), dropmenu_label(), main(), n_gui_add_button_bitmap(), n_gui_add_label_link(), n_gui_add_toggle_button(), n_gui_add_vslider(), n_gui_button_get_glyph(), n_gui_button_get_label(), n_gui_button_is_toggled(), n_gui_button_set_glyph(), n_gui_button_set_keycode(), n_gui_button_set_keycode_focused(), n_gui_button_set_label(), n_gui_button_set_state_bitmaps(), n_gui_button_set_toggle_mode(), n_gui_button_set_toggled(), n_gui_checkbox_get_label(), n_gui_checkbox_is_checked(), n_gui_checkbox_set_bitmaps(), n_gui_checkbox_set_checked(), n_gui_checkbox_set_label(), n_gui_close_menus(), n_gui_combobox_add_item(), n_gui_combobox_clear(), n_gui_combobox_get_count(), n_gui_combobox_get_item_text(), n_gui_combobox_get_selected(), n_gui_combobox_remove_item(), n_gui_combobox_set_bitmaps(), n_gui_combobox_set_flags(), n_gui_combobox_set_selected(), n_gui_custom_set_destroy(), n_gui_custom_set_mouse(), n_gui_datagrid_add_column(), n_gui_datagrid_add_row(), n_gui_datagrid_clear_row_color(), n_gui_datagrid_clear_row_colors(), n_gui_datagrid_clear_rows(), n_gui_datagrid_clear_selection(), n_gui_datagrid_columns_width(), n_gui_datagrid_get_cell(), n_gui_datagrid_get_h_scroll(), n_gui_datagrid_get_row_color(), n_gui_datagrid_get_row_count(), n_gui_datagrid_get_scroll_offset(), n_gui_datagrid_get_selected(), n_gui_datagrid_get_selected_rows(), n_gui_datagrid_get_sort(), n_gui_datagrid_is_row_selected(), n_gui_datagrid_select_row(), n_gui_datagrid_set_h_scroll(), n_gui_datagrid_set_multiselect(), n_gui_datagrid_set_on_context(), n_gui_datagrid_set_row_color(), n_gui_datagrid_set_scroll_offset(), n_gui_datagrid_set_selected(), n_gui_datagrid_sort(), 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_is_open(), n_gui_dropmenu_panel_width(), n_gui_dropmenu_set_bitmaps(), n_gui_dropmenu_set_entry_text(), n_gui_dropmenu_set_flags(), n_gui_dropmenu_set_label(), n_gui_dropmenu_set_open(), n_gui_hexview_get_cursor(), n_gui_hexview_get_data(), n_gui_hexview_get_length(), n_gui_hexview_set_cursor(), n_gui_hexview_set_data(), n_gui_hexview_set_editable(), n_gui_hexview_set_on_change(), n_gui_image_set_bitmap(), n_gui_is_widget_enabled(), n_gui_label_fits(), n_gui_label_get_text(), n_gui_label_get_truncate(), n_gui_label_set_bitmap(), n_gui_label_set_link(), n_gui_label_set_text(), n_gui_label_set_truncate(), n_gui_listbox_add_item(), n_gui_listbox_clear(), n_gui_listbox_content_width(), n_gui_listbox_get_count(), n_gui_listbox_get_h_scroll(), 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_h_scroll(), n_gui_listbox_set_scroll_offset(), n_gui_listbox_set_selected(), n_gui_needs_redraw(), n_gui_process_event(), n_gui_progressbar_get_value(), n_gui_progressbar_set_text(), n_gui_progressbar_set_value(), 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_scrollbar_set_wheel_step(), n_gui_sectionlist_add_widget(), n_gui_sectionlist_relayout(), n_gui_set_focus(), n_gui_set_widget_enabled(), n_gui_set_widget_theme(), n_gui_set_widget_tooltip(), n_gui_set_widget_visible(), n_gui_slider_get_default(), n_gui_slider_get_key_step(), n_gui_slider_get_value(), n_gui_slider_handle_pos(), n_gui_slider_set_bitmaps(), n_gui_slider_set_default(), n_gui_slider_set_key_step(), n_gui_slider_set_range(), n_gui_slider_set_step(), n_gui_slider_set_value(), n_gui_slider_set_value_format(), n_gui_slider_set_value_visible(), n_gui_slider_value_width(), n_gui_splitpane_band(), n_gui_splitpane_get_ratio(), n_gui_splitpane_set_limits(), n_gui_splitpane_set_ratio(), n_gui_syntaxview_content_width(), n_gui_syntaxview_get_h_scroll(), n_gui_syntaxview_get_line_count(), n_gui_syntaxview_get_selected_text(), n_gui_syntaxview_get_text(), n_gui_syntaxview_scroll_to_offset(), n_gui_syntaxview_select_all(), n_gui_syntaxview_set_h_scroll(), n_gui_syntaxview_set_mode(), n_gui_syntaxview_set_selection(), n_gui_syntaxview_set_text(), n_gui_tab_relayout(), n_gui_textarea_get_text(), n_gui_textarea_get_text_length(), n_gui_textarea_has_selection(), 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_placeholder(), n_gui_textarea_set_selection(), n_gui_textarea_set_suggest(), n_gui_textarea_set_text(), n_gui_textarea_suggest_close(), n_gui_textarea_suggest_is_open(), n_gui_tree_draw_overlay(), n_gui_widget_get_persist_key(), n_gui_widget_is_visible(), n_gui_widget_screen_rect(), n_gui_widget_set_persist_key(), n_gui_widget_set_rect(), placeholder_of(), and widget_y().

Here is the call graph for this function:

◆ n_gui_get_window()

N_GUI_WINDOW * n_gui_get_window ( N_GUI_CTX * ctx,
int window_id )

get a window by id

get a window by id

Definition at line 1397 of file n_gui.c.

References _find_window_node(), and LIST_NODE::ptr.

Referenced by _n_gui_kv_apply_layout(), _n_gui_tree_listbox_bounds(), click_middle(), level_window(), main(), main(), n_gui_add_button(), n_gui_add_checkbox(), n_gui_add_combobox(), n_gui_add_custom(), n_gui_add_datagrid(), n_gui_add_dropmenu(), n_gui_add_hexview(), n_gui_add_image(), n_gui_add_label(), n_gui_add_listbox(), n_gui_add_markdownview(), n_gui_add_progressbar(), n_gui_add_radiolist(), n_gui_add_scrollbar(), n_gui_add_slider(), n_gui_add_splitpane(), n_gui_add_syntaxview(), n_gui_add_textarea(), n_gui_close_window(), n_gui_color_picker_new(), n_gui_color_picker_open(), n_gui_focus_window(), n_gui_kvtable_create(), n_gui_maximize_window(), n_gui_minimize_window(), n_gui_open_window(), n_gui_process_event(), n_gui_restore_window(), n_gui_sectionlist_relayout(), n_gui_tab_relayout(), n_gui_toggle_window(), n_gui_window_apply_autofit(), n_gui_window_attach(), n_gui_window_autosize(), n_gui_window_button_rect(), n_gui_window_detach(), n_gui_window_find_button(), n_gui_window_get_display(), n_gui_window_get_flags(), n_gui_window_get_resize_policy(), n_gui_window_get_zorder(), n_gui_window_get_zvalue(), n_gui_window_is_detached(), n_gui_window_is_maximised(), n_gui_window_is_minimised(), n_gui_window_is_open(), n_gui_window_native_is_hidden(), n_gui_window_set_autofit(), n_gui_window_set_bitmaps(), n_gui_window_set_caption(), n_gui_window_set_close_callback(), n_gui_window_set_content_draw_callback(), n_gui_window_set_flags(), n_gui_window_set_maximize_callback(), n_gui_window_set_minimize_callback(), n_gui_window_set_native_icons(), n_gui_window_set_rect_axes(), n_gui_window_set_resize_policy(), n_gui_window_set_tb_btn_theme(), n_gui_window_set_tb_button_bitmaps(), n_gui_window_set_tb_close_theme(), n_gui_window_set_wheel_scrollbar(), n_gui_window_set_zorder(), n_gui_window_update_normalized(), and sample_chrome_titlebar().

Here is the call graph for this function:

◆ n_gui_hexview_get_cursor()

size_t n_gui_hexview_get_cursor ( N_GUI_CTX * ctx,
int widget_id )

the byte offset the edit cursor sits on

Parameters
ctxGUI context
widget_idid of the hex viewer widget
Returns
the offset, or 0 when the widget is invalid

Definition at line 4887 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_HEXVIEW, 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_hexview_get_data()

const unsigned char * n_gui_hexview_get_data ( N_GUI_CTX * ctx,
int widget_id,
size_t * len )

borrow the bytes a hex view holds (valid until the next edit or set_data); *len receives the count.

Returns NULL when there are none.

borrow the bytes a hex view holds (valid until the next edit or set_data); *len receives the count.

Parameters
ctxGUI context
widget_idid of the hex viewer widget
lenreceives the byte count (may be NULL)
Returns
the bytes, valid until the next edit or set_data, or NULL when empty

Definition at line 4858 of file n_gui.c.

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

Referenced by hex_equals(), and main().

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

◆ n_gui_hexview_get_length()

size_t n_gui_hexview_get_length ( N_GUI_CTX * ctx,
int widget_id )

get the number of bytes currently held by a hex viewer

Parameters
ctxGUI context
widget_idid of the hex viewer widget
Returns
the byte count, or 0 if the widget is invalid

Definition at line 4899 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_HEXVIEW, 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_hexview_set_cursor()

void n_gui_hexview_set_cursor ( N_GUI_CTX * ctx,
int widget_id,
size_t offset )

move the edit cursor to a byte offset (clamped to the data length)

move the edit cursor to a byte offset (clamped to the data length)

Parameters
ctxGUI context
widget_idid of the hex viewer widget
offsetthe byte offset, clamped to the data length

Definition at line 4872 of file n_gui.c.

References N_GUI_HEXVIEW_DATA::cursor, N_GUI_WIDGET::data, N_GUI_HEXVIEW_DATA::len, n_gui_get_widget(), N_GUI_TYPE_HEXVIEW, N_GUI_HEXVIEW_DATA::nibble, 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_hexview_set_data()

void n_gui_hexview_set_data ( N_GUI_CTX * ctx,
int widget_id,
const unsigned char * data,
size_t len )

set (copy) the bytes shown by a hex viewer; data may be NULL to clear

set (copy) the bytes shown by a hex viewer; data may be NULL to clear

Parameters
ctxGUI context
widget_idid of the hex viewer widget
datathe bytes to display, or NULL to clear
lennumber of bytes in data

Definition at line 4805 of file n_gui.c.

References N_GUI_HEXVIEW_DATA::cap, N_GUI_HEXVIEW_DATA::cursor, N_GUI_HEXVIEW_DATA::data, N_GUI_WIDGET::data, FreeNoLog, N_GUI_HEXVIEW_DATA::len, Malloc, n_gui_get_widget(), N_GUI_TYPE_HEXVIEW, N_GUI_HEXVIEW_DATA::nibble, N_GUI_HEXVIEW_DATA::scroll_offset, 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_hexview_set_editable()

void n_gui_hexview_set_editable ( N_GUI_CTX * ctx,
int widget_id,
int editable )

make a hex view editable (or read-only again)

An editable hex view is the only widget here that can hold and edit arbitrary bytes: a textarea normalizes CRLF and refuses any character below 32, so a caller that must author exact bytes (a protocol message, a malformed request, a binary body) cannot use one. Typing a hex digit overwrites the nibble under the cursor; Insert adds a zero byte, Delete and Backspace remove one; the arrows, Home, End, PageUp and PageDown move; a click places the cursor.

make a hex view editable (or read-only again)

Parameters
ctxGUI context
widget_idid of the hex viewer widget
editablenon-zero to allow editing

Definition at line 4831 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_HEXVIEW, 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_hexview_set_on_change()

void n_gui_hexview_set_on_change ( N_GUI_CTX * ctx,
int widget_id,
void(* on_change )(int, const unsigned char *, size_t, void *),
void * user_data )

set the callback fired after each edit (NULL to clear)

set the callback fired after each edit (NULL to clear)

Parameters
ctxGUI context
widget_idid of the hex viewer widget
on_changethe callback, or NULL to clear it
user_dataopaque pointer handed back to the callback

Definition at line 4844 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_HEXVIEW, on_change(), and N_GUI_WIDGET::type.

Here is the call graph for this function:

◆ n_gui_hovered_widget()

int n_gui_hovered_widget ( const N_GUI_CTX * ctx)

id of the widget currently under the mouse pointer (hover/active flag, maintained by n_gui_process_event; front-most open window wins), or -1.

Lets a host pick a system mouse cursor from the hovered widget's type.

id of the widget currently under the mouse pointer (hover/active flag, maintained by n_gui_process_event; front-most open window wins), or -1.

Returns the widget whose HOVER (or ACTIVE, during a press) state flag is set, n_gui_process_event maintains that flag exclusively on the topmost visible widget under the pointer on every mouse event, so this is a cheap per-frame query. Windows are scanned front-to-back; closed windows and invisible or disabled widgets are skipped. Typical use: pick a system mouse cursor (hand over a button, I-beam over a textarea) from n_gui_get_widget(ctx, id)->type.

Definition at line 3723 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::enabled, LIST::end, N_GUI_WIDGET::id, list_foreach, N_GUI_STATE_ACTIVE, N_GUI_STATE_HOVER, N_GUI_WIN_OPEN, LIST_NODE::prev, N_GUI_WIDGET::state, N_GUI_WINDOW::state, N_GUI_WIDGET::visible, N_GUI_WINDOW::widgets, and N_GUI_CTX::windows.

Referenced by main(), and n_gui_process_event().

Here is the caller graph for this function:

◆ 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 6134 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 3896 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_kvtable_add_row()

◆ n_gui_kvtable_clear()

void n_gui_kvtable_clear ( N_GUI_KVTABLE * table)

remove every row at once.

The key column and remove button are always kept; the freed row slots (and their widgets) are reused by the next add_row calls, so repeated clear+repopulate cycles do not grow the widget count toward N_GUI_KV_MAX. Use before reloading a table's contents.

Definition at line 18854 of file n_gui.c.

References _n_gui_kv_apply_layout(), N_GUI_KV_ROW::active, N_GUI_KVTABLE::ctx, n_gui_set_widget_visible(), N_GUI_KVTABLE::nb_active, N_GUI_KVTABLE::nb_rows, row(), and N_GUI_KVTABLE::rows.

Referenced by main().

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

◆ n_gui_kvtable_create()

◆ n_gui_kvtable_duplicate_row()

int n_gui_kvtable_duplicate_row ( N_GUI_KVTABLE * table,
int row_index )

insert a copy of the row at row_index directly after it.

Returns
the row index holding the copy, or -1 when the row is invalid or the table is full (N_GUI_KV_MAX)

insert a copy of the row at row_index directly after it.

A new row is appended (reusing a freed slot when there is one, which may sit anywhere in the array), then every active row's content is rewritten in the wanted order. Going through detached copies of the text keeps the rewrite correct whatever slot the new row landed in, instead of depending on the freed-slot order.

Parameters
tablethe KV table
row_indexthe row to copy
Returns
the row index holding the copy, or -1 when the row is invalid or the table is full (N_GUI_KV_MAX rows)

Definition at line 18973 of file n_gui.c.

References _n_gui_kv_active_order(), _n_gui_kv_content_free(), _n_gui_kv_content_grab(), _n_gui_kv_content_put(), _n_gui_kv_refresh_actions(), N_GUI_KV_ROW::active, N_GUI_KVTABLE::ctx, N_GUI_CTX::dirty, N_GUI_KV_MAX, n_gui_kvtable_add_row(), N_GUI_KVTABLE::nb_rows, N_GUI_KVTABLE::rows, and N_GUI_KVTABLE::show_actions.

Referenced by _n_gui_kv_dup_clicked(), and main().

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

◆ 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 19042 of file n_gui.c.

References FreeNoLog.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_kvtable_get_count()

int n_gui_kvtable_get_count ( const N_GUI_KVTABLE * table)

get the number of active rows

Definition at line 19034 of file n_gui.c.

References N_GUI_KVTABLE::nb_active.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_kvtable_move_row()

int n_gui_kvtable_move_row ( N_GUI_KVTABLE * table,
int row_index,
int direction )

move the row at row_index one position up (direction < 0) or down (direction > 0) among the ACTIVE rows, by swapping their contents.

Returns
the row index the contents landed on, or -1 when the row is invalid or already at that end

move the row at row_index one position up (direction < 0) or down (direction > 0) among the ACTIVE rows, by swapping their contents.

Row slots are stable (widgets are bound to them and freed slots are reused), so the CONTENTS are swapped with the neighbouring active row rather than the slots themselves. Everything that reads the table by walking the rows in slot order therefore sees the new order with no extra bookkeeping.

Parameters
tablethe KV table
row_indexthe row to move
directionnegative to move up, positive to move down
Returns
the row index the contents landed on, or -1 when the row is invalid, inactive, or already at that end of the table

Definition at line 18929 of file n_gui.c.

References _n_gui_kv_active_order(), _n_gui_kv_content_free(), _n_gui_kv_content_grab(), _n_gui_kv_content_put(), _n_gui_kv_refresh_actions(), N_GUI_KV_ROW::active, N_GUI_KVTABLE::ctx, N_GUI_CTX::dirty, N_GUI_KV_MAX, N_GUI_KVTABLE::nb_rows, and N_GUI_KVTABLE::rows.

Referenced by _n_gui_kv_down_clicked(), _n_gui_kv_up_clicked(), and main().

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

◆ n_gui_kvtable_relayout()

void n_gui_kvtable_relayout ( N_GUI_KVTABLE * table)

re-apply layout to all KV table widgets (positions, sizes, normalized coords).

Called automatically on create/add/remove; callers should invoke it after any manual window size change the kvtable cannot see.

Definition at line 19038 of file n_gui.c.

References _n_gui_kv_apply_layout().

Referenced by main().

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

◆ 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 18836 of file n_gui.c.

References _n_gui_kv_apply_layout(), _n_gui_kv_refresh_actions(), N_GUI_KV_ROW::active, N_GUI_KVTABLE::ctx, n_gui_set_widget_visible(), N_GUI_KVTABLE::nb_active, N_GUI_KVTABLE::nb_rows, row(), N_GUI_KVTABLE::rows, and N_GUI_KVTABLE::show_actions.

Referenced by _n_gui_kv_remove_clicked(), and main().

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

◆ n_gui_kvtable_set_columns()

void n_gui_kvtable_set_columns ( N_GUI_KVTABLE * table,
int show_value,
int show_desc,
int show_enabled )

choose which optional columns are shown: Value, Description, and the enabled checkbox.

The key column and the remove ("x") button are always shown. Defaults to all shown (a full three-column table, backward compatible). Pass 0 to hide a column for a simpler table, e.g. a single-value list (0,0,0). Hidden columns' widgets are hidden and the visible columns reflow to fill the width.

Definition at line 18875 of file n_gui.c.

References _n_gui_kv_apply_layout(), N_GUI_KVTABLE::show_desc, N_GUI_KVTABLE::show_enabled, and N_GUI_KVTABLE::show_value.

Referenced by main().

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

◆ n_gui_kvtable_set_placeholders()

void n_gui_kvtable_set_placeholders ( N_GUI_KVTABLE * table,
const char * key_hint,
const char * value_hint )

set the placeholder/hint text shown in each row's key (and value) textarea while it is empty.

Applies to existing rows and to rows added afterwards. Either argument may be NULL to clear that hint.

Definition at line 19014 of file n_gui.c.

References N_GUI_KVTABLE::ctx, FreeNoLog, N_GUI_KV_ROW::key_id, N_GUI_KVTABLE::key_placeholder, n_gui_textarea_set_placeholder(), N_GUI_KVTABLE::nb_rows, N_GUI_KVTABLE::rows, N_GUI_KV_ROW::value_id, and N_GUI_KVTABLE::value_placeholder.

Referenced by main().

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

◆ n_gui_kvtable_set_row_actions()

void n_gui_kvtable_set_row_actions ( N_GUI_KVTABLE * table,
int enabled )

show (1) or hide (0, the default) the per-row action buttons: move up, move down and duplicate, drawn as glyphs next to the remove button.

Use for tables whose row ORDER is meaningful (query parameters, headers) and where copying a row is common; leave off for unordered tables. The text columns reflow to make room, and the remove button switches to a matching cross glyph. Moving swaps a row with its neighbour; duplicating inserts the copy right after the source.

show (1) or hide (0, the default) the per-row action buttons: move up, move down and duplicate, drawn as glyphs next to the remove button.

Off by default, so existing tables are unchanged. Turn it on for tables whose row ORDER carries meaning (query parameters, request headers) or where copying a row is a common edit. The buttons exist on every row from creation and are only revealed here, so a table can gain or lose them at any time without rebuilding its rows. The text columns reflow to make room, and the remove button switches to a cross glyph so the trailing cluster reads as one set of icons.

Parameters
tablethe KV table
enabled1 to show the actions, 0 to hide them

Definition at line 18897 of file n_gui.c.

References _n_gui_kv_apply_layout(), _n_gui_kv_refresh_actions(), N_GUI_KVTABLE::btn_add, N_GUI_KVTABLE::ctx, n_gui_button_set_glyph(), N_GUI_GLYPH_CROSS, N_GUI_GLYPH_NONE, N_GUI_GLYPH_PLUS, n_gui_set_widget_tooltip(), N_GUI_KVTABLE::nb_rows, row(), N_GUI_KVTABLE::rows, and N_GUI_KVTABLE::show_actions.

Referenced by main().

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

◆ n_gui_kvtable_set_top_offset()

void n_gui_kvtable_set_top_offset ( N_GUI_KVTABLE * table,
float top_offset )

reserve top_offset unscaled pixels above the header row so other widgets (a toolbar, a heading) can share the table's window without overlapping it.

The offset scales with the window like the rest of the table. Default 0.

Definition at line 19028 of file n_gui.c.

References _n_gui_kv_apply_layout(), and N_GUI_KVTABLE::top_offset.

Referenced by main().

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

◆ n_gui_label_fits()

int n_gui_label_fits ( N_GUI_CTX * ctx,
int widget_id,
float * needed_w,
float * needed_h )

report whether a label's text is drawn in full inside its own box, and how big it would have to be to show all of it (out-params may be NULL)

report whether a label's text is drawn in full inside its own box, and how big it would have to be to show all of it (out-params may be NULL)

Parameters
ctxthe gui context
widget_idid of the label widget
needed_wreceives the width the text needs (0 when not applicable, may be NULL)
needed_hreceives the height the text needs (0 when not applicable, may be NULL)
Returns
1 when the text fits (or the widget is not a label with text), 0 when n_gui truncates it horizontally or clips it vertically as drawn

A label is drawn one of two ways, and both can silently lose text. A single-line label (N_GUI_ALIGN_LEFT, _CENTER, _RIGHT) whose text is wider than its box is drawn truncated; a wrapped one (N_GUI_ALIGN_JUSTIFIED) taller than its box is clipped and grows an inner scrollbar. Neither reports anything, so a layout that under-sizes a label just quietly shows less text. This measures the text the way the draw path does, against the widget's own rectangle, and hands back the size that would show all of it: a layout can size a label from it, and a layout audit can fail on it.

Definition at line 6215 of file n_gui.c.

References __n_assert, _label_content_height(), _label_line_at(), _label_line_count(), _label_wrap_w(), _text_w(), N_GUI_LABEL_DATA::align, N_GUI_WIDGET::data, N_GUI_CTX::default_font, font, N_GUI_WIDGET::font, h(), N_GUI_STYLE::label_padding, line(), N_GUI_ALIGN_JUSTIFIED, n_gui_get_widget(), N_GUI_TEXT_MAX, N_GUI_TYPE_LABEL, N_GUI_CTX::style, N_GUI_LABEL_DATA::text, N_GUI_WIDGET::type, and N_GUI_WIDGET::w.

Referenced by main().

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

◆ n_gui_label_get_text()

const char * n_gui_label_get_text ( N_GUI_CTX * ctx,
int widget_id )

What a label says now.

The counterpart of n_gui_label_set_text(), as n_gui_button_get_label() and n_gui_checkbox_get_label() are of theirs: for a test that checks the words a dialog was given without keeping its own copy of them.

Parameters
ctxthe GUI context
widget_ida label
Returns
The text, or NULL when the widget is not a label. Borrowed, and valid until the text is set again or the widget is destroyed.

Definition at line 6175 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_LABEL, 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_get_truncate()

int n_gui_label_get_truncate ( N_GUI_CTX * ctx,
int widget_id )

the label's truncate mode, N_GUI_TRUNCATE_END when it is not a label

the label's truncate mode, N_GUI_TRUNCATE_END when it is not a label

Parameters
ctxGUI context
widget_idid of the label widget
Returns
the mode, N_GUI_TRUNCATE_END when it is not a label

Definition at line 6169 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TRUNCATE_END, N_GUI_TYPE_LABEL, 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_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 6763 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 6260 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

Definition at line 6184 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, text(), and N_GUI_WIDGET::type.

Referenced by _n_gui_color_set_label(), main(), main(), n_gui_color_picker_open(), refresh_buttons(), and update_definitions().

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

◆ n_gui_label_set_truncate()

void n_gui_label_set_truncate ( N_GUI_CTX * ctx,
int widget_id,
int mode )

choose where a label's text is shortened when it does not fit: N_GUI_TRUNCATE_END (the default), N_GUI_TRUNCATE_START or N_GUI_TRUNCATE_PATH.

A path shown with the default loses its file name, the one part that says which file it is. Ignored for a justified label.

choose where a label's text is shortened when it does not fit: N_GUI_TRUNCATE_END (the default), N_GUI_TRUNCATE_START or N_GUI_TRUNCATE_PATH.

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

choose where a label's text is shortened when it does not fit

Parameters
ctxGUI context
widget_idid of the label widget
modeN_GUI_TRUNCATE_END, N_GUI_TRUNCATE_START or N_GUI_TRUNCATE_PATH; anything else is taken as N_GUI_TRUNCATE_END

Definition at line 6156 of file n_gui.c.

References N_GUI_WIDGET::data, mode, n_gui_get_widget(), N_GUI_TRUNCATE_END, N_GUI_TRUNCATE_PATH, N_GUI_TRUNCATE_START, N_GUI_TYPE_LABEL, 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_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 4359 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, text(), and N_GUI_WIDGET::type.

Referenced by _n_gui_tree_emit(), build_widgets_window(), chat_log_add(), main(), main(), 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 4406 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_LISTBOX_DATA::h_scroll, N_GUI_LISTBOX_DATA::h_scroll_dragging, 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 main(), n_gui_tree_clear(), 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_content_width()

float n_gui_listbox_content_width ( N_GUI_CTX * ctx,
int widget_id )

width in pixels the widest item needs to be drawn in full (text padding included), or 0 for an empty list / non-listbox widget.

When this exceeds the room left for the items, the listbox scrolls horizontally instead of truncating the text

width in pixels the widest item needs to be drawn in full (text padding included), or 0 for an empty list / non-listbox widget.

Text padding included, so it can be compared directly with the room left for the items. Past that width the listbox scrolls horizontally rather than cutting the text short with an ellipsis.

Parameters
ctxGUI context
widget_idid of the listbox widget
Returns
the content width in pixels, or 0 for an empty list, a listbox with no usable font, or a widget that is not a listbox

Definition at line 4532 of file n_gui.c.

References _text_w(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, font, N_GUI_WIDGET::font, N_GUI_STYLE::item_text_padding, N_GUI_LISTBOX_DATA::items, n_gui_get_widget(), N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_CTX::style, 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_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 4423 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_h_scroll()

float n_gui_listbox_get_h_scroll ( N_GUI_CTX * ctx,
int widget_id )

current horizontal scroll offset in pixels (0 = leftmost)

current horizontal scroll offset in pixels (0 = leftmost)

Parameters
ctxGUI context
widget_idid of the listbox widget
Returns
the offset, or 0 when the widget is not a listbox

Definition at line 4556 of file n_gui.c.

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

Referenced by main(), and n_gui_tree_state_save().

Here is the call graph for this function:
Here is the caller 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 4438 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(), and row().

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

Referenced by main(), n_gui_tree_rebuild(), and n_gui_tree_state_save().

Here is the call graph for this function:
Here is the caller 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 4455 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(), main(), and n_gui_tree_get_selection().

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 4473 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 4382 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 6700 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.

Referenced by main().

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

◆ n_gui_listbox_set_h_scroll()

void n_gui_listbox_set_h_scroll ( N_GUI_CTX * ctx,
int widget_id,
float px )

set the horizontal scroll offset in pixels; clamped to >= 0 here and to the live content width by the draw path, so a stale value after a refill is harmless

set the horizontal scroll offset in pixels; clamped to >= 0 here and to the live content width by the draw path, so a stale value after a refill is harmless

Clamped to >= 0 here; the draw path re-clamps to the live content width every frame, so a value left over from a wider list is harmless.

Parameters
ctxGUI context
widget_idid of the listbox widget
pxthe offset in pixels

Definition at line 4572 of file n_gui.c.

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

Referenced by main(), and n_gui_tree_state_apply().

Here is the call graph for this function:
Here is the caller 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 4509 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.

Referenced by main(), n_gui_tree_rebuild(), n_gui_tree_set_selection(), and n_gui_tree_state_apply().

Here is the call graph for this function:
Here is the caller 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 4491 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(), n_gui_tree_rebuild(), and n_gui_tree_set_selection().

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

◆ n_gui_load_layout_json()

int n_gui_load_layout_json ( N_GUI_CTX * ctx,
const char * filepath )

Load a JSON window layout file and apply it to matching windows in the context.

Matching is by window title (IDs are not stable across runs). If multiple windows share a title, they are matched in creation order (first-seen-first-match). Unknown titles in the file are ignored (defensive for versions). Missing titles in the context are ignored (no-op for windows not yet created). A missing file is treated as a successful no-op (returns -1 with LOG_DEBUG). Saved per-window widget state (see n_gui_save_layout_json) is stashed as pending and applied to each keyed widget when n_gui_widget_set_persist_key is next called with a matching window title + key (so lazily-created widgets restore too). Returns 0 on success, -1 on error.

Load a JSON window layout file and apply it to matching windows in the context.

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

Definition at line 17108 of file n_gui.c.

References __n_assert, _json_get_float(), _json_get_int(), _N_GUI_WIN_STATE_PERSIST_MASK, N_GUI_WINDOW::autofit_border, N_GUI_WINDOW::autofit_flags, N_GUI_PENDING_GEOM::consumed, N_GUI_WINDOW::detach_flags, N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_CTX::event_queue, N_GUI_WINDOW::flags, FreeNoLog, N_GUI_PENDING_GEOM::h, N_GUI_WINDOW::h, N_GUI_WINDOW::id, N_GUI_PENDING_WIDGET::key, N_GUI_PENDING_WIDGET::kind, list_foreach, LOG_DEBUG, Malloc, N_GUI_DETACH_NONE, N_GUI_ID_MAX, N_GUI_PERSIST_MAX_COLS, N_GUI_TYPE_DATAGRID, N_GUI_TYPE_SPLITPANE, N_GUI_WIN_OPEN, n_gui_window_detach(), n_log, N_GUI_WINDOW::native, N_GUI_WINDOW::native_h, N_GUI_WINDOW::native_pos_x, N_GUI_WINDOW::native_pos_y, N_GUI_WINDOW::native_w, N_GUI_PENDING_WIDGET::ncols, N_GUI_WINDOW::norm_h, N_GUI_WINDOW::norm_w, N_GUI_WINDOW::norm_x, N_GUI_WINDOW::norm_y, N_GUI_PENDING_WIDGET::order, N_GUI_CTX::pending_layout, N_GUI_CTX::pending_layout_count, N_GUI_CTX::pending_widgets, N_GUI_CTX::pending_widgets_count, N_GUI_PENDING_WIDGET::ratio, N_GUI_WINDOW::resize_policy, N_GUI_WINDOW::saved_flags, N_GUI_WINDOW::saved_h, N_GUI_WINDOW::saved_w, N_GUI_WINDOW::saved_x, N_GUI_WINDOW::saved_y, N_GUI_PENDING_GEOM::state, N_GUI_WINDOW::state, N_GUI_PENDING_GEOM::title, N_GUI_PENDING_WIDGET::title, N_GUI_WINDOW::title, N_GUI_PENDING_WIDGET::visible, N_GUI_PENDING_GEOM::w, N_GUI_WINDOW::w, N_GUI_WINDOW::want_native, N_GUI_PENDING_WIDGET::width, N_GUI_CTX::windows, N_GUI_PENDING_GEOM::x, N_GUI_WINDOW::x, N_GUI_PENDING_GEOM::y, N_GUI_WINDOW::y, N_GUI_WINDOW::z_order, and N_GUI_WINDOW::z_value.

Referenced by main(), on_load_layout(), and on_load_layout_click().

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 16796 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::shape_mode, 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_STYLE::tb_btn_glyph_thickness, N_GUI_STYLE::tb_btn_right_margin, N_GUI_STYLE::tb_btn_size, N_GUI_STYLE::tb_btn_spacing, 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 2076 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 825 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, text(), N_GUI_THEME::text_active, N_GUI_THEME::text_hover, and N_GUI_THEME::text_normal.

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

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

◆ n_gui_mark_dirty()

void n_gui_mark_dirty ( N_GUI_CTX * ctx)

Mark the GUI as needing a redraw.

Call after changing widget or window state from outside n_gui_process_event (for example a host timer that updates a label or progress bar); state changed inside an event callback is already covered because the event itself marks the GUI dirty. Cheap and idempotent.

Definition at line 1188 of file n_gui.c.

References N_GUI_CTX::dirty.

Referenced by _curve_mouse(), _grid_mouse(), _grid_on_bar(), _grid_place(), _n_gui_color_on_slider(), _popup_mouse(), _popup_show_level(), _wheel_mouse(), main(), n_gui_color_picker_close(), n_gui_color_picker_open(), n_gui_colorwheel_set(), n_gui_colorwheel_set_colour(), n_gui_curve_set_background(), n_gui_curve_set_eval(), n_gui_curve_set_point_radius(), n_gui_curve_set_points(), n_gui_dropmenu_set_open(), n_gui_grid_scroll_to(), n_gui_grid_set_scroll(), n_gui_grid_set_visible(), n_gui_markdownview_scroll_to(), n_gui_markdownview_set_fonts(), n_gui_markdownview_set_text(), n_gui_markdownview_style(), and n_gui_popup_close().

Here is the caller graph for this function:

◆ n_gui_markdownview_content_height()

float n_gui_markdownview_content_height ( N_GUI_CTX * ctx,
int widget_id )

the height of the whole document at the width it was last drawn at, or 0 before the first draw

Definition at line 5908 of file n_gui.c.

References _markdownview_of(), and N_GUI_MARKDOWNVIEW_DATA::content_h.

Referenced by main().

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

◆ n_gui_markdownview_get_scroll()

float n_gui_markdownview_get_scroll ( N_GUI_CTX * ctx,
int widget_id )

how far down the content the view is, in pixels

Definition at line 5903 of file n_gui.c.

References _markdownview_of(), and N_GUI_MARKDOWNVIEW_DATA::scroll_y.

Referenced by main().

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

◆ n_gui_markdownview_get_text()

const char * n_gui_markdownview_get_text ( N_GUI_CTX * ctx,
int widget_id )

the Markdown source, owned by the widget, or NULL

Definition at line 5867 of file n_gui.c.

References _markdownview_of(), and N_GUI_MARKDOWNVIEW_DATA::text.

Referenced by main().

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

◆ n_gui_markdownview_scroll_to()

void n_gui_markdownview_scroll_to ( N_GUI_CTX * ctx,
int widget_id,
float y )

scroll to y pixels down the content, clamped to what there is

Definition at line 5893 of file n_gui.c.

References _markdownview_of(), n_gui_mark_dirty(), and N_GUI_MARKDOWNVIEW_DATA::scroll_y.

Referenced by main().

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

◆ n_gui_markdownview_set_fonts()

void n_gui_markdownview_set_fonts ( N_GUI_CTX * ctx,
int widget_id,
const N_GUI_MD_FONTS * fonts )

replace the faces; the new ones are borrowed on the same terms

Definition at line 5872 of file n_gui.c.

References _markdownview_of(), N_GUI_MARKDOWNVIEW_DATA::dirty, N_GUI_MARKDOWNVIEW_DATA::fonts, and n_gui_mark_dirty().

Here is the call graph for this function:

◆ n_gui_markdownview_set_on_link()

void n_gui_markdownview_set_on_link ( N_GUI_CTX * ctx,
int widget_id,
void(* on_link )(int widget_id, const char *url, void *user_data),
void * user_data )

call on_link when a link in the view is clicked (NULL to stop).

The url it is handed is valid for the duration of the call and no longer.

Definition at line 5913 of file n_gui.c.

References _markdownview_of(), N_GUI_MARKDOWNVIEW_DATA::on_link, and N_GUI_MARKDOWNVIEW_DATA::user_data.

Here is the call graph for this function:

◆ n_gui_markdownview_set_text()

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

set the Markdown source (copied; NULL clears it).

Resets the scroll.

Definition at line 5852 of file n_gui.c.

References _markdownview_of(), N_GUI_MARKDOWNVIEW_DATA::dirty, FreeNoLog, n_gui_mark_dirty(), N_GUI_MARKDOWNVIEW_DATA::scroll_y, N_GUI_MARKDOWNVIEW_DATA::text, and text().

Referenced by main().

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

◆ n_gui_markdownview_style()

N_GUI_MD_STYLE * n_gui_markdownview_style ( N_GUI_CTX * ctx,
int widget_id )

the view's style, to read or to change in place, or NULL if there is no such widget.

Asking for it stops the style following the widget's theme, because there is no way to tell afterwards which of the two set a colour.

Definition at line 5881 of file n_gui.c.

References _markdownview_of(), N_GUI_MARKDOWNVIEW_DATA::dirty, n_gui_mark_dirty(), N_GUI_MARKDOWNVIEW_DATA::style, and N_GUI_MARKDOWNVIEW_DATA::theme_derived.

Referenced by main().

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

◆ n_gui_maximize_window()

void n_gui_maximize_window ( N_GUI_CTX * ctx,
int window_id )

toggle maximised state (full display or restore to previous size)

toggle maximised state (full display or restore to previous size)

When maximising: saves current position/size, expands to fill the display (or virtual canvas if enabled), and clears minimised state. When restoring: returns to the saved position/size.

Definition at line 1497 of file n_gui.c.

References __n_assert, _n_gui_window_capture_normalized(), _native_apply_minimised(), _native_monitor_info(), _native_own_chrome(), N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_WINDOW::h, LOG_DEBUG, n_gui_get_window(), N_GUI_RESIZE_ADAPTIVE, N_GUI_WIN_MAXIMISED, N_GUI_WIN_MINIMISED, n_log, N_GUI_WINDOW::native, N_GUI_CTX::resize_mode, N_GUI_TB_BUTTONS::restore_h, N_GUI_TB_BUTTONS::restore_w, N_GUI_TB_BUTTONS::restore_x, N_GUI_TB_BUTTONS::restore_y, N_GUI_WINDOW::state, N_GUI_WINDOW::tb_buttons, N_GUI_CTX::virtual_h, N_GUI_CTX::virtual_w, N_GUI_WINDOW::w, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.

Referenced by _tb_button_action(), and main().

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

◆ n_gui_menu_is_open()

int n_gui_menu_is_open ( const N_GUI_CTX * ctx)

Is a combo box's list or a drop menu's panel currently open.

Either one is drawn over whatever it happens to cover, and the press that chooses an item lands there rather than on the widget that opened it. An application that routes presses by position of its own - a canvas, a viewport, anything that claims the mouse inside its own rectangle - has to ask this first and let the toolkit have the press, or the thing underneath takes it and the list can neither be chosen from nor closed.

Parameters
ctxthe GUI context
Returns
1 when one is open, 0 otherwise.

Definition at line 2326 of file n_gui.c.

References __n_assert, N_GUI_CTX::open_combobox_id, and N_GUI_CTX::open_dropmenu_id.

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 1454 of file n_gui.c.

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

Referenced by _tb_button_action(), and main().

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

◆ n_gui_needs_redraw()

int n_gui_needs_redraw ( N_GUI_CTX * ctx)

Return non-zero if the GUI must be redrawn this frame, i.e.

something changed since the last n_gui_draw OR a time-based animation is in progress (focused text-area cursor blink, tooltip reveal, button key-press flash). Lets an event-driven host skip n_gui_draw + al_flip_display while the GUI is idle and unchanged: while (running) { while (al_get_next_event(q, &ev)) n_gui_process_event(ctx, &ev); if (n_gui_needs_redraw(ctx)) { clear; n_gui_draw(ctx); flip; } } Hosts that redraw every frame regardless (a GUI composited over a live game scene) can ignore this. Optional and additive: the dirty bit is maintained whether or not it is queried, so calling n_gui_draw unconditionally is unchanged. Detached native windows still need n_gui_draw_detached each frame.

Definition at line 1192 of file n_gui.c.

References N_GUI_CTX::anim_until, N_GUI_CTX::dirty, N_GUI_CTX::focused_widget_id, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, 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_new_ctx()

N_GUI_CTX * n_gui_new_ctx ( ALLEGRO_FONT * default_font)

create a new GUI context

create a new GUI context

Parameters
default_fontthe default ALLEGRO_FONT to use
Returns
a new N_GUI_CTX or NULL on error

Definition at line 1103 of file n_gui.c.

References __n_assert, N_GUI_CTX::active_display, N_GUI_CTX::anim_until, N_GUI_CTX::click_time, N_GUI_CTX::click_widget_id, N_GUI_CTX::click_x, N_GUI_CTX::click_y, N_GUI_CTX::cursor_custom, N_GUI_CTX::cursor_shape, N_GUI_CTX::cursor_want_custom, N_GUI_CTX::cursor_want_shape, N_GUI_CTX::default_font, N_GUI_CTX::default_tb_btn_theme, N_GUI_CTX::default_tb_close_theme, N_GUI_CTX::default_theme, N_GUI_CTX::dirty, N_GUI_CTX::display, N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_CTX::double_click_radius, N_GUI_CTX::double_click_time, N_GUI_CTX::double_clicked_widget_id, N_GUI_CTX::dpi_scale, N_GUI_CTX::event_queue, N_GUI_CTX::focused_widget_id, Free, N_GUI_CTX::global_hscroll_drag, N_GUI_CTX::global_scroll_x, N_GUI_CTX::global_scroll_y, N_GUI_CTX::global_vscroll_drag, 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, list_destroy(), LOG_ERR, Malloc, N_GUI_CTX::mouse_b1, N_GUI_CTX::mouse_b1_prev, N_GUI_CTX::mouse_x, N_GUI_CTX::mouse_y, n_gui_default_style(), n_gui_default_tb_btn_theme(), n_gui_default_tb_close_theme(), n_gui_default_theme(), N_GUI_RESIZE_VIRTUAL, n_log, new_generic_list(), new_ht(), N_GUI_CTX::next_widget_id, N_GUI_CTX::next_window_id, N_GUI_CTX::open_combobox_id, N_GUI_CTX::open_dropmenu_id, N_GUI_CTX::open_suggest_id, N_GUI_CTX::pass_display, N_GUI_CTX::pending_layout, N_GUI_CTX::pending_layout_count, N_GUI_CTX::pending_widgets, N_GUI_CTX::pending_widgets_count, N_GUI_CTX::prev_over_win, N_GUI_CTX::ref_display_h, N_GUI_CTX::ref_display_w, N_GUI_CTX::resize_mode, N_GUI_CTX::scrollbar_drag_widget_id, N_GUI_CTX::selected_label_id, N_GUI_CTX::selected_syntaxview_id, N_GUI_CTX::style, N_GUI_CTX::tooltip_anchor_x, N_GUI_CTX::tooltip_anchor_y, N_GUI_CTX::tooltip_armed_at, N_GUI_CTX::tooltip_widget_id, UNLIMITED_LIST_ITEMS, N_GUI_CTX::virtual_h, N_GUI_CTX::virtual_w, N_GUI_CTX::widgets_by_id, and N_GUI_CTX::windows.

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

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

◆ 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 1436 of file n_gui.c.

References N_GUI_WINDOW::detach_flags, N_GUI_CTX::event_queue, n_gui_get_window(), N_GUI_WIN_OPEN, n_gui_window_detach(), N_GUI_WINDOW::native, N_GUI_WINDOW::native_close_pending, N_GUI_WINDOW::state, and N_GUI_WINDOW::want_native.

Referenced by _popup_show_level(), main(), main(), main(), n_gui_color_picker_open(), n_gui_tab_set_active(), on_ghost_toggle(), on_open_popup(), and on_show_all().

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 13611 of file n_gui.c.

References __n_assert, _apply_cursor(), _button_key_press(), _button_neighbour(), _button_takes_key(), _clamp(), _clear_syntaxview_selection(), _combobox_dropdown_width(), _compute_gui_bounds(), _ctx_io_display(), _custom_mouse(), _datagrid_ensure_sel(), _datagrid_header_hit(), _datagrid_hmetrics(), _datagrid_resize_hover(), _dropdown_panel_y(), _event_display(), _find_focused_window(), _find_widget_window(), _global_scroll_needs(), _hexview_handle_key(), _is_focusable_type(), _is_tab_focusable_type(), _justified_char_at_pos(), _label_char_at_x(), _label_content_height(), _label_effective_w(), _label_lines_char_at(), _label_text_origin_x(), _label_wrap_w(), _list_panel_highlight_step(), _list_panel_wheel(), _listbox_clamp_h(), _listbox_hmetrics(), _markdownview_text_w(), _n_gui_window_capture_normalized(), _native_drag_begin(), _native_own_chrome(), _ngui_clip_get(), _ngui_clip_set(), _ngui_publish_primary_selection(), _point_in_rect(), _pointer_over_window(), _sb_track_hit(), _scrollbar_calc_scroll(), _scrollbar_calc_scroll_int(), _scrollbar_update_from_mouse(), _scrollbar_wheel(), _slider_key_step(), _slider_snap_value(), _slider_update_from_mouse(), _splitpane_cursor_hover(), _splitpane_on_divider(), _suggest_accept(), _suggest_close(), _suggest_handle_key(), _suggest_panel_rect(), _suggest_refresh(), _syntaxview_clamp_h(), _syntaxview_hmetrics(), _syntaxview_offset_from_mouse(), _tb_button_action(), _tb_button_rect(), _textarea_content_height(), _textarea_handle_key(), _textarea_paste_clip(), _textarea_pos_from_mouse(), _tooltip_widget_at(), _track_modifiers(), _widget_took_press(), _win_auto_sb_rects(), _win_on_pass(), _win_tbh(), _window_update_content_size(), N_GUI_CTX::active_display, N_GUI_LABEL_DATA::align, N_GUI_DATAGRID_DATA::anchor_row, N_GUI_CTX::anim_until, N_GUI_HEXVIEW_DATA::bytes_per_row, N_GUI_SYNTAXVIEW_DATA::cached_nb_lines, N_GUI_CHECKBOX_DATA::checked, N_GUI_CTX::click_time, N_GUI_CTX::click_widget_id, N_GUI_CTX::click_x, N_GUI_CTX::click_y, N_GUI_DATAGRID_DATA::col_resize_col, N_GUI_DATAGRID_DATA::col_resize_w0, N_GUI_DATAGRID_DATA::col_resize_x0, N_GUI_DATAGRID_DATA::cols, N_GUI_MARKDOWNVIEW_DATA::content_h, N_GUI_WINDOW::content_h, N_GUI_SCROLLBAR_DATA::content_size, N_GUI_WINDOW::content_w, N_GUI_HEXVIEW_DATA::cursor, N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_TEXTAREA_DATA::cursor_time, N_GUI_CTX::cursor_want_custom, N_GUI_CTX::cursor_want_shape, N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_SLIDER_DATA::default_value, N_GUI_WINDOW::detach_flags, N_GUI_CTX::dirty, N_GUI_CTX::display, N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_CTX::double_click_radius, N_GUI_CTX::double_click_time, N_GUI_CTX::double_clicked_widget_id, N_GUI_WINDOW::drag_ox, N_GUI_WINDOW::drag_oy, N_GUI_HEXVIEW_DATA::editable, N_GUI_WIDGET::enabled, LIST::end, N_GUI_DROPMENU_DATA::entries, N_GUI_COMBOBOX_DATA::flags, N_GUI_DROPMENU_DATA::flags, N_GUI_WINDOW::flags, N_GUI_CTX::focused_widget_id, N_GUI_WIDGET::font, N_GUI_MARKDOWNVIEW_DATA::fonts, Free, 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_DATAGRID_DATA::h_scroll, N_GUI_LISTBOX_DATA::h_scroll, N_GUI_SYNTAXVIEW_DATA::h_scroll, N_GUI_DATAGRID_DATA::h_scroll_dragging, N_GUI_LISTBOX_DATA::h_scroll_dragging, N_GUI_SYNTAXVIEW_DATA::h_scroll_dragging, N_GUI_COMBOBOX_DATA::highlight_index, N_GUI_DROPMENU_DATA::highlight_index, N_GUI_LISTBOX_DATA::hover_row, N_GUI_SB_TRACK::hovered, N_GUI_TB_BUTTONS::hovered, N_GUI_WIDGET::id, N_GUI_WINDOW::id, N_GUI_COMBOBOX_DATA::is_open, N_GUI_DROPMENU_DATA::is_open, N_GUI_COMBOBOX_DATA::item_height, N_GUI_DROPMENU_DATA::item_height, N_GUI_LISTBOX_DATA::item_height, N_GUI_RADIOLIST_DATA::item_height, N_GUI_STYLE::item_height_pad, N_GUI_STYLE::item_text_padding, N_GUI_LISTBOX_DATA::items, N_GUI_BUTTON_DATA::key_focus_only, N_GUI_BUTTON_DATA::key_modifiers, N_GUI_BUTTON_DATA::key_press_until, N_GUI_BUTTON_DATA::key_sources, N_GUI_BUTTON_DATA::keycode, N_GUI_STYLE::label_padding, last, N_GUI_HEXVIEW_DATA::len, line(), N_GUI_LABEL_DATA::link, list_foreach, N_GUI_SPLITPANE_DATA::max_ratio, 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_SPLITPANE_DATA::min_ratio, 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_DATAGRID_DATA::multiselect, N_CLIPBOARD_CLIPBOARD, N_CLIPBOARD_PRIMARY, N_GUI_ALIGN_JUSTIFIED, N_GUI_ANIM_TAIL_SEC, N_GUI_COMBOBOX_EXPAND_UP, n_gui_datagrid_sort(), N_GUI_DETACH_SCALE_CONTENT, N_GUI_DROPMENU_EXPAND_UP, n_gui_dropmenu_panel_width(), n_gui_get_widget(), n_gui_get_window(), n_gui_hovered_widget(), N_GUI_ID_MAX, N_GUI_KEY_MOD_MASK, N_GUI_KEY_PRESS_FLASH_SEC, N_GUI_KEY_SOURCES_MAX, n_gui_md_link_at(), N_GUI_MOUSE_DOWN, N_GUI_MOUSE_DRAG, N_GUI_MOUSE_MOVE, N_GUI_MOUSE_UP, N_GUI_MOUSE_WHEEL, 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_slider_set_value(), N_GUI_SPLIT_VERTICAL, N_GUI_STATE_ACTIVE, N_GUI_STATE_FOCUSED, N_GUI_STATE_HOVER, N_GUI_STATE_SCROLLBAR_DRAG, N_GUI_SUGGEST_VISIBLE, n_gui_syntaxview_get_selected_text(), n_gui_syntaxview_select_all(), N_GUI_TB_BTN_CLOSE, N_GUI_TB_BTN_MAXIMIZE, N_GUI_TB_BTN_MINIMIZE, N_GUI_TB_BTN_NONE, N_GUI_TEXT_MAX, n_gui_textarea_suggest_is_open(), N_GUI_TYPE_BUTTON, N_GUI_TYPE_CHECKBOX, N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_CUSTOM, N_GUI_TYPE_DATAGRID, N_GUI_TYPE_DROPMENU, N_GUI_TYPE_HEXVIEW, N_GUI_TYPE_LABEL, N_GUI_TYPE_LISTBOX, N_GUI_TYPE_MARKDOWNVIEW, N_GUI_TYPE_RADIOLIST, N_GUI_TYPE_SCROLLBAR, N_GUI_TYPE_SLIDER, N_GUI_TYPE_SPLITPANE, N_GUI_TYPE_SYNTAXVIEW, 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_HSCROLL_HOVER, N_GUI_WIN_MAXIMISED, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WIN_RESIZABLE, N_GUI_WIN_RESIZING, N_GUI_WIN_VSCROLL_DRAG, N_GUI_WIN_VSCROLL_HOVER, N_GUI_WINDOW::native, N_GUI_WINDOW::native_close_pending, N_GUI_WINDOW::native_drag_anchored, N_GUI_WINDOW::native_drag_cx, N_GUI_WINDOW::native_drag_cy, N_GUI_WINDOW::native_drag_wx, N_GUI_WINDOW::native_drag_wy, N_GUI_WINDOW::native_h, N_GUI_WINDOW::native_halted, N_GUI_WINDOW::native_pos_x, N_GUI_WINDOW::native_pos_y, N_GUI_WINDOW::native_w, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DROPMENU_DATA::nb_entries, LIST::nb_items, N_GUI_COMBOBOX_DATA::nb_items, N_GUI_LISTBOX_DATA::nb_items, N_GUI_RADIOLIST_DATA::nb_items, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_HEXVIEW_DATA::nibble, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_SLIDER_DATA::on_change, N_GUI_SPLITPANE_DATA::on_change, N_GUI_BUTTON_DATA::on_click, N_GUI_DROPMENU_ENTRY::on_click, N_GUI_TB_BUTTONS::on_close, N_GUI_TB_BUTTONS::on_close_user_data, N_GUI_DATAGRID_DATA::on_columns_changed, N_GUI_DATAGRID_DATA::on_context, N_GUI_MARKDOWNVIEW_DATA::on_link, 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_COMBOBOX_DATA::on_select, N_GUI_DATAGRID_DATA::on_select, N_GUI_LISTBOX_DATA::on_select, N_GUI_RADIOLIST_DATA::on_select, N_GUI_CHECKBOX_DATA::on_toggle, N_GUI_CTX::open_combobox_id, N_GUI_CTX::open_dropmenu_id, N_GUI_CTX::open_suggest_id, N_GUI_SCROLLBAR_DATA::orientation, N_GUI_SLIDER_DATA::orientation, N_GUI_SPLITPANE_DATA::orientation, N_GUI_CTX::pass_display, N_GUI_TB_BUTTONS::pressed, LIST_NODE::prev, N_GUI_CTX::prev_over_win, LIST_NODE::ptr, N_GUI_SPLITPANE_DATA::ratio, N_GUI_MD_FONTS::regular, N_GUI_CTX::resize_mode, row(), N_GUI_DATAGRID_DATA::row_sel, N_GUI_DATAGRID_DATA::rows_cap, N_GUI_WIDGET::sb_h, N_GUI_WIDGET::sb_v, N_GUI_TEXTAREA_DATA::scroll_from_wheel, N_GUI_COMBOBOX_DATA::scroll_offset, N_GUI_DATAGRID_DATA::scroll_offset, N_GUI_DROPMENU_DATA::scroll_offset, N_GUI_HEXVIEW_DATA::scroll_offset, N_GUI_LISTBOX_DATA::scroll_offset, N_GUI_RADIOLIST_DATA::scroll_offset, N_GUI_SYNTAXVIEW_DATA::scroll_offset, N_GUI_SCROLLBAR_DATA::scroll_pos, N_GUI_STYLE::scroll_step, N_GUI_WINDOW::scroll_x, N_GUI_LABEL_DATA::scroll_y, N_GUI_MARKDOWNVIEW_DATA::scroll_y, N_GUI_TEXTAREA_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_SYNTAXVIEW_DATA::sel_dragging, N_GUI_LABEL_DATA::sel_end, N_GUI_SYNTAXVIEW_DATA::sel_end, N_GUI_TEXTAREA_DATA::sel_end, N_GUI_LABEL_DATA::sel_start, N_GUI_SYNTAXVIEW_DATA::sel_start, N_GUI_TEXTAREA_DATA::sel_start, N_GUI_LISTITEM::selected, N_GUI_COMBOBOX_DATA::selected_index, N_GUI_RADIOLIST_DATA::selected_index, N_GUI_CTX::selected_label_id, N_GUI_DATAGRID_DATA::selected_row, N_GUI_CTX::selected_syntaxview_id, N_GUI_LISTBOX_DATA::selection_mode, N_GUI_DATAGRID_DATA::sort_col, N_GUI_DATAGRID_DATA::sort_dir, N_GUI_WIDGET::state, N_GUI_WINDOW::state, N_GUI_SLIDER_DATA::step, N_GUI_CTX::style, N_GUI_MARKDOWNVIEW_DATA::style, N_GUI_TEXTAREA_DATA::suggest_count, N_GUI_TEXTAREA_DATA::suggest_highlight, N_GUI_TEXTAREA_DATA::suggest_scroll, N_GUI_DROPMENU_ENTRY::tag, N_GUI_WINDOW::tb_buttons, N_GUI_LABEL_DATA::text, N_GUI_MARKDOWNVIEW_DATA::text, N_GUI_SYNTAXVIEW_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_CTX::tooltip_anchor_x, N_GUI_CTX::tooltip_anchor_y, N_GUI_CTX::tooltip_armed_at, N_GUI_STYLE::tooltip_delay, N_GUI_CTX::tooltip_widget_id, N_GUI_WIDGET::type, N_GUI_BUTTON_DATA::user_data, N_GUI_CHECKBOX_DATA::user_data, N_GUI_COMBOBOX_DATA::user_data, N_GUI_DATAGRID_DATA::user_data, N_GUI_DROPMENU_ENTRY::user_data, N_GUI_LABEL_DATA::user_data, N_GUI_LISTBOX_DATA::user_data, N_GUI_MARKDOWNVIEW_DATA::user_data, N_GUI_RADIOLIST_DATA::user_data, N_GUI_SCROLLBAR_DATA::user_data, N_GUI_SLIDER_DATA::user_data, N_GUI_SPLITPANE_DATA::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, visible(), N_GUI_WIDGET::w, N_GUI_WINDOW::w, N_GUI_WINDOW::wheel_scrollbar, N_GUI_WINDOW::widgets, N_GUI_DATAGRID_COL::width, N_GUI_CTX::windows, N_GUI_WIDGET::x, N_GUI_WINDOW::x, N_GUI_WIDGET::y, and N_GUI_WINDOW::y.

Referenced by click_and_report(), click_at(), click_at(), click_at(), click_middle(), click_on(), ctrl_key(), ctrl_key(), drag_right(), feed(), feed(), feed(), feed(), feed(), feed(), feed_key(), hover_tooltip_at(), key(), main(), main(), main(), mouse(), mouse_button(), mouse_button(), move_to(), move_to(), press_at(), press_at(), send_key(), type(), wheel(), and wheel_then_click().

Here is the caller graph for this function:

◆ n_gui_progressbar_get_value()

float n_gui_progressbar_get_value ( N_GUI_CTX * ctx,
int widget_id )

get the current progress fraction (0.0 on an invalid widget)

Definition at line 5673 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_PROGRESSBAR, 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_progressbar_set_text()

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

set the centered overlay text (NULL or "" clears it)

Definition at line 5680 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TEXT_MAX, N_GUI_TYPE_PROGRESSBAR, N_GUI_PROGRESSBAR_DATA::text, 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_progressbar_set_value()

void n_gui_progressbar_set_value ( N_GUI_CTX * ctx,
int widget_id,
float value )

set the progress fraction (clamped to 0.0 .

. 1.0)

Definition at line 5662 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_PROGRESSBAR, 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_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 5930 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, text(), and N_GUI_WIDGET::type.

Referenced by build_widgets_window(), and 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 5951 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 5967 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 6716 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.

Referenced by main().

Here is the call graph for this function:
Here is the caller 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 5981 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, FIXED and ALWAYS_ON_TOP windows are not moved. NORMAL and POPUP windows are raised WITHIN their own z-group (the stable re-sort keeps group boundaries). After raising, the window list is re-sorted.

Definition at line 2058 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, N_GUI_ZORDER_POPUP, LIST_NODE::ptr, remove_list_node_f(), N_GUI_CTX::windows, and N_GUI_WINDOW::z_order.

Referenced by _popup_show_level(), main(), n_gui_color_picker_open(), n_gui_focus_window(), n_gui_process_event(), n_gui_set_focus(), and on_open_popup().

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

◆ n_gui_reset_all_widget_themes()

void n_gui_reset_all_widget_themes ( N_GUI_CTX * ctx)

reset all widget and window themes to ctx->default_theme

reset all widget and window themes to ctx->default_theme

Iterates every window and every widget, setting their theme to the context default. Call this after changing ctx->default_theme so that all existing widgets pick up the new palette. Widgets that need a custom theme (accent buttons, status labels, etc.) must be re-themed individually after this call.

Definition at line 3809 of file n_gui.c.

References N_GUI_TB_BUTTONS::btn_theme, N_GUI_TB_BUTTONS::close_theme, N_GUI_CTX::default_tb_btn_theme, N_GUI_CTX::default_tb_close_theme, N_GUI_CTX::default_theme, list_foreach, N_GUI_WINDOW::tb_buttons, N_GUI_WIDGET::theme, N_GUI_WINDOW::theme, N_GUI_WINDOW::widgets, and N_GUI_CTX::windows.

◆ n_gui_restore_window()

void n_gui_restore_window ( N_GUI_CTX * ctx,
int window_id )

restore a minimised window to its full size

restore a minimised window to its full size

Unlike n_gui_minimize_window, which toggles, this always clears the minimised state, so a caller that is about to show a window (an "open this dialog" action) can guarantee the content is visible without knowing the current state. A window that is not minimised is left untouched, and the maximised state is not affected.

Parameters
ctxthe gui context
window_idthe id of the window to restore

Definition at line 1472 of file n_gui.c.

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

Referenced by main().

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

◆ n_gui_save_layout_json()

int n_gui_save_layout_json ( N_GUI_CTX * ctx,
const char * filepath )

Save the geometry + persistent state of every window in the context to a JSON file.

Persists per-window: title, x, y, w, h, state (persistent bits only), z_order, z_value, flags, norm_x/y/w/h, autofit_flags, autofit_border, resize_policy. Widget content and callbacks are NOT saved, they are domain data owned by the calling program, EXCEPT the user-adjustable state of widgets that were given a persist key (n_gui_widget_set_persist_key): each such widget's splitpane divider ratio, or datagrid column order/visibility/width, is saved under a per-window "widgets" array so the layout survives a restart. Returns 0 on success, -1 on error.

Save the geometry + persistent state of every window in the context to a JSON file.

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

Definition at line 16950 of file n_gui.c.

References __n_assert, _gui_fopen_write(), _N_GUI_WIN_STATE_PERSIST_MASK, N_GUI_WINDOW::autofit_border, N_GUI_WINDOW::autofit_flags, N_GUI_WIDGET::data, N_GUI_WINDOW::detach_flags, N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_WINDOW::flags, N_GUI_WINDOW::h, N_GUI_WIDGET::id, list_foreach, n_gui_datagrid_display_to_physical(), n_gui_datagrid_get_column_count(), n_gui_datagrid_get_column_visible(), n_gui_datagrid_get_column_width(), N_GUI_PERSIST_MAX_COLS, N_GUI_TYPE_DATAGRID, N_GUI_TYPE_SPLITPANE, N_GUI_WINDOW::native, N_GUI_WINDOW::native_h, N_GUI_WINDOW::native_pos_x, N_GUI_WINDOW::native_pos_y, N_GUI_WINDOW::native_w, N_GUI_WINDOW::norm_h, N_GUI_WINDOW::norm_w, N_GUI_WINDOW::norm_x, N_GUI_WINDOW::norm_y, N_GUI_WIDGET::persist_key, N_GUI_WINDOW::resize_policy, N_GUI_WINDOW::saved_flags, N_GUI_WINDOW::saved_h, N_GUI_WINDOW::saved_w, N_GUI_WINDOW::saved_x, N_GUI_WINDOW::saved_y, N_GUI_WINDOW::state, N_GUI_WINDOW::title, N_GUI_WIDGET::type, N_GUI_WINDOW::w, N_GUI_WINDOW::want_native, N_GUI_WINDOW::widgets, N_GUI_CTX::windows, N_GUI_WINDOW::x, N_GUI_WINDOW::y, N_GUI_WINDOW::z_order, and N_GUI_WINDOW::z_value.

Referenced by main(), on_save_layout(), and on_save_layout_click().

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 16667 of file n_gui.c.

References __n_assert, _gui_fopen_write(), _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::shape_mode, 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_STYLE::tb_btn_glyph_thickness, N_GUI_STYLE::tb_btn_right_margin, N_GUI_STYLE::tb_btn_size, N_GUI_STYLE::tb_btn_spacing, 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 12072 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 4293 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SCROLLBAR, 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_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 6624 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 4307 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.

Referenced by _grid_sync_bar().

Here is the call graph for this function:
Here is the caller 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 4338 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.

Referenced by _grid_sync_bar().

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

◆ n_gui_scrollbar_set_wheel_step()

void n_gui_scrollbar_set_wheel_step ( N_GUI_CTX * ctx,
int widget_id,
double step )

set how far one wheel notch moves a scrollbar, in its content units: 1 for a list whose content is counted in rows moves it a row a notch.

0 or less puts back the default, a twentieth of the range, which on a short list takes several notches to move one row.

set how far one wheel notch moves a scrollbar, in its content units: 1 for a list whose content is counted in rows moves it a row a notch.

Parameters
ctxGUI context
widget_idid of the scrollbar widget
stepcontent units per notch; 0 or less for a twentieth of the range

Definition at line 4323 of file n_gui.c.

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

Referenced by main().

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

◆ n_gui_sectionlist_add_section()

int n_gui_sectionlist_add_section ( N_GUI_SECTIONLIST * sl,
const char * title,
float header_y,
int folded )

add a section with a header button at header_y (members added next are captured relative to it); returns the section index or -1

Definition at line 19100 of file n_gui.c.

References _n_gui_sectionlist_header_clicked(), N_GUI_SECTIONLIST::ctx, N_GUI_SECTION::folded, N_GUI_SECTIONLIST::header_h, N_GUI_SECTION::header_id, n_gui_add_button(), N_GUI_SECTIONLIST_MAX, N_GUI_SHAPE_ROUNDED, N_GUI_SECTION::natural_h, N_GUI_SECTIONLIST::nb_sections, N_GUI_SECTION::nb_widgets, N_GUI_SECTIONLIST::order, N_GUI_SECTIONLIST::section_hidden, N_GUI_SECTIONLIST::sections, N_GUI_SECTION::title, N_GUI_SECTIONLIST::width, N_GUI_SECTIONLIST::window_id, and N_GUI_SECTIONLIST::x.

Referenced by main().

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

◆ n_gui_sectionlist_add_widget()

int n_gui_sectionlist_add_widget ( N_GUI_SECTIONLIST * sl,
int section_index,
int widget_id )

register an existing widget as a member of a section (captures its current y as the fold offset).

Returns 0, or -1 when the section is full (N_GUI_SECTION_WIDGETS_MAX, logged) or an argument is not usable; a member refused is left where it was created and nothing lays it out

Definition at line 19120 of file n_gui.c.

References N_GUI_SECTIONLIST::ctx, N_GUI_SECTIONLIST::gap, N_GUI_WIDGET::h, N_GUI_SECTIONLIST::header_h, N_GUI_SECTION::header_id, LOG_ERR, n_gui_get_widget(), N_GUI_SECTION_WIDGETS_MAX, n_log, N_GUI_SECTION::natural_h, N_GUI_SECTIONLIST::nb_sections, N_GUI_SECTION::nb_widgets, N_GUI_SECTIONLIST::sections, N_GUI_SECTION::title, N_GUI_SECTION::widget_dy, N_GUI_SECTION::widget_ids, 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_sectionlist_content_height()

float n_gui_sectionlist_content_height ( const N_GUI_SECTIONLIST * sl)

total content height in pixels under the current fold state, for sizing/scrolling the host window

Definition at line 19289 of file n_gui.c.

References N_GUI_SECTION::folded, N_GUI_SECTIONLIST::gap, N_GUI_SECTIONLIST::header_h, N_GUI_SECTION::natural_h, N_GUI_SECTIONLIST::nb_sections, N_GUI_SECTIONLIST::section_hidden, N_GUI_SECTIONLIST::sections, and N_GUI_SECTIONLIST::y0.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_sectionlist_create()

N_GUI_SECTIONLIST * n_gui_sectionlist_create ( N_GUI_CTX * ctx,
int window_id,
float x,
float y0,
float width,
float header_h,
float gap,
void(* on_toggle )(int, int, void *),
void * user_data )

create an empty section list anchored at (x,y0) in window_id; sections stack downward from y0

Definition at line 19081 of file n_gui.c.

References N_GUI_SECTIONLIST::ctx, N_GUI_SECTIONLIST::gap, N_GUI_SECTIONLIST::header_h, Malloc, N_GUI_SECTIONLIST::nb_sections, N_GUI_SECTIONLIST::on_toggle, on_toggle(), N_GUI_SECTIONLIST::user_data, N_GUI_SECTIONLIST::width, N_GUI_SECTIONLIST::window_id, N_GUI_SECTIONLIST::x, and N_GUI_SECTIONLIST::y0.

Referenced by main().

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

◆ n_gui_sectionlist_free()

void n_gui_sectionlist_free ( N_GUI_SECTIONLIST ** sl)

free the section list (does not destroy the N_GUI widgets or window)

Definition at line 19304 of file n_gui.c.

References FreeNoLog.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_sectionlist_get_count()

int n_gui_sectionlist_get_count ( const N_GUI_SECTIONLIST * sl)

number of sections in the list

Definition at line 19300 of file n_gui.c.

References N_GUI_SECTIONLIST::nb_sections.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_sectionlist_get_order()

int n_gui_sectionlist_get_order ( const N_GUI_SECTIONLIST * sl,
int position )

The section stacked at a position.

Parameters
slthe list
position0 for the top
Returns
its index, or -1 for a position out of range

Definition at line 19262 of file n_gui.c.

References N_GUI_SECTIONLIST::nb_sections, and N_GUI_SECTIONLIST::order.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_sectionlist_is_folded()

int n_gui_sectionlist_is_folded ( const N_GUI_SECTIONLIST * sl,
int section_index )

query a section's folded state (1 = folded, 0 = expanded)

Definition at line 19284 of file n_gui.c.

References N_GUI_SECTION::folded, N_GUI_SECTIONLIST::nb_sections, and N_GUI_SECTIONLIST::sections.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_sectionlist_is_section_hidden()

int n_gui_sectionlist_is_section_hidden ( const N_GUI_SECTIONLIST * sl,
int section_index )

Is a section left out of the stack.

Parameters
slthe list
section_indexthe section
Returns
1 when hidden, 0 otherwise or out of range

Definition at line 19273 of file n_gui.c.

References N_GUI_SECTIONLIST::nb_sections, and N_GUI_SECTIONLIST::section_hidden.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_sectionlist_relayout()

◆ n_gui_sectionlist_set_first_inset()

void n_gui_sectionlist_set_first_inset ( N_GUI_SECTIONLIST * sl,
float inset )

set a left inset applied to the FIRST section's header only, so a caller can place a button before it on the same row; relayout re-applies it

Definition at line 19176 of file n_gui.c.

References N_GUI_SECTIONLIST::first_inset.

◆ n_gui_sectionlist_set_folded()

void n_gui_sectionlist_set_folded ( N_GUI_SECTIONLIST * sl,
int section_index,
int folded )

set a section's folded state and relayout; does NOT fire on_toggle (for programmatic restore)

Definition at line 19278 of file n_gui.c.

References N_GUI_SECTION::folded, n_gui_sectionlist_relayout(), N_GUI_SECTIONLIST::nb_sections, and N_GUI_SECTIONLIST::sections.

Referenced by main().

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

◆ n_gui_sectionlist_set_geometry()

void n_gui_sectionlist_set_geometry ( N_GUI_SECTIONLIST * sl,
float x,
float y0,
float width,
float header_h,
float gap )

restate where the list stacks from, how wide its headers are and the two heights it stacks with, for a caller whose window is resized or whose interface scale changes after the list was made.

Takes effect at the next n_gui_sectionlist_relayout().

Definition at line 19167 of file n_gui.c.

References N_GUI_SECTIONLIST::gap, N_GUI_SECTIONLIST::header_h, N_GUI_SECTIONLIST::width, N_GUI_SECTIONLIST::x, and N_GUI_SECTIONLIST::y0.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_sectionlist_set_order()

void n_gui_sectionlist_set_order ( N_GUI_SECTIONLIST * sl,
const int * order,
int count )

Stack the sections in another order.

Section indices do not change - every call that takes an index still means the same section - only where each is drawn. order lists indices top to bottom; an index missing from it keeps its place after the listed ones, in index order, and an index out of range or given twice is ignored, so a saved order that predates a new section, or names one that has gone, still gives a complete stack. Relayouts.

Parameters
slthe list
ordersection indices, top to bottom
counthow many entries order has

Definition at line 19243 of file n_gui.c.

References N_GUI_SECTIONLIST_MAX, n_gui_sectionlist_relayout(), N_GUI_SECTIONLIST::nb_sections, and N_GUI_SECTIONLIST::order.

Referenced by main().

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

◆ n_gui_sectionlist_set_section_hidden()

void n_gui_sectionlist_set_section_hidden ( N_GUI_SECTIONLIST * sl,
int section_index,
int hidden )

Leave a whole section out of the stack, header and members, or put it back.

Its fold state is kept for when it returns. Relayouts.

Parameters
slthe list
section_indexthe section
hidden1 to leave it out

Definition at line 19267 of file n_gui.c.

References n_gui_sectionlist_relayout(), N_GUI_SECTIONLIST::nb_sections, and N_GUI_SECTIONLIST::section_hidden.

Referenced by main().

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

◆ n_gui_sectionlist_set_widget_hidden()

void n_gui_sectionlist_set_widget_hidden ( N_GUI_SECTIONLIST * sl,
int section_index,
int widget_id,
int hidden )

keep a member hidden whatever the fold state, and leave it out of the section's height.

For a section whose contents vary at run time: a plugin's unused sliders, a list's empty rows. Unhiding puts it back under the fold state like every other member.

Definition at line 19160 of file n_gui.c.

References _n_gui_sectionlist_slot(), N_GUI_SECTIONLIST::ctx, n_gui_set_widget_visible(), N_GUI_SECTIONLIST::sections, and N_GUI_SECTION::widget_hidden.

Referenced by main().

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

◆ n_gui_sectionlist_set_widget_offset()

void n_gui_sectionlist_set_widget_offset ( N_GUI_SECTIONLIST * sl,
int section_index,
int widget_id,
float dy )

state a member's y offset from the section's content top, for a caller that computes its own layout and recomputes it when the window is resized.

The offset captured by n_gui_sectionlist_add_widget() is only right while the layout it was captured from is; this is how it is corrected. Does nothing when the widget is not a member of that section.

Definition at line 19154 of file n_gui.c.

References _n_gui_sectionlist_slot(), N_GUI_SECTIONLIST::sections, and N_GUI_SECTION::widget_dy.

Referenced by main().

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

◆ n_gui_set_cursor()

void n_gui_set_cursor ( N_GUI_CTX * ctx,
int system_shape,
ALLEGRO_MOUSE_CURSOR * custom )

Say which mouse cursor the application wants.

The GUI sets the display's cursor itself: a resize cursor over a split pane divider or a datagrid column border, and the default everywhere else. An application that set a cursor of its own with Allegro, a crosshair for a picking tool, had it put back to the default by the GUI on the next pointer move, or kept it past the point where it applied. This makes the application's cursor the GUI's "everywhere else": the resize cursors still show where a drag would resize something, and this one shows the rest of the time. It is applied at once when the display is known, and the call is cheap when nothing changes, so an application can call it on every pointer move with what the pointer is over.

Parameters
ctxthe GUI context
system_shapean ALLEGRO_SYSTEM_MOUSE_CURSOR_* value; ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT with a NULL custom goes back to the GUI's own behaviour
customa cursor from al_create_mouse_cursor(), or NULL. Borrowed: the caller keeps it alive while it is set, and sets another before destroying it. Wins over system_shape when not NULL.

Definition at line 479 of file n_gui.c.

References __n_assert, _apply_cursor(), N_GUI_CTX::cursor_want_custom, N_GUI_CTX::cursor_want_shape, and N_GUI_CTX::mouse_b1.

Referenced by main().

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

◆ n_gui_set_default_font()

int n_gui_set_default_font ( N_GUI_CTX * ctx,
ALLEGRO_FONT * font )

Replace the context's default font, keeping every widget and its state.

Widgets resolve their font when they are DRAWN (wgt->font ? wgt->font : ctx->default_font) and the text-measurement cache is keyed on the font, so swapping it here re-fonts every widget that has not been given a font of its own. Window content sizes are recomputed from the new metrics so scrollbars and extents stay right.

This exists so a host does not have to destroy and rebuild its context when the UI scale changes (a phone rotating, a window resized). A rebuild loses everything the widgets hold - for the user that means half-typed text vanishing mid-edit.

The caller owns both fonts: keep the old one alive until this returns, and destroy it afterwards.

Parameters
ctxthe context
fontthe new default font, not NULL
Returns
TRUE on success, FALSE on a bad argument

Definition at line 1084 of file n_gui.c.

References __n_assert, _window_update_content_size(), N_GUI_CTX::default_font, font, list_foreach, and N_GUI_CTX::windows.

Here is the call graph for this function:

◆ n_gui_set_default_theme()

void n_gui_set_default_theme ( N_GUI_CTX * ctx,
N_GUI_THEME theme )

Set the default theme on a context and sync scrollbar style colors.

Sets ctx->default_theme and derives scrollbar track/thumb colors from the theme's bg_normal and border_normal fields so scrollbars match the active theme automatically.

Parameters
ctxN_GUI context. Must not be NULL.
themeTheme to apply as the new default.

Definition at line 919 of file n_gui.c.

References _color_with_alpha(), N_GUI_THEME::bg_active, N_GUI_THEME::bg_normal, N_GUI_THEME::border_normal, N_GUI_CTX::default_tb_btn_theme, N_GUI_CTX::default_tb_close_theme, N_GUI_CTX::default_theme, N_GUI_STYLE::global_scrollbar_thumb_border_color, N_GUI_STYLE::global_scrollbar_thumb_color, N_GUI_STYLE::global_scrollbar_track_color, N_GUI_STYLE::scrollbar_thumb_color, N_GUI_STYLE::scrollbar_track_color, N_GUI_CTX::style, N_GUI_THEME::text_active, N_GUI_THEME::text_hover, and N_GUI_THEME::text_normal.

Referenced by main(), and run().

Here is the call graph for this function:
Here is the caller 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 12378 of file n_gui.c.

References __n_assert, display, and N_GUI_CTX::display.

Referenced by main(), and 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. A context that is never given a size takes it from n_gui_draw()'s target bitmap on every pass, and logs once that it did; once this is called, the size given here is used and the target is not looked at again.

Definition at line 12348 of file n_gui.c.

References __n_assert, _n_gui_apply_display_size(), N_GUI_CTX::display_size_set, and h().

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

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

◆ n_gui_set_double_click_radius()

void n_gui_set_double_click_radius ( N_GUI_CTX * ctx,
int pixels )

how far the pointer may move between the two presses, in pixels (default 4)

how far the pointer may move between the two presses, in pixels (default 4)

Parameters
ctxGUI context
pixelsthe radius; negative is read as 0, which requires the two presses to land on exactly the same pixel

Definition at line 3787 of file n_gui.c.

References __n_assert, and N_GUI_CTX::double_click_radius.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_set_double_click_time()

void n_gui_set_double_click_time ( N_GUI_CTX * ctx,
double seconds )

how long after a press a second one still counts, in seconds (default 0.4)

how long after a press a second one still counts, in seconds (default 0.4)

Parameters
ctxGUI context
secondsthe interval; 0 or less disables double click reporting

Definition at line 3776 of file n_gui.c.

References __n_assert, and N_GUI_CTX::double_click_time.

Referenced by main(), and main().

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 12386 of file n_gui.c.

References __n_assert, and N_GUI_CTX::dpi_scale.

◆ n_gui_set_event_queue()

void n_gui_set_event_queue ( N_GUI_CTX * ctx,
ALLEGRO_EVENT_QUEUE * queue )

give the context the event queue it registers native window event sources into

Parameters
ctxthe GUI context
queuethe host's event queue, or NULL to forget it. Must be set before n_gui_window_detach, and must outlive every detached window.

give the context the event queue it registers native window event sources into

Definition at line 1586 of file n_gui.c.

References __n_assert, and N_GUI_CTX::event_queue.

Referenced by main().

Here is the caller graph for this function:

◆ 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 3908 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(), main(), main(), n_gui_close_window(), n_gui_focus_window(), 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 12093 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(), and main().

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

◆ n_gui_set_shape_mode()

void n_gui_set_shape_mode ( N_GUI_CTX * ctx,
int shape_mode )

set the global widget shape (N_GUI_SHAPE_ROUNDED for a round GUI, else square)

set the global widget shape (N_GUI_SHAPE_ROUNDED for a round GUI, else square)

Parameters
ctxGUI context. Ignored when NULL.
shape_modeN_GUI_SHAPE_ROUNDED for a rounded look, anything else for rectangular. Shape-aware widgets (the dropmenu button + panel, and the buttons/comboboxes that consult it) redraw accordingly on the next frame.

Definition at line 12361 of file n_gui.c.

References __n_assert, N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, N_GUI_STYLE::shape_mode, and N_GUI_CTX::style.

Referenced by main(), and run().

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 12027 of file n_gui.c.

References __n_assert, h(), LOG_ERR, n_gui_update_transform(), n_log, 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_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 3887 of file n_gui.c.

References N_GUI_WIDGET::enabled, and n_gui_get_widget().

Referenced by _n_gui_kv_refresh_actions(), and 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 3795 of file n_gui.c.

References n_gui_get_widget(), and N_GUI_WIDGET::theme.

Referenced by main(), and run().

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

◆ n_gui_set_widget_tooltip()

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

set (or clear with "" / NULL) the tooltip text shown after the pointer rests on a widget.

On a split pane only the divider band arms it, not the whole region the pane spans

set (or clear with "" / NULL) the tooltip text shown after the pointer rests on a widget.

The tooltip appears after the pointer rests on the widget for style.tooltip_delay seconds and hides on movement, click, or leave.

On a split pane only the divider band arms it, not the whole region the pane spans, so the text describes the divider the user is pointing at.

Parameters
ctxthe GUI context
widget_idid of the target widget
texttooltip text; NULL or "" clears it

Definition at line 2880 of file n_gui.c.

References FreeNoLog, n_gui_get_widget(), text(), and N_GUI_WIDGET::tooltip.

Referenced by _popup_mouse(), _popup_show_level(), build_panel(), main(), n_gui_color_picker_new(), n_gui_kvtable_add_row(), and n_gui_kvtable_set_row_actions().

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 3828 of file n_gui.c.

References n_gui_get_widget(), N_GUI_WIDGET::visible, and visible().

Referenced by _grid_place(), _n_gui_kv_apply_layout(), main(), main(), n_gui_grid_new(), n_gui_grid_set_visible(), n_gui_kvtable_add_row(), n_gui_kvtable_clear(), n_gui_kvtable_remove_row(), n_gui_popup_free(), n_gui_sectionlist_relayout(), and n_gui_sectionlist_set_widget_hidden().

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

◆ n_gui_slider_get_default()

int n_gui_slider_get_default ( N_GUI_CTX * ctx,
int widget_id,
double * value )

A slider's default, as n_gui_slider_set_default() gave it.

Parameters
ctxthe GUI context
widget_idthe slider
valuereceives the default when there is one; may be NULL
Returns
1 when the slider has a default, 0 otherwise

A slider's default, as n_gui_slider_set_default() gave it.

Parameters
ctxGUI context
widget_idid of the slider widget
valuereceives the default, may be NULL
Returns
1 when the slider has one, 0 otherwise

Definition at line 4091 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_SLIDER_DATA::default_value, N_GUI_SLIDER_DATA::has_default, 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_get_key_step()

double n_gui_slider_get_key_step ( N_GUI_CTX * ctx,
int widget_id )

get the arrow key and wheel increment actually in use for a slider

get the arrow key and wheel increment actually in use for a slider

Parameters
ctxGUI context
widget_idid of the slider widget
Returns
the increment, or 0.0 when the widget is not a slider

Definition at line 4136 of file n_gui.c.

References _slider_key_step(), 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_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 3962 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(), main(), and main().

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

◆ n_gui_slider_handle_pos()

int n_gui_slider_handle_pos ( N_GUI_CTX * ctx,
int widget_id,
float * pos,
float * radius )

Where a slider's handle is drawn and how big it is.

pos receives the centre of the handle measured along the slider's own axis from its left edge, or from its top edge for a vertical one, and radius receives half the handle's width. Both may be NULL.

The handle's centre travels along a strip inset by the radius at each end, so that the circle is drawn whole at every value rather than being cut in half by the widget's edge at the extremes. A caller that wants to put something beside the handle, or to check where it landed, asks here rather than repeating that arithmetic.

Returns
1 when the widget is a slider, 0 otherwise, in which case nothing is written.

Definition at line 4108 of file n_gui.c.

References _slider_handle_r(), _slider_travel(), N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_SLIDER_DATA::max_val, N_GUI_SLIDER_DATA::min_val, n_gui_get_widget(), N_GUI_SLIDER_V, N_GUI_TYPE_SLIDER, N_GUI_SLIDER_DATA::orientation, start(), N_GUI_CTX::style, N_GUI_WIDGET::type, and N_GUI_SLIDER_DATA::value.

Referenced by handle_stays_inside(), and 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 6606 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_default()

void n_gui_slider_set_default ( N_GUI_CTX * ctx,
int widget_id,
double value )

Give a slider a default value, which a double click on it puts back.

The double click sets the value (snapped and clamped as any other), calls the slider's on_change callback with it, as a drag would, and ends the drag the second press started, so the handle stays at the default when the pointer moves before the button is released. The first press of the pair has already moved the handle to the pointer and called on_change once; a host that merges consecutive changes of one control into one undo step gets the whole gesture as one.

A slider with no default ignores the gesture, as every slider did before this existed; n_gui_double_clicked_widget() still reports it either way.

Parameters
ctxthe GUI context
widget_idthe slider
valuethe default, inside the slider's range

Give a slider a default value, which a double click on it puts back.

Parameters
ctxGUI context
widget_idid of the slider widget
valuethe default

Definition at line 4075 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_SLIDER_DATA::default_value, N_GUI_SLIDER_DATA::has_default, 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_key_step()

void n_gui_slider_set_key_step ( N_GUI_CTX * ctx,
int widget_id,
double step )

set how far one arrow key press or wheel notch moves a slider, without snapping its drag

set how far one arrow key press or wheel notch moves a slider, without snapping its drag

Separate from n_gui_slider_set_step() because the two answer different questions. step decides which values are legal and snaps every input to them, the drag included; this decides only how far a key or a notch moves, and leaves a drag continuous. A program wanting "an arrow press moves exposure by a third of a stop" while a drag stays smooth needs this one.

The value is not snapped and the current value is not changed.

Parameters
ctxGUI context
widget_idid of the slider widget
stepincrement (0 falls back to the snapping step, then to a twentieth of the range)

Definition at line 4061 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_SLIDER_DATA::key_step, 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_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 3994 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 4014 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.

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

Here is the call graph for this function:
Here is the caller 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 3976 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 handle_stays_inside(), main(), main(), n_gui_color_picker_open(), and n_gui_process_event().

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

◆ n_gui_slider_set_value_format()

void n_gui_slider_set_value_format ( N_GUI_CTX * ctx,
int widget_id,
const char * fmt )

Override the built-in value readout's printf format string.

Pass NULL or "" to restore the default ("%.1f" in VALUE mode, "%.0f%%" in PERCENT mode). Format must consume the slider's double value (use f/g/e or cast with a precision width, a single d works too via stringification fallbacks). Buffer cap is 32 bytes.

Definition at line 4144 of file n_gui.c.

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

Here is the call graph for this function:

◆ n_gui_slider_set_value_visible()

void n_gui_slider_set_value_visible ( N_GUI_CTX * ctx,
int widget_id,
int visible )

Toggle the built-in value label.

Default 1 (visible). Set to 0 when the caller is already painting the value elsewhere so the slider doesn't double-render it.

Definition at line 4156 of file n_gui.c.

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

Referenced by n_gui_color_picker_new().

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

◆ n_gui_slider_value_width()

float n_gui_slider_value_width ( N_GUI_CTX * ctx,
int widget_id )

width in pixels a slider's built-in readout needs beside it, the gap between track and text included.

A horizontal slider draws its value past its own right edge, so a caller that sizes the track to the room available leaves none for the number and the window clips it. Subtract this from the width before setting the track's rectangle.

Measured at both ends of the slider's range and the wider taken, not at the current value: a layout sized from the value on show would change every time the handle moved.

Parameters
ctxthe GUI context
widget_idthe slider
Returns
the width, or 0 for a slider with no readout, a vertical one being irrelevant here, or a bad id

Definition at line 4163 of file n_gui.c.

References _slider_value_text(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, font, N_GUI_WIDGET::font, N_GUI_SLIDER_DATA::max_val, N_GUI_SLIDER_DATA::min_val, n_gui_get_text_dims(), n_gui_get_widget(), N_GUI_TYPE_SLIDER, N_GUI_STYLE::slider_value_label_offset, N_GUI_CTX::style, N_GUI_WIDGET::type, N_GUI_SLIDER_DATA::value_visible, and N_GUI_TEXT_DIMS::w.

Here is the call graph for this function:

◆ n_gui_splitpane_at()

int n_gui_splitpane_at ( N_GUI_CTX * ctx,
float x,
float y )

report the split pane whose divider band is under a point, or -1.

For an application that looks at raw mouse events before handing them to n_gui_process_event(): a split pane is click-through everywhere except its divider band, so an application that claims a press by rectangle alone swallows the drag the divider was about to start. The pointer turns into a resize cursor and nothing moves, which is how the problem shows up.

Windows are walked back to front and widgets bottom to top, so the topmost claimant wins, and any other widget over the point clears the answer.

Parameters
ctxthe GUI context
xscreen x
yscreen y
Returns
the split pane's widget id, or -1 when the point is not on a divider band

Definition at line 13570 of file n_gui.c.

References _splitpane_hit().

Here is the call graph for this function:

◆ n_gui_splitpane_band()

float n_gui_splitpane_band ( N_GUI_CTX * ctx,
int widget_id )

How far either side of a split pane's divider a press still counts as the divider's.

Wider than the bar that is drawn, so the divider can be grabbed without taking aim. An application that puts its own controls next to a divider has to know how much room the divider is really taking, or those controls can be seen and not touched: a scrollbar along a column's edge was unreachable for exactly that reason, because the application had assumed the band was the width of the bar.

Parameters
ctxthe GUI context
widget_idthe split pane
Returns
The band in pixels, measured from the divider's centre, or 0 when the widget is not a split pane.

Definition at line 13574 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SPLITPANE, and N_GUI_WIDGET::type.

Here is the call graph for this function:

◆ n_gui_splitpane_get_ratio()

float n_gui_splitpane_get_ratio ( N_GUI_CTX * ctx,
int widget_id )

get the current divider ratio (0..1), or 0.5 if the widget is invalid

get the current divider ratio (0..1), or 0.5 if the widget is invalid

Parameters
ctxGUI context
widget_idid of the split pane widget
Returns
the divider ratio (0..1), or 0.5 if the widget is invalid

Definition at line 4588 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SPLITPANE, 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_splitpane_set_limits()

void n_gui_splitpane_set_limits ( N_GUI_CTX * ctx,
int widget_id,
float min_ratio,
float max_ratio )

set the minimum and maximum allowed divider ratio

set the minimum and maximum allowed divider ratio

Parameters
ctxGUI context
widget_idid of the split pane widget
min_ratiolower clamp (0..1)
max_ratioupper clamp (0..1)

Definition at line 4616 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_SPLITPANE_DATA::max_ratio, N_GUI_SPLITPANE_DATA::min_ratio, n_gui_get_widget(), N_GUI_TYPE_SPLITPANE, N_GUI_SPLITPANE_DATA::ratio, and N_GUI_WIDGET::type.

Referenced by _n_gui_kv_apply_layout(), and main().

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

◆ n_gui_splitpane_set_ratio()

void n_gui_splitpane_set_ratio ( N_GUI_CTX * ctx,
int widget_id,
float ratio )

set the divider ratio (clamped to the configured min/max)

set the divider ratio (clamped to the configured min/max)

Parameters
ctxGUI context
widget_idid of the split pane widget
ratiothe requested divider ratio (0..1)

Definition at line 4600 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_SPLITPANE_DATA::max_ratio, N_GUI_SPLITPANE_DATA::min_ratio, n_gui_get_widget(), N_GUI_TYPE_SPLITPANE, N_GUI_SPLITPANE_DATA::ratio, and N_GUI_WIDGET::type.

Referenced by _apply_pending_widget(), _n_gui_kv_apply_layout(), and main().

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

◆ n_gui_suggest_add()

int n_gui_suggest_add ( N_GUI_SUGGEST_SINK * sink,
const char * text )

add one completion to a suggestion sink

Called from a N_GUI_SUGGEST_FN and nowhere else. The text is copied, so the provider's own buffer can be reused or go out of scope immediately. An empty text, a duplicate of one already added, and anything past N_GUI_SUGGEST_MAX are all refused rather than stored.

Parameters
sinkthe sink handed to the provider
textthe completion to offer
Returns
1 when it was taken, 0 when it was refused

Definition at line 12705 of file n_gui.c.

References N_GUI_SUGGEST_MAX, N_GUI_LISTITEM::selected, N_GUI_TEXTAREA_DATA::suggest_count, N_GUI_TEXTAREA_DATA::suggest_items, N_GUI_LISTITEM::text, and text().

Referenced by vocabulary().

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

◆ n_gui_syntaxview_content_width()

float n_gui_syntaxview_content_width ( N_GUI_CTX * ctx,
int widget_id )

pixel width the widest line of a syntax view needs, padding included

Parameters
ctxGUI context
widget_idid of the syntax view widget
Returns
the content width in pixels, or 0 if the widget is invalid or empty

Definition at line 5095 of file n_gui.c.

References _syntaxview_ensure_width(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, font, N_GUI_WIDGET::font, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, N_GUI_CTX::style, 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_syntaxview_get_h_scroll()

float n_gui_syntaxview_get_h_scroll ( N_GUI_CTX * ctx,
int widget_id )

current horizontal scroll offset of a syntax view, in pixels.

Pair with n_gui_syntaxview_set_h_scroll to preserve the horizontal view across a set_text.

current horizontal scroll offset of a syntax view, in pixels.

Parameters
ctxGUI context
widget_idid of the syntax view widget
Returns
the offset in pixels, or 0 if the widget is invalid

Definition at line 5109 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, 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_syntaxview_get_line_count()

int n_gui_syntaxview_get_line_count ( N_GUI_CTX * ctx,
int widget_id )

get the number of text lines in a syntax view

Parameters
ctxGUI context
widget_idid of the syntax view widget
Returns
the line count, or 0 if the widget is invalid

Definition at line 4959 of file n_gui.c.

References _text_line_count(), N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, 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_syntaxview_get_selected_text()

char * n_gui_syntaxview_get_selected_text ( N_GUI_CTX * ctx,
int widget_id )

copy of the currently selected text in a syntax view, or NULL when nothing is selected.

The caller owns the returned buffer and must Free() it.

copy of the currently selected text in a syntax view, or NULL when nothing is selected.

Parameters
ctxGUI context
widget_idid of the syntax view widget
Returns
a newly allocated copy of the selected substring (caller frees with Free()), or NULL when nothing is selected or the widget is invalid

Definition at line 4984 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_SYNTAXVIEW_DATA::len, Malloc, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, N_GUI_SYNTAXVIEW_DATA::sel_end, N_GUI_SYNTAXVIEW_DATA::sel_start, N_GUI_SYNTAXVIEW_DATA::text, and N_GUI_WIDGET::type.

Referenced by _ngui_publish_primary_selection(), main(), and n_gui_process_event().

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

◆ n_gui_syntaxview_get_text()

const char * n_gui_syntaxview_get_text ( N_GUI_CTX * ctx,
int widget_id )

get the text shown by a syntax view (borrowed pointer, do not free; NULL if empty)

get the text shown by a syntax view (borrowed pointer, do not free; NULL if empty)

Parameters
ctxGUI context
widget_idid of the syntax view widget
Returns
a borrowed pointer to the text (do not free), or NULL when empty/invalid

Definition at line 4971 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, 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_syntaxview_scroll_to_offset()

void n_gui_syntaxview_scroll_to_offset ( N_GUI_CTX * ctx,
int widget_id,
int byte_offset )

scroll a syntax view so the line holding the given byte offset is vertically centered, and horizontally so the offset itself is inside the visible width

scroll a syntax view so the line holding the given byte offset is vertically centered, and horizontally so the offset itself is inside the visible width

Parameters
ctxGUI context
widget_idid of the syntax view widget
byte_offsetbyte offset into the text (clamped to the text length)

Definition at line 5044 of file n_gui.c.

References _syntax_prefix_w(), _syntaxview_clamp_h(), _syntaxview_hmetrics(), N_GUI_SYNTAXVIEW_DATA::cached_nb_lines, N_GUI_WIDGET::data, N_GUI_CTX::default_font, font, N_GUI_WIDGET::font, N_GUI_SYNTAXVIEW_DATA::h_scroll, N_GUI_SYNTAXVIEW_DATA::len, line(), n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, N_GUI_SYNTAXVIEW_DATA::scroll_offset, N_GUI_CTX::style, N_GUI_SYNTAXVIEW_DATA::text, N_GUI_STYLE::textarea_padding, N_GUI_WIDGET::type, visible(), and N_GUI_WIDGET::w.

Referenced by main().

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

◆ n_gui_syntaxview_select_all()

void n_gui_syntaxview_select_all ( N_GUI_CTX * ctx,
int widget_id )

select the entire text of a syntax view

Parameters
ctxGUI context
widget_idid of the syntax view widget

Definition at line 5031 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), n_gui_syntaxview_set_selection(), N_GUI_TYPE_SYNTAXVIEW, and N_GUI_WIDGET::type.

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_syntaxview_set_h_scroll()

void n_gui_syntaxview_set_h_scroll ( N_GUI_CTX * ctx,
int widget_id,
float px )

set the horizontal scroll offset of a syntax view, in pixels (clamped to the content width by the draw path)

set the horizontal scroll offset of a syntax view, in pixels (clamped to the content width by the draw path)

Parameters
ctxGUI context
widget_idid of the syntax view widget
pxthe offset in pixels (negative values are clamped to 0, the upper bound is applied by the draw path against the live content width)

Definition at line 5122 of file n_gui.c.

References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, 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_syntaxview_set_mode()

void n_gui_syntaxview_set_mode ( N_GUI_CTX * ctx,
int widget_id,
int mode )

set the highlighting mode (N_GUI_SYNTAX_*) of a syntax view

set the highlighting mode (N_GUI_SYNTAX_*) of a syntax view

Parameters
ctxGUI context
widget_idid of the syntax view widget
modeone of the N_GUI_SYNTAX_* modes (PLAIN, HTTP, JSON, XML, YAML, JS, DIFF)

Definition at line 4947 of file n_gui.c.

References N_GUI_WIDGET::data, mode, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, 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_syntaxview_set_selection()

void n_gui_syntaxview_set_selection ( N_GUI_CTX * ctx,
int widget_id,
int start,
int end )

set the selection range (byte offsets into the text, clamped to its length); pass start == end to clear the selection

set the selection range (byte offsets into the text, clamped to its length); pass start == end to clear the selection

Parameters
ctxGUI context
widget_idid of the syntax view widget
startselection start byte offset (clamped to the text length)
endselection end byte offset (clamped to the text length); start == end clears

Definition at line 5011 of file n_gui.c.

References N_GUI_WIDGET::data, N_GUI_SYNTAXVIEW_DATA::len, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, N_GUI_SYNTAXVIEW_DATA::sel_end, N_GUI_SYNTAXVIEW_DATA::sel_start, N_GUI_CTX::selected_syntaxview_id, start(), and N_GUI_WIDGET::type.

Referenced by main(), and n_gui_syntaxview_select_all().

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

◆ n_gui_syntaxview_set_text()

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

set (copy) the text shown by a syntax view; text may be NULL to clear

set (copy) the text shown by a syntax view; text may be NULL to clear

Parameters
ctxGUI context
widget_idid of the syntax view widget
textthe text to display, or NULL to clear

Definition at line 4913 of file n_gui.c.

References N_GUI_WIDGET::data, FreeNoLog, N_GUI_SYNTAXVIEW_DATA::h_scroll, N_GUI_SYNTAXVIEW_DATA::h_scroll_dragging, N_GUI_SYNTAXVIEW_DATA::len, N_GUI_SYNTAXVIEW_DATA::lines_valid, Malloc, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, N_GUI_SYNTAXVIEW_DATA::scroll_offset, N_GUI_SYNTAXVIEW_DATA::sel_dragging, N_GUI_SYNTAXVIEW_DATA::sel_end, N_GUI_SYNTAXVIEW_DATA::sel_start, N_GUI_CTX::selected_syntaxview_id, N_GUI_SYNTAXVIEW_DATA::text, text(), N_GUI_WIDGET::type, and N_GUI_SYNTAXVIEW_DATA::width_valid.

Referenced by build_syntaxview_window(), and main().

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

◆ n_gui_tab_add()

int n_gui_tab_add ( N_GUI_TAB_PANEL * panel,
const char * label )

add a tab to the panel, returns tab index

Definition at line 17522 of file n_gui.c.

References _n_gui_tab_button_clicked(), N_GUI_TAB_PANEL::active_tab, N_GUI_TAB_PANEL::button_h, N_GUI_TAB_PANEL::button_ids, N_GUI_TAB_PANEL::button_w, N_GUI_TAB_PANEL::ctx, n_gui_add_toggle_button(), N_GUI_SHAPE_RECT, N_GUI_TAB_MAX, N_GUI_TAB_PANEL::nb_tabs, N_GUI_TAB_PANEL::parent_window_id, N_GUI_TAB_PANEL::x, and N_GUI_TAB_PANEL::y.

Referenced by main().

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

◆ 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(* on_tab_change )(int, void *),
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 17595 of file n_gui.c.

References FreeNoLog.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_tab_get_active()

int n_gui_tab_get_active ( const N_GUI_TAB_PANEL * panel)

get the active tab index

Definition at line 17556 of file n_gui.c.

References N_GUI_TAB_PANEL::active_tab.

◆ n_gui_tab_relayout()

void n_gui_tab_relayout ( N_GUI_TAB_PANEL * panel,
float x,
float y,
float button_w,
float button_h )

move/resize the button row after creation (a host-owned or resizable layout); pass <= 0 for button_w / button_h to keep the current value.

Content windows are separate windows, place them with n_gui_window_set_rect

move/resize the button row after creation (a host-owned or resizable layout); pass <= 0 for button_w / button_h to keep the current value.

The buttons are laid out once, when each tab is added. A host that owns its own layout (a resizable panel, a split-pane pane) needs to re-place the row afterwards; this re-applies the origin and button size to every tab and refreshes their normalized coordinates so they keep following their window. The content windows are not touched: they are ordinary windows, position them with n_gui_window_set_rect().

Parameters
panelthe tab panel
xnew x of the first tab button, in the parent window's coordinates
ynew y of the button row
button_wnew per-button width (<= 0 keeps the current one)
button_hnew button height (<= 0 keeps the current one)

Definition at line 17576 of file n_gui.c.

References _n_gui_widget_capture_normalized(), N_GUI_TAB_PANEL::button_h, N_GUI_TAB_PANEL::button_ids, N_GUI_TAB_PANEL::button_w, N_GUI_TAB_PANEL::ctx, N_GUI_CTX::dirty, N_GUI_WIDGET::h, n_gui_get_widget(), n_gui_get_window(), N_GUI_TAB_PANEL::nb_tabs, N_GUI_TAB_PANEL::parent_window_id, N_GUI_WIDGET::w, N_GUI_TAB_PANEL::x, N_GUI_WIDGET::x, N_GUI_TAB_PANEL::y, 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_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 17542 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 17537 of file n_gui.c.

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

◆ n_gui_text_shorten()

int n_gui_text_shorten ( ALLEGRO_FONT * font,
const char * text,
float max_w,
int mode,
char * out,
size_t out_len )

shorten text to fit max_w pixels in font, the way a label with truncate mode mode shows it: unchanged when it fits, otherwise with "..." at the end, at the start, or in place of whole leading path components (N_GUI_TRUNCATE_END, _START, _PATH).

Cuts only between UTF-8 sequences. Returns 1 when out is shorter than text, 0 when it is the whole of it, -1 on a NULL argument or no room. out is always terminated when out_len > 0.

Definition at line 6890 of file n_gui.c.

References _shorten_start(), _text_w(), _utf8_step(), font, mode, N_GUI_TRUNCATE_PATH, N_GUI_TRUNCATE_START, and text().

Referenced by _draw_label_overflow(), and main().

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

◆ 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 4196 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 _n_gui_kv_dup_text(), main(), main(), and 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 7389 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.

Referenced by main().

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

◆ n_gui_textarea_has_selection()

int n_gui_textarea_has_selection ( N_GUI_CTX * ctx,
int widget_id )

is any text selected in a text area (0 for no selection or a bad id)

is any text selected in a text area (0 for no selection or a bad id)

What Ctrl+C would copy and Ctrl+X would cut: an application that binds those keys to an action of its own can leave them to the field while it has something selected, and take them otherwise, when the field's copy would put nothing on the clipboard.

Parameters
ctxGUI context
widget_idid of the textarea widget
Returns
1 when a non empty range is selected, 0 when none is or the id is not a text area

Definition at line 7409 of file n_gui.c.

References _textarea_has_selection(), N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, 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_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 7294 of file n_gui.c.

References _textarea_content_height(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, 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 )

◆ 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 6657 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.

Referenced by main().

Here is the call graph for this function:
Here is the caller 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 6671 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_placeholder()

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

set placeholder/hint text for a textarea, shown dimmed while the field is empty and cleared from view as soon as the user types.

Pass NULL or "" to remove the placeholder. The string is copied.

Parameters
ctxthe GUI context
widget_idid of the textarea widget
textthe placeholder text, or NULL to clear

set placeholder/hint text for a textarea, shown dimmed while the field is empty and cleared from view as soon as the user types.

Definition at line 6683 of file n_gui.c.

References N_GUI_WIDGET::data, FreeNoLog, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, n_log, N_GUI_TEXTAREA_DATA::placeholder, text(), and N_GUI_WIDGET::type.

Referenced by main(), n_gui_kvtable_add_row(), and n_gui_kvtable_set_placeholders().

Here is the call graph for this function:
Here is the caller 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 7316 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, start(), N_GUI_TEXTAREA_DATA::text_len, 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_textarea_set_suggest()

void n_gui_textarea_set_suggest ( N_GUI_CTX * ctx,
int widget_id,
N_GUI_SUGGEST_FN fn,
const char * separators,
void * user_data )

offer completions in a textarea

While the field has focus, the word under the cursor is handed to fn and what it answers is shown in a panel under the field. Up and Down move through it, ENTER or TAB puts the highlighted one in place of that word, ESCAPE dismisses it, and a click picks one. Typing keeps it in step; a word that nothing matches closes it.

The provider is asked when the word under the cursor changes, and not when a key leaves it as it was: the panel remembers which word its answers are for, so arrow keys and edits elsewhere in the line cost nothing.

What is replaced is exactly the word under the cursor, and nothing is added after it. A field holding a list gets its separator typed by the person using it, because a widget that helpfully appends one is a widget that has to guess whether they wanted another entry.

Parameters
ctxthe GUI context
widget_idid of the textarea widget
fnthe provider, or NULL to stop offering completions
separatorscharacters that end a word, e.g. "," for a comma separated list. NULL or "" makes the whole content one word.
user_datahanded back to the provider untouched, not owned

Definition at line 12852 of file n_gui.c.

References _suggest_close(), N_GUI_WIDGET::data, FreeNoLog, LOG_WARNING, n_gui_get_widget(), N_GUI_TYPE_TEXTAREA, n_log, N_GUI_TEXTAREA_DATA::suggest, N_GUI_TEXTAREA_DATA::suggest_items, N_GUI_TEXTAREA_DATA::suggest_separators, N_GUI_TEXTAREA_DATA::suggest_user_data, 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_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 4210 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, text(), N_GUI_TEXTAREA_DATA::text_len, and N_GUI_WIDGET::type.

Referenced by _n_gui_kv_content_put(), build_textarea_window(), main(), main(), 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_textarea_suggest_close()

void n_gui_textarea_suggest_close ( N_GUI_CTX * ctx,
int widget_id )

put a textarea's completion panel away

What ESCAPE does, for a caller that needs to dismiss it for its own reasons: a window closing over it, or a key the application wants back.

Parameters
ctxthe GUI context
widget_idid of the textarea widget

Definition at line 12878 of file n_gui.c.

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

Here is the call graph for this function:

◆ n_gui_textarea_suggest_is_open()

int n_gui_textarea_suggest_is_open ( N_GUI_CTX * ctx,
int widget_id )

is a textarea's completion panel up

Parameters
ctxthe GUI context
widget_idid of the textarea widget
Returns
1 when the panel is open

Definition at line 12871 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 main(), and n_gui_process_event().

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 2497 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_tooltip_pending()

int n_gui_tooltip_pending ( N_GUI_CTX * ctx)

tooltip phase: 0 = none (or tooltips disabled via style.tooltip_delay <= 0), 1 = arming (hosts with cached GUI renders must keep redrawing so the bubble can appear on time), 2 = shown (static - re-render once on the transition, then stop)

tooltip phase: 0 = none (or tooltips disabled via style.tooltip_delay <= 0), 1 = arming (hosts with cached GUI renders must keep redrawing so the bubble can appear on time), 2 = shown (static - re-render once on the transition, then stop)

Hosts that cache the GUI render must keep invalidating/redrawing while this returns 1 (arming), or the bubble can never appear - it shows only after the pointer STOPS, when no more input events trigger redraws. A steady 2 (shown) needs one re-render on the transition and none after; re-rendering every tick during 2 would burn the cache for nothing.

Answers 0 while another window covers the pointer, even though a widget is armed underneath it: the bubble is drawn last and over everything, so one armed before a window opened on top of it would be painted over that window. The arming scan already picks the top-most window's widget, but nothing re-runs it when a window opens without the pointer moving – a context menu on a right click is the case this was found in.

Parameters
ctxthe GUI context
Returns
0 = none/disabled/obscured, 1 = arming, 2 = shown

Definition at line 2970 of file n_gui.c.

References _find_widget_window(), _topmost_window_at(), N_GUI_CTX::mouse_x, N_GUI_CTX::mouse_y, N_GUI_CTX::style, N_GUI_CTX::tooltip_armed_at, N_GUI_STYLE::tooltip_delay, and N_GUI_CTX::tooltip_widget_id.

Referenced by _draw_tooltip(), and main().

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_clear()

void n_gui_tree_clear ( N_GUI_TREE * tree)

remove all nodes and clear the backing listbox; tree object remains valid

Definition at line 17705 of file n_gui.c.

References N_GUI_TREE::ctx, N_GUI_TREE::listbox_id, n_gui_listbox_clear(), N_GUI_TREE::nb_nodes, and N_GUI_TREE::nb_visible.

Referenced by build_tree(), and main().

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

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

◆ n_gui_tree_draw_overlay()

void n_gui_tree_draw_overlay ( N_GUI_TREE * tree)

per-frame overlay drawing: draws the active drop-indicator on top of the listbox.

Call after n_gui_draw(). No-op when no drag is in progress.

Definition at line 18195 of file n_gui.c.

References _n_gui_tree_listbox_bounds(), N_GUI_THEME::border_active, N_GUI_TREE::ctx, N_GUI_CTX::default_theme, N_GUI_TREE::drag_active, N_GUI_TREE::drag_hover_node, N_GUI_TREE::drop_position, N_GUI_TREE::listbox_id, N_GUI_DROP_BEFORE, N_GUI_DROP_INTO, n_gui_get_widget(), N_GUI_TREE::nb_visible, right(), row(), row_y(), N_GUI_WIDGET::theme, and N_GUI_TREE::visible_map.

Here is the call graph for this function:

◆ n_gui_tree_expand()

void n_gui_tree_expand ( N_GUI_TREE * tree,
int node_index )

open a node, filling it first through the expand callback if it has not been; a node already open stays open.

For a caller revealing a path one level at a time. No-op for a node that cannot be opened.

Definition at line 17846 of file n_gui.c.

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

Referenced by main().

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

◆ n_gui_tree_find_by_path()

int n_gui_tree_find_by_path ( const N_GUI_TREE * tree,
const char * path )

index of the first node with the given path, or -1.

Paths survive a rebuild that replaces every node, which pointers and indices do not

Definition at line 17951 of file n_gui.c.

References n_gui_tree_node_path(), N_GUI_TREE_PATH_MAX, and N_GUI_TREE::nb_nodes.

Referenced by main(), and n_gui_tree_state_apply().

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

◆ n_gui_tree_find_by_user_data()

int n_gui_tree_find_by_user_data ( const N_GUI_TREE * tree,
const void * ptr )

find the first node whose user_data pointer equals ptr, or -1.

Used to re-resolve a node index after a rebuild compacted the array: the caller stashes the stable user_data pointer before the rebuild, then calls this to find the new index.

Definition at line 17803 of file n_gui.c.

References N_GUI_TREE::nb_nodes, N_GUI_TREE::nodes, and N_GUI_TREE_NODE::user_data.

◆ 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 17898 of file n_gui.c.

References FreeNoLog.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_tree_get_selection()

int n_gui_tree_get_selection ( N_GUI_TREE * tree)

get the index of the currently selected node, or -1 when nothing is selected or the selection points at a hidden row

Definition at line 17774 of file n_gui.c.

References N_GUI_TREE::ctx, N_GUI_TREE::listbox_id, n_gui_listbox_get_selected(), N_GUI_TREE::nb_visible, row(), and N_GUI_TREE::visible_map.

Referenced by main(), n_gui_tree_rebuild(), and n_gui_tree_state_save().

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

◆ n_gui_tree_node_path()

int n_gui_tree_node_path ( const N_GUI_TREE * tree,
int node_index,
char * buf,
size_t bufsz )

write the path of a node (its label and its ancestors', joined by N_GUI_TREE_PATH_SEP) into buf.

Returns 0 on success, -1 on a bad node or a path that does not fit

write the path of a node (its label and its ancestors', joined by N_GUI_TREE_PATH_SEP) into buf.

The path is the node's label preceded by its ancestors', joined by N_GUI_TREE_PATH_SEP (a unit separator, which cannot occur inside a label, so the path is unambiguous). It identifies a node across a rebuild, which node indices and user_data pointers do not when the model behind the tree was reloaded from disk.

Parameters
treethe tree
node_indexthe node to describe
bufdestination buffer
bufszsize of buf
Returns
0 on success, -1 on an invalid node or a path that does not fit

Definition at line 17921 of file n_gui.c.

References N_GUI_TREE_NODE::label, N_GUI_TREE_MAX, N_GUI_TREE_PATH_SEP, N_GUI_TREE::nb_nodes, N_GUI_TREE::nodes, and N_GUI_TREE_NODE::parent_index.

Referenced by main(), n_gui_tree_find_by_path(), n_gui_tree_state_apply(), and n_gui_tree_state_save().

Here is the caller graph for this function:

◆ n_gui_tree_rebuild()

◆ n_gui_tree_remove_node()

void n_gui_tree_remove_node ( N_GUI_TREE * tree,
int node_index )

remove a node and its entire subtree; remaining node indices are compacted (callers holding indices across the call must discard or re-resolve them)

Definition at line 17712 of file n_gui.c.

References changed, N_GUI_TREE_NODE::has_children, N_GUI_TREE_MAX, n_gui_tree_rebuild(), N_GUI_TREE::nb_nodes, N_GUI_TREE::nodes, and N_GUI_TREE_NODE::parent_index.

Here is the call graph for this function:

◆ n_gui_tree_set_expand_callback()

void n_gui_tree_set_expand_callback ( N_GUI_TREE * tree,
void(* on_expand )(int node_index, void *user_data),
void * user_data )

set the callback that fills a node the first time it is opened, for a tree too large to build before it is shown: a folder tree reads a directory only when somebody opens it.

Called with the node's index, before the rebuild, so the children it adds with n_gui_tree_add_node() show in the same frame. A node the callback leaves empty loses its expander. NULL removes it.

Definition at line 17852 of file n_gui.c.

References N_GUI_TREE::expand_user_data, N_GUI_TREE::on_expand, and on_expand().

Referenced by main().

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

◆ n_gui_tree_set_expandable()

void n_gui_tree_set_expandable ( N_GUI_TREE * tree,
int node_index,
int expandable )

mark a node as openable before it has children, so it shows an expander and the expand callback fills it when it is opened

Definition at line 17858 of file n_gui.c.

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

Referenced by main(), and on_expand().

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

◆ n_gui_tree_set_label()

void n_gui_tree_set_label ( N_GUI_TREE * tree,
int node_index,
const char * new_label )

change the display label of a node

Definition at line 17766 of file n_gui.c.

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

Here is the call graph for this function:

◆ n_gui_tree_set_on_drop()

void n_gui_tree_set_on_drop ( N_GUI_TREE * tree,
n_gui_tree_on_drop_t on_drop,
void * user_data )

install (or clear, with NULL) a drag-reorder drop callback.

Drag state is only tracked when on_drop is non-NULL.

Definition at line 18038 of file n_gui.c.

References N_GUI_TREE::drag_active, N_GUI_TREE::drag_armed_node, N_GUI_TREE::drag_hover_node, N_GUI_TREE::drag_source_node, N_GUI_TREE::drop_user_data, and N_GUI_TREE::on_drop.

◆ n_gui_tree_set_selection()

void n_gui_tree_set_selection ( N_GUI_TREE * tree,
int node_index )

programmatically select a node; ancestors are expanded so the node is visible, and the listbox scrolls to reveal it.

Does not fire the on_select callback. No-op if node_index is out of range.

Definition at line 17781 of file n_gui.c.

References N_GUI_TREE::ctx, N_GUI_TREE_NODE::expanded, N_GUI_TREE::listbox_id, n_gui_listbox_set_scroll_offset(), n_gui_listbox_set_selected(), n_gui_tree_rebuild(), N_GUI_TREE::nb_nodes, N_GUI_TREE::nb_visible, N_GUI_TREE::nodes, N_GUI_TREE_NODE::parent_index, row(), and N_GUI_TREE::visible_map.

Referenced by main(), and n_gui_tree_state_apply().

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

◆ n_gui_tree_state_apply()

void n_gui_tree_state_apply ( N_GUI_TREE * tree,
const N_GUI_TREE_STATE * state )

re-expand, re-select and re-scroll a rebuilt tree from a saved state.

Nodes that no longer exist are skipped; nodes that appeared stay collapsed. On a tree filled on demand, an expanded node is filled through the expand callback as it is reopened, level by level, so a whole unfolded branch comes back, read afresh

Definition at line 17986 of file n_gui.c.

References _n_gui_tree_open(), changed, N_GUI_TREE::ctx, N_GUI_TREE_NODE::expanded, N_GUI_TREE_STATE::expanded, N_GUI_TREE_STATE::h_scroll, N_GUI_TREE::listbox_id, n_gui_listbox_set_h_scroll(), n_gui_listbox_set_scroll_offset(), n_gui_tree_find_by_path(), n_gui_tree_node_path(), N_GUI_TREE_PATH_MAX, n_gui_tree_rebuild(), n_gui_tree_set_selection(), N_GUI_TREE_STATE::nb_expanded, N_GUI_TREE::nb_nodes, N_GUI_TREE::nodes, N_GUI_TREE_STATE::scroll_offset, and N_GUI_TREE_STATE::selected.

Referenced by main().

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

◆ n_gui_tree_state_free()

void n_gui_tree_state_free ( N_GUI_TREE_STATE * state)

release the strings owned by a saved state (safe on a zeroed struct)

Definition at line 18023 of file n_gui.c.

References N_GUI_TREE_STATE::expanded, FreeNoLog, N_GUI_TREE_STATE::nb_expanded, and N_GUI_TREE_STATE::selected.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_tree_state_save()

int n_gui_tree_state_save ( const N_GUI_TREE * tree,
N_GUI_TREE_STATE * out )

capture which nodes are expanded, which one is selected, and where the view is scrolled, all by path.

Call before a rebuild that replaces the nodes (a reloaded model), then n_gui_tree_state_apply after it, so the user does not lose their unfolded branches and their place. Returns 0 on success

Definition at line 17962 of file n_gui.c.

References N_GUI_TREE::ctx, N_GUI_TREE_NODE::expanded, N_GUI_TREE_STATE::expanded, N_GUI_TREE_STATE::h_scroll, N_GUI_TREE::listbox_id, n_gui_listbox_get_h_scroll(), n_gui_listbox_get_scroll_offset(), n_gui_tree_get_selection(), n_gui_tree_node_path(), N_GUI_TREE_PATH_MAX, N_GUI_TREE_STATE_MAX, N_GUI_TREE_STATE::nb_expanded, N_GUI_TREE::nb_nodes, N_GUI_TREE::nodes, N_GUI_TREE_STATE::scroll_offset, and N_GUI_TREE_STATE::selected.

Referenced by main().

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

◆ n_gui_tree_tick()

void n_gui_tree_tick ( N_GUI_TREE * tree)

per-frame poll: reads ctx->mouse_* to track drag state and fires the on_drop callback on release.

Call once per frame while the tree is visible, before n_gui_draw(). No-op when on_drop is NULL.

Definition at line 18133 of file n_gui.c.

References _N_GUI_TREE_DRAG_THRESHOLD_PX, _n_gui_tree_hit_row(), N_GUI_TREE::ctx, N_GUI_TREE::drag_active, N_GUI_TREE::drag_armed_node, N_GUI_TREE::drag_hover_node, N_GUI_TREE::drag_press_x, N_GUI_TREE::drag_press_y, N_GUI_TREE::drag_source_node, N_GUI_TREE::drop_position, N_GUI_TREE::drop_user_data, N_GUI_CTX::mouse_b1, N_GUI_TREE::mouse_b1_prev, N_GUI_CTX::mouse_x, N_GUI_CTX::mouse_y, N_GUI_DROP_INTO, and N_GUI_TREE::on_drop.

Here is the call graph for this function:

◆ n_gui_tree_toggle_expand()

void n_gui_tree_toggle_expand ( N_GUI_TREE * tree,
int node_index )

toggle expand/collapse of a node.

Opening a node the expand callback has not filled yet calls it first.

Definition at line 17836 of file n_gui.c.

References _n_gui_tree_open(), N_GUI_TREE_NODE::expandable, 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(), and main().

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 12045 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_apply_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 16575 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::native, 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(), and main().

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

◆ n_gui_was_double_click()

int n_gui_was_double_click ( const N_GUI_CTX * ctx,
int widget_id )

whether the press just processed double clicked this particular widget

whether the press just processed double clicked this particular widget

Parameters
ctxGUI context
widget_idthe widget to ask about
Returns
1 when it did, 0 otherwise

Definition at line 3764 of file n_gui.c.

References __n_assert, and N_GUI_CTX::double_clicked_widget_id.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_widget_get_persist_key()

const char * n_gui_widget_get_persist_key ( N_GUI_CTX * ctx,
int widget_id )

Get a widget's persist key ("" when unset), or NULL when the widget is invalid.

Definition at line 2946 of file n_gui.c.

References n_gui_get_widget(), and N_GUI_WIDGET::persist_key.

Referenced by main().

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

◆ n_gui_widget_is_visible()

int n_gui_widget_is_visible ( N_GUI_CTX * ctx,
int widget_id )

Is a widget currently shown.

The other half of n_gui_set_widget_visible(), which had none: an application that shows a control in one state and hides it in another had to keep its own copy of what it had just said, and a second copy of a fact the toolkit already holds is a second place for it to be wrong.

Parameters
ctxthe GUI context
widget_idthe widget
Returns
1 when it is shown, 0 when it is hidden or unknown.

Definition at line 2316 of file n_gui.c.

References __n_assert, n_gui_get_widget(), and N_GUI_WIDGET::visible.

Referenced by widget_visible().

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

◆ n_gui_widget_screen_rect()

int n_gui_widget_screen_rect ( N_GUI_CTX * ctx,
int widget_id,
float * x,
float * y,
float * w,
float * h )

Where a widget is on screen, rather than inside its window.

A widget's own x and y are relative to the window it lives in, and a mouse event's are not, so the two cannot be compared without adding the window's origin, its title bar and its scroll offset. An application that has to decide what a press at a given point is for - or a test that has to aim one - asks here instead of repeating that arithmetic and getting the scrolled or the framed case wrong.

A widget in a detached window answers in that window's own coordinates, which is the space its events arrive in.

Parameters
ctxthe GUI context
widget_idthe widget
xreceives the left edge, may be NULL
yreceives the top edge, may be NULL
wreceives the width, may be NULL
hreceives the height, may be NULL
Returns
1 when the widget was found, 0 otherwise, in which case nothing is written.

Definition at line 2091 of file n_gui.c.

References __n_assert, _find_widget_window(), h(), N_GUI_WIDGET::h, n_gui_get_widget(), N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.

Referenced by _grid_mouse(), main(), n_gui_grid_cell_rect(), and n_gui_grid_index_at().

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

◆ n_gui_widget_set_persist_key()

void n_gui_widget_set_persist_key ( N_GUI_CTX * ctx,
int widget_id,
const char * key )

Give a widget a stable key so its user-adjustable state (a splitpane's divider ratio, or a datagrid's column order/visibility/width) is persisted by n_gui_save_layout_json and restored by n_gui_load_layout_json.

The key is unique within its window (matching is by owning-window title + key). Passing NULL/"" clears the key (stops persisting). If a saved layout was already loaded, the matching pending state is applied to the widget immediately (consume-once). No-op for a widget type that carries no persistable state.

Definition at line 2933 of file n_gui.c.

References _apply_pending_widget(), _find_widget_window(), key, n_gui_get_widget(), N_GUI_WIDGET::persist_key, and N_GUI_WINDOW::title.

Referenced by build_window(), and main().

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

◆ n_gui_widget_set_rect()

void n_gui_widget_set_rect ( N_GUI_CTX * ctx,
int widget_id,
float x,
float y,
float w,
float h )

move/resize a widget after creation, refreshing the normalized coordinates the resize passes read.

For hosts that compute their own layout; the owning window is found open or closed, so hidden tab pages can be laid out too

move/resize a widget after creation, refreshing the normalized coordinates the resize passes read.

Widgets are placed by the n_gui_add_* call that creates them, which is all a static dialog needs. A host that computes its own layout (a resizable panel, the two sides of a split pane) has to place them again on every relayout, and reaching into N_GUI_WIDGET from application code would skip the normalized coordinates the resize passes read.

The rectangle is applied and the widget's norms are recaptured against its window, so n_gui_apply_adaptive_resize and n_gui_window_set_rect keep scaling it correctly from its new position. The owning window is found whether it is open or closed, so the pages of a tab panel can be laid out while hidden.

Parameters
ctxthe GUI context
widget_idthe widget to place
xnew x, relative to the window's content area
ynew y, relative to the window's content area
wnew width (negative is clamped to 0)
hnew height (negative is clamped to 0)

Definition at line 3854 of file n_gui.c.

References __n_assert, _n_gui_widget_capture_normalized(), N_GUI_CTX::dirty, h(), N_GUI_WIDGET::h, N_GUI_WIDGET::id, list_foreach, n_gui_get_widget(), N_GUI_WIDGET::w, N_GUI_WINDOW::widgets, N_GUI_CTX::windows, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.

Referenced by _grid_place(), _popup_show_level(), and 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 2582 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(), n_gui_draw(), and n_gui_draw_detached().

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

◆ n_gui_window_attach()

int n_gui_window_attach ( N_GUI_CTX * ctx,
int window_id )

return a detached window to being an in-display pop-up

Parameters
ctxthe GUI context
window_idthe window to re-attach
Returns
0 on success (or if the window was not detached), -1 on error

return a detached window to being an in-display pop-up

Definition at line 1776 of file n_gui.c.

References __n_assert, _n_gui_widget_capture_normalized(), _release_native_window(), N_GUI_WINDOW::flags, N_GUI_WINDOW::h, list_foreach, LOG_DEBUG, LOG_ERR, n_gui_get_window(), n_log, N_GUI_WINDOW::native, N_GUI_WINDOW::saved_flags, N_GUI_WINDOW::saved_h, N_GUI_WINDOW::saved_w, N_GUI_WINDOW::saved_x, N_GUI_WINDOW::saved_y, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_WINDOW::title, N_GUI_WINDOW::w, N_GUI_WINDOW::want_native, N_GUI_WINDOW::widgets, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.

Referenced by main(), on_attach_all(), and on_toggle_detach().

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 2534 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_button_rect()

int n_gui_window_button_rect ( N_GUI_CTX * ctx,
int window_id,
int btn_type,
float * x,
float * y,
float * w,
float * h )

Where one of a window's title bar buttons is, on screen.

The close cross and its neighbours are drawn by the toolkit from the window's flags and the style, so nothing outside can work out where they are. A test that has to press one, or an application that wants to put something beside them, asks here.

Parameters
ctxthe GUI context
window_idthe window
btn_typeN_GUI_TB_BTN_MINIMIZE, _MAXIMIZE or _CLOSE
xreceives the left edge, may be NULL
yreceives the top edge, may be NULL
wreceives the width, may be NULL
hreceives the height, may be NULL
Returns
1 when that window has that button, 0 otherwise, in which case nothing is written.

Definition at line 2108 of file n_gui.c.

References __n_assert, _tb_button_rect(), h(), n_gui_get_window(), and N_GUI_CTX::style.

Here is the call graph for this function:

◆ n_gui_window_detach()

int n_gui_window_detach ( N_GUI_CTX * ctx,
int window_id,
int detach_flags )

promote a pop-up window to a native OS window

Creates an ALLEGRO_DISPLAY sized to the window's body, registers its event source in the context's event queue, and moves the window to (0,0) inside it. The window is forced frameless: the OS supplies the title bar, so dragging, resizing, minimising and maximising are handled by the window manager and the window's own title bar buttons are no longer drawn. The window's title becomes the OS window title.

The host must call n_gui_draw_detached() once per frame to render and flip the native windows, and keep feeding every event to n_gui_process_event(), which routes each one to the display it came from.

Parameters
ctxthe GUI context. An event queue must have been set.
window_idthe window to detach
detach_flagsbitmask of N_GUI_DETACH_* options
Returns
0 on success (or if the window was already detached), -1 on error

promote a pop-up window to a native OS window

Definition at line 1639 of file n_gui.c.

References __n_assert, _n_gui_widget_capture_normalized(), _win_tbh(), N_GUI_WINDOW::caption, N_GUI_WINDOW::detach_flags, N_GUI_CTX::event_queue, N_GUI_WINDOW::flags, N_GUI_WINDOW::h, N_GUI_TB_BUTTONS::hovered, list_foreach, LOG_DEBUG, LOG_ERR, N_GUI_WINDOW::min_h, N_GUI_WINDOW::min_w, N_GUI_DETACH_OWN_CHROME, N_GUI_DETACH_RESIZABLE, n_gui_get_window(), N_GUI_TB_BTN_NONE, N_GUI_WIN_DRAGGING, N_GUI_WIN_FRAMELESS, N_GUI_WIN_HSCROLL_DRAG, N_GUI_WIN_HSCROLL_HOVER, N_GUI_WIN_MAXIMISED, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WIN_RESIZING, N_GUI_WIN_VSCROLL_DRAG, N_GUI_WIN_VSCROLL_HOVER, n_log, N_GUI_WINDOW::native, N_GUI_WINDOW::native_close_pending, N_GUI_WINDOW::native_drag_anchored, N_GUI_WINDOW::native_h, N_GUI_WINDOW::native_pos_x, N_GUI_WINDOW::native_pos_y, N_GUI_WINDOW::native_w, N_GUI_TB_BUTTONS::pressed, N_GUI_WINDOW::saved_flags, N_GUI_WINDOW::saved_h, N_GUI_WINDOW::saved_w, N_GUI_WINDOW::saved_x, N_GUI_WINDOW::saved_y, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_WINDOW::state, N_GUI_WINDOW::tb_buttons, N_GUI_WINDOW::title, N_GUI_WINDOW::w, N_GUI_WINDOW::want_native, N_GUI_WINDOW::widgets, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.

Referenced by main(), n_gui_load_layout_json(), n_gui_open_window(), on_detach_all(), and on_toggle_detach().

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

◆ n_gui_window_find_button()

int n_gui_window_find_button ( N_GUI_CTX * ctx,
int window_id,
const char * label )

Find the button in a window whose label is exactly this.

For the case where a window's widgets were built by a helper that did not hand every id back, and for a test that has to press "the Close button" of every window without knowing any of them by number.

Parameters
ctxthe GUI context
window_idthe window to look in
labelthe label to match, case sensitive
Returns
The widget id, or -1 when the window has no such button.

Definition at line 2135 of file n_gui.c.

References __n_assert, N_GUI_WIDGET::data, N_GUI_WIDGET::id, list_foreach, n_gui_get_window(), N_GUI_TYPE_BUTTON, N_GUI_WIDGET::type, and N_GUI_WINDOW::widgets.

Here is the call graph for this function:

◆ n_gui_window_from_display()

int n_gui_window_from_display ( N_GUI_CTX * ctx,
ALLEGRO_DISPLAY * display )

find the window detached into a given display

Returns
the window id, or -1 when no detached window owns display

find the window detached into a given display

Definition at line 1830 of file n_gui.c.

References __n_assert, display, N_GUI_WINDOW::id, list_foreach, N_GUI_WINDOW::native, and N_GUI_CTX::windows.

Referenced by main().

Here is the caller graph for this function:

◆ n_gui_window_get_display()

ALLEGRO_DISPLAY * n_gui_window_get_display ( N_GUI_CTX * ctx,
int window_id )

get the native display backing a window, or NULL when it is a pop-up

get the native display backing a window, or NULL when it is a pop-up

Definition at line 1818 of file n_gui.c.

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

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 2524 of file n_gui.c.

References N_GUI_WINDOW::flags, and n_gui_get_window().

Referenced by main().

Here is the call graph for this function:
Here is the caller 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 12145 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 2468 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 2478 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_detached()

int n_gui_window_is_detached ( N_GUI_CTX * ctx,
int window_id )

check whether a window currently lives in a native OS window

check whether a window currently lives in a native OS window

Definition at line 1809 of file n_gui.c.

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

Referenced by main(), on_detach_all(), on_toggle_detach(), and refresh_buttons().

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

◆ n_gui_window_is_maximised()

int n_gui_window_is_maximised ( N_GUI_CTX * ctx,
int window_id )

check if a window is currently maximised

check if a window is currently maximised

Returns
1 if maximised, 0 if not (or invalid id)

Definition at line 1574 of file n_gui.c.

References __n_assert, n_gui_get_window(), N_GUI_WIN_MAXIMISED, and N_GUI_WINDOW::state.

Here is the call graph for this function:

◆ n_gui_window_is_minimised()

int n_gui_window_is_minimised ( N_GUI_CTX * ctx,
int window_id )

check if a window is currently minimised

check if a window is currently minimised

Parameters
ctxthe gui context
window_idthe id of the window to query
Returns
1 if the window is minimised, 0 otherwise (or on a bad id)

Definition at line 1485 of file n_gui.c.

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

Referenced by main().

Here is the call graph for this function:
Here is the caller 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 2506 of file n_gui.c.

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

Referenced by level_window(), main(), n_gui_color_picker_is_open(), n_gui_popup_is_open(), n_gui_popup_press(), and on_windows_menu_open().

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

◆ n_gui_window_native_is_hidden()

int n_gui_window_native_is_hidden ( N_GUI_CTX * ctx,
int window_id )

check whether a detached window's drawing is currently halted by the OS (Android surface loss) or the window manager has iconified it.

A halted window is skipped by n_gui_draw_detached.

Returns
1 when the window is detached and not currently drawable, else 0

check whether a detached window's drawing is currently halted by the OS (Android surface loss) or the window manager has iconified it.

Definition at line 1878 of file n_gui.c.

References __n_assert, n_gui_get_window(), N_GUI_WINDOW::native, and N_GUI_WINDOW::native_halted.

Referenced by main().

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 2563 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 6591 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_caption()

void n_gui_window_set_caption ( N_GUI_CTX * ctx,
int window_id,
const char * caption )

show a caption in a window's title bar in place of its title, for a title that carries live state ("Export - 3 photographs").

The title stays the window's name in a saved layout, which matches windows by it, so a changing caption does not lose the window's saved place. A detached window's native title follows. NULL or "" shows the title again.

Parameters
ctxthe GUI context
window_idthe window
captionwhat to show, copied, cut to N_GUI_ID_MAX - 1 bytes

show a caption in a window's title bar in place of its title, for a title that carries live state ("Export - 3 photographs").

The title is left alone: it is the window's name in a saved layout.

Definition at line 2442 of file n_gui.c.

References __n_assert, N_GUI_WINDOW::caption, n_gui_get_window(), N_GUI_ID_MAX, N_GUI_WINDOW::native, and N_GUI_WINDOW::title.

Referenced by on_button_click().

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

◆ n_gui_window_set_close_callback()

void n_gui_window_set_close_callback ( N_GUI_CTX * ctx,
int window_id,
void(* on_close )(int, void *),
void * user_data )

set the close button callback for a window (NULL = default: hide window)

Parameters
ctxthe GUI context
window_idthe target window
on_closecallback receiving (window_id, user_data). Must call n_gui_close_window() itself if desired.
user_datauser data passed to the callback

set the close button callback for a window (NULL = default: hide window)

Definition at line 1889 of file n_gui.c.

References __n_assert, n_gui_get_window(), N_GUI_TB_BUTTONS::on_close, N_GUI_TB_BUTTONS::on_close_user_data, and N_GUI_WINDOW::tb_buttons.

Referenced by build_panel(), main(), n_gui_color_picker_free(), and n_gui_color_picker_new().

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

◆ n_gui_window_set_content_draw_callback()

void n_gui_window_set_content_draw_callback ( N_GUI_CTX * ctx,
int window_id,
void(* on_content_draw )(int, void *),
void * user_data )

set a content-draw callback for a window, invoked during n_gui_draw right after the window's own content is drawn (at the window's z-order)

Parameters
ctxthe GUI context
window_idthe target window
on_content_drawcallback receiving (window_id, user_data); NULL clears it
user_datauser data passed to the callback

set a content-draw callback for a window, invoked during n_gui_draw right after the window's own content is drawn (at the window's z-order)

The callback runs during n_gui_draw immediately after the window's own content is drawn, at the window's z-order, so any custom rendering it performs is occluded by windows that draw on top of this one.

Definition at line 1904 of file n_gui.c.

References __n_assert, n_gui_get_window(), N_GUI_WINDOW::on_content_draw, and N_GUI_WINDOW::on_content_draw_data.

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 2515 of file n_gui.c.

References N_GUI_WINDOW::flags, and n_gui_get_window().

Referenced by _popup_make_window(), build_panel(), main(), main(), main(), n_gui_color_picker_new(), and run().

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

◆ n_gui_window_set_maximize_callback()

void n_gui_window_set_maximize_callback ( N_GUI_CTX * ctx,
int window_id,
void(* on_maximize )(int, void *),
void * user_data )

set the maximize button callback for a window (NULL = default: toggle maximised)

Parameters
ctxthe GUI context
window_idthe target window
on_maximizecallback receiving (window_id, user_data)
user_datauser data passed to the callback

set the maximize button callback for a window (NULL = default: toggle maximised)

Definition at line 1926 of file n_gui.c.

References __n_assert, n_gui_get_window(), N_GUI_TB_BUTTONS::on_maximize, N_GUI_TB_BUTTONS::on_maximize_user_data, and N_GUI_WINDOW::tb_buttons.

Here is the call graph for this function:

◆ n_gui_window_set_minimize_callback()

void n_gui_window_set_minimize_callback ( N_GUI_CTX * ctx,
int window_id,
void(* on_minimize )(int, void *),
void * user_data )

set the minimize button callback for a window (NULL = default: toggle minimised)

Parameters
ctxthe GUI context
window_idthe target window
on_minimizecallback receiving (window_id, user_data)
user_datauser data passed to the callback

set the minimize button callback for a window (NULL = default: toggle minimised)

Definition at line 1915 of file n_gui.c.

References __n_assert, n_gui_get_window(), N_GUI_TB_BUTTONS::on_minimize, N_GUI_TB_BUTTONS::on_minimize_user_data, and N_GUI_WINDOW::tb_buttons.

Here is the call graph for this function:

◆ n_gui_window_set_native_icons()

int n_gui_window_set_native_icons ( N_GUI_CTX * ctx,
int window_id,
ALLEGRO_BITMAP ** icons,
int num_icons )

give a detached window's OS window a taskbar / title bar icon

Only meaningful while the window is detached, a pop-up has no OS window to put an icon on. Like every other bitmap N_GUI is handed, the bitmaps are BORROWED: Allegro copies what it needs at call time, but keep them alive for as long as you may re-apply them and destroy them yourself.

Parameters
ctxthe GUI context
window_ida detached window
iconsarray of bitmaps, ideally several sizes so the platform can pick
num_iconsnumber of entries in icons (1 is fine)
Returns
0 on success, -1 when the window does not exist or is not detached

give a detached window's OS window a taskbar / title bar icon

Definition at line 1856 of file n_gui.c.

References __n_assert, LOG_ERR, n_gui_get_window(), n_log, and N_GUI_WINDOW::native.

Referenced by main().

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

◆ n_gui_window_set_rect()

void n_gui_window_set_rect ( N_GUI_CTX * ctx,
int window_id,
float x,
float y,
float w,
float h )

move and resize a window at runtime, rescaling its child widgets from their normalized coordinates (what a split-pane divider drag or a collapsing panel needs, since the adaptive pass only runs on a display resize).

The window's own norms are recaptured against the current display size. Widget groups that lay themselves out (kvtable, tab panel, section list) cannot see this call: follow it with their own _relayout.

move and resize a window at runtime, rescaling its child widgets from their normalized coordinates (what a split-pane divider drag or a collapsing panel needs, since the adaptive pass only runs on a display resize).

The adaptive pass only runs on a display resize, so a host that resizes a window itself (a split-pane divider drag, a collapsing panel) had no way to make the widgets inside follow. This applies the new rectangle and rescales every child widget from its normalized coordinates, which every widget captures relative to its window when it is added, whatever the window's resize policy.

The window's own normalized geometry is recaptured against the current display size, so a later n_gui_apply_adaptive_resize keeps the proportions the caller just set instead of snapping back to the creation layout. Widget norms are left alone: they already describe the widgets relative to the window and are what this call reads.

Helper-owned widget groups do their own math from the window size and cannot see this call: after resizing a window that hosts one, also call n_gui_kvtable_relayout() / n_gui_tab_relayout() / n_gui_sectionlist_relayout().

Parameters
ctxthe GUI context
window_idthe window to move/resize
xnew window x
ynew window y
wnew window width (clamped to at least 1)
hnew window height (clamped to at least 1)

Definition at line 12196 of file n_gui.c.

References h(), and n_gui_window_set_rect_axes().

Referenced by _popup_show_level(), main(), and n_gui_color_picker_new().

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

◆ n_gui_window_set_rect_axes()

void n_gui_window_set_rect_axes ( N_GUI_CTX * ctx,
int window_id,
float x,
float y,
float w,
float h,
int scale_x,
int scale_y )

n_gui_window_set_rect with per-axis reflow control.

scale_y = 0 keeps the widgets' vertical layout, so a shorter window shows less of a page of fixed-height rows (and scrolls it, with N_GUI_WIN_AUTO_SCROLLBAR) instead of squeezing the rows; the width still tracks the window. The skipped axis's norms are refreshed from the kept pixel layout.

n_gui_window_set_rect with per-axis reflow control.

Stretching a window's widgets along both axes is right for a canvas or a body of text, and wrong for a stack of fixed-height rows: a settings page squeezed into a short pane ends up with 9-pixel rows instead of a scrollbar. Passing scale_y = 0 keeps the widgets' vertical layout, so a shorter window simply shows less of the page (and scrolls it, with N_GUI_WIN_AUTO_SCROLLBAR) while its width still tracks the window. That is the same rule n_gui_kvtable applies to its rows.

The skipped axis keeps its normalized coordinates as they were, so the widgets stay where the host put them rather than drifting.

Parameters
ctxthe GUI context
window_idthe window to move/resize
xnew window x
ynew window y
wnew window width (clamped to at least 1)
hnew window height (clamped to at least 1)
scale_xnon-zero to rescale the widgets horizontally
scale_ynon-zero to rescale the widgets vertically

Definition at line 12223 of file n_gui.c.

References __n_assert, N_GUI_CTX::dirty, N_GUI_CTX::display_h, N_GUI_CTX::display_w, h(), N_GUI_WIDGET::h, N_GUI_WINDOW::h, list_foreach, n_gui_get_window(), 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_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(), n_gui_color_picker_open(), and n_gui_window_set_rect().

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 12132 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(), and main().

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

◆ n_gui_window_set_tb_btn_theme()

void n_gui_window_set_tb_btn_theme ( N_GUI_CTX * ctx,
int window_id,
N_GUI_THEME theme )

set the theme for titlebar minimize/maximize buttons on a specific window

set the theme for titlebar minimize/maximize buttons on a specific window

Definition at line 1937 of file n_gui.c.

References __n_assert, N_GUI_TB_BUTTONS::btn_theme, n_gui_get_window(), and N_GUI_WINDOW::tb_buttons.

Here is the call graph for this function:

◆ n_gui_window_set_tb_button_bitmaps()

void n_gui_window_set_tb_button_bitmaps ( N_GUI_CTX * ctx,
int window_id,
int btn_type,
ALLEGRO_BITMAP * normal,
ALLEGRO_BITMAP * hover,
ALLEGRO_BITMAP * active )

set optional bitmap overlays on a titlebar button

Parameters
ctxthe GUI context
window_idthe target window
btn_typeN_GUI_TB_BTN_MINIMIZE, N_GUI_TB_BTN_MAXIMIZE, or N_GUI_TB_BTN_CLOSE
normalbitmap for normal state (NULL = color theme)
hoverbitmap for hover state (NULL = fallback to normal)
activebitmap for active/pressed state (NULL = fallback to normal)

set optional bitmap overlays on a titlebar button

Definition at line 1957 of file n_gui.c.

References __n_assert, N_GUI_TB_BUTTONS::close_active_bitmap, N_GUI_TB_BUTTONS::close_bitmap, N_GUI_TB_BUTTONS::close_hover_bitmap, N_GUI_TB_BUTTONS::maximize_active_bitmap, N_GUI_TB_BUTTONS::maximize_bitmap, N_GUI_TB_BUTTONS::maximize_hover_bitmap, N_GUI_TB_BUTTONS::minimize_active_bitmap, N_GUI_TB_BUTTONS::minimize_bitmap, N_GUI_TB_BUTTONS::minimize_hover_bitmap, n_gui_get_window(), N_GUI_TB_BTN_CLOSE, N_GUI_TB_BTN_MAXIMIZE, N_GUI_TB_BTN_MINIMIZE, and N_GUI_WINDOW::tb_buttons.

Referenced by main().

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

◆ n_gui_window_set_tb_close_theme()

void n_gui_window_set_tb_close_theme ( N_GUI_CTX * ctx,
int window_id,
N_GUI_THEME theme )

set the theme for the titlebar close button on a specific window

set the theme for the titlebar close button on a specific window

Definition at line 1947 of file n_gui.c.

References __n_assert, N_GUI_TB_BUTTONS::close_theme, n_gui_get_window(), and N_GUI_WINDOW::tb_buttons.

Here is the call graph for this function:

◆ n_gui_window_set_wheel_scrollbar()

void n_gui_window_set_wheel_scrollbar ( N_GUI_CTX * ctx,
int window_id,
int scrollbar_id )

make the wheel anywhere over a window move one of its scrollbars, for a window that scrolls its own rows with a scrollbar widget rather than with N_GUI_WIN_AUTO_SCROLLBAR (a fixed set of rows refilled from an offset).

Without it the wheel moves that scrollbar only with the pointer on it. A widget under the pointer that takes the wheel (a list, a slider) still takes it first; the scrollbar moves as if the wheel were turned over it, and its on_scroll callback is called.

Parameters
ctxthe GUI context
window_idthe window
scrollbar_ida scrollbar widget of that window, or -1 for none

make the wheel anywhere over a window move one of its scrollbars, for a window that scrolls its own rows with a scrollbar widget rather than with N_GUI_WIN_AUTO_SCROLLBAR (a fixed set of rows refilled from an offset).

Definition at line 2458 of file n_gui.c.

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

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, N_GUI_ZORDER_POPUP
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 2403 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_GUI_ZORDER_POPUP, n_log, N_GUI_WINDOW::z_order, and N_GUI_WINDOW::z_value.

Referenced by _popup_make_window(), main(), and n_gui_color_picker_new().

Here is the call graph for this function:
Here is the caller 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 12158 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: