![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows. More...
#include "nilorea/n_gui.h"#include "nilorea/n_gui_md.h"#include "nilorea/n_clipboard.h"#include "nilorea/n_wrap.h"#include <limits.h>#include "cJSON.h"#include <fcntl.h>#include <unistd.h>Go to the source code of this file.
Data Structures | |
| struct | _N_GUI_SB_SKIN |
| The look of one scrollbar: the style values a bar's paint reads, gathered so that the painter does not have to know which set of them it was handed. More... | |
| struct | _N_GUI_TA_STEP |
| one step of a textarea's per-character wrapped layout More... | |
| struct | _N_GUI_THUMB |
| a scrollbar thumb: length along the track, and offset from the track start More... | |
| struct | _N_GUI_WRAP_ACC |
| accumulator for _wrap_words: records the first word index of each line, and whether the line ends a paragraph More... | |
| struct | N_GUI_KV_CONTENT |
| struct | N_GUI_MEAS_ENTRY |
| struct | N_GUI_SUGGEST_SINK |
| handle textarea key input. More... | |
| struct | SYNTAX_RUN |
| draw a run of text and advance the pen x by its width. More... | |
Macros | |
| #define | _N_GUI_HELD_ALT 0x10 |
| #define | _N_GUI_HELD_ALTGR 0x20 |
| #define | _N_GUI_HELD_LCTRL 0x01 |
| bits of N_GUI_CTX::held_modifier_keys, one per modifier key | |
| #define | _N_GUI_HELD_LSHIFT 0x04 |
| #define | _N_GUI_HELD_RCTRL 0x02 |
| #define | _N_GUI_HELD_RSHIFT 0x08 |
| #define | _N_GUI_TREE_DRAG_THRESHOLD_PX 4.0f |
| pixels of mouse movement before a press becomes a drag | |
| #define | _N_GUI_WIN_STATE_PERSIST_MASK (N_GUI_WIN_OPEN | N_GUI_WIN_MINIMISED | N_GUI_WIN_MAXIMISED) |
| #define | N_GUI_ANIM_TAIL_SEC 0.05 |
| #define | N_GUI_COLRESIZE_GRAB 4.0f |
| grab zone, in pixels either side of a column's right border | |
| #define | N_GUI_KEY_PRESS_FLASH_SEC 0.12 |
| #define | N_GUI_MEAS_CACHE_SIZE 1024u /* power of two */ |
| #define | N_GUI_MEAS_KEY_MAX 32 /* strings this long or longer bypass the cache */ |
| #define | N_GUI_WRAP_MAX_ITEMS (3 * N_GUI_WRAP_MAX_WORDS + 2) |
| most layout items one wrap takes: every word, the break between each two, and room for the hard breaks of a text with blank lines in it | |
| #define | N_GUI_WRAP_MAX_WORDS 256 |
| the most words any justified layout will consider | |
Functions | |
| static void | _apply_cursor (N_GUI_CTX *ctx, int shape, ALLEGRO_MOUSE_CURSOR *custom) |
| helper: show a cursor on the GUI's display, recording it whether or not there is a display, and touching Allegro only when it changes. | |
| static void | _apply_pending_widget (N_GUI_CTX *ctx, const char *title, const N_GUI_WIDGET *wgt) |
| static ALLEGRO_COLOR | _bg_for_state (const N_GUI_THEME *t, int state) |
| helper: pick colour based on widget state | |
| static ALLEGRO_COLOR | _border_for_state (const N_GUI_THEME *t, int state) |
| static void | _button_key_press (N_GUI_CTX *ctx, N_GUI_WIDGET *wgt) |
| Press a button from the keyboard, as a click would. | |
| static int | _button_neighbour (N_GUI_CTX *ctx, const N_GUI_WIDGET *from, int forward) |
| The button before or after one, in its window, in reading order. | |
| static int | _button_takes_key (int keycode) |
| helper: is a key one a focused button does something with: Enter and Space press it, the arrows move to the next button of its window | |
| static int | _cell_cmp (const char *a, const char *b) |
| compare two cell strings: numerically when both are integers, else case-insensitive | |
| static int | _cell_is_num (const char *s) |
| true when every character of a non-empty string is a decimal digit | |
| static double | _clamp (double v, double lo, double hi) |
| helper: clamp a double between lo and hi | |
| static void | _clear_syntaxview_selection (N_GUI_CTX *ctx) |
| drop any active syntax-view text selection (used when focus moves to another selectable widget, so only one selection is live at a time). | |
| static ALLEGRO_COLOR | _color_mix (ALLEGRO_COLOR a, ALLEGRO_COLOR b, float t) |
Helper: mix two colours, t of the way from a to b. | |
| static ALLEGRO_COLOR | _color_with_alpha (ALLEGRO_COLOR c, float a) |
| Helper: return a copy of c with the given alpha (0..1). | |
| static float | _combobox_dropdown_width (N_GUI_CTX *ctx, const N_GUI_COMBOBOX_DATA *cd, ALLEGRO_FONT *font, float widget_w, float ax, float pad) |
| helper: the effective width of an open combobox dropdown panel. | |
| static int | _combobox_index_after_remove (int index, int removed) |
| shift an index that pointed into a list one item shorter now | |
| static void | _compute_gui_bounds (N_GUI_CTX *ctx) |
| helper: compute the bounding box of all open windows | |
| static ALLEGRO_DISPLAY * | _ctx_io_display (const N_GUI_CTX *ctx) |
| helper: the display to use for clipboard and mouse-cursor calls. | |
| static int | _custom_mouse (const N_GUI_CTX *ctx, N_GUI_WIDGET *wgt, int type, int button, float local_x, float local_y, int dz) |
| helper: hand a mouse event to a custom widget that takes them. | |
| static void | _datagrid_apply_columns (N_GUI_CTX *ctx, int widget_id, int ncols, const int *order, const int *visible, const float *width) |
| static N_GUI_DATAGRID_DATA * | _datagrid_data (N_GUI_CTX *ctx, int widget_id) |
| fetch a data grid's column table for an API call, or NULL on a bad id. | |
| static int | _datagrid_ensure_colors (N_GUI_DATAGRID_DATA *gd) |
| helper: ensure the per-row tint arrays exist, sized to rows_cap (rows start untinted); returns 1 when both arrays are available | |
| static void | _datagrid_ensure_sel (N_GUI_DATAGRID_DATA *gd) |
| helper: ensure the per-row selection array exists, sized to rows_cap | |
| static void | _datagrid_header_hit (const N_GUI_DATAGRID_DATA *gd, float ax, float x, int *border_col, int *cell_col) |
| helper: what a datagrid header row is offering at x. | |
| static void | _datagrid_hmetrics (const N_GUI_WIDGET *wgt, const N_GUI_DATAGRID_DATA *gd, ALLEGRO_FONT *font, const N_GUI_STYLE *style, float *content_w, float *pane_w, int *need_hsb) |
Compute the datagrid horizontal-scroll metrics used identically by the draw path and the mouse handlers, so the thumb geometry never drifts between them: content_w = left pad + the total width of the visible columns; pane_w = the viewport width available to the columns (widget width minus a vertical scrollbar when the rows overflow); need_hsb = 1 when the content is wider than the pane. | |
| static size_t | _datagrid_phys (const N_GUI_DATAGRID_DATA *gd, size_t dp) |
physical column index shown at display position dp (identity when no order). | |
| static int | _datagrid_resize_hover (N_GUI_CTX *ctx, float px, float py) |
| Whether the pointer at (px,py) rests on a datagrid column-resize border: the header row of a visible datagrid, within a few pixels of a visible column's right edge. | |
| static void | _destroy_widget (void *ptr) |
| static void | _destroy_window (void *ptr) |
| helper: destroy a single window (called by list destructor) | |
| static void | _draw_bitmap_scaled (ALLEGRO_BITMAP *bmp, float dx, float dy, float dw, float dh, int mode) |
| helper: draw a bitmap into a rectangle, respecting the given scale mode. | |
| static void | _draw_button (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, const N_GUI_STYLE *style) |
| static void | _draw_checkbox (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| draw a checkbox widget | |
| static void | _draw_cols_scrollbar (float ax, float bar_y, float track_w, float content_w, float h_scroll, N_GUI_SB_TRACK *track, const N_GUI_STYLE *style, const N_GUI_THEME *theme) |
draw a horizontal scrollbar along the bottom edge of a widget: track_w is the width of the scrollable pane (from ax), bar_y its top, content_w the total content width, h_scroll the current pixel offset, track the owning widget's N_GUI_SB_TRACK for this bar. | |
| static void | _draw_combobox (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, const N_GUI_STYLE *style) |
| draw a combobox widget (closed state) | |
| static void | _draw_combobox_dropdown (N_GUI_CTX *ctx) |
| static void | _draw_custom (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font) |
| draw a single widget. | |
| static void | _draw_datagrid (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| static void | _draw_dropmenu (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, const N_GUI_STYLE *style) |
| draw a dropdown menu button (closed state) | |
| static void | _draw_dropmenu_panel (N_GUI_CTX *ctx) |
| draw the dropdown menu panel overlay (called after all windows) | |
| static void | _draw_focus_outline (const N_GUI_WIDGET *wgt, float ox, float oy) |
| draw the keyboard focus outline over a widget that has the focus: a line just inside its edge, twice the theme's border and at least 2 pixels, in the theme's active border colour, so it follows the palette. | |
| static void | _draw_glyph (int glyph, float cx, float cy, float s, ALLEGRO_COLOR fg, ALLEGRO_COLOR bg, float thick) |
| draw a button widget | |
| static void | _draw_hexview (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| draw a read-only hex viewer: offset, hex bytes, and an ASCII gutter | |
| static void | _draw_image (N_GUI_WIDGET *wgt, float ox, float oy) |
| draw an image widget | |
| static void | _draw_justified_selection (ALLEGRO_FONT *font, float x, float y, float max_w, float max_h, const char *text, int sel_start, int sel_end, ALLEGRO_COLOR sel_color) |
| helper: draw selection highlight rectangles over justified/wrapped text. | |
| static void | _draw_label (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, float win_w, N_GUI_STYLE *style) |
| static void | _draw_label_lines (ALLEGRO_FONT *font, ALLEGRO_COLOR tc, float ax, float ay, float effective_w, float h, float pad, const N_GUI_LABEL_DATA *lb, ALLEGRO_COLOR sel_color) |
| helper: draw a LEFT, CENTER or RIGHT label whose text has line breaks, one line under another, each aligned and shortened on its own, with the selection highlighted line by line. | |
| static void | _draw_label_overflow (ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, float max_w, const N_GUI_LABEL_DATA *lb, const char *text) |
| helper: draw a label's text, or one line of it, that is too wide for it, shortened the way its truncate mode says. | |
| static void | _draw_listbox (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| draw a listbox widget | |
| static void | _draw_markdownview (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, const N_GUI_STYLE *style) |
| draw a sortable data grid: fixed header row plus scrollable data rows | |
| static void | _draw_progressbar (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| static void | _draw_radiolist (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, const N_GUI_STYLE *style) |
| draw a radiolist widget | |
| static void | _draw_rows_scrollbar (float ax, float ay, float w, float h, int nb_rows, int visible, int scroll_offset, N_GUI_SB_TRACK *track, const N_GUI_STYLE *style, const N_GUI_THEME *theme) |
| draw a row-indexed vertical scrollbar (shared by hexview, syntaxview, datagrid, listbox and radiolist) at the right edge of [ax,ay,w,h]. | |
| static void | _draw_scrollbar (N_GUI_WIDGET *wgt, float ox, float oy, const N_GUI_STYLE *style) |
| draw a scrollbar widget. | |
| static void | _draw_scrollbar_body (float bar_x, float bar_y, float bar_w, float bar_h, float thumb_off, float thumb_len, int vertical, int state, N_GUI_SB_TRACK *track, const _N_GUI_SB_SKIN *skin, const N_GUI_THEME *theme) |
| Draw one whole scrollbar: track, divider and thumb. | |
| static void | _draw_scrollbar_thumb (float x, float y, float w, float h, int state, const _N_GUI_SB_SKIN *skin, const N_GUI_THEME *theme) |
| Draw the thumb of a scrollbar, in the state its owner is in. | |
| static void | _draw_scrollbar_track (float bar_x, float bar_y, float bar_w, float bar_h, int vertical, int state, const _N_GUI_SB_SKIN *skin, const N_GUI_THEME *theme) |
| Draw the track of a scrollbar: the one look every bar shares. | |
| static void | _draw_slider (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| static void | _draw_splitpane (N_GUI_WIDGET *wgt, float ox, float oy) |
| draw a split pane: only the divider bar is painted (the app fills the two regions with its own widgets, positioned from the divider ratio) | |
| static void | _draw_syntaxview (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| static void | _draw_tb_buttons (N_GUI_WINDOW *win, const N_GUI_STYLE *style) |
| draw the titlebar buttons for a window | |
| static void | _draw_text_justified (ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, float max_w, float max_h, const char *text) |
| helper: draw justified text within a given width, with multi-line word wrapping. | |
| static void | _draw_text_truncated (ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, float max_w, const char *text) |
| helper: draw text truncated to a maximum pixel width. | |
| static void | _draw_textarea (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| draw a textarea widget | |
| static void | _draw_textarea_placeholder (const N_GUI_TEXTAREA_DATA *td, const N_GUI_WIDGET *wgt, ALLEGRO_FONT *font, float tx, float ty) |
| draw a textarea's placeholder/hint at (tx,ty), dimmed, while the field is empty; a no-op once any text has been entered or when no placeholder is set | |
| static void | _draw_textarea_suggest (N_GUI_CTX *ctx) |
| draw the open completion panel (called after all windows, with the other floating overlays) | |
| static void | _draw_themed_rect (N_GUI_THEME *t, int state, float x, float y, float w, float h, int rounded) |
| draw a themed rectangle or rounded rectangle. | |
| static void | _draw_tooltip (N_GUI_CTX *ctx) |
| helper: draw the hover-tooltip bubble for the currently armed tooltip widget, but ONLY in the render pass of the display that owns that widget's window. | |
| static void | _draw_widget (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, float win_w, N_GUI_STYLE *style) |
| static void | _draw_widget_vscrollbar (float area_x, float area_y, float area_w, float view_h, float content_h, float scroll_y, N_GUI_SB_TRACK *track, const N_GUI_STYLE *style, const N_GUI_THEME *theme) |
| helper: draw a mini vertical scrollbar inside a widget, at the right edge of the area [area_x . | |
| static void | _draw_window (N_GUI_WINDOW *win, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| draw a window chrome + its widgets | |
| static float | _dropdown_panel_y (const N_GUI_CTX *ctx, float widget_top, float widget_bottom, float panel_h, int expand_up) |
| draw the combobox dropdown overlay (called after all windows) | |
| static int | _dropmenu_entries_grow (N_GUI_DROPMENU_ENTRY **entries, const size_t *nb, size_t *cap) |
| helper: ensure dropmenu entries array has room for one more | |
| static ALLEGRO_DISPLAY * | _event_display (const ALLEGRO_EVENT *event) |
| helper: the display an event originates from, or NULL when the event carries no display (timer, user and joystick events) or the field is unset, as in the headless tests that synthesize events with memset. | |
| static N_GUI_WINDOW * | _find_focused_window (N_GUI_CTX *ctx) |
| helper: find the window containing a focused widget | |
| static const N_GUI_WIDGET * | _find_widget_const (const N_GUI_CTX *ctx, int widget_id) |
| find a widget without a non-const context, for the queries that only read | |
| static N_GUI_WINDOW * | _find_widget_window (N_GUI_CTX *ctx, int wgt_id, float *ox, float *oy) |
| helper: find the parent window of a widget by id, returning the window's content origin (accounting for scroll offsets). | |
| static LIST_NODE * | _find_window_node (N_GUI_CTX *ctx, int window_id) |
| helper: find a window node in the context list by id | |
| static void | _global_scroll_needs (const N_GUI_CTX *ctx, float eff_w, float eff_h, int *need_v, int *need_h) |
| helper: which global scrollbars the open windows need in a view of eff_w by eff_h, from the bounds _compute_gui_bounds() left. | |
| static FILE * | _gui_fopen_write (const char *path, const char *mode) |
| static int | _held_bit (int keycode) |
| the held-key bit of a key code, 0 for a key that is not a modifier | |
| static int | _hexview_digit (int keycode, int unichar) |
| the value of a hex digit key (0-15), or -1 when the key is not one. | |
| static int | _hexview_erase (N_GUI_HEXVIEW_DATA *hd, size_t at) |
| remove the byte at at from an editable hex view. | |
| static int | _hexview_handle_key (N_GUI_WIDGET *wgt, const ALLEGRO_EVENT *ev, int visible_rows) |
| handle one key for a focused editable hex view. | |
| static int | _hexview_insert (N_GUI_HEXVIEW_DATA *hd) |
| insert one zero byte before the cursor of an editable hex view. | |
| static int | _hexview_reserve (N_GUI_HEXVIEW_DATA *hd, size_t need) |
| grow an editable hex view's buffer so it can hold at least need bytes. | |
| static void | _hexview_reveal (N_GUI_HEXVIEW_DATA *hd, int visible_rows) |
| scroll an editable hex view so its cursor row is visible | |
| static int | _is_focusable_type (int type) |
| helper: check if a widget type takes keys once it has focus. | |
| static int | _is_tab_focusable_type (int type) |
| helper: check if a widget type is reached by Tab and Shift+Tab: every widget that takes keys, and the buttons, which Enter or Space presses once they have focus. | |
| static int | _items_grow (N_GUI_LISTITEM **items, const size_t *nb, size_t *cap) |
| helper: ensure items array has room for one more, returns 1 on success | |
| static void | _json_add_color (cJSON *parent, const char *name, ALLEGRO_COLOR c) |
| helper: add an RGBA colour as a JSON array [r,g,b,a] (0-255) | |
| static ALLEGRO_COLOR | _json_get_color (cJSON *parent, const char *name, ALLEGRO_COLOR fallback) |
| helper: read an RGBA colour from a JSON array [r,g,b,a] | |
| static float | _json_get_float (cJSON *parent, const char *name, float fallback) |
| helper: read a float from JSON, return fallback if missing | |
| static int | _json_get_int (cJSON *parent, const char *name, int fallback) |
| helper: read an int from JSON, return fallback if missing | |
| static int | _justified_char_at_pos (const char *text, ALLEGRO_FONT *font, float max_w, float text_x, float text_y, float scroll_y, float click_mx, float click_my) |
| helper: find the byte offset in justified text closest to a click position. | |
| static int | _key_navigates (int keycode) |
| is this one of the keys that move through a widget rather than type into it: the arrows, the page keys, Home, End and Enter | |
| static int | _label_char_at_x (const N_GUI_LABEL_DATA *lb, ALLEGRO_FONT *font, float click_x) |
| draw a label widget. | |
| static float | _label_content_height (const char *text, ALLEGRO_FONT *font, float max_w) |
| forward declaration: height the wrapped text of a justified label needs at a given width. | |
| static float | _label_effective_w (const N_GUI_LABEL_DATA *lb, ALLEGRO_FONT *font, float wgt_w, float win_w, float wgt_x, float label_padding) |
| helper: the width a LEFT, CENTER or RIGHT label lays its text out in. | |
| static int | _label_line_at (const char *text, int index, char *out, size_t out_len) |
helper: line index of text, copied into out without its break. | |
| static int | _label_line_count (const char *text) |
| forward declarations: the lines of a label whose text has line breaks, used by n_gui_label_fits(). | |
| static float | _label_line_x (const N_GUI_LABEL_DATA *lb, float line_w, float ax, float effective_w, float pad) |
| helper: where a line of a multi-line label starts on screen, by the label's alignment. | |
| static int | _label_lines_char_at (const N_GUI_LABEL_DATA *lb, ALLEGRO_FONT *font, float ax, float ay, float effective_w, float h, float pad, float mx, float my) |
| helper: the byte offset in a multi-line label closest to a click. | |
| static float | _label_lines_top (float ay, float h, int lines, float fh) |
| helper: the top of a multi-line label's first line: the block of lines centred in the box as a single line is, and never above the box. | |
| static float | _label_text_origin_x (const N_GUI_LABEL_DATA *lb, ALLEGRO_FONT *font, float ax, float wgt_w, float win_w, float wgt_x, float label_padding) |
| helper: compute the screen-space x origin where label text starts, accounting for alignment. | |
| static float | _label_wrap_w (const N_GUI_WIDGET *wgt, const N_GUI_STYLE *style) |
| forward declaration: the width a justified label wraps its text to. | |
| static void | _list_panel_highlight_step (int *highlight, int *scroll, int nb, int max_visible, int delta, int fallback) |
helper: move an open list panel's highlight cursor (combobox / dropmenu) by delta items and scroll the visible window so the highlighted item stays in view. | |
| static void | _list_panel_wheel (int *highlight, int *scroll, int nb, int max_visible, int notches, int row) |
| helper: the mouse wheel over an open list panel (combobox / dropmenu). | |
| static void | _listbox_clamp_h (N_GUI_LISTBOX_DATA *ld, float content_w, float pane_w) |
| clamp a listbox's horizontal scroll to the room its content actually needs | |
| static void | _listbox_hmetrics (const N_GUI_WIDGET *wgt, const N_GUI_LISTBOX_DATA *ld, ALLEGRO_FONT *font, const N_GUI_STYLE *style, float *content_w, float *pane_w, int *need_hsb, int *visible) |
| Listbox horizontal-scroll metrics, computed identically by the draw path and the mouse handlers so the thumb and the hit test never drift apart. | |
| static void | _markdownview_follow_theme (N_GUI_WIDGET *wgt, N_GUI_MARKDOWNVIEW_DATA *md) |
| Re-derive the view's colours from the widget's theme, while the caller has not taken the style over. | |
| static float | _markdownview_measure (const N_GUI_WIDGET *wgt, N_GUI_MARKDOWNVIEW_DATA *md, const N_GUI_STYLE *style) |
| Measure the document if anything it depends on has changed, and clamp the scroll to what is left. | |
| static N_GUI_MARKDOWNVIEW_DATA * | _markdownview_of (N_GUI_CTX *ctx, int widget_id) |
| The view's data, or NULL when that widget is not one. | |
| static float | _markdownview_text_w (const N_GUI_WIDGET *wgt, const N_GUI_MARKDOWNVIEW_DATA *md, const N_GUI_STYLE *style, int with_bar) |
| The width the document is laid out at: the widget less its padding, and less the bar when there is one. | |
| static float | _min_thickness (float requested) |
| helper: compute minimum line thickness so it stays >= 1 physical pixel. | |
| static void | _n_gui_apply_display_size (N_GUI_CTX *ctx, float w, float h) |
| Draw all visible windows and their widgets. | |
| static int | _n_gui_kv_active_order (const N_GUI_KVTABLE *table, int *out) |
| static void | _n_gui_kv_add_clicked (int widget_id, void *user_data) |
| static void | _n_gui_kv_apply_layout (N_GUI_KVTABLE *table) |
| static void | _n_gui_kv_content_free (N_GUI_KV_CONTENT *c) |
| static void | _n_gui_kv_content_grab (N_GUI_KVTABLE *table, int idx, N_GUI_KV_CONTENT *out) |
| static void | _n_gui_kv_content_put (N_GUI_KVTABLE *table, int idx, const N_GUI_KV_CONTENT *in) |
| static void | _n_gui_kv_down_clicked (int widget_id, void *user_data) |
| static void | _n_gui_kv_dup_clicked (int widget_id, void *user_data) |
| static char * | _n_gui_kv_dup_text (N_GUI_CTX *ctx, int widget_id) |
| static void | _n_gui_kv_refresh_actions (N_GUI_KVTABLE *table) |
| static void | _n_gui_kv_remove_clicked (int widget_id, void *user_data) |
| static void | _n_gui_kv_split_a_changed (int widget_id, float ratio, void *user_data) |
| static void | _n_gui_kv_split_b_changed (int widget_id, float ratio, void *user_data) |
| static void | _n_gui_kv_up_clicked (int widget_id, void *user_data) |
| static void | _n_gui_sectionlist_header_clicked (int widget_id, void *user_data) |
| static void | _n_gui_sectionlist_set_header_label (N_GUI_SECTIONLIST *sl, int idx) |
| static int | _n_gui_sectionlist_slot (const N_GUI_SECTIONLIST *sl, int section_index, int widget_id) |
| static void | _n_gui_tab_button_clicked (int widget_id, void *user_data) |
| static void | _n_gui_tree_emit (N_GUI_TREE *tree, int parent) |
| helper: add the children of one node to the listbox, in order, then each expanded child's own children under it. | |
| static int | _n_gui_tree_hit_row (N_GUI_TREE *tree, float mx, float my, int *out_node_idx, int *out_drop_pos) |
| Hit-test the mouse against the listbox's visible rows and fill the out params. | |
| static int | _n_gui_tree_listbox_bounds (N_GUI_TREE *tree, float *out_x, float *out_y, float *out_w, float *out_h, float *out_item_area_w, float *out_inset, float *out_item_h, int *out_scroll_off) |
| Return the listbox's absolute (screen-space) bounds and geometry via out params. | |
| static void | _n_gui_tree_listbox_selected (int widget_id, int index, int selected, void *user_data) |
| static int | _n_gui_tree_open (N_GUI_TREE *tree, int node_index) |
| helper: open a node, calling the expand callback first when it has not filled this node yet. | |
| static void | _n_gui_widget_capture_normalized (const N_GUI_WINDOW *win, N_GUI_WIDGET *wgt) |
| capture normalized coords for a single widget relative to its parent window | |
| static void | _n_gui_window_capture_normalized (const N_GUI_CTX *ctx, N_GUI_WINDOW *win) |
| capture normalized coords for a window and its widgets from current absolutes | |
| static void | _native_apply_minimised (N_GUI_WINDOW *win) |
| helper: mirror an own-chrome window's minimised state onto its OS window by shrinking the display to the title bar and growing it back. | |
| static void | _native_drag_begin (N_GUI_WINDOW *win) |
| helper: anchor an own-chrome window's title bar drag on the desktop cursor. | |
| static int | _native_monitor_info (ALLEGRO_DISPLAY *display, ALLEGRO_MONITOR_INFO *info) |
| helper: the monitor rectangle a native window sits on. | |
| static int | _native_own_chrome (const N_GUI_WINDOW *win) |
| helper: whether a window is detached AND keeps drawing its own chrome (N_GUI_DETACH_OWN_CHROME). | |
| static N_GUI_WIDGET * | _new_widget (N_GUI_CTX *ctx, int type, float x, float y, float w, float h) |
| helper: allocate and initialise a base widget | |
| static char * | _ngui_clip_get (ALLEGRO_DISPLAY *display, int which) |
| static void | _ngui_clip_set (ALLEGRO_DISPLAY *display, int which, const char *text) |
| static N_GUI_MEAS_ENTRY * | _ngui_meas_slot (ALLEGRO_FONT *font, const char *text, size_t len) |
| find (or claim) the cache slot for (font, text[len]). | |
| static void | _ngui_publish_primary_selection (N_GUI_CTX *ctx) |
| publish the active text selection (syntax view, label, or focused textarea) to the X11 PRIMARY selection, implementing select-to-copy: selecting text with the mouse or keyboard makes it available for a middle-click paste, without disturbing CLIPBOARD. | |
| static void | _normalize_crlf (char *s) |
| helper: strip CR from a string in-place, normalizing CRLF to LF. | |
| static int | _opt_rounded (const N_GUI_STYLE *style) |
| the widget types that have no shape of their own (textarea, checkbox, a frameless window's body, the combobox dropdown) round only when the context ASKS for a round GUI: their square look is every existing program's default, and must not change under it. | |
| static int | _point_in_rect (float px, float py, float rx, float ry, float rw, float rh) |
| helper: test if point is inside a rectangle | |
| static int | _pointer_over_window (const N_GUI_CTX *ctx, float px, float py) |
| helper: is the pointer over any open window that takes part in the current pass? | |
| static int | _reading_order (const N_GUI_WIDGET *a, const N_GUI_WIDGET *b) |
| Which of two widgets comes first in reading order. | |
| static void | _register_widget (N_GUI_CTX *ctx, N_GUI_WIDGET *w) |
| helper: register a widget in the hash table | |
| static void | _release_native_window (N_GUI_CTX *ctx, N_GUI_WINDOW *win) |
| forward declaration: unregister and destroy a window's native display, leaving the window's geometry untouched (see the native window section) | |
| static _N_GUI_SB_SKIN | _sb_skin (const N_GUI_STYLE *style) |
| helper: the skin of a bar belonging to a widget or a window. | |
| static _N_GUI_SB_SKIN | _sb_skin_global (const N_GUI_STYLE *style) |
| helper: the skin of one of the display's own bars, which scroll the whole virtual canvas rather than anything inside it. | |
| static int | _sb_track_hit (const N_GUI_SB_TRACK *track, float mx, float my) |
| helper: is the pointer inside a bar's last painted rectangle. | |
| static float | _scrollbar_calc_scroll (float mouse, float track_start, float track_length, float viewport, float content, float thumb_min) |
| helper: compute scroll position from mouse coordinate using thumb-aware math. | |
| static int | _scrollbar_calc_scroll_int (float mouse, float track_start, float track_length, int visible_items, int total_items, float thumb_min) |
| helper: integer variant of _scrollbar_calc_scroll for item-based widgets. | |
| static ALLEGRO_COLOR | _scrollbar_edge_for_state (const N_GUI_THEME *t, int state) |
| helper: the colour of the outline round a scrollbar's thumb, for the state of the bar. | |
| static _N_GUI_THUMB | _scrollbar_thumb (float track_len, float visible, float content, float offset, float min_len) |
| helper: where a scrollbar thumb sits and how long it is. | |
| static ALLEGRO_COLOR | _scrollbar_thumb_for_state (ALLEGRO_COLOR at_rest, const N_GUI_THEME *t, int state) |
| helper: the fill of a scrollbar thumb, for the state of the bar. | |
| static void | _scrollbar_update_from_mouse (N_GUI_WIDGET *wgt, float mx, float my, float win_x, float win_content_y, const N_GUI_STYLE *style) |
| handle scrollbar drag | |
| static int | _scrollbar_wheel (N_GUI_WIDGET *wgt, int dz) |
| helper: turn the wheel over a scrollbar: its wheel step per notch, a twentieth of its range when it has none, clamped, its on_scroll called. | |
| static ALLEGRO_BITMAP * | _select_state_bitmap (int state, ALLEGRO_BITMAP *normal_bmp, ALLEGRO_BITMAP *hover_bmp, ALLEGRO_BITMAP *active_bmp) |
| helper: select per-state bitmap with fallback chain. | |
| static void | _set_clipping_rect_transformed (int wx, int wy, int ww, int wh) |
| helper: set clipping rectangle in world space, transforming to screen space. | |
| static int | _shape_rounded (const N_GUI_STYLE *style, int widget_shape) |
| resolve whether a shape-aware widget draws rounded: the global shape_mode override (style->shape_mode) wins when set to ROUNDED or RECT, otherwise the widget's own shape decides. | |
| static int | _shorten_start (ALLEGRO_FONT *font, const char *text, float max_w, char *out, size_t out_len) |
helper: "..." followed by the shortest tail of text, cut between UTF-8 sequences, that fits max_w. | |
| static float | _slider_handle_r (const N_GUI_WIDGET *wgt, const N_GUI_STYLE *style) |
| Radius of a slider's handle, from the widget's short side. | |
| static double | _slider_key_step (const N_GUI_SLIDER_DATA *sd) |
| how far one arrow key press or one wheel notch moves a slider | |
| static double | _slider_snap_value (double val, double min_val, double max_val, double step) |
| helper: snap a slider value to the nearest valid step from min_val. | |
| static void | _slider_travel (const N_GUI_WIDGET *wgt, const N_GUI_STYLE *style, float *start, float *length) |
| The strip a slider's handle centre travels along, inset by its radius at each end. | |
| static void | _slider_update_from_mouse (N_GUI_WIDGET *wgt, float mx, float my, float win_x, float win_content_y, const N_GUI_STYLE *style) |
| handle slider drag (horizontal or vertical) | |
| static void | _slider_value_text (const N_GUI_SLIDER_DATA *sd, double value, char *out, size_t out_len) |
| draw a slider widget (horizontal or vertical) | |
| static void | _sort_windows_by_zorder (N_GUI_CTX *ctx) |
| Sort windows list by z-order: ALWAYS_BEHIND first, then FIXED (by z_value), then NORMAL, then ALWAYS_ON_TOP, then POPUP. | |
| static int | _split_words (const char *text, ALLEGRO_FONT *font, int *starts, int *lens, float *widths, int max_words, int *nl_before) |
helper: split text into whitespace-separated words, recording each word's byte offset in text, its byte length and its pixel width. | |
| static int | _splitpane_cursor_hover (N_GUI_CTX *ctx, float px, float py) |
| report the split-pane divider under a point, for the mouse cursor shape: 0 = none, 1 = vertical divider (drags left/right), 2 = horizontal divider (drags up/down). | |
| static int | _splitpane_hit (N_GUI_CTX *ctx, float px, float py) |
| report the split pane whose divider band is under a point, or -1. | |
| static int | _splitpane_on_divider (const N_GUI_WIDGET *wgt, float px, float py, float ax, float ay) |
| forward declaration: test whether a point falls on a split pane's draggable divider band. | |
| static void | _suggest_accept (N_GUI_CTX *ctx, N_GUI_WIDGET *wgt) |
| put the highlighted completion in place of the word under the cursor | |
| static void | _suggest_close (N_GUI_CTX *ctx, N_GUI_WIDGET *wgt) |
| put the panel away, and forget which word it answered | |
| static int | _suggest_handle_key (N_GUI_CTX *ctx, N_GUI_WIDGET *wgt, ALLEGRO_EVENT *ev) |
| the keys a completion panel takes before the textarea sees them. | |
| static int | _suggest_is_sep (const N_GUI_TEXTAREA_DATA *td, char c) |
is c one of the characters that end a word in this field | |
| static int | _suggest_panel_rect (N_GUI_CTX *ctx, N_GUI_WIDGET *wgt, float *out_x, float *out_y, float *out_w, float *out_h, float *out_ih, int *out_vis) |
| the geometry of an open completion panel, so the draw and the pointer agree about where its rows are. | |
| static void | _suggest_refresh (N_GUI_CTX *ctx, N_GUI_WIDGET *wgt, int force) |
| ask the provider about the word under the cursor, and open or close the panel by what it answers. | |
| static void | _suggest_word (const N_GUI_TEXTAREA_DATA *td, size_t *start, size_t *end) |
| the word the cursor is in. | |
| static ALLEGRO_COLOR | _syntax_diff_add (void) |
| unified diff line colours. | |
| static ALLEGRO_COLOR | _syntax_diff_del (void) |
| see _syntax_diff_add: colour of a removed line | |
| static ALLEGRO_COLOR | _syntax_diff_hunk (void) |
| see _syntax_diff_add: colour of a hunk header line | |
| static void | _syntax_draw_line (ALLEGRO_FONT *font, N_GUI_THEME *th, float x, float y, const char *s, int n, int mode, int line_idx, int in_headers, float x_min, float x_max) |
| draw one text line with mode-specific highlighting starting at (x,y), inside the horizontal window [x_min,x_max] (see SYNTAX_RUN) | |
| static int | _syntax_js_keyword (const char *s, int n) |
| whether the n bytes at s form a JavaScript keyword or literal name | |
| static int | _syntax_js_regex_kw (const char *s, int n) |
| whether the n bytes at s are a keyword after which an expression (and therefore a regex literal) can start, e.g. | |
| static int | _syntax_js_regex_possible (char c) |
| whether a '/' may start a regex literal after last significant char c (start of line, after an operator, an opener, or a separator) | |
| static float | _syntax_prefix_w (ALLEGRO_FONT *font, const char *s, int n) |
| forward declaration: pixel width of the first n bytes of a line. | |
| static float | _syntax_prefix_w_lim (ALLEGRO_FONT *font, const char *s, int n, float limit) |
pixel width of the first n bytes of s in font, of any length: the measurement needs a NUL-terminated copy, so it accumulates over chunks of the same size _syntax_run draws in, which keeps the two in step. | |
| static void | _syntax_run (SYNTAX_RUN *r, ALLEGRO_COLOR col, const char *s, int len) |
| draw one coloured run of a syntax line and advance the pen past it. | |
| static void | _syntaxview_clamp_h (N_GUI_SYNTAXVIEW_DATA *yd, float content_w, float pane_w) |
| forward declaration: clamp a syntaxview's horizontal scroll to its content. | |
| static void | _syntaxview_ensure_lines (N_GUI_SYNTAXVIEW_DATA *yd) |
| forward declaration: (re)build a syntaxview's cached line count and headers-end index when stale. | |
| static void | _syntaxview_ensure_width (N_GUI_SYNTAXVIEW_DATA *yd, ALLEGRO_FONT *font, const N_GUI_STYLE *style) |
| forward declaration: (re)build a syntaxview's cached content width when stale. | |
| static void | _syntaxview_hmetrics (const N_GUI_WIDGET *wgt, N_GUI_SYNTAXVIEW_DATA *yd, ALLEGRO_FONT *font, const N_GUI_STYLE *style, float *content_w, float *pane_w, int *need_hsb, int *visible) |
| forward declaration: syntaxview horizontal-scroll metrics, shared by the draw path and every mouse handler. | |
| static int | _syntaxview_offset_from_mouse (const N_GUI_SYNTAXVIEW_DATA *yd, ALLEGRO_FONT *font, float mx, float my, float ax, float ay, float pad) |
| Map a mouse position over a syntax view to a byte offset into its text. | |
| static float | _tb_btn_resolved_size (const N_GUI_WINDOW *win, const N_GUI_STYLE *style) |
| return the effective titlebar button size (0 = auto from titlebar_h) | |
| static void | _tb_button_action (N_GUI_CTX *ctx, N_GUI_WINDOW *win, int btn_type) |
| Dispatch a titlebar button action, invoke the user callback if set, otherwise fall back to the built-in minimize / maximize / close behaviour. | |
| static int | _tb_button_rect (const N_GUI_WINDOW *win, const N_GUI_STYLE *style, int btn_type, float *out_x, float *out_y, float *out_w, float *out_h) |
| compute the absolute rect for a titlebar button. | |
| static float | _tb_buttons_area_width (const N_GUI_WINDOW *win, const N_GUI_STYLE *style) |
| compute the total width consumed by enabled titlebar buttons (0 if none/frameless) | |
| static void | _text_dims (ALLEGRO_FONT *font, const char *text, int *x, int *y, int *w, int *h) |
| helper: memoized al_get_text_dimensions (bounding box x/y/w/h). | |
| static ALLEGRO_COLOR | _text_for_state (const N_GUI_THEME *t, int state) |
| static int | _text_line_count (const char *s) |
| helper: destroy a single widget (called by list destructor) | |
| static float | _text_w (ALLEGRO_FONT *font, const char *text) |
| helper: get the advance width of text. | |
| static void | _textarea_clear_selection (N_GUI_TEXTAREA_DATA *td) |
| clear the selection (set both anchors to cursor_pos) | |
| static float | _textarea_content_height (const N_GUI_TEXTAREA_DATA *td, ALLEGRO_FONT *font, float widget_w, float pad) |
| helper: compute the total content height of multiline textarea text (with line-wrap), in pixels. | |
| static int | _textarea_copy_to_clipboard (const N_GUI_TEXTAREA_DATA *td, ALLEGRO_DISPLAY *display) |
| copy selected text to clipboard. | |
| static void | _textarea_delete_selection (N_GUI_WIDGET *wgt) |
| delete the currently selected text, move cursor to selection start | |
| static int | _textarea_handle_key (N_GUI_WIDGET *wgt, ALLEGRO_EVENT *ev, ALLEGRO_FONT *font, float pad, float sb_size, N_GUI_CTX *ctx) |
| static int | _textarea_has_selection (const N_GUI_TEXTAREA_DATA *td) |
| forward declaration: whether a text area has a non empty selection. | |
| static void | _textarea_paste_clip (N_GUI_WIDGET *wgt, N_GUI_TEXTAREA_DATA *td, const char *clip) |
| insert clipboard text at the cursor, replacing any selection. | |
| static size_t | _textarea_pos_from_mouse (const N_GUI_TEXTAREA_DATA *td, ALLEGRO_FONT *font, float mx, float my, float ax, float ay, float widget_w, float widget_h, float pad, float scrollbar_size) |
| helper: find the byte position in a textarea closest to the given mouse coordinates (mx, my in screen space). | |
| static void | _textarea_sel_range (const N_GUI_TEXTAREA_DATA *td, size_t *lo, size_t *hi) |
| get the ordered selection range (lo, hi) | |
| static _N_GUI_TA_STEP | _textarea_step (const char *text, size_t len, size_t i, ALLEGRO_FONT *font, float cx, float wrap_limit, float line_x0) |
| helper: decode, measure and wrap-test one character of textarea text. | |
| static bool | _tooltip_line_cb (int line_num, const char *line, int size, void *extra) |
| helper: al_do_multiline_text callback that just counts the wrapped lines. | |
| static int | _tooltip_widget_at (N_GUI_CTX *ctx, float px, float py) |
| helper: top-most visible tooltip-bearing widget under a gui-space point (-1 = none). | |
| static N_GUI_WINDOW * | _topmost_window_at (const N_GUI_CTX *ctx, float px, float py) |
| helper: the top-most open window of the current pass under a point, or NULL. | |
| static void | _track_modifiers (N_GUI_CTX *ctx, const ALLEGRO_EVENT *event) |
| follow the modifier keys through one event | |
| static int | _utf8_char_len (unsigned char c) |
| return the byte length of a UTF-8 character from its lead byte | |
| static int | _utf8_encode (int cp, char *out) |
| encode a Unicode code point into UTF-8, return the number of bytes written (0 on error) | |
| static size_t | _utf8_step (unsigned char lead) |
helper: the length in bytes of the UTF-8 sequence led by lead, 1 for a byte that does not lead one. | |
| static int | _widget_took_press (const N_GUI_WIDGET *wgt) |
helper: did the press just handled by wgt belong to it? | |
| static void | _win_auto_sb_rects (N_GUI_WINDOW *win, ALLEGRO_FONT *font, float size, float v[4], float h[4]) |
| helper: where a window's automatic scrollbars are, in display coordinates. | |
| static int | _win_on_pass (const N_GUI_CTX *ctx, const N_GUI_WINDOW *win) |
| helper: whether a window takes part in the pass currently being processed or drawn. | |
| static float | _win_tbh (const N_GUI_WINDOW *win) |
| helper: effective title bar height (0 for frameless windows) | |
| static void | _window_update_content_size (N_GUI_WINDOW *win, ALLEGRO_FONT *default_font) |
| helper: recompute content extents for a window (for scrollbar support) | |
| static void | _word_text (const char *text, int start, int len, char *out) |
helper: copy one word out of text into out (bounded by N_GUI_TEXT_MAX, which is also the widget text cap) and NUL-terminate it. | |
| static int | _wrap_words (const float *word_widths, const int *nl_before, int nwords, float space_w, float max_w, int *line_first, unsigned char *para_end, int max_lines) |
| helper: pack word widths into justified lines. | |
| static void | _wrap_words_emit (size_t first, size_t last, size_t line, double width, void *user) |
| static int | _zorder_group (const N_GUI_WINDOW *w) |
| int | n_gui_add_button (N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, int shape, void(*on_click)(int, void *), void *user_data) |
| Add a button widget to a window. | |
| 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. | |
| 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 (dropdown selector). | |
| 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; returns the widget id or -1 | |
| 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 widget. | |
| int | n_gui_add_dropmenu (N_GUI_CTX *ctx, int window_id, const char *label, float x, float y, float w, float h, void(*on_open)(int, void *), void *on_open_user_data) |
| Add a dropdown menu widget. | |
| int | n_gui_add_hexview (N_GUI_CTX *ctx, int window_id, float x, float y, float w, float h) |
| Add a read-only hexadecimal byte viewer. | |
| 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 display 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 static text label. | |
| 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 static 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 (single selection with radio bullets). | |
| 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 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 widget: a draggable divider between two regions. | |
| 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. | |
| 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) |
| Add a toggle button widget (stays clicked/unclicked on single click). | |
| 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 widget. | |
| int | n_gui_add_window (N_GUI_CTX *ctx, const char *title, float x, float y, float w, float h) |
| Add a new pseudo-window to the context. | |
| int | n_gui_add_window_auto (N_GUI_CTX *ctx, const char *title, float x, float y) |
| Add a window with automatic sizing (use n_gui_window_autosize after adding 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) |
| Get the glyph currently drawn on a button. | |
| 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 a toggle button is currently in the "on" state. | |
| void | n_gui_button_set_glyph (N_GUI_CTX *ctx, int widget_id, int glyph) |
| Draw a glyph on a button instead of its text 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) |
| Set a focused key binding on a button. | |
| 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 per-state bitmaps. | |
| void | n_gui_button_set_toggle_mode (N_GUI_CTX *ctx, int widget_id, int toggle_mode) |
| Enable or disable toggle mode on a button. | |
| void | n_gui_button_set_toggled (N_GUI_CTX *ctx, int widget_id, int toggled) |
| Set the toggle state of a button. | |
| 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 a checkbox widget 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 the checked state of a checkbox widget | |
| 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 widget | |
| int | n_gui_combobox_get_count (N_GUI_CTX *ctx, int widget_id) |
| get the number of items in a combobox widget | |
| 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 in a combobox widget | |
| int | n_gui_combobox_remove_item (N_GUI_CTX *ctx, int widget_id, int index) |
| remove an item from a combobox widget | |
| 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. | |
| void | n_gui_combobox_set_selected (N_GUI_CTX *ctx, int widget_id, int index) |
| set the selected item in a combobox widget | |
| 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) |
| Build sensible default style (all configurable sizes, colours, paddings). | |
| N_GUI_THEME | n_gui_default_tb_btn_theme (void) |
| Build a default theme for titlebar minimize/maximize buttons. | |
| N_GUI_THEME | n_gui_default_tb_close_theme (void) |
| Build a default theme for the titlebar close button. | |
| N_GUI_THEME | n_gui_default_theme (void) |
| Build a sensible default colour theme. | |
| void | n_gui_destroy_ctx (N_GUI_CTX **ctx) |
| Destroy a GUI context and all its windows/widgets. | |
| float | n_gui_detect_dpi_scale (N_GUI_CTX *ctx, ALLEGRO_DISPLAY *display) |
| Detect and apply DPI scale from an Allegro display. | |
| int | n_gui_double_clicked_widget (const N_GUI_CTX *ctx) |
| id of the widget the primary press just processed double clicked | |
| 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 from a dropdown menu. | |
| void | n_gui_dropmenu_clear_dynamic (N_GUI_CTX *ctx, int widget_id) |
| Remove all dynamic entries (keep static ones). | |
| int | n_gui_dropmenu_get_count (N_GUI_CTX *ctx, int widget_id) |
| Get number of entries in a dropdown menu. | |
| 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 drop-down panel needs to show its entries. | |
| void | n_gui_dropmenu_set_bitmaps (N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *panel, ALLEGRO_BITMAP *item_hover) |
| Set optional bitmap overlays on a dropmenu widget. | |
| void | n_gui_dropmenu_set_entry_text (N_GUI_CTX *ctx, int widget_id, int index, const char *text) |
| Update text of an existing entry. | |
| 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. | |
| int | n_gui_dropmenu_set_open (N_GUI_CTX *ctx, int widget_id, int open) |
| Open or close a dropdown menu without a click on 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 and bring it to the front. | |
| 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. | |
| 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_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. | |
| N_GUI_WIDGET * | n_gui_get_widget (N_GUI_CTX *ctx, int widget_id) |
| Get a widget pointer by id. | |
| N_GUI_WINDOW * | n_gui_get_window (N_GUI_CTX *ctx, int window_id) |
| Get a window pointer 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 | |
| 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 | |
| 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 | |
| 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 | |
| int | n_gui_hovered_widget (const N_GUI_CTX *ctx) |
| Id of the widget currently under the mouse pointer, or -1. | |
| void | n_gui_image_set_bitmap (N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bitmap) |
| set the bitmap of 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 a row 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 a row one position up or down among the active rows. | |
| 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 or hide the per-row move-up / move-down / duplicate buttons. | |
| 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 widget box. | |
| 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) |
| a label's truncate mode | |
| 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 the link URL of a label widget | |
| 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) |
| set the text of a label widget | |
| int | n_gui_listbox_add_item (N_GUI_CTX *ctx, int widget_id, const char *text) |
| add an item to a listbox widget | |
| void | n_gui_listbox_clear (N_GUI_CTX *ctx, int widget_id) |
| remove all items from a listbox widget | |
| float | n_gui_listbox_content_width (N_GUI_CTX *ctx, int widget_id) |
| width the widest item of a listbox needs to be drawn in full | |
| int | n_gui_listbox_get_count (N_GUI_CTX *ctx, int widget_id) |
| get the number of items in a listbox widget | |
| float | n_gui_listbox_get_h_scroll (N_GUI_CTX *ctx, int widget_id) |
| get a listbox's 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 the text of a listbox item | |
| 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 index of the first selected item in a listbox | |
| int | n_gui_listbox_is_selected (N_GUI_CTX *ctx, int widget_id, int index) |
| check if a listbox item is selected | |
| int | n_gui_listbox_remove_item (N_GUI_CTX *ctx, int widget_id, int index) |
| remove an item from a listbox widget | |
| 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 a listbox's horizontal scroll offset in pixels | |
| 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 the selection state of a listbox item | |
| 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 | |
| int | n_gui_load_theme_json (N_GUI_CTX *ctx, const char *filepath) |
| load a theme and style from a JSON file | |
| void | n_gui_lower_window (N_GUI_CTX *ctx, int window_id) |
| Lower a window to the bottom of the draw order. | |
| 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 with explicit colours. | |
| 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) |
| Minimise a window (show 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 through the GUI system. | |
| 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 radiolist widget | |
| void | n_gui_radiolist_clear (N_GUI_CTX *ctx, int widget_id) |
| remove all items from a radiolist widget | |
| int | n_gui_radiolist_get_selected (N_GUI_CTX *ctx, int widget_id) |
| get the selected item index in a radiolist widget | |
| 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 in a radiolist widget | |
| void | n_gui_raise_window (N_GUI_CTX *ctx, int window_id) |
| Bring a window to the front (top of draw order). | |
| 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 to a JSON file | |
| int | n_gui_save_theme_json (N_GUI_CTX *ctx, const char *filepath) |
| save the current theme and 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 the current scroll position of a scrollbar widget | |
| 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 the scroll position of a scrollbar widget | |
| void | n_gui_scrollbar_set_sizes (N_GUI_CTX *ctx, int widget_id, double content_size, double viewport_size) |
| set the content and viewport sizes of a scrollbar widget | |
| 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 | |
| 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) |
| set how far the pointer may move between the two presses | |
| void | n_gui_set_double_click_time (N_GUI_CTX *ctx, double seconds) |
| set how long after a press a second one still counts as a double click | |
| void | n_gui_set_dpi_scale (N_GUI_CTX *ctx, float scale) |
| Set DPI scale factor manually (default 1.0). | |
| void | n_gui_set_event_queue (N_GUI_CTX *ctx, ALLEGRO_EVENT_QUEUE *queue) |
| Set the event queue used to register native window event sources. | |
| void | n_gui_set_focus (N_GUI_CTX *ctx, int widget_id) |
| Set keyboard focus to a specific widget. | |
| 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 (round or square GUI). | |
| 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) |
| Enable or disable a widget. | |
| void | n_gui_set_widget_theme (N_GUI_CTX *ctx, int widget_id, N_GUI_THEME theme) |
| Override the theme of a specific widget. | |
| void | n_gui_set_widget_tooltip (N_GUI_CTX *ctx, int widget_id, const char *text) |
| Set (or clear) the tooltip text of any widget. | |
| void | n_gui_set_widget_visible (N_GUI_CTX *ctx, int widget_id, int visible) |
| Show or hide a widget. | |
| int | n_gui_slider_get_default (N_GUI_CTX *ctx, int widget_id, double *value) |
| read a slider's default | |
| double | n_gui_slider_get_key_step (N_GUI_CTX *ctx, int widget_id) |
| get the arrow key and wheel increment a slider actually uses | |
| double | n_gui_slider_get_value (N_GUI_CTX *ctx, int widget_id) |
| get the current value of a slider widget | |
| 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 the value 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 | |
| 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. | |
| void | n_gui_slider_set_value (N_GUI_CTX *ctx, int widget_id, double value) |
| set the value of a slider widget | |
| 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 of a split pane | |
| 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 of a split pane | |
| void | n_gui_splitpane_set_ratio (N_GUI_CTX *ctx, int widget_id, float ratio) |
| set the divider ratio of a split pane (clamped to its 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) |
| get the horizontal scroll offset of a syntax view | |
| 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) |
| get a copy of the currently selected text in a syntax view | |
| const char * | n_gui_syntaxview_get_text (N_GUI_CTX *ctx, int widget_id) |
| get the text currently shown by a syntax view | |
| 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 a 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 | |
| void | n_gui_syntaxview_set_mode (N_GUI_CTX *ctx, int widget_id, int mode) |
| set the highlighting mode 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 of a syntax view (byte offsets into the 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 | |
| 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 a tab panel's button row after creation. | |
| 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 the text content of a textarea widget | |
| size_t | n_gui_textarea_get_text_length (N_GUI_CTX *ctx, int widget_id) |
| return the current text length in bytes | |
| int | n_gui_textarea_has_selection (N_GUI_CTX *ctx, int widget_id) |
| is any text selected in a text area | |
| 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. | |
| void | n_gui_textarea_set_placeholder (N_GUI_CTX *ctx, int widget_id, const char *text) |
| Set placeholder/hint text shown dimmed while a textarea is empty. | |
| 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 the text content of a textarea widget | |
| 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 if hidden, hide if shown). | |
| int | n_gui_tooltip_pending (N_GUI_CTX *ctx) |
| Report the tooltip phase. | |
| 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 into a buffer. | |
| 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 physical display. | |
| int | n_gui_wants_mouse (N_GUI_CTX *ctx) |
| Check if the mouse is currently over any open GUI window. | |
| int | n_gui_was_double_click (const N_GUI_CTX *ctx, int widget_id) |
| whether the press just processed double clicked this 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 and resize a widget after creation. | |
| void | n_gui_window_apply_autofit (N_GUI_CTX *ctx, int window_id) |
| Trigger auto-fit recalculation for a window. | |
| 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 a window is currently visible. | |
| int | n_gui_window_native_is_hidden (N_GUI_CTX *ctx, int window_id) |
| Check whether a detached window is currently not drawable. | |
| 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. | |
| 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. | |
| 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 the content-draw callback for a window. | |
| void | n_gui_window_set_flags (N_GUI_CTX *ctx, int window_id, int flags) |
| Set feature flags on a window. | |
| 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. | |
| 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. | |
| 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, reflowing its widgets. | |
| 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 control over the widget reflow. | |
| 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. | |
| 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. | |
Variables | |
| static N_GUI_MEAS_ENTRY | _ngui_meas_cache [1024u] |
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.
Definition in file n_gui.c.
| struct _N_GUI_SB_SKIN |
The look of one scrollbar: the style values a bar's paint reads, gathered so that the painter does not have to know which set of them it was handed.
The toolkit has two sets - the scrollbar_* values every widget's bar uses, and the global_scrollbar_* ones the display's own bars use - and had two copies of the drawing to go with them.
| struct _N_GUI_TA_STEP |
| struct _N_GUI_THUMB |
| struct _N_GUI_WRAP_ACC |
accumulator for _wrap_words: records the first word index of each line, and whether the line ends a paragraph
| Data Fields | ||
|---|---|---|
| int | cap | |
| size_t | count | |
| int * | first | |
| const int * | item_word | |
| const n_wrap_item * | items | |
| int | n | |
| int | nwords | |
| unsigned char * | para_end | |
| struct N_GUI_KV_CONTENT |
| struct N_GUI_MEAS_ENTRY |
| struct N_GUI_SUGGEST_SINK |
handle textarea key input.
what a suggestion provider writes its answers into.
Returns 1 if the event was consumed, 0 if it should be passed through (e.g. ENTER in single-line mode falls through to button keybinds).
what n_gui_suggest_add() writes through. The widget's own data, behind a handle, so a provider can add entries and can do nothing else.
Opaque on purpose: the widget owns the storage, decides how much of it there is, and stops taking entries when it is full, so a provider cannot overrun anything by answering generously.
| Data Fields | ||
|---|---|---|
| N_GUI_TEXTAREA_DATA * | td | the field being completed |
| struct SYNTAX_RUN |
draw a run of text and advance the pen x by its width.
Runs longer than the stack buffer are drawn in successive chunks rather than cut short, which a whole-line mode (plain text, a diff line) would otherwise do to any long line. Chunks never split a UTF-8 sequence.
the horizontal window one syntax line is drawn into, plus the pen carried between its coloured runs. A run that ends left of x_min is measured but not drawn, and the run that takes the pen past x_max ends the line. Without that a single very long line costs one al_draw_text plus one uncached measurement per 511 bytes on every frame, nearly all of it off screen: measured on a 1 MB line, 151 ms per frame before, 0.5 ms after.
| #define _N_GUI_HELD_ALT 0x10 |
Definition at line 13205 of file n_gui.c.
Referenced by _held_bit(), _track_modifiers(), and n_gui_get_key_modifiers().
| #define _N_GUI_HELD_ALTGR 0x20 |
Definition at line 13206 of file n_gui.c.
Referenced by _held_bit(), _track_modifiers(), and n_gui_get_key_modifiers().
| #define _N_GUI_HELD_LCTRL 0x01 |
bits of N_GUI_CTX::held_modifier_keys, one per modifier key
Definition at line 13201 of file n_gui.c.
Referenced by _held_bit(), _track_modifiers(), and n_gui_get_key_modifiers().
| #define _N_GUI_HELD_LSHIFT 0x04 |
Definition at line 13203 of file n_gui.c.
Referenced by _held_bit(), _track_modifiers(), and n_gui_get_key_modifiers().
| #define _N_GUI_HELD_RCTRL 0x02 |
Definition at line 13202 of file n_gui.c.
Referenced by _held_bit(), _track_modifiers(), and n_gui_get_key_modifiers().
| #define _N_GUI_HELD_RSHIFT 0x08 |
Definition at line 13204 of file n_gui.c.
Referenced by _held_bit(), _track_modifiers(), and n_gui_get_key_modifiers().
| #define _N_GUI_TREE_DRAG_THRESHOLD_PX 4.0f |
pixels of mouse movement before a press becomes a drag
Definition at line 18036 of file n_gui.c.
Referenced by n_gui_tree_tick().
| #define _N_GUI_WIN_STATE_PERSIST_MASK (N_GUI_WIN_OPEN | N_GUI_WIN_MINIMISED | N_GUI_WIN_MAXIMISED) |
Definition at line 16942 of file n_gui.c.
Referenced by n_gui_load_layout_json(), and n_gui_save_layout_json().
| #define N_GUI_ANIM_TAIL_SEC 0.05 |
Definition at line 81 of file n_gui.c.
Referenced by _button_key_press(), and n_gui_process_event().
| #define N_GUI_COLRESIZE_GRAB 4.0f |
grab zone, in pixels either side of a column's right border
Definition at line 13445 of file n_gui.c.
Referenced by _datagrid_header_hit().
| #define N_GUI_KEY_PRESS_FLASH_SEC 0.12 |
Definition at line 74 of file n_gui.c.
Referenced by _button_key_press(), and n_gui_process_event().
| #define N_GUI_MEAS_CACHE_SIZE 1024u /* power of two */ |
Definition at line 198 of file n_gui.c.
Referenced by _ngui_meas_slot().
| #define N_GUI_MEAS_KEY_MAX 32 /* strings this long or longer bypass the cache */ |
Definition at line 199 of file n_gui.c.
Referenced by _text_dims(), and _text_w().
| #define N_GUI_WRAP_MAX_ITEMS (3 * N_GUI_WRAP_MAX_WORDS + 2) |
most layout items one wrap takes: every word, the break between each two, and room for the hard breaks of a text with blank lines in it
Definition at line 7030 of file n_gui.c.
Referenced by _wrap_words().
| #define N_GUI_WRAP_MAX_WORDS 256 |
the most words any justified layout will consider
Definition at line 6983 of file n_gui.c.
Referenced by _draw_justified_selection(), _draw_text_justified(), _justified_char_at_pos(), _label_content_height(), and _wrap_words().
|
static |
helper: show a cursor on the GUI's display, recording it whether or not there is a display, and touching Allegro only when it changes.
| ctx | the GUI context |
| shape | an ALLEGRO_SYSTEM_MOUSE_CURSOR_* value, used when custom is NULL |
| custom | a custom cursor, or NULL |
Definition at line 465 of file n_gui.c.
References _ctx_io_display(), N_GUI_CTX::cursor_custom, N_GUI_CTX::cursor_shape, and display.
Referenced by n_gui_process_event(), and n_gui_set_cursor().
|
static |
Definition at line 2911 of file n_gui.c.
References _datagrid_apply_columns(), N_GUI_PENDING_WIDGET::consumed, N_GUI_WIDGET::id, N_GUI_PENDING_WIDGET::key, N_GUI_PENDING_WIDGET::kind, n_gui_datagrid_get_column_count(), N_GUI_ID_MAX, n_gui_splitpane_set_ratio(), N_GUI_TYPE_DATAGRID, N_GUI_TYPE_SPLITPANE, N_GUI_PENDING_WIDGET::ncols, N_GUI_PENDING_WIDGET::order, N_GUI_CTX::pending_widgets, N_GUI_CTX::pending_widgets_count, N_GUI_WIDGET::persist_key, N_GUI_PENDING_WIDGET::ratio, N_GUI_PENDING_WIDGET::title, N_GUI_WIDGET::type, N_GUI_PENDING_WIDGET::visible, and N_GUI_PENDING_WIDGET::width.
Referenced by n_gui_widget_set_persist_key().
|
static |
helper: pick colour based on widget state
Definition at line 7681 of file n_gui.c.
References N_GUI_THEME::bg_active, N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_STATE_ACTIVE, and N_GUI_STATE_HOVER.
Referenced by _draw_button(), _draw_slider(), and _draw_themed_rect().
|
static |
Definition at line 7687 of file n_gui.c.
References N_GUI_THEME::border_active, N_GUI_THEME::border_hover, N_GUI_THEME::border_normal, N_GUI_STATE_ACTIVE, and N_GUI_STATE_HOVER.
Referenced by _draw_slider(), and _draw_themed_rect().
|
static |
Press a button from the keyboard, as a click would.
Toggles a toggle button, flashes the pressed look for as long as a key binding's press does, and calls on_click. The callback may close the window or free widgets, so nothing is read from the button after it.
| ctx | The context. |
| wgt | The focused button. |
Definition at line 2203 of file n_gui.c.
References N_GUI_CTX::anim_until, N_GUI_WIDGET::data, N_GUI_WIDGET::id, N_GUI_BUTTON_DATA::key_press_until, N_GUI_ANIM_TAIL_SEC, N_GUI_KEY_PRESS_FLASH_SEC, N_GUI_BUTTON_DATA::on_click, N_GUI_BUTTON_DATA::toggle_mode, N_GUI_BUTTON_DATA::toggled, and N_GUI_BUTTON_DATA::user_data.
Referenced by n_gui_process_event().
|
static |
The button before or after one, in its window, in reading order.
Only visible, enabled buttons count. The order goes round, so the arrows cycle through a dialog's buttons as Tab cycles through its widgets.
| ctx | The context. |
| from | The focused button. |
| forward | 1 for the next, 0 for the previous. |
Definition at line 2245 of file n_gui.c.
References _reading_order(), N_GUI_WIDGET::enabled, N_GUI_WIDGET::id, list_foreach, N_GUI_TYPE_BUTTON, N_GUI_WIDGET::type, N_GUI_WIDGET::visible, N_GUI_WINDOW::widgets, and N_GUI_CTX::windows.
Referenced by n_gui_process_event().
|
static |
helper: is a key one a focused button does something with: Enter and Space press it, the arrows move to the next button of its window
Definition at line 138 of file n_gui.c.
Referenced by n_gui_focus_takes_key(), and n_gui_process_event().
|
static |
compare two cell strings: numerically when both are integers, else case-insensitive
Definition at line 5142 of file n_gui.c.
References _cell_is_num().
Referenced by n_gui_datagrid_sort().
|
static |
true when every character of a non-empty string is a decimal digit
Definition at line 5132 of file n_gui.c.
Referenced by _cell_cmp().
|
static |
helper: clamp a double between lo and hi
Definition at line 86 of file n_gui.c.
Referenced by _slider_update_from_mouse(), n_gui_add_slider(), n_gui_process_event(), n_gui_scrollbar_set_pos(), n_gui_scrollbar_set_sizes(), n_gui_slider_set_range(), and n_gui_slider_set_value().
|
static |
drop any active syntax-view text selection (used when focus moves to another selectable widget, so only one selection is live at a time).
Definition at line 9471 of file n_gui.c.
References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_SYNTAXVIEW, N_GUI_SYNTAXVIEW_DATA::sel_dragging, N_GUI_SYNTAXVIEW_DATA::sel_end, N_GUI_SYNTAXVIEW_DATA::sel_start, N_GUI_CTX::selected_syntaxview_id, and N_GUI_WIDGET::type.
Referenced by n_gui_process_event().
|
static |
Helper: mix two colours, t of the way from a to b.
All four channels are interpolated, alpha included. Allegro's default blender treats a colour as premultiplied, and premultiplied colours mix linearly, so this is the mix that lands on screen as well as the mix of the numbers. t outside 0..1 is clamped rather than extrapolated: a caller asking for more than the whole way wants the endpoint, not a colour off the end of the ramp with channels out of range.
Definition at line 873 of file n_gui.c.
Referenced by _scrollbar_thumb_for_state().
|
static |
Helper: return a copy of c with the given alpha (0..1).
Definition at line 858 of file n_gui.c.
Referenced by n_gui_set_default_theme().
|
static |
helper: the effective width of an open combobox dropdown panel.
The draw path and the mouse handler both need it, and both used to compute it – the same auto-width scan, cap and display-edge clamp, once with cb_ prefixed locals and a comment saying it mirrored the other. When those two disagree the panel is drawn at one width and clicked at another, so an item near the edge selects nothing.
font may be NULL, in which case the widget width is used unchanged – which is what the mouse handler's && cb_font guard already did.
Definition at line 10422 of file n_gui.c.
References _text_w(), N_GUI_STYLE::combobox_max_dropdown_width, N_GUI_CTX::display_w, N_GUI_COMBOBOX_DATA::flags, font, N_GUI_COMBOBOX_DATA::items, N_GUI_COMBOBOX_AUTO_WIDTH, N_GUI_COMBOBOX_DATA::nb_items, N_GUI_CTX::style, and N_GUI_LISTITEM::text.
Referenced by _draw_combobox_dropdown(), and n_gui_process_event().
|
static |
shift an index that pointed into a list one item shorter now
| index | the index, -1 for none |
| removed | the item that was removed |
Definition at line 6074 of file n_gui.c.
Referenced by n_gui_combobox_remove_item().
|
static |
helper: compute the bounding box of all open windows
Definition at line 11577 of file n_gui.c.
References _win_on_pass(), N_GUI_CTX::gui_bounds_h, N_GUI_CTX::gui_bounds_w, N_GUI_WINDOW::h, list_foreach, N_GUI_WIN_OPEN, N_GUI_WINDOW::state, N_GUI_WINDOW::w, N_GUI_CTX::windows, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by n_gui_draw(), and n_gui_process_event().
|
static |
helper: the display to use for clipboard and mouse-cursor calls.
Follows the display that last received input, so a copy/paste or a cursor change inside a detached window addresses that window rather than the host's main display. Falls back to the display given to n_gui_set_display.
Definition at line 456 of file n_gui.c.
References N_GUI_CTX::active_display, and N_GUI_CTX::display.
Referenced by _apply_cursor(), _ngui_publish_primary_selection(), _textarea_handle_key(), and n_gui_process_event().
|
static |
helper: hand a mouse event to a custom widget that takes them.
Returns the callback's answer, or 0 when the widget takes no mouse input.
Definition at line 13586 of file n_gui.c.
References N_GUI_MOUSE_EVENT::button, N_GUI_WIDGET::data, N_GUI_MOUSE_EVENT::dz, N_GUI_WIDGET::id, N_GUI_MOUSE_EVENT::modifiers, N_GUI_CUSTOM_DATA::mouse_user_data, n_gui_get_key_modifiers(), N_GUI_TYPE_CUSTOM, N_GUI_CUSTOM_DATA::on_mouse, N_GUI_MOUSE_EVENT::type, N_GUI_WIDGET::type, type(), N_GUI_MOUSE_EVENT::x, and N_GUI_MOUSE_EVENT::y.
Referenced by n_gui_process_event().
|
static |
Definition at line 2891 of file n_gui.c.
References n_gui_datagrid_display_to_physical(), n_gui_datagrid_move_column(), n_gui_datagrid_set_column_visible(), n_gui_datagrid_set_column_width(), and visible().
Referenced by _apply_pending_widget().
|
static |
fetch a data grid's column table for an API call, or NULL on a bad id.
Definition at line 5475 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 n_gui_datagrid_display_to_physical(), n_gui_datagrid_get_column_count(), n_gui_datagrid_get_column_title(), n_gui_datagrid_get_column_visible(), n_gui_datagrid_get_column_width(), n_gui_datagrid_move_column(), n_gui_datagrid_set_column_visible(), n_gui_datagrid_set_column_width(), and n_gui_datagrid_set_on_columns_changed().
|
static |
helper: ensure the per-row tint arrays exist, sized to rows_cap (rows start untinted); returns 1 when both arrays are available
Definition at line 5200 of file n_gui.c.
References Malloc, N_GUI_DATAGRID_DATA::row_color, N_GUI_DATAGRID_DATA::row_has_color, and N_GUI_DATAGRID_DATA::rows_cap.
Referenced by n_gui_datagrid_set_row_color().
|
static |
helper: ensure the per-row selection array exists, sized to rows_cap
Definition at line 5192 of file n_gui.c.
References Malloc, N_GUI_DATAGRID_DATA::row_sel, and N_GUI_DATAGRID_DATA::rows_cap.
Referenced by n_gui_datagrid_select_row(), n_gui_datagrid_set_multiselect(), and n_gui_process_event().
|
static |
helper: what a datagrid header row is offering at x.
Walks the visible columns left to right from ax minus the horizontal scroll and answers both questions the header asks: which column's RIGHT BORDER x is within the grab zone of (a resize drag), and failing that which column x is INSIDE (a sort click). Border wins, and the walk stops at the first answer – the order the mouse handler has always used.
Both the mouse-down handler and the hover test that shows the resize cursor call this. They used to walk separately, and a hover that disagrees with the handler is a cursor promising a drag that does nothing. Either out may be NULL; both are set to -1 when nothing matches.
Definition at line 13459 of file n_gui.c.
References _datagrid_phys(), N_GUI_DATAGRID_DATA::cols, N_GUI_DATAGRID_DATA::h_scroll, N_GUI_COLRESIZE_GRAB, N_GUI_DATAGRID_DATA::nb_cols, right(), N_GUI_DATAGRID_COL::visible, and N_GUI_DATAGRID_COL::width.
Referenced by _datagrid_resize_hover(), and n_gui_process_event().
|
static |
Compute the datagrid horizontal-scroll metrics used identically by the draw path and the mouse handlers, so the thumb geometry never drifts between them: content_w = left pad + the total width of the visible columns; pane_w = the viewport width available to the columns (widget width minus a vertical scrollbar when the rows overflow); need_hsb = 1 when the content is wider than the pane.
Any output pointer may be NULL.
Definition at line 8902 of file n_gui.c.
References _datagrid_phys(), N_GUI_DATAGRID_DATA::cols, font, N_GUI_WIDGET::h, N_GUI_STYLE::item_height_pad, N_GUI_STYLE::item_text_padding, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_STYLE::scrollbar_size, N_GUI_DATAGRID_COL::visible, visible(), N_GUI_WIDGET::w, and N_GUI_DATAGRID_COL::width.
Referenced by _draw_datagrid(), and n_gui_process_event().
|
static |
physical column index shown at display position dp (identity when no order).
Definition at line 5187 of file n_gui.c.
References N_GUI_DATAGRID_DATA::col_order.
Referenced by _datagrid_header_hit(), _datagrid_hmetrics(), _draw_datagrid(), n_gui_datagrid_columns_width(), and n_gui_datagrid_display_to_physical().
|
static |
Whether the pointer at (px,py) rests on a datagrid column-resize border: the header row of a visible datagrid, within a few pixels of a visible column's right edge.
Mirrors the hit test that starts a resize drag on mouse-down, so the caller can show a horizontal-resize cursor there for discoverability. The topmost datagrid under the point wins (windows are ordered back to front).
Definition at line 13487 of file n_gui.c.
References _datagrid_header_hit(), _point_in_rect(), _win_on_pass(), _win_tbh(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_STYLE::item_height_pad, list_foreach, N_GUI_TYPE_DATAGRID, N_GUI_WIN_OPEN, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_WINDOW::state, N_GUI_CTX::style, N_GUI_WIDGET::type, N_GUI_WIDGET::visible, N_GUI_WIDGET::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_process_event().
|
static |
Definition at line 659 of file n_gui.c.
References N_GUI_DATAGRID_DATA::cells, N_GUI_DATAGRID_DATA::col_order, N_GUI_DATAGRID_DATA::cols, N_GUI_HEXVIEW_DATA::data, N_GUI_WIDGET::data, N_GUI_CUSTOM_DATA::destroy, N_GUI_DROPMENU_DATA::entries, FreeNoLog, N_GUI_COMBOBOX_DATA::items, N_GUI_LISTBOX_DATA::items, N_GUI_RADIOLIST_DATA::items, N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_CUSTOM, 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_SYNTAXVIEW, N_GUI_TYPE_TEXTAREA, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DATAGRID_DATA::nb_rows, N_GUI_TEXTAREA_DATA::placeholder, N_GUI_DATAGRID_DATA::row_color, N_GUI_DATAGRID_DATA::row_has_color, N_GUI_DATAGRID_DATA::row_sel, N_GUI_TEXTAREA_DATA::suggest_items, N_GUI_MARKDOWNVIEW_DATA::text, N_GUI_SYNTAXVIEW_DATA::text, N_GUI_TEXTAREA_DATA::text, N_GUI_WIDGET::tooltip, N_GUI_WIDGET::type, and N_GUI_CUSTOM_DATA::user_data.
Referenced by 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(), and n_gui_add_textarea().
|
static |
helper: destroy a single window (called by list destructor)
Definition at line 715 of file n_gui.c.
References FreeNoLog, list_destroy(), and N_GUI_WINDOW::widgets.
Referenced by _sort_windows_by_zorder(), n_gui_add_window(), n_gui_lower_window(), and n_gui_raise_window().
|
static |
helper: draw a bitmap into a rectangle, respecting the given scale mode.
mode: N_GUI_IMAGE_FIT, N_GUI_IMAGE_STRETCH, or N_GUI_IMAGE_CENTER.
Definition at line 6776 of file n_gui.c.
References mode, N_GUI_IMAGE_CENTER, and N_GUI_IMAGE_STRETCH.
Referenced by _draw_window().
|
static |
Definition at line 8057 of file n_gui.c.
References _bg_for_state(), _draw_glyph(), _draw_text_truncated(), _draw_themed_rect(), _min_thickness(), _shape_rounded(), _text_dims(), _text_for_state(), N_GUI_BUTTON_DATA::bitmap, N_GUI_BUTTON_DATA::bitmap_active, N_GUI_BUTTON_DATA::bitmap_hover, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, N_GUI_BUTTON_DATA::glyph, N_GUI_WIDGET::h, N_GUI_BUTTON_DATA::key_press_until, N_GUI_BUTTON_DATA::label, N_GUI_STYLE::label_padding, N_GUI_GLYPH_NONE, N_GUI_SHAPE_BITMAP, N_GUI_STATE_ACTIVE, N_GUI_STATE_HOVER, N_GUI_BUTTON_DATA::shape, N_GUI_WIDGET::state, N_GUI_STYLE::tb_btn_glyph_thickness, N_GUI_WIDGET::theme, N_GUI_BUTTON_DATA::toggle_mode, N_GUI_BUTTON_DATA::toggled, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a checkbox widget
Definition at line 8749 of file n_gui.c.
References _draw_text_truncated(), _draw_themed_rect(), _min_thickness(), _opt_rounded(), _text_dims(), _text_for_state(), N_GUI_CHECKBOX_DATA::box_bitmap, N_GUI_CHECKBOX_DATA::box_checked_bitmap, N_GUI_CHECKBOX_DATA::box_hover_bitmap, 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_CHECKBOX_DATA::checked, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_CHECKBOX_DATA::label, N_GUI_STATE_HOVER, N_GUI_WIDGET::state, N_GUI_THEME::text_active, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a horizontal scrollbar along the bottom edge of a widget: track_w is the width of the scrollable pane (from ax), bar_y its top, content_w the total content width, h_scroll the current pixel offset, track the owning widget's N_GUI_SB_TRACK for this bar.
The vertical twin is _draw_rows_scrollbar.
Definition at line 8889 of file n_gui.c.
References _draw_scrollbar_body(), _sb_skin(), _scrollbar_thumb(), _N_GUI_THUMB::len, N_GUI_STATE_IDLE, _N_GUI_THUMB::off, N_GUI_STYLE::scrollbar_size, and N_GUI_STYLE::scrollbar_thumb_min.
Referenced by _draw_datagrid(), _draw_listbox(), and _draw_syntaxview().
|
static |
draw a combobox widget (closed state)
Definition at line 10236 of file n_gui.c.
References _draw_text_truncated(), _draw_themed_rect(), _min_thickness(), _shape_rounded(), _text_dims(), _text_for_state(), N_GUI_COMBOBOX_DATA::bg_bitmap, N_GUI_WIDGET::data, 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, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_STYLE::item_text_padding, N_GUI_COMBOBOX_DATA::items, N_GUI_SHAPE_RECT, N_GUI_COMBOBOX_DATA::nb_items, N_GUI_COMBOBOX_DATA::selected_index, N_GUI_WIDGET::state, N_GUI_LISTITEM::text, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
Definition at line 10446 of file n_gui.c.
References _combobox_dropdown_width(), _draw_scrollbar_body(), _draw_text_truncated(), _dropdown_panel_y(), _find_widget_window(), _min_thickness(), _opt_rounded(), _sb_skin(), _scrollbar_thumb(), _win_on_pass(), N_GUI_THEME::bg_active, N_GUI_COMBOBOX_DATA::bg_bitmap, N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_STYLE::dropdown_border_thickness, N_GUI_COMBOBOX_DATA::flags, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_COMBOBOX_DATA::highlight_index, N_GUI_WIDGET::id, N_GUI_COMBOBOX_DATA::is_open, N_GUI_COMBOBOX_DATA::item_bg_bitmap, N_GUI_COMBOBOX_DATA::item_height, N_GUI_STYLE::item_height_pad, N_GUI_COMBOBOX_DATA::item_selected_bitmap, N_GUI_STYLE::item_selection_inset, N_GUI_STYLE::item_text_padding, N_GUI_COMBOBOX_DATA::items, _N_GUI_THUMB::len, N_GUI_COMBOBOX_DATA::max_visible, N_GUI_COMBOBOX_EXPAND_UP, n_gui_get_widget(), N_GUI_STATE_SCROLLBAR_DRAG, N_GUI_COMBOBOX_DATA::nb_items, _N_GUI_THUMB::off, N_GUI_CTX::open_combobox_id, N_GUI_COMBOBOX_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_COMBOBOX_DATA::selected_index, N_GUI_WIDGET::state, N_GUI_CTX::style, N_GUI_LISTITEM::text, N_GUI_THEME::text_active, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by n_gui_draw(), and n_gui_draw_detached().
|
static |
draw a single widget.
win_w is the parent window width (>0 for resizable windows, 0 otherwise) so that labels can expand to fill available space.
Definition at line 11130 of file n_gui.c.
References N_GUI_WIDGET::data, N_GUI_CUSTOM_DATA::draw, N_GUI_WIDGET::font, N_GUI_CUSTOM_DATA::user_data, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
Definition at line 9776 of file n_gui.c.
References _datagrid_hmetrics(), _datagrid_phys(), _draw_cols_scrollbar(), _draw_rows_scrollbar(), _draw_text_truncated(), _min_thickness(), N_GUI_THEME::bg_active, N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_DATAGRID_DATA::cells, N_GUI_DATAGRID_DATA::cols, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_DATAGRID_DATA::h_scroll, N_GUI_STYLE::item_height_pad, N_GUI_STYLE::item_text_padding, N_GUI_DATAGRID_DATA::multiselect, N_GUI_ID_MAX, N_GUI_STATE_FOCUSED, N_GUI_DATAGRID_DATA::nb_cols, N_GUI_DATAGRID_DATA::nb_rows, row(), N_GUI_DATAGRID_DATA::row_color, N_GUI_DATAGRID_DATA::row_has_color, N_GUI_DATAGRID_DATA::row_sel, N_GUI_WIDGET::sb_h, N_GUI_WIDGET::sb_v, N_GUI_DATAGRID_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_DATAGRID_DATA::selected_row, N_GUI_DATAGRID_DATA::sort_col, N_GUI_DATAGRID_DATA::sort_dir, N_GUI_WIDGET::state, N_GUI_THEME::text_active, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_DATAGRID_COL::title, N_GUI_DATAGRID_COL::visible, visible(), N_GUI_WIDGET::w, N_GUI_DATAGRID_COL::width, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a dropdown menu button (closed state)
Definition at line 10568 of file n_gui.c.
References _draw_text_truncated(), _draw_themed_rect(), _min_thickness(), _text_dims(), _text_for_state(), N_GUI_WIDGET::data, 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, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_DROPMENU_DATA::is_open, N_GUI_STYLE::item_text_padding, N_GUI_DROPMENU_DATA::label, N_GUI_SHAPE_RECT, N_GUI_STATE_ACTIVE, N_GUI_STYLE::shape_mode, N_GUI_WIDGET::state, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw the dropdown menu panel overlay (called after all windows)
Definition at line 10601 of file n_gui.c.
References _draw_scrollbar_body(), _draw_text_truncated(), _dropdown_panel_y(), _find_widget_window(), _min_thickness(), _sb_skin(), _scrollbar_thumb(), _win_on_pass(), N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_STYLE::dropdown_border_thickness, N_GUI_DROPMENU_DATA::entries, N_GUI_DROPMENU_DATA::flags, font, N_GUI_WIDGET::font, N_GUI_WIDGET::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_STYLE::item_height_pad, N_GUI_DROPMENU_DATA::item_hover_bitmap, N_GUI_STYLE::item_selection_inset, N_GUI_STYLE::item_text_padding, _N_GUI_THUMB::len, N_GUI_DROPMENU_DATA::max_visible, N_GUI_DROPMENU_EXPAND_UP, n_gui_dropmenu_panel_width(), n_gui_get_widget(), N_GUI_SHAPE_RECT, N_GUI_STATE_SCROLLBAR_DRAG, N_GUI_DROPMENU_DATA::nb_entries, _N_GUI_THUMB::off, N_GUI_CTX::open_dropmenu_id, N_GUI_DROPMENU_DATA::panel_bitmap, N_GUI_DROPMENU_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::shape_mode, N_GUI_WIDGET::state, N_GUI_CTX::style, N_GUI_DROPMENU_ENTRY::text, N_GUI_THEME::text_hover, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by n_gui_draw(), and n_gui_draw_detached().
|
static |
draw the keyboard focus outline over a widget that has the focus: a line just inside its edge, twice the theme's border and at least 2 pixels, in the theme's active border colour, so it follows the palette.
One outline for every widget Tab reaches, so what the keyboard is on reads the same whatever it is. A text area is left out: its caret and border already say so.
Definition at line 11142 of file n_gui.c.
References _min_thickness(), N_GUI_THEME::border_active, N_GUI_THEME::border_thickness, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_WIDGET::h, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a button widget
draw an N_GUI_GLYPH_* icon centred on (cx, cy), sized to a half-extent of s. fg is the button's text colour and bg its current background, so a glyph built from overlapping shapes (COPY) can mask what it covers.
Definition at line 8010 of file n_gui.c.
References N_GUI_GLYPH_ARROW_DOWN, N_GUI_GLYPH_ARROW_LEFT, N_GUI_GLYPH_ARROW_RIGHT, N_GUI_GLYPH_ARROW_UP, N_GUI_GLYPH_COPY, N_GUI_GLYPH_CROSS, N_GUI_GLYPH_MINUS, and N_GUI_GLYPH_PLUS.
Referenced by _draw_button().
|
static |
draw a read-only hex viewer: offset, hex bytes, and an ASCII gutter
Definition at line 8924 of file n_gui.c.
References _draw_rows_scrollbar(), _min_thickness(), N_GUI_THEME::bg_normal, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_HEXVIEW_DATA::bytes_per_row, N_GUI_HEXVIEW_DATA::cursor, N_GUI_HEXVIEW_DATA::data, N_GUI_WIDGET::data, N_GUI_HEXVIEW_DATA::editable, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_HEXVIEW_DATA::len, line(), N_GUI_HEXVIEW_DATA::nibble, row(), N_GUI_WIDGET::sb_v, N_GUI_HEXVIEW_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_THEME::text_normal, N_GUI_STYLE::textarea_padding, N_GUI_WIDGET::theme, visible(), N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw an image widget
Definition at line 10701 of file n_gui.c.
References N_GUI_IMAGE_DATA::bitmap, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_IMAGE_CENTER, N_GUI_IMAGE_STRETCH, N_GUI_IMAGE_DATA::scale_mode, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
helper: draw selection highlight rectangles over justified/wrapped text.
Shares _split_words + _wrap_words with the draw, so the rectangles cannot land on a different line than the text they highlight.
Definition at line 7516 of file n_gui.c.
References _split_words(), _text_w(), _wrap_words(), font, N_GUI_TEXT_MAX, N_GUI_WRAP_MAX_WORDS, and text().
Referenced by _draw_label().
|
static |
Definition at line 10977 of file n_gui.c.
References _draw_justified_selection(), _draw_label_lines(), _draw_label_overflow(), _draw_text_justified(), _draw_widget_vscrollbar(), _label_content_height(), _label_effective_w(), _label_wrap_w(), _min_thickness(), _set_clipping_rect_transformed(), _text_dims(), _text_for_state(), _text_w(), N_GUI_LABEL_DATA::align, N_GUI_LABEL_DATA::bg_bitmap, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_STYLE::label_padding, N_GUI_LABEL_DATA::link, N_GUI_STYLE::link_color_hover, N_GUI_STYLE::link_color_normal, N_GUI_STYLE::link_underline_thickness, N_GUI_ALIGN_CENTER, N_GUI_ALIGN_JUSTIFIED, N_GUI_ALIGN_RIGHT, N_GUI_STATE_HOVER, N_GUI_TEXT_MAX, N_GUI_WIDGET::sb_v, N_GUI_LABEL_DATA::scroll_y, N_GUI_STYLE::scrollbar_size, N_GUI_LABEL_DATA::sel_end, N_GUI_LABEL_DATA::sel_start, N_GUI_THEME::selection_color, N_GUI_WIDGET::state, N_GUI_LABEL_DATA::text, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
helper: draw a LEFT, CENTER or RIGHT label whose text has line breaks, one line under another, each aligned and shortened on its own, with the selection highlighted line by line.
Definition at line 10884 of file n_gui.c.
References _draw_label_overflow(), _label_line_at(), _label_line_count(), _label_line_x(), _label_lines_top(), _set_clipping_rect_transformed(), _text_w(), font, h(), line(), N_GUI_TEXT_MAX, N_GUI_LABEL_DATA::sel_end, N_GUI_LABEL_DATA::sel_start, start(), and N_GUI_LABEL_DATA::text.
Referenced by _draw_label().
|
static |
helper: draw a label's text, or one line of it, that is too wide for it, shortened the way its truncate mode says.
Definition at line 10819 of file n_gui.c.
References _draw_text_truncated(), font, N_GUI_TEXT_MAX, n_gui_text_shorten(), N_GUI_TRUNCATE_END, text(), and N_GUI_LABEL_DATA::truncate.
Referenced by _draw_label(), and _draw_label_lines().
|
static |
draw a listbox widget
Definition at line 10020 of file n_gui.c.
References _draw_cols_scrollbar(), _draw_rows_scrollbar(), _draw_text_truncated(), _listbox_clamp_h(), _listbox_hmetrics(), N_GUI_THEME::bg_active, N_GUI_LISTBOX_DATA::bg_bitmap, N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_LISTBOX_DATA::h_scroll, N_GUI_LISTBOX_DATA::hover_row, N_GUI_LISTBOX_DATA::item_bg_bitmap, N_GUI_LISTBOX_DATA::item_height, N_GUI_STYLE::item_height_pad, N_GUI_LISTBOX_DATA::item_selected_bitmap, N_GUI_STYLE::item_selection_inset, N_GUI_STYLE::item_text_padding, N_GUI_LISTBOX_DATA::items, N_GUI_LISTBOX_DATA::nb_items, N_GUI_WIDGET::sb_h, N_GUI_WIDGET::sb_v, N_GUI_LISTBOX_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_LISTITEM::selected, N_GUI_THEME::text_active, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a sortable data grid: fixed header row plus scrollable data rows
draw a markdown view: the panel, the rendered document clipped to it, and the vertical bar when there is more document than pane.
The document is laid out by n_gui_md, which measures and draws in one walk, so the height the bar is sized from is the height that was painted.
Definition at line 9709 of file n_gui.c.
References _draw_themed_rect(), _draw_widget_vscrollbar(), _markdownview_follow_theme(), _markdownview_measure(), _markdownview_text_w(), _set_clipping_rect_transformed(), _shape_rounded(), N_GUI_MARKDOWNVIEW_DATA::content_h, N_GUI_WIDGET::data, N_GUI_MARKDOWNVIEW_DATA::fonts, N_GUI_WIDGET::h, n_gui_md_draw(), N_GUI_SHAPE_RECT, N_GUI_STATE_IDLE, N_GUI_MD_FONTS::regular, N_GUI_WIDGET::sb_v, N_GUI_MARKDOWNVIEW_DATA::scroll_y, N_GUI_MARKDOWNVIEW_DATA::style, N_GUI_MARKDOWNVIEW_DATA::text, N_GUI_STYLE::textarea_padding, N_GUI_WIDGET::theme, N_GUI_SB_TRACK::w, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
Definition at line 9748 of file n_gui.c.
References N_GUI_THEME::bg_active, N_GUI_THEME::bg_normal, N_GUI_THEME::border_normal, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_PROGRESSBAR_DATA::text, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_PROGRESSBAR_DATA::value, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a radiolist widget
Definition at line 10152 of file n_gui.c.
References _draw_rows_scrollbar(), _min_thickness(), N_GUI_RADIOLIST_DATA::bg_bitmap, N_GUI_THEME::bg_hover, N_GUI_THEME::bg_normal, N_GUI_THEME::border_hover, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_RADIOLIST_DATA::item_bg_bitmap, N_GUI_RADIOLIST_DATA::item_height, N_GUI_STYLE::item_height_pad, N_GUI_RADIOLIST_DATA::item_selected_bitmap, N_GUI_RADIOLIST_DATA::items, N_GUI_STATE_HOVER, N_GUI_RADIOLIST_DATA::nb_items, 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_WIDGET::sb_v, N_GUI_RADIOLIST_DATA::scroll_offset, N_GUI_RADIOLIST_DATA::selected_index, N_GUI_WIDGET::state, N_GUI_LISTITEM::text, N_GUI_THEME::text_active, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a row-indexed vertical scrollbar (shared by hexview, syntaxview, datagrid, listbox and radiolist) at the right edge of [ax,ay,w,h].
nb_rows total, visible per page, scroll_offset is the first visible row, track the owning widget's N_GUI_SB_TRACK for this bar, which the paint records into and reads the pointer's answer back out of.
Definition at line 8876 of file n_gui.c.
References _draw_scrollbar_body(), _sb_skin(), _scrollbar_thumb(), h(), _N_GUI_THUMB::len, N_GUI_STATE_IDLE, _N_GUI_THUMB::off, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_min, and visible().
Referenced by _draw_datagrid(), _draw_hexview(), _draw_listbox(), _draw_radiolist(), and _draw_syntaxview().
|
static |
draw a scrollbar widget.
A scrollbar on its own is drawn exactly like the bars a list or a text box draws inside itself, through the same two helpers: a flat track, the divider, and a rounded thumb that lifts towards the accent when the bar is hovered, dragged or holding the keyboard. It used to draw a themed box with an outlined block for a thumb instead, which made a pane scrolled by a scrollbar widget look like a different program from the pane next to it.
The widget rectangle IS the bar here, so the widget's own state is the bar's state – hover included, unlike an inner bar.
A caller that supplied bitmaps still gets them: each part that has one is drawn from the bitmap, each part that has none is painted.
Definition at line 8819 of file n_gui.c.
References _draw_scrollbar_thumb(), _draw_scrollbar_track(), _sb_skin(), _scrollbar_thumb(), _select_state_bitmap(), _shape_rounded(), N_GUI_SCROLLBAR_DATA::content_size, _N_GUI_SB_SKIN::corner_r, N_GUI_WIDGET::data, N_GUI_WIDGET::h, _N_GUI_THUMB::len, N_GUI_SCROLLBAR_V, _N_GUI_THUMB::off, N_GUI_SCROLLBAR_DATA::orientation, N_GUI_SCROLLBAR_DATA::scroll_pos, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_SCROLLBAR_DATA::shape, N_GUI_WIDGET::state, N_GUI_WIDGET::theme, 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, N_GUI_SCROLLBAR_DATA::viewport_size, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
Draw one whole scrollbar: track, divider and thumb.
The convenience over calling the two halves. Every bar in the toolkit comes through this pair – the scrollbar widget, the bars a list, a grid or a text box draws inside itself, a combo box or drop menu panel's, a window's own, and the display's – so they cannot drift apart the way they had: the scrollbar widget drew a themed box with a hollow outlined block for a thumb while everything else drew a track and a pill, and each of the last four carried its own copy of the arithmetic.
Nothing is allocated and nothing is kept; the caller owns the geometry.
| bar_x | Left edge of the strip the bar occupies. |
| bar_y | Top edge of that strip. |
| bar_w | Width of the strip. |
| bar_h | Height of the strip. |
| thumb_off | Thumb offset from the start of the track along the scrolling axis, in pixels, as _scrollbar_thumb() gives it. |
| thumb_len | Thumb length along that axis, in pixels, likewise. |
| vertical | Non-zero for a bar that scrolls up and down. |
| state | N_GUI_STATE_* flags the caller can vouch for itself. |
| track | The owning widget's record for this bar, recorded into and read for the pointer's position. NULL for a bar no widget owns, which then relies on state alone. |
| skin | Colours and metrics, from _sb_skin() or _sb_skin_global(). Must not be NULL. |
| theme | Theme the divider and the thumb follow. Must not be NULL. |
Definition at line 7929 of file n_gui.c.
References _draw_scrollbar_thumb(), _draw_scrollbar_track(), N_GUI_SB_TRACK::h, N_GUI_SB_TRACK::hovered, N_GUI_STATE_HOVER, _N_GUI_SB_SKIN::thumb_padding, N_GUI_SB_TRACK::w, N_GUI_SB_TRACK::x, and N_GUI_SB_TRACK::y.
Referenced by _draw_cols_scrollbar(), _draw_combobox_dropdown(), _draw_dropmenu_panel(), _draw_rows_scrollbar(), _draw_widget_vscrollbar(), _draw_window(), and n_gui_draw().
|
static |
Draw the thumb of a scrollbar, in the state its owner is in.
The fill is the skin's thumb colour, lifted towards the theme's accent once the bar is hovered, pressed or holding the keyboard; a bar in any of those states is outlined in that colour as well, which is what says "this one has the focus" on a track too narrow for anything subtler to read. A skin that asks for an outline of its own gets it in every state, under the state one.
| x | Left edge of the thumb. |
| y | Top edge of the thumb. |
| w | Thumb width. A width or height below zero draws nothing. |
| h | Thumb height. |
| state | N_GUI_STATE_* flags of whatever owns the bar. Only the flags the bar itself can vouch for should be passed; see _inner_scrollbar_state(). |
| skin | Colours and metrics, from _sb_skin() or _sb_skin_global(). Must not be NULL. |
| theme | Theme the lift and the state outline follow. Must not be NULL. |
Definition at line 7871 of file n_gui.c.
References _min_thickness(), _scrollbar_edge_for_state(), _scrollbar_thumb_for_state(), N_GUI_THEME::border_thickness, _N_GUI_SB_SKIN::corner_r, h(), N_GUI_STATE_ACTIVE, N_GUI_STATE_FOCUSED, N_GUI_STATE_HOVER, N_GUI_STATE_SCROLLBAR_DRAG, _N_GUI_SB_SKIN::outline, _N_GUI_SB_SKIN::outline_thickness, and _N_GUI_SB_SKIN::thumb.
Referenced by _draw_scrollbar(), and _draw_scrollbar_body().
|
static |
Draw the track of a scrollbar: the one look every bar shares.
A flat rectangle in the skin's track colour, and the hairline that divides the bar from the content it scrolls – on the left of a vertical bar, along the top of a horizontal one, because that is the side the content is on. Without the line a dark track on a dark panel has no edge at all. The line does not react to state; only the thumb does. See the body.
| bar_x | Left edge of the strip the bar occupies. |
| bar_y | Top edge of that strip. |
| bar_w | Width of the strip. |
| bar_h | Height of the strip. |
| vertical | Non-zero for a bar that scrolls up and down. |
| state | N_GUI_STATE_* flags of whatever owns the bar. |
| skin | Colours and metrics, from _sb_skin() or _sb_skin_global(). Must not be NULL. |
| theme | Theme the divider follows. Must not be NULL. |
Definition at line 7822 of file n_gui.c.
References _min_thickness(), N_GUI_THEME::border_normal, _N_GUI_SB_SKIN::track, _N_GUI_SB_SKIN::track_inset, and _N_GUI_SB_SKIN::track_round.
Referenced by _draw_scrollbar(), and _draw_scrollbar_body().
|
static |
Definition at line 8186 of file n_gui.c.
References _bg_for_state(), _border_for_state(), _min_thickness(), _select_state_bitmap(), _slider_handle_r(), _slider_travel(), _slider_value_text(), _text_dims(), N_GUI_THEME::bg_active, N_GUI_THEME::bg_normal, N_GUI_THEME::border_normal, N_GUI_WIDGET::data, N_GUI_SLIDER_DATA::fill_bitmap, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_SLIDER_DATA::handle_active_bitmap, N_GUI_SLIDER_DATA::handle_bitmap, N_GUI_SLIDER_DATA::handle_hover_bitmap, N_GUI_SLIDER_DATA::max_val, N_GUI_SLIDER_DATA::min_val, N_GUI_SLIDER_V, N_GUI_SLIDER_DATA::orientation, N_GUI_STYLE::slider_handle_border_thickness, 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_WIDGET::state, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_SLIDER_DATA::track_bitmap, N_GUI_SLIDER_DATA::value, N_GUI_SLIDER_DATA::value_visible, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a split pane: only the divider bar is painted (the app fills the two regions with its own widgets, positioned from the divider ratio)
Definition at line 9948 of file n_gui.c.
References N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_THEME::border_normal, N_GUI_WIDGET::data, N_GUI_SPLITPANE_DATA::divider, N_GUI_WIDGET::h, N_GUI_SPLIT_VERTICAL, N_GUI_STATE_ACTIVE, N_GUI_STATE_HOVER, N_GUI_SPLITPANE_DATA::orientation, N_GUI_SPLITPANE_DATA::ratio, N_GUI_WIDGET::state, N_GUI_WIDGET::theme, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
Definition at line 9593 of file n_gui.c.
References _draw_cols_scrollbar(), _draw_rows_scrollbar(), _min_thickness(), _syntax_draw_line(), _syntax_prefix_w_lim(), _syntaxview_clamp_h(), _syntaxview_hmetrics(), N_GUI_THEME::bg_normal, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_SYNTAXVIEW_DATA::cached_headers_end, N_GUI_SYNTAXVIEW_DATA::cached_nb_lines, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_SYNTAXVIEW_DATA::h_scroll, le(), N_GUI_SYNTAXVIEW_DATA::len, N_GUI_SYNTAXVIEW_DATA::mode, N_GUI_WIDGET::sb_h, N_GUI_WIDGET::sb_v, N_GUI_SYNTAXVIEW_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_SYNTAXVIEW_DATA::sel_end, N_GUI_SYNTAXVIEW_DATA::sel_start, N_GUI_THEME::selection_color, N_GUI_SYNTAXVIEW_DATA::text, N_GUI_STYLE::textarea_padding, N_GUI_WIDGET::theme, visible(), N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw the titlebar buttons for a window
Definition at line 11300 of file n_gui.c.
References _draw_themed_rect(), _tb_button_rect(), _text_for_state(), N_GUI_TB_BUTTONS::btn_theme, N_GUI_TB_BUTTONS::close_active_bitmap, N_GUI_TB_BUTTONS::close_bitmap, N_GUI_TB_BUTTONS::close_hover_bitmap, N_GUI_TB_BUTTONS::close_theme, N_GUI_TB_BUTTONS::hovered, 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_STATE_ACTIVE, N_GUI_STATE_HOVER, N_GUI_STATE_IDLE, N_GUI_TB_BTN_CLOSE, N_GUI_TB_BTN_MAXIMIZE, N_GUI_TB_BTN_MINIMIZE, N_GUI_WIN_MAXIMISED, N_GUI_TB_BUTTONS::pressed, N_GUI_WINDOW::state, N_GUI_STYLE::tb_btn_glyph_thickness, and N_GUI_WINDOW::tb_buttons.
Referenced by _draw_window().
|
static |
helper: draw justified text within a given width, with multi-line word wrapping.
Words are packed into lines using minimum spacing; full lines are justified (gaps spread evenly), the last line is left-aligned. Only shows "..." when a single word is wider than max_w.
Definition at line 7137 of file n_gui.c.
References _draw_text_truncated(), _split_words(), _text_w(), _word_text(), _wrap_words(), font, N_GUI_TEXT_MAX, N_GUI_WRAP_MAX_WORDS, and text().
Referenced by _draw_label().
|
static |
helper: draw text truncated to a maximum pixel width.
If the text is wider than max_w, it is clipped and "..." is appended.
Definition at line 6942 of file n_gui.c.
References _text_w(), font, N_GUI_TEXT_MAX, and text().
Referenced by _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_combobox_dropdown(), _draw_datagrid(), _draw_dropmenu(), _draw_dropmenu_panel(), _draw_label_overflow(), _draw_listbox(), _draw_text_justified(), _draw_textarea_suggest(), and _draw_window().
|
static |
draw a textarea widget
Definition at line 8445 of file n_gui.c.
References _draw_textarea_placeholder(), _draw_widget_vscrollbar(), _min_thickness(), _opt_rounded(), _set_clipping_rect_transformed(), _text_w(), _textarea_content_height(), _textarea_has_selection(), _textarea_sel_range(), _textarea_step(), N_GUI_THEME::bg_active, N_GUI_TEXTAREA_DATA::bg_bitmap, 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_TA_STEP::ch, _N_GUI_TA_STEP::clen, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_TEXTAREA_DATA::cursor_time, _N_GUI_TA_STEP::cw, N_GUI_WIDGET::data, font, N_GUI_WIDGET::font, h(), N_GUI_WIDGET::h, N_GUI_TEXTAREA_DATA::mask_char, N_GUI_TEXTAREA_DATA::multiline, N_GUI_STATE_FOCUSED, N_GUI_STATE_HOVER, N_GUI_TEXT_MAX, _N_GUI_TA_STEP::newline, run, N_GUI_WIDGET::sb_v, N_GUI_TEXTAREA_DATA::scroll_from_wheel, N_GUI_TEXTAREA_DATA::scroll_x, N_GUI_TEXTAREA_DATA::scroll_y, N_GUI_STYLE::scrollbar_size, N_GUI_THEME::selection_color, N_GUI_WIDGET::state, N_GUI_TEXTAREA_DATA::text, N_GUI_THEME::text_active, N_GUI_TEXTAREA_DATA::text_len, 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_WIDGET::w, _N_GUI_TA_STEP::wrapped, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
|
static |
draw a textarea's placeholder/hint at (tx,ty), dimmed, while the field is empty; a no-op once any text has been entered or when no placeholder is set
Definition at line 8433 of file n_gui.c.
References N_GUI_THEME::bg_normal, font, N_GUI_TEXTAREA_DATA::placeholder, N_GUI_TEXTAREA_DATA::text_len, N_GUI_THEME::text_normal, and N_GUI_WIDGET::theme.
Referenced by _draw_textarea().
|
static |
draw the open completion panel (called after all windows, with the other floating overlays)
Definition at line 10346 of file n_gui.c.
References _draw_text_truncated(), _find_widget_window(), _min_thickness(), _suggest_close(), _suggest_panel_rect(), _win_on_pass(), N_GUI_THEME::bg_active, N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_STYLE::dropdown_border_thickness, N_GUI_WIDGET::enabled, font, N_GUI_WIDGET::font, N_GUI_WIDGET::id, N_GUI_STYLE::item_selection_inset, N_GUI_STYLE::item_text_padding, n_gui_get_widget(), N_GUI_STATE_FOCUSED, N_GUI_CTX::open_suggest_id, N_GUI_WIDGET::state, N_GUI_CTX::style, N_GUI_TEXTAREA_DATA::suggest_count, N_GUI_TEXTAREA_DATA::suggest_highlight, N_GUI_TEXTAREA_DATA::suggest_items, N_GUI_TEXTAREA_DATA::suggest_scroll, N_GUI_LISTITEM::text, N_GUI_THEME::text_active, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, and N_GUI_WIDGET::visible.
Referenced by n_gui_draw(), and n_gui_draw_detached().
|
static |
draw a themed rectangle or rounded rectangle.
For thin outlines, inset the border by half the thickness so that all four corners render symmetrically (avoids Allegro pixel-alignment artifact on the bottom-right corner).
Definition at line 7975 of file n_gui.c.
References _bg_for_state(), _border_for_state(), _min_thickness(), N_GUI_THEME::border_thickness, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, and h().
Referenced by _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_dropmenu(), _draw_markdownview(), and _draw_tb_buttons().
|
static |
helper: draw the hover-tooltip bubble for the currently armed tooltip widget, but ONLY in the render pass of the display that owns that widget's window.
A detached (native) window is a separate Allegro display, so a tooltip for a widget on it must be drawn into that display with that window's local mouse coordinates, exactly like the combobox/dropmenu overlays; drawing it once in the main pass (as before) put the bubble under the native window and it did not follow the window. Called from both the main pass and each detached pass; the pass_display guard makes it draw exactly once, on the right display.
The bubble is kept ENTIRELY inside a clamp rectangle: a tooltip wider than that rectangle is WORD-WRAPPED to it and the bubble is shifted left/up (flipping above the cursor) so the full text always shows and nothing is clipped at the edge - unless the rectangle is genuinely too small to hold even the wrapped text, in which case it is best-effort clamped.
The clamp rectangle is the DISPLAY, narrowed to the widget's window only when that window owns a display, i.e. is detached. An in-app window clips nothing (the bubble is drawn over the whole display after every window has been painted), so narrowing to it would squeeze a sentence to a few characters per line on a small panel and push the resulting tall bubble off that panel. Independently of the clamp, style.tooltip_max_w caps the text width so a long tooltip does not stretch into one unreadable line the width of a wide display; 0 disables the cap.
Definition at line 11647 of file n_gui.c.
References _find_widget_window(), _text_w(), _tooltip_line_cb(), N_GUI_CTX::default_font, N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_WINDOW::h, N_GUI_CTX::mouse_x, N_GUI_CTX::mouse_y, n_gui_get_widget(), n_gui_tooltip_pending(), N_GUI_WINDOW::native, N_GUI_CTX::pass_display, N_GUI_CTX::style, N_GUI_WIDGET::tooltip, N_GUI_STYLE::tooltip_bg, N_GUI_STYLE::tooltip_border, N_GUI_STYLE::tooltip_fg, N_GUI_STYLE::tooltip_max_w, N_GUI_CTX::tooltip_widget_id, N_GUI_WIDGET::visible, N_GUI_WINDOW::w, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by n_gui_draw(), and n_gui_draw_detached().
|
static |
Definition at line 11158 of file n_gui.c.
References _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_custom(), _draw_datagrid(), _draw_dropmenu(), _draw_focus_outline(), _draw_hexview(), _draw_image(), _draw_label(), _draw_listbox(), _draw_markdownview(), _draw_progressbar(), _draw_radiolist(), _draw_scrollbar(), _draw_slider(), _draw_splitpane(), _draw_syntaxview(), _draw_textarea(), _is_tab_focusable_type(), N_GUI_WIDGET::enabled, N_GUI_WIDGET::h, N_GUI_STATE_FOCUSED, N_GUI_STATE_IDLE, 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_IMAGE, N_GUI_TYPE_LABEL, N_GUI_TYPE_LISTBOX, N_GUI_TYPE_MARKDOWNVIEW, N_GUI_TYPE_PROGRESSBAR, 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_WIDGET::state, N_GUI_WIDGET::type, N_GUI_WIDGET::visible, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_window().
|
static |
helper: draw a mini vertical scrollbar inside a widget, at the right edge of the area [area_x .
. area_x+area_w], [area_y .. area_y+view_h]. content_h = total content height, view_h = visible area height, scroll_y = current scroll offset, track = the owning widget's N_GUI_SB_TRACK for this bar.
Definition at line 7962 of file n_gui.c.
References _draw_scrollbar_body(), _sb_skin(), _scrollbar_thumb(), _N_GUI_THUMB::len, N_GUI_STATE_IDLE, _N_GUI_THUMB::off, N_GUI_STYLE::scrollbar_size, and N_GUI_STYLE::scrollbar_thumb_min.
Referenced by _draw_label(), _draw_markdownview(), and _draw_textarea().
|
static |
draw a window chrome + its widgets
Definition at line 11379 of file n_gui.c.
References _draw_bitmap_scaled(), _draw_scrollbar_body(), _draw_tb_buttons(), _draw_text_truncated(), _draw_widget(), _min_thickness(), _opt_rounded(), _sb_skin(), _scrollbar_thumb(), _set_clipping_rect_transformed(), _tb_buttons_area_width(), _text_dims(), _window_update_content_size(), N_GUI_THEME::bg_active, N_GUI_WINDOW::bg_bitmap, N_GUI_THEME::bg_normal, N_GUI_WINDOW::bg_scale_mode, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_WINDOW::caption, N_GUI_WINDOW::content_h, N_GUI_WINDOW::content_w, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_WINDOW::flags, font, N_GUI_WINDOW::font, N_GUI_STYLE::grip_color, N_GUI_STYLE::grip_line_thickness, N_GUI_STYLE::grip_size, N_GUI_WINDOW::h, N_GUI_STYLE::label_padding, _N_GUI_THUMB::len, list_foreach, N_GUI_STATE_HOVER, N_GUI_STATE_IDLE, N_GUI_STATE_SCROLLBAR_DRAG, N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_FRAMELESS, N_GUI_WIN_HSCROLL_DRAG, N_GUI_WIN_HSCROLL_HOVER, N_GUI_WIN_MINIMISED, N_GUI_WIN_NO_HSCROLL, N_GUI_WIN_OPEN, N_GUI_WIN_RESIZABLE, N_GUI_WIN_VSCROLL_DRAG, N_GUI_WIN_VSCROLL_HOVER, _N_GUI_THUMB::off, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_WINDOW::state, N_GUI_THEME::text_active, N_GUI_WINDOW::theme, N_GUI_WINDOW::title, N_GUI_STYLE::title_max_w_reserve, N_GUI_STYLE::title_padding, N_GUI_WINDOW::titlebar_bitmap, N_GUI_WINDOW::titlebar_h, _N_GUI_SB_SKIN::track_inset, _N_GUI_SB_SKIN::track_round, N_GUI_WINDOW::w, N_GUI_WINDOW::widgets, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by n_gui_draw(), and n_gui_draw_detached().
|
static |
draw the combobox dropdown overlay (called after all windows)
Definition at line 10285 of file n_gui.c.
References N_GUI_CTX::display_h.
Referenced by _draw_combobox_dropdown(), _draw_dropmenu_panel(), _suggest_panel_rect(), and n_gui_process_event().
|
static |
helper: ensure dropmenu entries array has room for one more
Definition at line 6276 of file n_gui.c.
References FreeNoLog, and Malloc.
Referenced by n_gui_dropmenu_add_entry().
|
static |
helper: the display an event originates from, or NULL when the event carries no display (timer, user and joystick events) or the field is unset, as in the headless tests that synthesize events with memset.
Definition at line 412 of file n_gui.c.
Referenced by n_gui_process_event().
|
static |
helper: find the window containing a focused widget
Definition at line 154 of file n_gui.c.
References N_GUI_CTX::focused_widget_id, N_GUI_WIDGET::id, list_foreach, N_GUI_WIN_OPEN, N_GUI_WINDOW::state, N_GUI_WINDOW::widgets, and N_GUI_CTX::windows.
Referenced by n_gui_process_event().
|
static |
find a widget without a non-const context, for the queries that only read
Definition at line 2150 of file n_gui.c.
References N_GUI_WIDGET::id, list_foreach, N_GUI_WINDOW::widgets, and N_GUI_CTX::windows.
Referenced by n_gui_focus_takes_key().
|
static |
helper: find the parent window of a widget by id, returning the window's content origin (accounting for scroll offsets).
| ctx | GUI context |
| wgt_id | widget id to search for |
| ox | [out] content origin X |
| oy | [out] content origin Y |
Definition at line 606 of file n_gui.c.
References _win_tbh(), list_foreach, N_GUI_WIN_OPEN, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_WINDOW::state, N_GUI_WINDOW::widgets, N_GUI_CTX::windows, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by _draw_combobox_dropdown(), _draw_dropmenu_panel(), _draw_textarea_suggest(), _draw_tooltip(), _suggest_panel_rect(), n_gui_process_event(), n_gui_tooltip_pending(), n_gui_widget_screen_rect(), and n_gui_widget_set_persist_key().
helper: find a window node in the context list by id
Definition at line 725 of file n_gui.c.
References __n_assert, N_GUI_WINDOW::id, list_foreach, and N_GUI_CTX::windows.
Referenced by n_gui_get_window(), n_gui_lower_window(), and n_gui_raise_window().
|
static |
helper: which global scrollbars the open windows need in a view of eff_w by eff_h, from the bounds _compute_gui_bounds() left.
Less than N_GUI_GLOBAL_SCROLL_SLACK over is a rounding error of a layout computed in floats, 1920.000122 for 1920: nothing of it is hidden, yet one bar would appear and take room enough to bring the other. One rule for the drawing, the clicks, the drags and the wheel, so they agree on what is shown.
Definition at line 11600 of file n_gui.c.
References N_GUI_STYLE::global_scrollbar_size, N_GUI_CTX::gui_bounds_h, N_GUI_CTX::gui_bounds_w, h(), N_GUI_GLOBAL_SCROLL_SLACK, and N_GUI_CTX::style.
Referenced by n_gui_draw(), and n_gui_process_event().
|
static |
Definition at line 16611 of file n_gui.c.
References mode.
Referenced by n_gui_save_layout_json(), and n_gui_save_theme_json().
|
static |
the held-key bit of a key code, 0 for a key that is not a modifier
| keycode | an ALLEGRO_KEY_* code |
Definition at line 13213 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, and _N_GUI_HELD_RSHIFT.
Referenced by _track_modifiers().
|
static |
the value of a hex digit key (0-15), or -1 when the key is not one.
Both the main row and the numeric keypad count, since a hex editor is a numeric tool.
Definition at line 4671 of file n_gui.c.
Referenced by _hexview_handle_key().
|
static |
remove the byte at at from an editable hex view.
Returns 1 when one was removed, 0 when the offset is past the end.
Definition at line 4660 of file n_gui.c.
References N_GUI_HEXVIEW_DATA::cursor, N_GUI_HEXVIEW_DATA::data, N_GUI_HEXVIEW_DATA::len, and N_GUI_HEXVIEW_DATA::nibble.
Referenced by _hexview_handle_key().
|
static |
handle one key for a focused editable hex view.
Returns 1 when the key was consumed. visible_rows is how many rows the widget shows, for paging.
Definition at line 4691 of file n_gui.c.
References _hexview_digit(), _hexview_erase(), _hexview_insert(), _hexview_reserve(), _hexview_reveal(), N_GUI_HEXVIEW_DATA::bytes_per_row, changed, N_GUI_HEXVIEW_DATA::cursor, N_GUI_HEXVIEW_DATA::data, N_GUI_WIDGET::data, N_GUI_HEXVIEW_DATA::editable, N_GUI_WIDGET::id, N_GUI_HEXVIEW_DATA::len, N_GUI_HEXVIEW_DATA::nibble, N_GUI_HEXVIEW_DATA::on_change, and N_GUI_HEXVIEW_DATA::user_data.
Referenced by n_gui_process_event().
|
static |
insert one zero byte before the cursor of an editable hex view.
Returns 1 on success, 0 when the allocation failed.
Definition at line 4648 of file n_gui.c.
References _hexview_reserve(), N_GUI_HEXVIEW_DATA::cursor, N_GUI_HEXVIEW_DATA::data, N_GUI_HEXVIEW_DATA::len, and N_GUI_HEXVIEW_DATA::nibble.
Referenced by _hexview_handle_key().
|
static |
grow an editable hex view's buffer so it can hold at least need bytes.
Returns 1 on success, 0 when the allocation failed (the data is left intact).
Definition at line 4633 of file n_gui.c.
References N_GUI_HEXVIEW_DATA::cap, and N_GUI_HEXVIEW_DATA::data.
Referenced by _hexview_handle_key(), and _hexview_insert().
|
static |
scroll an editable hex view so its cursor row is visible
Definition at line 4680 of file n_gui.c.
References N_GUI_HEXVIEW_DATA::bytes_per_row, N_GUI_HEXVIEW_DATA::cursor, row(), and N_GUI_HEXVIEW_DATA::scroll_offset.
Referenced by _hexview_handle_key().
|
static |
helper: check if a widget type takes keys once it has focus.
A button is not one of them: it has the keyboard only through Tab or an arrow, see _is_tab_focusable_type(), and keys it does nothing with pass on.
Definition at line 115 of file n_gui.c.
References N_GUI_TYPE_CHECKBOX, N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_DATAGRID, N_GUI_TYPE_DROPMENU, N_GUI_TYPE_LISTBOX, N_GUI_TYPE_MARKDOWNVIEW, N_GUI_TYPE_RADIOLIST, N_GUI_TYPE_SCROLLBAR, N_GUI_TYPE_SLIDER, N_GUI_TYPE_TEXTAREA, and type().
Referenced by _is_tab_focusable_type(), n_gui_focus_window(), and n_gui_process_event().
|
static |
helper: check if a widget type is reached by Tab and Shift+Tab: every widget that takes keys, and the buttons, which Enter or Space presses once they have focus.
A mouse press still never focuses a button, so a click leaves the keyboard where it was.
Definition at line 132 of file n_gui.c.
References _is_focusable_type(), N_GUI_TYPE_BUTTON, and type().
Referenced by _draw_widget(), and n_gui_process_event().
|
static |
helper: ensure items array has room for one more, returns 1 on success
Definition at line 746 of file n_gui.c.
References FreeNoLog, and Malloc.
Referenced by n_gui_combobox_add_item(), n_gui_listbox_add_item(), and n_gui_radiolist_add_item().
|
static |
helper: add an RGBA colour as a JSON array [r,g,b,a] (0-255)
Definition at line 16625 of file n_gui.c.
Referenced by n_gui_save_theme_json().
|
static |
helper: read an RGBA colour from a JSON array [r,g,b,a]
Definition at line 16637 of file n_gui.c.
Referenced by n_gui_load_theme_json().
|
static |
helper: read a float from JSON, return fallback if missing
Definition at line 16648 of file n_gui.c.
Referenced by n_gui_load_layout_json(), and n_gui_load_theme_json().
|
static |
helper: read an int from JSON, return fallback if missing
Definition at line 16655 of file n_gui.c.
Referenced by n_gui_load_layout_json(), and n_gui_load_theme_json().
|
static |
helper: find the byte offset in justified text closest to a click position.
text_x, text_y = top-left of the text area. Returns -1 on error.
Definition at line 7418 of file n_gui.c.
References _split_words(), _text_w(), _utf8_char_len(), _wrap_words(), font, N_GUI_WRAP_MAX_WORDS, and text().
Referenced by n_gui_process_event().
|
static |
is this one of the keys that move through a widget rather than type into it: the arrows, the page keys, Home, End and Enter
Definition at line 2175 of file n_gui.c.
Referenced by n_gui_focus_takes_key().
|
static |
draw a label widget.
win_w > 0 means the parent window is resizable and the label may expand horizontally to fill the available window width.
helper: find the byte offset in a label's text closest to a given pixel x position. Returns -1 if the label has no text or font.
Definition at line 10737 of file n_gui.c.
References _text_w(), _utf8_char_len(), font, N_GUI_TEXT_MAX, and N_GUI_LABEL_DATA::text.
Referenced by n_gui_process_event().
|
static |
forward declaration: height the wrapped text of a justified label needs at a given width.
helper: compute the total content height of justified/wrapped label text, in pixels.
Defined near the label draw code.
Counts the lines _wrap_words gives the draw, so a scrollbar can never disagree with what is rendered.
Definition at line 7613 of file n_gui.c.
References _split_words(), _text_w(), _wrap_words(), font, N_GUI_WRAP_MAX_WORDS, and text().
Referenced by _draw_label(), n_gui_label_fits(), and n_gui_process_event().
|
static |
helper: the width a LEFT, CENTER or RIGHT label lays its text out in.
In a resizable or auto-scrollbar window (win_w > 0) a label may reach past its own box to the window's right edge, so its text is not cut. A left aligned label always does: its text starts at the same place either way. A centred or right aligned one does so only when its widest line does not fit its own box: stretched while it fits, it was centred on the gap between its box and the window edge rather than on the box, which put a label meant to sit over one of two columns off to one side.
Definition at line 10771 of file n_gui.c.
References _label_line_at(), _label_line_count(), _text_w(), N_GUI_LABEL_DATA::align, font, line(), N_GUI_ALIGN_CENTER, N_GUI_ALIGN_RIGHT, N_GUI_TEXT_MAX, and N_GUI_LABEL_DATA::text.
Referenced by _draw_label(), _label_text_origin_x(), and n_gui_process_event().
|
static |
helper: line index of text, copied into out without its break.
Returns the byte offset of the line's start in text, or -1 past the last line.
Definition at line 10842 of file n_gui.c.
References start(), and text().
Referenced by _draw_label_lines(), _label_effective_w(), _label_lines_char_at(), and n_gui_label_fits().
|
static |
forward declarations: the lines of a label whose text has line breaks, used by n_gui_label_fits().
helper: the number of lines a label's text has, one more than its line breaks
Defined near the label draw code.
Definition at line 10832 of file n_gui.c.
References text().
Referenced by _draw_label_lines(), _label_effective_w(), _label_lines_char_at(), and n_gui_label_fits().
|
static |
helper: where a line of a multi-line label starts on screen, by the label's alignment.
A line too wide for the box starts at the padding.
Definition at line 10865 of file n_gui.c.
References N_GUI_LABEL_DATA::align, N_GUI_ALIGN_CENTER, and N_GUI_ALIGN_RIGHT.
Referenced by _draw_label_lines(), and _label_lines_char_at().
|
static |
helper: the byte offset in a multi-line label closest to a click.
Definition at line 10939 of file n_gui.c.
References _label_line_at(), _label_line_count(), _label_line_x(), _label_lines_top(), _text_w(), _utf8_char_len(), font, h(), line(), N_GUI_TEXT_MAX, start(), and N_GUI_LABEL_DATA::text.
Referenced by n_gui_process_event().
|
static |
helper: the top of a multi-line label's first line: the block of lines centred in the box as a single line is, and never above the box.
Definition at line 10876 of file n_gui.c.
References h().
Referenced by _draw_label_lines(), and _label_lines_char_at().
|
static |
helper: compute the screen-space x origin where label text starts, accounting for alignment.
ax is the widget's screen-space left edge. win_w is the label_win_w hint (0 for fixed windows).
Definition at line 10799 of file n_gui.c.
References _label_effective_w(), _text_dims(), N_GUI_LABEL_DATA::align, font, N_GUI_ALIGN_CENTER, N_GUI_ALIGN_RIGHT, and N_GUI_LABEL_DATA::text.
Referenced by n_gui_process_event().
|
static |
forward declaration: the width a justified label wraps its text to.
helper: the width a JUSTIFIED label wraps its text to.
Defined near the label draw code.
A wrapped label is drawn clipped to its own box, so wrapping it to anything wider (the window-expanded width a single-line label may grow into) lays out text that is then cut away unseen: the reader loses the end of every line and nothing says so. The box is what the reader sees, so the box is what the text wraps to.
Definition at line 7605 of file n_gui.c.
References N_GUI_STYLE::label_padding, and N_GUI_WIDGET::w.
Referenced by _draw_label(), n_gui_label_fits(), and n_gui_process_event().
|
static |
helper: move an open list panel's highlight cursor (combobox / dropmenu) by delta items and scroll the visible window so the highlighted item stays in view.
Shared by the wheel and the Up/Down keys so both drive the same cursor.
| highlight | in/out highlight index (-1 = none; seeded from fallback) |
| scroll | in/out first-visible-item offset |
| nb | total item count |
| max_visible | number of items the panel shows at once |
| delta | signed step (negative = up, positive = down) |
| fallback | index to start from when highlight is -1 (e.g. the selected item, or the first visible item) |
Definition at line 13340 of file n_gui.c.
Referenced by _suggest_handle_key(), and n_gui_process_event().
|
static |
helper: the mouse wheel over an open list panel (combobox / dropmenu).
Scrolls the list by one item a notch, as every desktop toolkit does, and puts the highlight on whatever item is now under the pointer. It used to step the highlight instead and scroll only once the highlight reached an edge, and the next pointer move put the highlight back under the pointer, so the wheel ran over the visible items and the rest stayed out of reach (examples/ex_gui_combobox_wheel.c). The Up/Down keys still step the highlight through _list_panel_highlight_step().
| highlight | in/out highlight index |
| scroll | in/out first-visible-item offset |
| nb | total item count |
| max_visible | number of items the panel shows at once |
| notches | wheel notches, positive down the list (-event.mouse.dz) |
| row | the panel row under the pointer, or -1 to leave the highlight alone. Only called with the pointer over the panel: away from it the wheel steps the highlight, as the arrow keys do (ex_gui_dropmenu.c) |
Definition at line 13386 of file n_gui.c.
References row().
Referenced by n_gui_process_event().
|
static |
clamp a listbox's horizontal scroll to the room its content actually needs
Definition at line 10012 of file n_gui.c.
References N_GUI_LISTBOX_DATA::h_scroll.
Referenced by _draw_listbox(), and n_gui_process_event().
|
static |
Listbox horizontal-scroll metrics, computed identically by the draw path and the mouse handlers so the thumb and the hit test never drift apart.
content_w is the width the widest item needs (text padding included), pane_w the room left for the items (widget width minus a vertical scrollbar), need_hsb whether the content overflows that room, and visible the number of rows that fit above the horizontal scrollbar. Any output pointer may be NULL.
Definition at line 9975 of file n_gui.c.
References _text_w(), font, N_GUI_WIDGET::h, N_GUI_LISTBOX_DATA::item_height, N_GUI_STYLE::item_height_pad, N_GUI_STYLE::item_text_padding, N_GUI_LISTBOX_DATA::items, N_GUI_LISTBOX_DATA::nb_items, N_GUI_STYLE::scrollbar_size, N_GUI_LISTITEM::text, visible(), and N_GUI_WIDGET::w.
Referenced by _draw_listbox(), and n_gui_process_event().
|
static |
Re-derive the view's colours from the widget's theme, while the caller has not taken the style over.
What a palette change needs, and it costs one call a frame rather than a hook into every theme setter.
Definition at line 5757 of file n_gui.c.
References N_GUI_THEME::bg_normal, N_GUI_MARKDOWNVIEW_DATA::dirty, N_GUI_MARKDOWNVIEW_DATA::fonts, n_gui_md_style_default(), N_GUI_MD_FONTS::regular, N_GUI_MARKDOWNVIEW_DATA::style, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, and N_GUI_MARKDOWNVIEW_DATA::theme_derived.
Referenced by _draw_markdownview(), and n_gui_add_markdownview().
|
static |
Measure the document if anything it depends on has changed, and clamp the scroll to what is left.
Returns the height of the view's inside.
Definition at line 5783 of file n_gui.c.
References _markdownview_text_w(), N_GUI_MARKDOWNVIEW_DATA::content_h, N_GUI_MARKDOWNVIEW_DATA::dirty, N_GUI_MARKDOWNVIEW_DATA::fonts, N_GUI_WIDGET::h, N_GUI_MARKDOWNVIEW_DATA::measured_w, n_gui_md_height(), N_GUI_MARKDOWNVIEW_DATA::scroll_y, N_GUI_MARKDOWNVIEW_DATA::style, N_GUI_MARKDOWNVIEW_DATA::text, and N_GUI_STYLE::textarea_padding.
Referenced by _draw_markdownview().
|
static |
The view's data, or NULL when that widget is not one.
Definition at line 5845 of file n_gui.c.
References N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_TYPE_MARKDOWNVIEW, and N_GUI_WIDGET::type.
Referenced by n_gui_markdownview_content_height(), n_gui_markdownview_get_scroll(), n_gui_markdownview_get_text(), n_gui_markdownview_scroll_to(), n_gui_markdownview_set_fonts(), n_gui_markdownview_set_on_link(), n_gui_markdownview_set_text(), and n_gui_markdownview_style().
|
static |
The width the document is laid out at: the widget less its padding, and less the bar when there is one.
Asked by the draw and by the event paths, which have to agree or a click lands on a different line from the one it looks like it is on.
Definition at line 5770 of file n_gui.c.
References N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::textarea_padding, and N_GUI_WIDGET::w.
Referenced by _draw_markdownview(), _markdownview_measure(), and n_gui_process_event().
|
static |
helper: compute minimum line thickness so it stays >= 1 physical pixel.
Extracts the scale factor from the current Allegro transform using the lengths of the basis vectors so that rotation and non-uniform scaling are handled correctly (m[0][0] alone can be near 0 for a 90-degree rotation).
Definition at line 7667 of file n_gui.c.
Referenced by _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_combobox_dropdown(), _draw_datagrid(), _draw_dropmenu(), _draw_dropmenu_panel(), _draw_focus_outline(), _draw_hexview(), _draw_label(), _draw_radiolist(), _draw_scrollbar_thumb(), _draw_scrollbar_track(), _draw_slider(), _draw_syntaxview(), _draw_textarea(), _draw_textarea_suggest(), _draw_themed_rect(), and _draw_window().
|
static |
Draw all visible windows and their widgets.
Set the display (viewport) size for global scrollbar computation.
When a display size has been set (via n_gui_set_display_size) and the total GUI bounding box exceeds it, global scrollbars are drawn at the edges of the display and all windows are offset by the global scroll position.
| ctx | the GUI context |
Call on startup and whenever ALLEGRO_EVENT_DISPLAY_RESIZE is received. When virtual canvas is enabled, also recalculates the virtual-to-display transform.
Apply a display size: store it and redo what depends on it.
The body of n_gui_set_display_size(), shared with the fallback in n_gui_draw() that takes the size from the target bitmap when the caller never set one.
| ctx | GUI context. Must not be NULL. |
| w | Width in pixels. |
| h | Height in pixels. |
Definition at line 12336 of file n_gui.c.
References N_GUI_CTX::display_h, N_GUI_CTX::display_w, h(), n_gui_apply_adaptive_resize(), N_GUI_RESIZE_ADAPTIVE, n_gui_update_transform(), N_GUI_CTX::resize_mode, N_GUI_CTX::virtual_h, and N_GUI_CTX::virtual_w.
Referenced by n_gui_draw(), and n_gui_set_display_size().
|
static |
Definition at line 18349 of file n_gui.c.
References N_GUI_KV_ROW::active, N_GUI_KVTABLE::nb_rows, and N_GUI_KVTABLE::rows.
Referenced by _n_gui_kv_refresh_actions(), n_gui_kvtable_duplicate_row(), and n_gui_kvtable_move_row().
|
static |
Definition at line 18260 of file n_gui.c.
References n_gui_kvtable_add_row().
Referenced by n_gui_kvtable_create().
|
static |
Definition at line 18399 of file n_gui.c.
References _n_gui_widget_capture_normalized(), N_GUI_KV_ROW::active, N_GUI_KVTABLE::btn_add, N_GUI_KVTABLE::col_frac, N_GUI_KVTABLE::ctx, N_GUI_WINDOW::detach_flags, N_GUI_KVTABLE::frac_cols, N_GUI_WIDGET::h, N_GUI_WINDOW::h, N_GUI_KVTABLE::header_height, N_GUI_KVTABLE::init_win_h, N_GUI_KVTABLE::init_win_w, N_GUI_KVTABLE::lbl_desc, N_GUI_KVTABLE::lbl_enabled, N_GUI_KVTABLE::lbl_key, N_GUI_KVTABLE::lbl_value, N_GUI_DETACH_SCALE_CONTENT, n_gui_get_widget(), n_gui_get_window(), n_gui_set_widget_visible(), n_gui_splitpane_set_limits(), n_gui_splitpane_set_ratio(), N_GUI_WIN_RESIZE_SCALE, N_GUI_WINDOW::native, N_GUI_KVTABLE::nb_rows, N_GUI_KVTABLE::padding, N_GUI_WINDOW::resize_policy, row(), N_GUI_KVTABLE::row_height, N_GUI_KVTABLE::rows, N_GUI_KVTABLE::show_actions, N_GUI_KVTABLE::show_desc, N_GUI_KVTABLE::show_enabled, N_GUI_KVTABLE::show_value, N_GUI_KVTABLE::split_a, N_GUI_KVTABLE::split_b, N_GUI_KVTABLE::top_offset, N_GUI_WIDGET::w, N_GUI_WINDOW::w, N_GUI_KVTABLE::window_id, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _n_gui_kv_split_a_changed(), _n_gui_kv_split_b_changed(), n_gui_kvtable_add_row(), n_gui_kvtable_clear(), n_gui_kvtable_create(), n_gui_kvtable_relayout(), n_gui_kvtable_remove_row(), n_gui_kvtable_set_columns(), n_gui_kvtable_set_row_actions(), and n_gui_kvtable_set_top_offset().
|
static |
Definition at line 18342 of file n_gui.c.
References N_GUI_KV_CONTENT::desc, FreeNoLog, N_GUI_KV_CONTENT::key, and N_GUI_KV_CONTENT::value.
Referenced by n_gui_kvtable_duplicate_row(), and n_gui_kvtable_move_row().
|
static |
Definition at line 18326 of file n_gui.c.
References _n_gui_kv_dup_text(), N_GUI_KVTABLE::ctx, N_GUI_KV_CONTENT::desc, N_GUI_KV_CONTENT::enabled, N_GUI_KV_CONTENT::key, n_gui_checkbox_is_checked(), row(), N_GUI_KVTABLE::rows, and N_GUI_KV_CONTENT::value.
Referenced by n_gui_kvtable_duplicate_row(), and n_gui_kvtable_move_row().
|
static |
Definition at line 18334 of file n_gui.c.
References N_GUI_KVTABLE::ctx, N_GUI_KV_CONTENT::desc, N_GUI_KV_CONTENT::enabled, N_GUI_KV_CONTENT::key, n_gui_checkbox_set_checked(), n_gui_textarea_set_text(), row(), N_GUI_KVTABLE::rows, and N_GUI_KV_CONTENT::value.
Referenced by n_gui_kvtable_duplicate_row(), and n_gui_kvtable_move_row().
|
static |
Definition at line 18290 of file n_gui.c.
References N_GUI_KV_ROW::active, N_GUI_KV_ROW::down_id, n_gui_kvtable_move_row(), N_GUI_KVTABLE::nb_rows, and N_GUI_KVTABLE::rows.
Referenced by n_gui_kvtable_add_row().
|
static |
Definition at line 18301 of file n_gui.c.
References N_GUI_KV_ROW::active, N_GUI_KV_ROW::dup_id, n_gui_kvtable_duplicate_row(), N_GUI_KVTABLE::nb_rows, and N_GUI_KVTABLE::rows.
Referenced by n_gui_kvtable_add_row().
|
static |
Definition at line 18321 of file n_gui.c.
References n_gui_textarea_get_text().
Referenced by _n_gui_kv_content_grab().
|
static |
Definition at line 18359 of file n_gui.c.
References _n_gui_kv_active_order(), N_GUI_KVTABLE::ctx, N_GUI_KV_MAX, n_gui_set_widget_enabled(), row(), and N_GUI_KVTABLE::rows.
Referenced by n_gui_kvtable_add_row(), n_gui_kvtable_duplicate_row(), n_gui_kvtable_move_row(), n_gui_kvtable_remove_row(), and n_gui_kvtable_set_row_actions().
|
static |
Definition at line 18267 of file n_gui.c.
References N_GUI_KV_ROW::active, n_gui_kvtable_remove_row(), N_GUI_KVTABLE::nb_rows, N_GUI_KVTABLE::on_remove, N_GUI_KV_ROW::remove_id, N_GUI_KVTABLE::rows, and N_GUI_KVTABLE::user_data.
Referenced by n_gui_kvtable_add_row().
|
static |
Definition at line 18373 of file n_gui.c.
References _n_gui_kv_apply_layout(), N_GUI_KVTABLE::col_frac, and N_GUI_KVTABLE::frac_cols.
Referenced by n_gui_kvtable_create().
|
static |
Definition at line 18384 of file n_gui.c.
References _n_gui_kv_apply_layout(), N_GUI_KVTABLE::col_frac, and N_GUI_KVTABLE::frac_cols.
Referenced by n_gui_kvtable_create().
|
static |
Definition at line 18279 of file n_gui.c.
References N_GUI_KV_ROW::active, n_gui_kvtable_move_row(), N_GUI_KVTABLE::nb_rows, N_GUI_KVTABLE::rows, and N_GUI_KV_ROW::up_id.
Referenced by n_gui_kvtable_add_row().
|
static |
Definition at line 19068 of file n_gui.c.
References N_GUI_SECTION::folded, N_GUI_SECTION::header_id, n_gui_sectionlist_relayout(), N_GUI_SECTIONLIST::nb_sections, N_GUI_SECTIONLIST::on_toggle, N_GUI_SECTIONLIST::sections, and N_GUI_SECTIONLIST::user_data.
Referenced by n_gui_sectionlist_add_section().
|
static |
Definition at line 19059 of file n_gui.c.
References N_GUI_SECTIONLIST::ctx, N_GUI_SECTION::folded, N_GUI_SECTION::header_id, n_gui_button_set_label(), N_GUI_SECTIONLIST::sections, and N_GUI_SECTION::title.
Referenced by n_gui_sectionlist_relayout().
|
static |
Definition at line 19145 of file n_gui.c.
References N_GUI_SECTIONLIST::nb_sections, N_GUI_SECTION::nb_widgets, N_GUI_SECTIONLIST::sections, and N_GUI_SECTION::widget_ids.
Referenced by n_gui_sectionlist_set_widget_hidden(), and n_gui_sectionlist_set_widget_offset().
|
static |
Definition at line 17485 of file n_gui.c.
References N_GUI_TAB_PANEL::button_ids, n_gui_tab_set_active(), N_GUI_TAB_PANEL::nb_tabs, N_GUI_TAB_PANEL::on_tab_change, and N_GUI_TAB_PANEL::user_data.
Referenced by n_gui_tab_add().
|
static |
helper: add the children of one node to the listbox, in order, then each expanded child's own children under it.
The nodes array is append only, so a child added while its parent was being expanded sits at the end of it, nowhere near the parent. Walking the parent links rather than the array is what draws it under its parent; the array walk this replaced drew every lazily filled branch at the bottom of the tree, with the right indent and the wrong place, which is what a file browser filling a folder on demand looks like. Siblings keep their array order, which is the order they were added in and the order a drag-reorder rearranges.
Definition at line 17656 of file n_gui.c.
References _n_gui_tree_emit(), N_GUI_TREE::ctx, N_GUI_TREE_NODE::depth, display, N_GUI_TREE_NODE::expandable, N_GUI_TREE_NODE::expanded, N_GUI_TREE_NODE::has_children, N_GUI_TREE_NODE::label, N_GUI_TREE::listbox_id, n_gui_listbox_add_item(), N_GUI_TREE_MAX, N_GUI_TREE::nb_nodes, N_GUI_TREE::nb_visible, N_GUI_TREE::nodes, N_GUI_TREE_NODE::parent_index, and N_GUI_TREE::visible_map.
Referenced by _n_gui_tree_emit(), and n_gui_tree_rebuild().
|
static |
Hit-test the mouse against the listbox's visible rows and fill the out params.
Returns 1 if the mouse is over a valid row, 0 otherwise. Points inside the scrollbar column are excluded so the user cannot start a drag by grabbing the scrollbar.
Definition at line 18097 of file n_gui.c.
References _n_gui_tree_listbox_bounds(), N_GUI_DROP_AFTER, N_GUI_DROP_BEFORE, N_GUI_DROP_INTO, N_GUI_TREE::nb_nodes, N_GUI_TREE::nb_visible, and N_GUI_TREE::visible_map.
Referenced by n_gui_tree_tick().
|
static |
Return the listbox's absolute (screen-space) bounds and geometry via out params.
out_item_area_w is the row content width (total width minus the scrollbar column, when one is needed) and matches where the selection / hover highlight actually paints. out_inset is the horizontal padding applied to row highlights, kept in sync with _draw_listbox so DnD indicators line up exactly. Returns 1 on success, 0 on failure.
Definition at line 18057 of file n_gui.c.
References N_GUI_TREE::ctx, N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_LISTBOX_DATA::item_height, N_GUI_STYLE::item_selection_inset, N_GUI_TREE::listbox_id, n_gui_get_widget(), n_gui_get_window(), N_GUI_TYPE_LISTBOX, N_GUI_LISTBOX_DATA::nb_items, N_GUI_LISTBOX_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_CTX::style, N_GUI_WINDOW::titlebar_h, N_GUI_WIDGET::type, N_GUI_WIDGET::w, N_GUI_TREE::window_id, N_GUI_WIDGET::x, N_GUI_WINDOW::x, N_GUI_WIDGET::y, and N_GUI_WINDOW::y.
Referenced by _n_gui_tree_hit_row(), and n_gui_tree_draw_overlay().
|
static |
Definition at line 17603 of file n_gui.c.
References N_GUI_TREE_NODE::expandable, N_GUI_TREE_NODE::has_children, n_gui_tree_toggle_expand(), N_GUI_TREE::nb_nodes, N_GUI_TREE::nb_visible, N_GUI_TREE::nodes, N_GUI_TREE::on_select, N_GUI_TREE::user_data, and N_GUI_TREE::visible_map.
Referenced by n_gui_tree_create().
|
static |
helper: open a node, calling the expand callback first when it has not filled this node yet.
A node the callback leaves empty loses its expander and stays shut. Does not rebuild. Returns 1 when the node is now open.
Definition at line 17815 of file n_gui.c.
References N_GUI_TREE::expand_user_data, N_GUI_TREE_NODE::expandable, N_GUI_TREE_NODE::expanded, N_GUI_TREE_NODE::filled, N_GUI_TREE_NODE::has_children, N_GUI_TREE::nodes, and N_GUI_TREE::on_expand.
Referenced by n_gui_tree_expand(), n_gui_tree_state_apply(), and n_gui_tree_toggle_expand().
|
static |
capture normalized coords for a single widget relative to its parent window
Definition at line 1260 of file n_gui.c.
References N_GUI_WIDGET::h, N_GUI_WINDOW::h, N_GUI_WIDGET::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WIDGET::norm_y, N_GUI_WIDGET::w, N_GUI_WINDOW::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _n_gui_kv_apply_layout(), 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_sectionlist_relayout(), n_gui_tab_relayout(), n_gui_widget_set_rect(), n_gui_window_attach(), and n_gui_window_detach().
|
static |
capture normalized coords for a window and its widgets from current absolutes
Definition at line 1235 of file n_gui.c.
References N_GUI_CTX::display_h, N_GUI_CTX::display_w, N_GUI_WIDGET::h, N_GUI_WINDOW::h, list_foreach, N_GUI_WIN_RESIZE_SCALE, N_GUI_WIDGET::norm_h, N_GUI_WINDOW::norm_h, N_GUI_WIDGET::norm_w, N_GUI_WINDOW::norm_w, N_GUI_WIDGET::norm_x, N_GUI_WINDOW::norm_x, N_GUI_WIDGET::norm_y, N_GUI_WINDOW::norm_y, N_GUI_CTX::ref_display_h, N_GUI_CTX::ref_display_w, N_GUI_WINDOW::resize_policy, 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 n_gui_add_window(), n_gui_maximize_window(), n_gui_process_event(), n_gui_set_resize_mode(), n_gui_window_set_resize_policy(), and n_gui_window_update_normalized().
|
static |
helper: mirror an own-chrome window's minimised state onto its OS window by shrinking the display to the title bar and growing it back.
Allegro's ALLEGRO_MINIMIZED is documented read-only (and "very platform-dependent"), so there is no portable iconify call to use. Shrinking is the honest mapping anyway: N_GUI minimised means "title bar only", which is exactly what the user then sees on the desktop.
win->h keeps the full height throughout, it is what the window grows back to and what the layout persists. The DISPLAY_RESIZE handler skips its geometry update while the window is minimised for the same reason.
Definition at line 349 of file n_gui.c.
References _native_own_chrome(), _win_tbh(), N_GUI_WINDOW::h, N_GUI_WINDOW::min_h, N_GUI_WINDOW::min_w, N_GUI_WIN_MINIMISED, N_GUI_WINDOW::native, N_GUI_WINDOW::state, and N_GUI_WINDOW::w.
Referenced by n_gui_maximize_window(), n_gui_minimize_window(), and n_gui_restore_window().
|
static |
helper: anchor an own-chrome window's title bar drag on the desktop cursor.
Mouse coordinates in an Allegro event are relative to the display the event came from, so moving the OS window changes the coordinate system the NEXT events are expressed in. Deriving each move from those coordinates therefore feeds every move back into the following one: the events already queued when al_set_window_position runs were generated against the OLD position, and each of them re-applies the travel the previous one already applied. Draining a burst of three motion events moves the window three times as far as the pointer went, then the correction events send it back, which is the jitter and the run-away seen when dragging a detached window around the desktop.
al_get_mouse_cursor_position reports the pointer in desktop coordinates, which no window move can alter. Capturing it once with the window position at the grab turns the drag into an absolute mapping (window = grab position + cursor travel), so a stale event carries no state and a backlog simply converges on the current pointer instead of compounding.
Definition at line 324 of file n_gui.c.
References _native_own_chrome(), N_GUI_WINDOW::native, N_GUI_WINDOW::native_drag_anchored, N_GUI_WINDOW::native_drag_cx, N_GUI_WINDOW::native_drag_cy, N_GUI_WINDOW::native_drag_wx, and N_GUI_WINDOW::native_drag_wy.
Referenced by n_gui_process_event().
|
static |
helper: the monitor rectangle a native window sits on.
al_get_display_adapter answers this in one call but it only exists from Allegro 5.2.10 on, and builds still target 5.2.6 (Debian 11). The window position is enough to derive it: pick the monitor whose rectangle contains the window origin, and fall back to the first adapter when the origin sits outside every reported monitor (window manager has not placed the window yet, or an adapter reports no info). Returns 1 when info was filled.
Definition at line 393 of file n_gui.c.
References display.
Referenced by n_gui_maximize_window().
|
static |
helper: whether a window is detached AND keeps drawing its own chrome (N_GUI_DETACH_OWN_CHROME).
Such a window fills a frameless native window title bar included, so the title bar drag, the resize grip and the three title bar buttons have to act on the OS window instead of on x/y/w/h.
Definition at line 303 of file n_gui.c.
References N_GUI_WINDOW::detach_flags, N_GUI_DETACH_OWN_CHROME, and N_GUI_WINDOW::native.
Referenced by _native_apply_minimised(), _native_drag_begin(), _tb_button_action(), n_gui_maximize_window(), and n_gui_process_event().
|
static |
helper: allocate and initialise a base widget
Definition at line 764 of file n_gui.c.
References __n_assert, N_GUI_WIDGET::data, N_GUI_CTX::default_theme, N_GUI_WIDGET::enabled, N_GUI_WIDGET::font, h(), N_GUI_WIDGET::h, N_GUI_WIDGET::id, Malloc, N_GUI_STATE_IDLE, N_GUI_CTX::next_widget_id, N_GUI_WIDGET::state, N_GUI_WIDGET::theme, N_GUI_WIDGET::tooltip, N_GUI_WIDGET::type, type(), N_GUI_WIDGET::visible, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by 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(), and n_gui_add_textarea().
|
static |
Definition at line 56 of file n_gui.c.
References display, n_clipboard_available(), N_CLIPBOARD_CLIPBOARD, and n_clipboard_get().
Referenced by _textarea_handle_key(), and n_gui_process_event().
|
static |
Definition at line 44 of file n_gui.c.
References display, n_clipboard_available(), N_CLIPBOARD_CLIPBOARD, n_clipboard_set(), and text().
Referenced by _ngui_publish_primary_selection(), _textarea_copy_to_clipboard(), and n_gui_process_event().
|
static |
find (or claim) the cache slot for (font, text[len]).
On a slot miss the entry is reset to this key with both metrics marked absent. Callers must have ruled out len >= N_GUI_MEAS_KEY_MAX.
Definition at line 218 of file n_gui.c.
References _ngui_meas_cache, font, N_GUI_MEAS_ENTRY::font, h(), N_GUI_MEAS_ENTRY::hash, N_GUI_MEAS_ENTRY::have_adv, N_GUI_MEAS_ENTRY::have_dims, N_GUI_MEAS_ENTRY::key, N_GUI_MEAS_ENTRY::len, N_GUI_MEAS_ENTRY::line_h, N_GUI_MEAS_CACHE_SIZE, and text().
Referenced by _text_dims(), and _text_w().
|
static |
publish the active text selection (syntax view, label, or focused textarea) to the X11 PRIMARY selection, implementing select-to-copy: selecting text with the mouse or keyboard makes it available for a middle-click paste, without disturbing CLIPBOARD.
No-op when no X11 clipboard backend is present (so the CLIPBOARD fallback is never clobbered by a selection).
Definition at line 12638 of file n_gui.c.
References _ctx_io_display(), _ngui_clip_set(), _textarea_has_selection(), _textarea_sel_range(), N_GUI_WIDGET::data, N_GUI_CTX::focused_widget_id, Free, Malloc, n_clipboard_available(), N_CLIPBOARD_PRIMARY, n_gui_get_widget(), n_gui_syntaxview_get_selected_text(), N_GUI_TYPE_LABEL, N_GUI_TYPE_TEXTAREA, N_GUI_LABEL_DATA::sel_end, N_GUI_LABEL_DATA::sel_start, N_GUI_CTX::selected_label_id, N_GUI_CTX::selected_syntaxview_id, N_GUI_LABEL_DATA::text, N_GUI_TEXTAREA_DATA::text, and N_GUI_WIDGET::type.
Referenced by _textarea_handle_key(), and n_gui_process_event().
|
static |
helper: strip CR from a string in-place, normalizing CRLF to LF.
Used at text entry points so all rendering code only needs to handle LF.
Definition at line 169 of file n_gui.c.
Referenced by n_gui_add_label(), n_gui_label_set_text(), and n_gui_textarea_set_text().
|
static |
the widget types that have no shape of their own (textarea, checkbox, a frameless window's body, the combobox dropdown) round only when the context ASKS for a round GUI: their square look is every existing program's default, and must not change under it.
Definition at line 8002 of file n_gui.c.
References N_GUI_SHAPE_ROUNDED, and N_GUI_STYLE::shape_mode.
Referenced by _draw_checkbox(), _draw_combobox_dropdown(), _draw_textarea(), and _draw_window().
|
static |
helper: test if point is inside a rectangle
Definition at line 497 of file n_gui.c.
Referenced by _datagrid_resize_hover(), _pointer_over_window(), _sb_track_hit(), _splitpane_hit(), _tooltip_widget_at(), _topmost_window_at(), n_gui_process_event(), and n_gui_wants_mouse().
|
static |
helper: is the pointer over any open window that takes part in the current pass?
O(windows) and used to short-circuit the per-widget tooltip and datagrid-cursor scans on motion events when the pointer is over empty background (the common case when the GUI is composited over a game). Both of those scans only ever match widgets that live inside a window, so skipping them off-window yields the same "nothing under the pointer" result.
Definition at line 526 of file n_gui.c.
References _point_in_rect(), _win_on_pass(), _win_tbh(), N_GUI_WINDOW::h, list_foreach, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WINDOW::state, N_GUI_WINDOW::w, N_GUI_CTX::windows, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by n_gui_process_event().
|
static |
Which of two widgets comes first in reading order.
By row, then across: two widgets are on one row when their tops are less than half the shorter one's height apart, so buttons a pixel or two out of line still read left to right. The id breaks a tie.
| a | One widget. |
| b | The other. |
Definition at line 2225 of file n_gui.c.
References N_GUI_WIDGET::h, N_GUI_WIDGET::id, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _button_neighbour().
|
static |
helper: register a widget in the hash table
Definition at line 736 of file n_gui.c.
References __n_assert, N_GUI_CTX::dirty, ht_put_ptr(), N_GUI_WIDGET::id, key, and N_GUI_CTX::widgets_by_id.
Referenced by 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(), and n_gui_add_textarea().
|
static |
forward declaration: unregister and destroy a window's native display, leaving the window's geometry untouched (see the native window section)
helper: unregister and destroy a window's native display.
The window's geometry and flags are left alone, the callers decide whether the window goes back to being a pop-up (n_gui_window_attach) or simply disappears with the context (n_gui_destroy_ctx).
Definition at line 1604 of file n_gui.c.
References N_GUI_CTX::active_display, N_GUI_CTX::display, N_GUI_CTX::event_queue, N_GUI_WINDOW::native, N_GUI_WINDOW::native_close_pending, N_GUI_WINDOW::native_h, N_GUI_WINDOW::native_pos_x, N_GUI_WINDOW::native_pos_y, N_GUI_WINDOW::native_w, and N_GUI_CTX::pass_display.
Referenced by n_gui_destroy_ctx(), n_gui_draw_detached(), and n_gui_window_attach().
|
static |
helper: the skin of a bar belonging to a widget or a window.
Definition at line 7775 of file n_gui.c.
References _N_GUI_SB_SKIN::corner_r, _N_GUI_SB_SKIN::outline, _N_GUI_SB_SKIN::outline_thickness, N_GUI_STYLE::scrollbar_thumb_color, N_GUI_STYLE::scrollbar_thumb_corner_r, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_STYLE::scrollbar_track_color, _N_GUI_SB_SKIN::thumb, _N_GUI_SB_SKIN::thumb_padding, _N_GUI_SB_SKIN::track, _N_GUI_SB_SKIN::track_inset, and _N_GUI_SB_SKIN::track_round.
Referenced by _draw_cols_scrollbar(), _draw_combobox_dropdown(), _draw_dropmenu_panel(), _draw_rows_scrollbar(), _draw_scrollbar(), _draw_widget_vscrollbar(), and _draw_window().
|
static |
helper: the skin of one of the display's own bars, which scroll the whole virtual canvas rather than anything inside it.
Definition at line 7790 of file n_gui.c.
References _N_GUI_SB_SKIN::corner_r, N_GUI_STYLE::global_scrollbar_border_thickness, 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_padding, N_GUI_STYLE::global_scrollbar_track_color, _N_GUI_SB_SKIN::outline, _N_GUI_SB_SKIN::outline_thickness, _N_GUI_SB_SKIN::thumb, _N_GUI_SB_SKIN::thumb_padding, _N_GUI_SB_SKIN::track, _N_GUI_SB_SKIN::track_inset, and _N_GUI_SB_SKIN::track_round.
Referenced by n_gui_draw().
|
static |
helper: is the pointer inside a bar's last painted rectangle.
A bar that was not painted has a zero width or height and can never be hit.
Definition at line 7739 of file n_gui.c.
References _point_in_rect(), N_GUI_SB_TRACK::h, N_GUI_SB_TRACK::w, N_GUI_SB_TRACK::x, and N_GUI_SB_TRACK::y.
Referenced by n_gui_process_event().
|
static |
helper: compute scroll position from mouse coordinate using thumb-aware math.
This is the formula used by the window auto-scrollbar, it maps the mouse to where the center of the thumb should be, giving smooth proportional feel.
| mouse | current mouse coordinate (x or y) |
| track_start | pixel start of the scrollbar track |
| track_length | pixel length of the scrollbar track |
| viewport | visible portion size |
| content | total content size |
| thumb_min | minimum thumb size in pixels |
Definition at line 564 of file n_gui.c.
References mouse().
Referenced by _scrollbar_calc_scroll_int(), and n_gui_process_event().
|
static |
helper: integer variant of _scrollbar_calc_scroll for item-based widgets.
| mouse | current mouse coordinate |
| track_start | pixel start of the scrollbar track |
| track_length | pixel length of the scrollbar track |
| visible_items | number of visible items |
| total_items | total number of items |
| thumb_min | minimum thumb size in pixels |
Definition at line 587 of file n_gui.c.
References _scrollbar_calc_scroll(), and mouse().
Referenced by n_gui_process_event().
|
static |
helper: the colour of the outline round a scrollbar's thumb, for the state of the bar.
A press or a drag reads as border_active and the pointer merely being on the bar as border_hover, the mapping _draw_textarea uses for those two. The bar's divider does not use this; it is border_normal always, because a line running the length of the bar is not a way of pointing at it.
Keyboard focus is deliberately NOT one of them, though it was to begin with. A widget has one focus and can have two bars, so focus lit both of them at once, and it lit them on a click anywhere in the widget: clicking a row of a tree made both of its bars glow and nothing about that said what the arrow keys would move. The pointer is the only thing that names one bar out of two, so the highlight follows the pointer.
Definition at line 7713 of file n_gui.c.
References N_GUI_THEME::border_active, N_GUI_THEME::border_hover, N_GUI_THEME::border_normal, N_GUI_STATE_ACTIVE, N_GUI_STATE_HOVER, and N_GUI_STATE_SCROLLBAR_DRAG.
Referenced by _draw_scrollbar_thumb().
|
static |
helper: where a scrollbar thumb sits and how long it is.
The same five lines used to appear in all three scrollbar drawers – the widget vertical bar, the row-based one and the pixel-based horizontal one – differing only in axis and units, with one of them commented as mirroring another. A thumb that disagrees with the scroll it represents is the kind of bug you feel rather than see, so it is computed once here.
visible, content and offset are in the CALLER's units (rows for the row bar, pixels for the others); track_len and the result are pixels. A zero content yields a full-length thumb rather than a division by zero, which is what the row and column bars already did explicitly.
Definition at line 7649 of file n_gui.c.
References _N_GUI_THUMB::len, _N_GUI_THUMB::off, and visible().
Referenced by _draw_cols_scrollbar(), _draw_combobox_dropdown(), _draw_dropmenu_panel(), _draw_rows_scrollbar(), _draw_scrollbar(), _draw_widget_vscrollbar(), _draw_window(), and n_gui_draw().
|
static |
helper: the fill of a scrollbar thumb, for the state of the bar.
at_rest is the skin's own thumb colour, which is deliberately not derived from the widget theme so that a bar stays legible over any background. A live bar is that colour lifted part of the way towards the theme's accent rather than replaced by it: enough to see which bar the pointer is on, not enough to turn a scrollbar into the brightest thing on screen. A drag lifts further than a hover, because it is doing something. Focus is not read here; see _scrollbar_edge_for_state.
Definition at line 7729 of file n_gui.c.
References _color_mix(), N_GUI_THEME::border_active, N_GUI_THEME::border_hover, N_GUI_STATE_ACTIVE, N_GUI_STATE_HOVER, and N_GUI_STATE_SCROLLBAR_DRAG.
Referenced by _draw_scrollbar_thumb().
|
static |
handle scrollbar drag
Definition at line 12502 of file n_gui.c.
References N_GUI_SCROLLBAR_DATA::content_size, N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_WIDGET::id, N_GUI_SCROLLBAR_V, N_GUI_SCROLLBAR_DATA::on_scroll, N_GUI_SCROLLBAR_DATA::orientation, N_GUI_SCROLLBAR_DATA::scroll_pos, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_SCROLLBAR_DATA::user_data, N_GUI_SCROLLBAR_DATA::viewport_size, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by n_gui_process_event().
|
static |
helper: turn the wheel over a scrollbar: its wheel step per notch, a twentieth of its range when it has none, clamped, its on_scroll called.
Returns 1 when it could move (its content is longer than its viewport), 0 otherwise.
Definition at line 2421 of file n_gui.c.
References N_GUI_SCROLLBAR_DATA::content_size, N_GUI_WIDGET::data, N_GUI_WIDGET::id, N_GUI_SCROLLBAR_DATA::on_scroll, N_GUI_SCROLLBAR_DATA::scroll_pos, N_GUI_SCROLLBAR_DATA::user_data, N_GUI_SCROLLBAR_DATA::viewport_size, and N_GUI_SCROLLBAR_DATA::wheel_step.
Referenced by n_gui_process_event().
|
static |
helper: select per-state bitmap with fallback chain.
Returns the appropriate bitmap for the given state, falling back to normal_bmp. Returns NULL if all pointers are NULL.
Definition at line 6797 of file n_gui.c.
References N_GUI_STATE_ACTIVE, and N_GUI_STATE_HOVER.
Referenced by _draw_scrollbar(), and _draw_slider().
|
static |
helper: set clipping rectangle in world space, transforming to screen space.
This accounts for the current Allegro transform (e.g. global scroll) so that clipping works correctly even when a translation transform is active. The resulting clip rect is also intersected with the current (parent) clip to avoid drawing outside the parent's visible area.
Definition at line 6809 of file n_gui.c.
References right().
Referenced by _draw_label(), _draw_label_lines(), _draw_markdownview(), _draw_textarea(), and _draw_window().
|
static |
resolve whether a shape-aware widget draws rounded: the global shape_mode override (style->shape_mode) wins when set to ROUNDED or RECT, otherwise the widget's own shape decides.
Definition at line 7992 of file n_gui.c.
References N_GUI_SHAPE_RECT, N_GUI_SHAPE_ROUNDED, and N_GUI_STYLE::shape_mode.
Referenced by _draw_button(), _draw_combobox(), _draw_markdownview(), and _draw_scrollbar().
|
static |
helper: "..." followed by the shortest tail of text, cut between UTF-8 sequences, that fits max_w.
Returns 1 with out filled, or 0 when not even "..." and one character fit.
Definition at line 6874 of file n_gui.c.
References _text_w(), _utf8_step(), font, and text().
Referenced by n_gui_text_shorten().
|
static |
Radius of a slider's handle, from the widget's short side.
Both the drawing and the hit test need it, and they have to agree or the handle lands somewhere other than where the pointer is.
Definition at line 8140 of file n_gui.c.
References N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_SLIDER_V, N_GUI_STYLE::slider_handle_edge_offset, N_GUI_STYLE::slider_handle_min_r, and N_GUI_WIDGET::w.
Referenced by _draw_slider(), _slider_travel(), and n_gui_slider_handle_pos().
|
static |
how far one arrow key press or one wheel notch moves a slider
| sd | slider data, must not be NULL |
Definition at line 4030 of file n_gui.c.
References N_GUI_SLIDER_DATA::key_step, N_GUI_SLIDER_DATA::max_val, N_GUI_SLIDER_DATA::min_val, and N_GUI_SLIDER_DATA::step.
Referenced by n_gui_process_event(), and n_gui_slider_get_key_step().
|
static |
helper: snap a slider value to the nearest valid step from min_val.
Uses round() to avoid floating-point drift (e.g. 0.1 steps never produce 0.30000000000000004). Result is clamped to [min_val, max_val]. step <= 0 is treated as 1.
Definition at line 95 of file n_gui.c.
Referenced by _slider_update_from_mouse(), n_gui_process_event(), n_gui_slider_set_range(), n_gui_slider_set_step(), and n_gui_slider_set_value().
|
static |
The strip a slider's handle centre travels along, inset by its radius at each end.
The handle is a circle centred on the value's position. Letting that centre reach the widget's own edges puts half the circle outside the widget, where the clipping rectangle cuts it off, so a slider at its minimum drew a half moon instead of a handle and one at its maximum did the same on the other side. The centre travels along an inset strip instead, and the same strip is what a press or a drag is measured against so the handle still lands under the pointer.
A widget shorter than two radii has nowhere to travel; the length is then zero and the handle sits in the middle, which is the best a slider that small can do.
| wgt | the slider |
| style | the style the radius comes from |
| start | receives the offset of the first position from the widget's left or top edge |
| length | receives how far the centre may travel, never negative |
Definition at line 8170 of file n_gui.c.
References _slider_handle_r(), N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_SLIDER_V, start(), and N_GUI_WIDGET::w.
Referenced by _draw_slider(), _slider_update_from_mouse(), and n_gui_slider_handle_pos().
|
static |
handle slider drag (horizontal or vertical)
Definition at line 12462 of file n_gui.c.
References _clamp(), _slider_snap_value(), _slider_travel(), N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_WIDGET::id, N_GUI_SLIDER_DATA::max_val, N_GUI_SLIDER_DATA::min_val, N_GUI_SLIDER_V, N_GUI_SLIDER_DATA::on_change, N_GUI_SLIDER_DATA::orientation, N_GUI_SLIDER_DATA::step, N_GUI_SLIDER_DATA::user_data, N_GUI_SLIDER_DATA::value, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by n_gui_process_event().
|
static |
draw a slider widget (horizontal or vertical)
helper: the text a slider's built-in readout shows for one value. The format is the caller's when it set one, a percentage in percent mode, and one decimal otherwise. Shared by the draw and by n_gui_slider_value_width(), so a layout that reserves room for the readout reserves the room the readout actually takes.
Definition at line 8121 of file n_gui.c.
References N_GUI_SLIDER_DATA::mode, N_GUI_SLIDER_PERCENT, and N_GUI_SLIDER_DATA::value_format.
Referenced by _draw_slider(), and n_gui_slider_value_width().
|
static |
Sort windows list by z-order: ALWAYS_BEHIND first, then FIXED (by z_value), then NORMAL, then ALWAYS_ON_TOP, then POPUP.
Within each group, preserve relative order. Uses stable insertion sort since window lists are typically small.
Definition at line 2000 of file n_gui.c.
References _destroy_window(), _zorder_group(), LIST_NODE::destroy_func, Free, list_foreach, list_push(), Malloc, LIST::nb_items, remove_list_node_f(), LIST::start, N_GUI_CTX::windows, and N_GUI_WINDOW::z_value.
Referenced by n_gui_add_window(), n_gui_lower_window(), n_gui_raise_window(), and n_gui_window_set_zorder().
|
static |
helper: split text into whitespace-separated words, recording each word's byte offset in text, its byte length and its pixel width.
Returns the word count, capped at max_words.
Note the measure buffer is bounded: a word longer than N_GUI_TEXT_MAX used to be memcpy'd whole into a stack array of that size by two of the callers this replaces. The recorded length stays the true one, so byte offsets are unaffected; only the width is that of the measurable prefix.
Definition at line 6993 of file n_gui.c.
References _text_w(), font, N_GUI_TEXT_MAX, and text().
Referenced by _draw_justified_selection(), _draw_text_justified(), _justified_char_at_pos(), and _label_content_height().
|
static |
report the split-pane divider under a point, for the mouse cursor shape: 0 = none, 1 = vertical divider (drags left/right), 2 = horizontal divider (drags up/down).
Definition at line 13561 of file n_gui.c.
References _splitpane_hit(), N_GUI_WIDGET::data, n_gui_get_widget(), N_GUI_SPLIT_VERTICAL, N_GUI_TYPE_SPLITPANE, and N_GUI_WIDGET::type.
Referenced by n_gui_process_event().
|
static |
report the split pane whose divider band is under a point, or -1.
Windows are walked back to front and widgets bottom to top, so the topmost claimant wins. A split pane off its band is click-through and therefore does not hide a divider beneath it, while any other widget under the point does take the press and clears the verdict.
Definition at line 13527 of file n_gui.c.
References _point_in_rect(), _splitpane_on_divider(), _win_on_pass(), _win_tbh(), N_GUI_WIDGET::enabled, N_GUI_WIDGET::h, N_GUI_WINDOW::h, N_GUI_WIDGET::id, list_foreach, N_GUI_TYPE_SPLITPANE, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_WINDOW::state, N_GUI_WIDGET::type, N_GUI_WIDGET::visible, N_GUI_WIDGET::w, N_GUI_WINDOW::w, N_GUI_WINDOW::widgets, N_GUI_CTX::windows, N_GUI_WIDGET::x, N_GUI_WINDOW::x, N_GUI_WIDGET::y, and N_GUI_WINDOW::y.
Referenced by _splitpane_cursor_hover(), and n_gui_splitpane_at().
|
static |
forward declaration: test whether a point falls on a split pane's draggable divider band.
test whether a point falls on a split pane's draggable divider band.
Defined near the split pane draw code.
The widget spans the whole region it splits, so this is what tells a press meant for the divider apart from a press anywhere else over the two panes. ax/ay are the widget's absolute top-left corner.
Definition at line 9930 of file n_gui.c.
References N_GUI_WIDGET::data, N_GUI_SPLITPANE_DATA::divider, N_GUI_WIDGET::h, N_GUI_SPLIT_VERTICAL, N_GUI_TYPE_SPLITPANE, N_GUI_SPLITPANE_DATA::orientation, N_GUI_SPLITPANE_DATA::ratio, N_GUI_WIDGET::type, and N_GUI_WIDGET::w.
Referenced by _splitpane_hit(), _tooltip_widget_at(), and n_gui_process_event().
|
static |
put the highlighted completion in place of the word under the cursor
Definition at line 12823 of file n_gui.c.
References _suggest_close(), _suggest_word(), N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_WIDGET::data, N_GUI_WIDGET::id, N_GUI_TEXTAREA_DATA::on_change, N_GUI_TEXTAREA_DATA::sel_end, N_GUI_TEXTAREA_DATA::sel_start, start(), N_GUI_TEXTAREA_DATA::suggest_count, N_GUI_TEXTAREA_DATA::suggest_highlight, N_GUI_TEXTAREA_DATA::suggest_items, N_GUI_TEXTAREA_DATA::suggest_open, N_GUI_LISTITEM::text, N_GUI_TEXTAREA_DATA::text, N_GUI_TEXTAREA_DATA::text_alloc, N_GUI_TEXTAREA_DATA::text_len, and N_GUI_TEXTAREA_DATA::user_data.
Referenced by _suggest_handle_key(), and n_gui_process_event().
|
static |
put the panel away, and forget which word it answered
Definition at line 12757 of file n_gui.c.
References N_GUI_WIDGET::data, N_GUI_WIDGET::id, N_GUI_CTX::open_suggest_id, N_GUI_TEXTAREA_DATA::suggest_count, N_GUI_TEXTAREA_DATA::suggest_highlight, N_GUI_TEXTAREA_DATA::suggest_open, N_GUI_TEXTAREA_DATA::suggest_prefix, and N_GUI_TEXTAREA_DATA::suggest_scroll.
Referenced by _draw_textarea_suggest(), _suggest_accept(), _suggest_handle_key(), _suggest_refresh(), n_gui_process_event(), n_gui_textarea_set_suggest(), and n_gui_textarea_suggest_close().
|
static |
the keys a completion panel takes before the textarea sees them.
Up, Down, ENTER, TAB and ESCAPE mean something else entirely while a panel is up, so they are answered here and the field never hears them. Down with no panel up asks for one, which is how somebody who dismissed it gets it back without retyping the word.
| ctx | the GUI context |
| wgt | the focused textarea |
| ev | the key event |
Definition at line 13411 of file n_gui.c.
References _list_panel_highlight_step(), _suggest_accept(), _suggest_close(), _suggest_refresh(), N_GUI_WIDGET::data, N_GUI_SUGGEST_VISIBLE, N_GUI_TEXTAREA_DATA::suggest, N_GUI_TEXTAREA_DATA::suggest_count, N_GUI_TEXTAREA_DATA::suggest_highlight, N_GUI_TEXTAREA_DATA::suggest_open, and N_GUI_TEXTAREA_DATA::suggest_scroll.
Referenced by n_gui_process_event().
|
static |
is c one of the characters that end a word in this field
Definition at line 12726 of file n_gui.c.
References N_GUI_TEXTAREA_DATA::suggest_separators.
Referenced by _suggest_word().
|
static |
the geometry of an open completion panel, so the draw and the pointer agree about where its rows are.
Returns 0 when there is nothing to show, in which case the out parameters are untouched. The width follows the field rather than the longest entry: a completion is a word that is about to go into that field, so a panel wider than the field is a panel promising something the field cannot hold on one line.
Definition at line 10316 of file n_gui.c.
References _dropdown_panel_y(), _find_widget_window(), N_GUI_WIDGET::data, N_GUI_CTX::default_font, font, N_GUI_WIDGET::font, h(), N_GUI_WIDGET::h, N_GUI_WIDGET::id, N_GUI_STYLE::item_height_pad, N_GUI_SUGGEST_VISIBLE, N_GUI_CTX::style, N_GUI_TEXTAREA_DATA::suggest_count, N_GUI_TEXTAREA_DATA::suggest_open, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_textarea_suggest(), and n_gui_process_event().
|
static |
ask the provider about the word under the cursor, and open or close the panel by what it answers.
The prefix the answers are for is remembered, so a key that leaves the word as it was does not send the provider off again. force asks anyway, which is what the Down key needs when the panel was dismissed over a word that has not changed since.
Definition at line 12776 of file n_gui.c.
References _suggest_close(), _suggest_word(), N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_WIDGET::data, N_GUI_WIDGET::id, Malloc, n_gui_get_widget(), N_GUI_ID_MAX, N_GUI_SUGGEST_MAX, N_GUI_CTX::open_suggest_id, start(), N_GUI_TEXTAREA_DATA::suggest, N_GUI_TEXTAREA_DATA::suggest_count, N_GUI_TEXTAREA_DATA::suggest_highlight, N_GUI_TEXTAREA_DATA::suggest_items, N_GUI_TEXTAREA_DATA::suggest_open, N_GUI_TEXTAREA_DATA::suggest_prefix, N_GUI_TEXTAREA_DATA::suggest_scroll, N_GUI_TEXTAREA_DATA::suggest_user_data, and N_GUI_TEXTAREA_DATA::text.
Referenced by _suggest_handle_key(), and n_gui_process_event().
|
static |
the word the cursor is in.
start receives where it begins and end where it ends, both byte offsets into the text. Leading blanks are left out of the word, so that "sunset, be" completes "be" and not " be" and the replacement does not eat the space after the comma.
Definition at line 12744 of file n_gui.c.
References _suggest_is_sep(), N_GUI_TEXTAREA_DATA::cursor_pos, start(), and N_GUI_TEXTAREA_DATA::text.
Referenced by _suggest_accept(), and _suggest_refresh().
|
static |
unified diff line colours.
Added and removed carry meaning the way an HTTP status colour does, so they must not shift with the theme; they are picked mid-range to stay legible on light and dark backgrounds alike.
Definition at line 9091 of file n_gui.c.
Referenced by _syntax_draw_line().
|
static |
see _syntax_diff_add: colour of a removed line
Definition at line 9095 of file n_gui.c.
Referenced by _syntax_draw_line().
|
static |
see _syntax_diff_add: colour of a hunk header line
Definition at line 9099 of file n_gui.c.
Referenced by _syntax_draw_line().
|
static |
draw one text line with mode-specific highlighting starting at (x,y), inside the horizontal window [x_min,x_max] (see SYNTAX_RUN)
Definition at line 9105 of file n_gui.c.
References _syntax_diff_add(), _syntax_diff_del(), _syntax_diff_hunk(), _syntax_js_keyword(), _syntax_js_regex_kw(), _syntax_js_regex_possible(), _syntax_run(), N_GUI_THEME::border_active, N_GUI_THEME::border_hover, SYNTAX_RUN::cx, SYNTAX_RUN::done, font, SYNTAX_RUN::font, mode, N_GUI_SYNTAX_DIFF, N_GUI_SYNTAX_HTTP, N_GUI_SYNTAX_JS, N_GUI_SYNTAX_JSON, N_GUI_SYNTAX_XML, N_GUI_SYNTAX_YAML, N_GUI_THEME::text_active, N_GUI_THEME::text_normal, SYNTAX_RUN::x_max, SYNTAX_RUN::x_min, and SYNTAX_RUN::y.
Referenced by _draw_syntaxview().
|
static |
whether the n bytes at s form a JavaScript keyword or literal name
Definition at line 9074 of file n_gui.c.
Referenced by _syntax_draw_line().
|
static |
whether the n bytes at s are a keyword after which an expression (and therefore a regex literal) can start, e.g.
return /re/
Definition at line 9056 of file n_gui.c.
Referenced by _syntax_draw_line().
|
static |
whether a '/' may start a regex literal after last significant char c (start of line, after an operator, an opener, or a separator)
Definition at line 9068 of file n_gui.c.
Referenced by _syntax_draw_line().
|
static |
forward declaration: pixel width of the first n bytes of a line.
exact pixel width of the first n bytes of s, see _syntax_prefix_w_lim
Defined near the syntaxview draw code.
Definition at line 9407 of file n_gui.c.
References _syntax_prefix_w_lim(), and font.
Referenced by _syntaxview_ensure_width(), _syntaxview_offset_from_mouse(), and n_gui_syntaxview_scroll_to_offset().
|
static |
pixel width of the first n bytes of s in font, of any length: the measurement needs a NUL-terminated copy, so it accumulates over chunks of the same size _syntax_run draws in, which keeps the two in step.
A single fixed buffer instead would silently stop measuring at its end, and put a selection highlight or a click far from the glyphs it belongs to on a long line. limit stops the walk once the width passes it, for callers that only need to know where something lands on screen (anything past the right edge is clipped to the same pixel); pass 0 or less to measure the whole prefix.
Definition at line 9384 of file n_gui.c.
References _text_w(), and font.
Referenced by _draw_syntaxview(), and _syntax_prefix_w().
|
static |
draw one coloured run of a syntax line and advance the pen past it.
Runs outside the window are measured but not drawn (the pen still has to land in the right place), and the run that crosses the right edge sets done.
Definition at line 9027 of file n_gui.c.
References _text_w(), SYNTAX_RUN::cx, SYNTAX_RUN::done, SYNTAX_RUN::font, SYNTAX_RUN::x_max, SYNTAX_RUN::x_min, and SYNTAX_RUN::y.
Referenced by _syntax_draw_line().
|
static |
forward declaration: clamp a syntaxview's horizontal scroll to its content.
clamp a syntax view's horizontal scroll to the room its content actually needs
Defined near the syntaxview draw code.
Definition at line 9586 of file n_gui.c.
References N_GUI_SYNTAXVIEW_DATA::h_scroll.
Referenced by _draw_syntaxview(), n_gui_process_event(), and n_gui_syntaxview_scroll_to_offset().
|
static |
forward declaration: (re)build a syntaxview's cached line count and headers-end index when stale.
draw a read-only syntax-highlighted text view
Defined near the syntaxview draw code.
(re)build a syntaxview's cached line count and first-blank-line index. Both are pure functions of the text, so they are computed once per text change instead of scanning the whole buffer twice on every frame (and on every scroll/click event). Invalidated by clearing lines_valid in n_gui_syntaxview_set_text.
Definition at line 9489 of file n_gui.c.
References N_GUI_SYNTAXVIEW_DATA::cached_headers_end, N_GUI_SYNTAXVIEW_DATA::cached_nb_lines, N_GUI_SYNTAXVIEW_DATA::lines_valid, and N_GUI_SYNTAXVIEW_DATA::text.
Referenced by _syntaxview_hmetrics().
|
static |
forward declaration: (re)build a syntaxview's cached content width when stale.
(re)build a syntax view's cached content width: the pixel width of its widest line, plus the padding on both sides.
Defined near the syntaxview draw code.
Measured once per text (and once per font change), not once per frame the way the listbox can afford to: a reformatted document runs to tens of thousands of lines.
Definition at line 9523 of file n_gui.c.
References _syntax_prefix_w(), N_GUI_SYNTAXVIEW_DATA::cached_content_w, font, N_GUI_SYNTAXVIEW_DATA::metrics_font, N_GUI_SYNTAXVIEW_DATA::text, N_GUI_STYLE::textarea_padding, and N_GUI_SYNTAXVIEW_DATA::width_valid.
Referenced by _syntaxview_hmetrics(), and n_gui_syntaxview_content_width().
|
static |
forward declaration: syntaxview horizontal-scroll metrics, shared by the draw path and every mouse handler.
Syntax view horizontal-scroll metrics, computed identically by the draw path and the mouse handlers so the thumb and the hit test never drift apart.
Defined near the syntaxview draw code.
content_w is the width the widest line needs, pane_w the room left for the text (widget width minus a vertical scrollbar), need_hsb whether the content overflows that room, and visible the number of lines that fit above the horizontal scrollbar. Any output pointer may be NULL.
Definition at line 9550 of file n_gui.c.
References _syntaxview_ensure_lines(), _syntaxview_ensure_width(), N_GUI_SYNTAXVIEW_DATA::cached_content_w, N_GUI_SYNTAXVIEW_DATA::cached_nb_lines, font, N_GUI_WIDGET::h, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::textarea_padding, visible(), and N_GUI_WIDGET::w.
Referenced by _draw_syntaxview(), n_gui_process_event(), and n_gui_syntaxview_scroll_to_offset().
|
static |
Map a mouse position over a syntax view to a byte offset into its text.
The view does not wrap, so one source line maps to one display row; the row is chosen from the y position (plus the scroll offset) and the column from the x position by measuring incremental prefix widths of that line. The offset returned indexes the real text buffer (a trailing CR is treated as the end of the visible line).
Definition at line 9416 of file n_gui.c.
References _syntax_prefix_w(), font, N_GUI_SYNTAXVIEW_DATA::h_scroll, row(), N_GUI_SYNTAXVIEW_DATA::scroll_offset, and N_GUI_SYNTAXVIEW_DATA::text.
Referenced by n_gui_process_event().
|
static |
return the effective titlebar button size (0 = auto from titlebar_h)
Definition at line 11246 of file n_gui.c.
References N_GUI_STYLE::tb_btn_size, and N_GUI_WINDOW::titlebar_h.
Referenced by _tb_button_rect(), and _tb_buttons_area_width().
|
static |
Dispatch a titlebar button action, invoke the user callback if set, otherwise fall back to the built-in minimize / maximize / close behaviour.
| ctx | the GUI context (used for the default close/min/max paths) |
| win | the target window |
| btn_type | one of N_GUI_TB_BTN_MINIMIZE, _MAXIMIZE, _CLOSE |
Definition at line 13300 of file n_gui.c.
References _native_own_chrome(), N_GUI_WINDOW::id, n_gui_close_window(), n_gui_maximize_window(), n_gui_minimize_window(), N_GUI_TB_BTN_CLOSE, N_GUI_TB_BTN_MAXIMIZE, N_GUI_TB_BTN_MINIMIZE, N_GUI_WIN_OPEN, N_GUI_WINDOW::native, N_GUI_WINDOW::native_close_pending, N_GUI_TB_BUTTONS::on_close, N_GUI_TB_BUTTONS::on_close_user_data, N_GUI_TB_BUTTONS::on_maximize, N_GUI_TB_BUTTONS::on_maximize_user_data, N_GUI_TB_BUTTONS::on_minimize, N_GUI_TB_BUTTONS::on_minimize_user_data, N_GUI_WINDOW::state, and N_GUI_WINDOW::tb_buttons.
Referenced by n_gui_process_event().
|
static |
compute the absolute rect for a titlebar button.
Layout right-to-left: close rightmost, maximize next, minimize leftmost. Returns 1 if the button is enabled, 0 if not.
Definition at line 11266 of file n_gui.c.
References _tb_btn_resolved_size(), N_GUI_WINDOW::flags, N_GUI_TB_BTN_CLOSE, N_GUI_TB_BTN_MAXIMIZE, N_GUI_TB_BTN_MINIMIZE, N_GUI_WIN_BTN_CLOSE, N_GUI_WIN_BTN_MAXIMIZE, N_GUI_WIN_BTN_MINIMIZE, N_GUI_WIN_FRAMELESS, N_GUI_STYLE::tb_btn_right_margin, N_GUI_STYLE::tb_btn_spacing, N_GUI_WINDOW::titlebar_h, N_GUI_WINDOW::w, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by _draw_tb_buttons(), n_gui_process_event(), and n_gui_window_button_rect().
|
static |
compute the total width consumed by enabled titlebar buttons (0 if none/frameless)
Definition at line 11252 of file n_gui.c.
References _tb_btn_resolved_size(), N_GUI_WINDOW::flags, N_GUI_WIN_BTN_CLOSE, N_GUI_WIN_BTN_MAXIMIZE, N_GUI_WIN_BTN_MINIMIZE, N_GUI_WIN_FRAMELESS, N_GUI_STYLE::tb_btn_right_margin, and N_GUI_STYLE::tb_btn_spacing.
Referenced by _draw_window().
|
static |
helper: memoized al_get_text_dimensions (bounding box x/y/w/h).
Same result as calling al_get_text_dimensions directly; used by the per-widget label centring paths that re-measure unchanging text every frame.
Definition at line 261 of file n_gui.c.
References _ngui_meas_slot(), N_GUI_MEAS_ENTRY::dh, N_GUI_MEAS_ENTRY::dw, N_GUI_MEAS_ENTRY::dx, N_GUI_MEAS_ENTRY::dy, font, h(), N_GUI_MEAS_ENTRY::have_dims, N_GUI_MEAS_KEY_MAX, and text().
Referenced by _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_dropmenu(), _draw_label(), _draw_slider(), _draw_window(), and _label_text_origin_x().
|
static |
Definition at line 7693 of file n_gui.c.
References N_GUI_STATE_ACTIVE, N_GUI_STATE_HOVER, N_GUI_THEME::text_active, N_GUI_THEME::text_hover, and N_GUI_THEME::text_normal.
Referenced by _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_dropmenu(), _draw_label(), and _draw_tb_buttons().
|
static |
helper: destroy a single widget (called by list destructor)
count the lines in a NUL-terminated text (0 for empty)
forward declaration: count the lines in a NUL-terminated text
Definition at line 8988 of file n_gui.c.
Referenced by n_gui_syntaxview_get_line_count().
|
static |
helper: get the advance width of text.
Uses al_get_text_width which returns the advance width (includes space characters), unlike al_get_text_dimensions which returns the bounding box (zero width for spaces since they have no visible pixels). Memoized.
Definition at line 246 of file n_gui.c.
References _ngui_meas_slot(), N_GUI_MEAS_ENTRY::adv_w, font, N_GUI_MEAS_ENTRY::have_adv, N_GUI_MEAS_KEY_MAX, and text().
Referenced by _combobox_dropdown_width(), _draw_justified_selection(), _draw_label(), _draw_label_lines(), _draw_text_justified(), _draw_text_truncated(), _draw_textarea(), _draw_tooltip(), _justified_char_at_pos(), _label_char_at_x(), _label_content_height(), _label_effective_w(), _label_lines_char_at(), _listbox_hmetrics(), _shorten_start(), _split_words(), _syntax_prefix_w_lim(), _syntax_run(), _textarea_pos_from_mouse(), _textarea_step(), _window_update_content_size(), n_gui_dropmenu_panel_width(), n_gui_label_fits(), n_gui_listbox_content_width(), and n_gui_text_shorten().
|
static |
clear the selection (set both anchors to cursor_pos)
Definition at line 12562 of file n_gui.c.
References N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_TEXTAREA_DATA::sel_end, and N_GUI_TEXTAREA_DATA::sel_start.
Referenced by _textarea_delete_selection(), _textarea_handle_key(), and _textarea_paste_clip().
|
static |
helper: compute the total content height of multiline textarea text (with line-wrap), in pixels.
Uses the shared _textarea_step.
Definition at line 7266 of file n_gui.c.
References _textarea_step(), _N_GUI_TA_STEP::clen, _N_GUI_TA_STEP::cw, font, _N_GUI_TA_STEP::newline, N_GUI_TEXTAREA_DATA::text, N_GUI_TEXTAREA_DATA::text_len, and _N_GUI_TA_STEP::wrapped.
Referenced by _draw_textarea(), _textarea_handle_key(), _textarea_pos_from_mouse(), n_gui_process_event(), n_gui_textarea_scroll_to_bottom(), and n_gui_textarea_scroll_to_offset().
|
static |
copy selected text to clipboard.
Returns 1 on success.
Definition at line 12582 of file n_gui.c.
References _ngui_clip_set(), _textarea_has_selection(), _textarea_sel_range(), display, FreeNoLog, Malloc, N_CLIPBOARD_CLIPBOARD, and N_GUI_TEXTAREA_DATA::text.
Referenced by _textarea_handle_key().
|
static |
delete the currently selected text, move cursor to selection start
Definition at line 12568 of file n_gui.c.
References _textarea_clear_selection(), _textarea_has_selection(), _textarea_sel_range(), N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_WIDGET::data, N_GUI_WIDGET::id, N_GUI_TEXTAREA_DATA::on_change, N_GUI_TEXTAREA_DATA::text, N_GUI_TEXTAREA_DATA::text_len, and N_GUI_TEXTAREA_DATA::user_data.
Referenced by _textarea_handle_key(), and _textarea_paste_clip().
|
static |
Definition at line 12885 of file n_gui.c.
References _ctx_io_display(), _ngui_clip_get(), _ngui_publish_primary_selection(), _textarea_clear_selection(), _textarea_content_height(), _textarea_copy_to_clipboard(), _textarea_delete_selection(), _textarea_has_selection(), _textarea_paste_clip(), _textarea_sel_range(), _textarea_step(), _utf8_char_len(), _utf8_encode(), N_GUI_TEXTAREA_DATA::char_limit, _N_GUI_TA_STEP::clen, N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_TEXTAREA_DATA::cursor_time, _N_GUI_TA_STEP::cw, N_GUI_WIDGET::data, font, N_GUI_WIDGET::h, N_GUI_WIDGET::id, line(), N_GUI_TEXTAREA_DATA::multiline, N_CLIPBOARD_CLIPBOARD, N_GUI_TEXTAREA_DATA::on_change, N_GUI_TEXTAREA_DATA::scroll_from_wheel, N_GUI_TEXTAREA_DATA::sel_end, N_GUI_TEXTAREA_DATA::sel_start, N_GUI_TEXTAREA_DATA::text, N_GUI_TEXTAREA_DATA::text_len, N_GUI_TEXTAREA_DATA::user_data, N_GUI_WIDGET::w, and _N_GUI_TA_STEP::wrapped.
Referenced by n_gui_process_event().
|
static |
forward declaration: whether a text area has a non empty selection.
return 1 if the textarea has an active selection
Defined near the text area editing code.
Definition at line 8416 of file n_gui.c.
References N_GUI_TEXTAREA_DATA::sel_end, and N_GUI_TEXTAREA_DATA::sel_start.
Referenced by _draw_textarea(), _ngui_publish_primary_selection(), _textarea_copy_to_clipboard(), _textarea_delete_selection(), _textarea_handle_key(), _textarea_paste_clip(), and n_gui_textarea_has_selection().
|
static |
insert clipboard text at the cursor, replacing any selection.
Shared by Ctrl+V and middle-click paste. clip is NUL-terminated; CR is stripped and, in single-line mode, newlines are dropped. Respects the char limit and fires on_change.
Definition at line 12600 of file n_gui.c.
References _textarea_clear_selection(), _textarea_delete_selection(), _textarea_has_selection(), N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_WIDGET::id, N_GUI_TEXTAREA_DATA::multiline, N_GUI_TEXT_MAX, N_GUI_TEXTAREA_DATA::on_change, N_GUI_TEXTAREA_DATA::text, N_GUI_TEXTAREA_DATA::text_len, and N_GUI_TEXTAREA_DATA::user_data.
Referenced by _textarea_handle_key(), and n_gui_process_event().
|
static |
helper: find the byte position in a textarea closest to the given mouse coordinates (mx, my in screen space).
ax, ay are the widget's screen-space top-left corner. Returns the byte offset into td->text.
Definition at line 8311 of file n_gui.c.
References _text_w(), _textarea_content_height(), _utf8_char_len(), display, font, N_GUI_TEXTAREA_DATA::mask_char, N_GUI_TEXTAREA_DATA::multiline, N_GUI_TEXT_MAX, N_GUI_TEXTAREA_DATA::scroll_x, N_GUI_TEXTAREA_DATA::scroll_y, N_GUI_TEXTAREA_DATA::text, and N_GUI_TEXTAREA_DATA::text_len.
Referenced by n_gui_process_event().
|
static |
get the ordered selection range (lo, hi)
Definition at line 8421 of file n_gui.c.
References N_GUI_TEXTAREA_DATA::sel_end, and N_GUI_TEXTAREA_DATA::sel_start.
Referenced by _draw_textarea(), _ngui_publish_primary_selection(), _textarea_copy_to_clipboard(), _textarea_delete_selection(), and _textarea_handle_key().
|
static |
helper: decode, measure and wrap-test one character of textarea text.
This is the mechanical half of the per-character layout – the UTF-8 decode with its end-of-buffer clamp, the width measure, and the cx + cw > limit wrap rule – which used to be written out at FIVE sites: the content height, scroll-to-offset, the draw, and both passes of the click hit test. Each was commented as mirroring the drawing logic, and a wrap rule that exists five times is a wrap rule that eventually disagrees with itself, which shows up as a caret landing where the text is not.
What a caller does AT a wrap, at a newline and at each character stays at the call site, because those genuinely differ (one draws, one tracks a cursor, one measures a distance). cx and wrap_limit only have to be in the same coordinate space: the draw passes absolute x, the others relative.
Definition at line 7237 of file n_gui.c.
References _text_w(), _utf8_char_len(), _N_GUI_TA_STEP::ch, _N_GUI_TA_STEP::clen, _N_GUI_TA_STEP::cw, font, _N_GUI_TA_STEP::newline, text(), and _N_GUI_TA_STEP::wrapped.
Referenced by _draw_textarea(), _textarea_content_height(), _textarea_handle_key(), and n_gui_textarea_scroll_to_offset().
|
static |
helper: al_do_multiline_text callback that just counts the wrapped lines.
Definition at line 11617 of file n_gui.c.
References line().
Referenced by _draw_tooltip().
|
static |
helper: top-most visible tooltip-bearing widget under a gui-space point (-1 = none).
A split pane spans the whole region it divides, so only its divider band counts as a hit: a tooltip on one describes the divider, and taking the whole region would answer for every widget-free pixel of both panes (and hide the tooltip of anything created before it). Same rule as the mouse-down scan.
Definition at line 2991 of file n_gui.c.
References _point_in_rect(), _splitpane_on_divider(), _win_on_pass(), _win_tbh(), N_GUI_WIDGET::h, N_GUI_WIDGET::id, list_foreach, N_GUI_TYPE_SPLITPANE, N_GUI_WIN_OPEN, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_WINDOW::state, N_GUI_WIDGET::tooltip, N_GUI_WIDGET::type, N_GUI_WIDGET::visible, N_GUI_WIDGET::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_process_event().
|
static |
helper: the top-most open window of the current pass under a point, or NULL.
ctx->windows is kept sorted back to front by _sort_windows_by_zorder(), so the last window that contains the point is the one drawn over the rest – the same rule _tooltip_widget_at() and the mouse-down scan follow.
Definition at line 541 of file n_gui.c.
References _point_in_rect(), _win_on_pass(), _win_tbh(), N_GUI_WINDOW::h, list_foreach, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WINDOW::state, N_GUI_WINDOW::w, N_GUI_CTX::windows, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by n_gui_tooltip_pending().
|
static |
follow the modifier keys through one event
KEY_DOWN and KEY_UP of a modifier set and clear its bit. KEY_CHAR carries the modifiers Allegro knows of, so it corrects a bit whose KEY_UP was not seen: a modifier it says is up is cleared, one it says is down and was not seen going down is set on its left key. Losing the focus clears them all.
| ctx | the GUI context |
| event | the event |
Definition at line 13242 of file n_gui.c.
References _held_bit(), _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 n_gui_process_event().
|
static |
return the byte length of a UTF-8 character from its lead byte
Definition at line 7205 of file n_gui.c.
Referenced by _justified_char_at_pos(), _label_char_at_x(), _label_lines_char_at(), _textarea_handle_key(), _textarea_pos_from_mouse(), and _textarea_step().
|
static |
encode a Unicode code point into UTF-8, return the number of bytes written (0 on error)
Definition at line 12535 of file n_gui.c.
Referenced by _textarea_handle_key().
|
static |
helper: the length in bytes of the UTF-8 sequence led by lead, 1 for a byte that does not lead one.
Definition at line 6864 of file n_gui.c.
Referenced by _shorten_start(), and n_gui_text_shorten().
|
static |
helper: did the press just handled by wgt belong to it?
Called after the press handler has run, so a label can answer by whether the press started a text selection. A press a widget took is not also a window drag: in a draggable frameless window the drag moves the window under the pointer, so a slider, a scrollbar or a selection would see the pointer standing still and never follow it. An image, a progress bar, and a label pressed beside its text do nothing with a press, and those stay a handle for the window.
Definition at line 508 of file n_gui.c.
References N_GUI_WIDGET::data, N_GUI_TYPE_IMAGE, N_GUI_TYPE_LABEL, N_GUI_TYPE_PROGRESSBAR, and N_GUI_WIDGET::type.
Referenced by n_gui_process_event().
|
static |
helper: where a window's automatic scrollbars are, in display coordinates.
The same geometry _draw_window() paints the bars on: the vertical bar takes the right strip of the body, the horizontal one the bottom strip, each shortened by the resize corner when the other is absent, and no horizontal bar at all under N_GUI_WIN_NO_HSCROLL. A bar that is not shown gets a zero size, so a point test against it always fails. Refreshes the window's content extents on the way, which is what decides whether a bar is shown.
| win | window to measure. Must not be NULL. |
| font | default font, for the content extents. |
| size | thickness of a bar (style scrollbar_size). |
| v | receives x, y, w, h of the vertical bar. |
| h | receives x, y, w, h of the horizontal bar. |
Definition at line 2679 of file n_gui.c.
References _win_tbh(), _window_update_content_size(), N_GUI_WINDOW::content_h, N_GUI_WINDOW::content_w, N_GUI_WINDOW::flags, font, h(), N_GUI_WINDOW::h, N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_MINIMISED, N_GUI_WIN_NO_HSCROLL, N_GUI_WIN_RESIZABLE, N_GUI_WINDOW::state, N_GUI_WINDOW::w, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by n_gui_process_event().
|
static |
helper: whether a window takes part in the pass currently being processed or drawn.
Pop-up windows (native == NULL) belong to the main display's pass, detached ones only to their own display's pass. With no window detached ctx->pass_display stays NULL and this is always true, so the single-display path behaves exactly as it did before display routing existed.
Definition at line 295 of file n_gui.c.
References N_GUI_WINDOW::native, and N_GUI_CTX::pass_display.
Referenced by _compute_gui_bounds(), _datagrid_resize_hover(), _draw_combobox_dropdown(), _draw_dropmenu_panel(), _draw_textarea_suggest(), _pointer_over_window(), _splitpane_hit(), _tooltip_widget_at(), _topmost_window_at(), n_gui_draw(), and n_gui_process_event().
|
static |
helper: effective title bar height (0 for frameless windows)
Definition at line 286 of file n_gui.c.
References N_GUI_WINDOW::flags, N_GUI_WIN_FRAMELESS, and N_GUI_WINDOW::titlebar_h.
Referenced by _datagrid_resize_hover(), _find_widget_window(), _native_apply_minimised(), _pointer_over_window(), _splitpane_hit(), _tooltip_widget_at(), _topmost_window_at(), _win_auto_sb_rects(), n_gui_process_event(), n_gui_wants_mouse(), n_gui_window_apply_autofit(), n_gui_window_autosize(), and n_gui_window_detach().
|
static |
helper: recompute content extents for a window (for scrollbar support)
Definition at line 2636 of file n_gui.c.
References _text_w(), N_GUI_LABEL_DATA::align, N_GUI_WINDOW::content_h, N_GUI_WINDOW::content_w, N_GUI_WIDGET::data, N_GUI_WINDOW::flags, font, N_GUI_WIDGET::font, N_GUI_WIDGET::h, list_foreach, N_GUI_ALIGN_JUSTIFIED, N_GUI_TYPE_LABEL, N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_LABEL_DATA::text, N_GUI_WIDGET::type, N_GUI_WIDGET::visible, N_GUI_WIDGET::w, N_GUI_WINDOW::widgets, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_window(), _win_auto_sb_rects(), n_gui_process_event(), and n_gui_set_default_font().
|
static |
helper: copy one word out of text into out (bounded by N_GUI_TEXT_MAX, which is also the widget text cap) and NUL-terminate it.
Definition at line 7126 of file n_gui.c.
References N_GUI_TEXT_MAX, start(), and text().
Referenced by _draw_text_justified().
|
static |
helper: pack word widths into justified lines.
Fills line_first with the first word index of each line PLUS a sentinel line_first[lines] == nwords, so a caller iterates [line_first[l], line_first[l + 1]). line_first must hold max_lines + 1 entries. Returns the line count.
The loop this replaces existed FOUR times in this file – the draw, the selection rectangles, the click hit test and the content height – each commented as mirroring the others, which is precisely how they drift apart. It is nilorea's own n_wrap now: a word is an item, the single space between two words is a break-point item, and the lines break in exactly the same places (differential-checked against the previous loop over 200k random width sets before the swap).
Definition at line 7076 of file n_gui.c.
References _wrap_words_emit(), _N_GUI_WRAP_ACC::cap, _N_GUI_WRAP_ACC::count, _N_GUI_WRAP_ACC::first, n_wrap_item::flags, _N_GUI_WRAP_ACC::item_word, _N_GUI_WRAP_ACC::items, _N_GUI_WRAP_ACC::n, N_GUI_WRAP_MAX_ITEMS, N_GUI_WRAP_MAX_WORDS, n_wrap_layout(), N_WRAP_NEWLINE, N_WRAP_SPACE, _N_GUI_WRAP_ACC::nwords, _N_GUI_WRAP_ACC::para_end, and n_wrap_item::width.
Referenced by _draw_justified_selection(), _draw_text_justified(), _justified_char_at_pos(), and _label_content_height().
|
static |
Definition at line 7045 of file n_gui.c.
References _N_GUI_WRAP_ACC::cap, _N_GUI_WRAP_ACC::count, _N_GUI_WRAP_ACC::first, n_wrap_item::flags, _N_GUI_WRAP_ACC::item_word, _N_GUI_WRAP_ACC::items, last, line(), _N_GUI_WRAP_ACC::n, N_WRAP_NEWLINE, _N_GUI_WRAP_ACC::nwords, and _N_GUI_WRAP_ACC::para_end.
Referenced by _wrap_words().
|
static |
Definition at line 1979 of file n_gui.c.
References N_GUI_ZORDER_ALWAYS_BEHIND, N_GUI_ZORDER_ALWAYS_ON_TOP, N_GUI_ZORDER_FIXED, N_GUI_ZORDER_POPUP, and N_GUI_WINDOW::z_order.
Referenced by _sort_windows_by_zorder().
|
static |
Definition at line 213 of file n_gui.c.
Referenced by _ngui_meas_slot().