![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows. More...
Include dependency graph for n_gui.c:Go to the source code of this file.
Functions | |
| 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 double | _clamp (double v, double lo, double hi) |
| helper: clamp a double between lo and hi | |
| static void | _compute_gui_bounds (N_GUI_CTX *ctx) |
| helper: compute the bounding box of all open windows | |
| static void | _destroy_widget (void *ptr) |
| helper: destroy a single widget (called by list destructor) | |
| 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) |
| draw a button widget | |
| 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_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) |
| draw the combobox dropdown overlay (called after all windows) | |
| 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_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_listbox (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| draw a listbox widget | |
| 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_scrollbar (N_GUI_WIDGET *wgt, float ox, float oy, const N_GUI_STYLE *style) |
| draw a scrollbar widget | |
| static void | _draw_slider (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| draw a slider widget (horizontal or vertical) | |
| 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_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_widget (N_GUI_WIDGET *wgt, float ox, float oy, ALLEGRO_FONT *default_font, float win_w, N_GUI_STYLE *style) |
| draw a single widget. | |
| 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_STYLE *style) |
| helper: draw a mini vertical scrollbar inside a widget. | |
| static void | _draw_window (N_GUI_WINDOW *win, ALLEGRO_FONT *default_font, N_GUI_STYLE *style) |
| draw a window chrome + its widgets | |
| 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 N_GUI_WINDOW * | _find_focused_window (N_GUI_CTX *ctx) |
| helper: find the window containing a focused widget | |
| 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 int | _is_focusable_type (int type) |
| helper: check if a widget type is focusable via Tab navigation | |
| 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 | _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) |
| helper: compute the total content height of justified/wrapped label text, in pixels. | |
| static float | _label_text_origin_x (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 | _min_thickness (float requested) |
| helper: compute minimum line thickness so it stays >= 1 physical pixel. | |
| static void | _n_gui_kv_add_clicked (int widget_id, void *user_data) |
| static void | _n_gui_kv_remove_clicked (int widget_id, void *user_data) |
| static void | _n_gui_kv_reposition (N_GUI_KVTABLE *table) |
| static void | _n_gui_tab_button_clicked (int widget_id, void *user_data) |
| static void | _n_gui_tree_listbox_selected (int widget_id, int index, int selected, void *user_data) |
| static int | _n_gui_tree_node_visible (N_GUI_TREE *tree, int node_index) |
| 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 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 void | _normalize_crlf (char *s) |
| helper: strip CR from a string in-place, normalizing CRLF to LF. | |
| 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 void | _register_widget (N_GUI_CTX *ctx, N_GUI_WIDGET *w) |
| helper: register a widget in the hash table | |
| 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 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 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 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_update_from_mouse (N_GUI_WIDGET *wgt, float mx, float my, float win_x, float win_content_y) |
| handle slider drag (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. | |
| static ALLEGRO_COLOR | _text_for_state (const N_GUI_THEME *t, int state) |
| 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) |
| handle textarea key input. | |
| static int | _textarea_has_selection (const N_GUI_TEXTAREA_DATA *td) |
| return 1 if the textarea has an active 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 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 float | _win_tbh (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 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_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_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_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_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_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_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_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. | |
| 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_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_selected (N_GUI_CTX *ctx, int widget_id) |
| get the selected item index in 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 | |
| N_GUI_STYLE | n_gui_default_style (void) |
| Build sensible default style (all configurable sizes, colours, paddings) | |
| 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. | |
| void | n_gui_draw (N_GUI_CTX *ctx) |
| Draw all visible windows and their widgets. | |
| int | n_gui_dropmenu_add_dynamic_entry (N_GUI_CTX *ctx, int widget_id, const char *text, int tag, void(*on_click)(int, int, int, void *), void *user_data) |
| Add a dynamic entry (rebuilt each time menu opens) | |
| int | n_gui_dropmenu_add_entry (N_GUI_CTX *ctx, int widget_id, const char *text, int tag, void(*on_click)(int, int, int, void *), void *user_data) |
| Add a static entry to a dropdown menu. | |
| void | n_gui_dropmenu_clear (N_GUI_CTX *ctx, int widget_id) |
| Remove all entries 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. | |
| 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. | |
| float | n_gui_get_dpi_scale (const N_GUI_CTX *ctx) |
| Get current DPI scale factor. | |
| int | n_gui_get_resize_mode (N_GUI_CTX *ctx) |
| Get current resize mode. | |
| N_GUI_TEXT_DIMS | n_gui_get_text_dims (ALLEGRO_FONT *font, const char *text) |
| get the bounding box dimensions of text rendered with the given font. | |
| N_GUI_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. | |
| 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 | |
| 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 | |
| void | n_gui_kvtable_free (N_GUI_KVTABLE **table) |
| free a KV table (does not destroy the N_GUI widgets) | |
| int | n_gui_kvtable_get_count (N_GUI_KVTABLE *table) |
| get the number of active rows | |
| void | n_gui_kvtable_remove_row (N_GUI_KVTABLE *table, int row_index) |
| remove a row by index (hides widgets, marks inactive) | |
| void | n_gui_label_set_bitmap (N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *bg) |
| Set optional background bitmap on a label widget. | |
| void | n_gui_label_set_link (N_GUI_CTX *ctx, int widget_id, const char *link) |
| set the link URL of a label widget | |
| void | n_gui_label_set_text (N_GUI_CTX *ctx, int widget_id, const char *text) |
| 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 | |
| int | n_gui_listbox_get_count (N_GUI_CTX *ctx, int widget_id) |
| get the number of items in a listbox widget | |
| 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_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_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_minimize_window (N_GUI_CTX *ctx, int window_id) |
| Minimise a window (show title bar only) | |
| 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. | |
| 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). | |
| 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_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 for global scrollbar computation. | |
| void | n_gui_set_dpi_scale (N_GUI_CTX *ctx, float scale) |
| Set DPI scale factor manually (default 1.0) | |
| 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_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_visible (N_GUI_CTX *ctx, int widget_id, int visible) |
| Show or hide a widget. | |
| double | n_gui_slider_get_value (N_GUI_CTX *ctx, int widget_id) |
| get the current value of a slider widget | |
| void | n_gui_slider_set_bitmaps (N_GUI_CTX *ctx, int widget_id, ALLEGRO_BITMAP *track, ALLEGRO_BITMAP *fill, ALLEGRO_BITMAP *handle, ALLEGRO_BITMAP *handle_hover, ALLEGRO_BITMAP *handle_active) |
| Set optional bitmap overlays on a slider widget. | |
| void | n_gui_slider_set_range (N_GUI_CTX *ctx, int widget_id, double min_val, double max_val) |
| set slider min/max range, clamping the current value if needed | |
| void | n_gui_slider_set_step (N_GUI_CTX *ctx, int widget_id, double step) |
| set slider step increment. | |
| void | n_gui_slider_set_value (N_GUI_CTX *ctx, int widget_id, double value) |
| set the value of a slider widget | |
| 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 (N_GUI_TAB_PANEL *panel) |
| get the active tab index | |
| void | n_gui_tab_set_active (N_GUI_TAB_PANEL *panel, int index) |
| set the active tab (toggles buttons, opens/closes content windows) | |
| void | n_gui_tab_set_content_window (N_GUI_TAB_PANEL *panel, int tab_index, int window_id) |
| associate a content window with a tab | |
| const char * | n_gui_textarea_get_text (N_GUI_CTX *ctx, int widget_id) |
| get 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 | |
| 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_selection (N_GUI_CTX *ctx, int widget_id, size_t start, size_t end) |
| set the text selection range (byte offsets into text content) | |
| void | n_gui_textarea_set_text (N_GUI_CTX *ctx, int widget_id, const char *text) |
| set the text content of a textarea widget | |
| void | n_gui_toggle_window (N_GUI_CTX *ctx, int window_id) |
| Toggle window visibility (show if hidden, hide if shown) | |
| int | n_gui_tree_add_node (N_GUI_TREE *tree, const char *label, int parent_index, void *user_data) |
| add a node to the tree | |
| N_GUI_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_free (N_GUI_TREE **tree) |
| free a tree view (does not destroy the N_GUI listbox) | |
| void | n_gui_tree_rebuild (N_GUI_TREE *tree) |
| rebuild the listbox to reflect current tree state | |
| void | n_gui_tree_toggle_expand (N_GUI_TREE *tree, int node_index) |
| toggle expand/collapse of a node | |
| void | n_gui_update_transform (N_GUI_CTX *ctx) |
| Recalculate scale and offset from virtual canvas to physical display. | |
| int | n_gui_wants_mouse (N_GUI_CTX *ctx) |
| Check if the mouse is currently over any open GUI window. | |
| void | n_gui_window_apply_autofit (N_GUI_CTX *ctx, int window_id) |
| Trigger auto-fit recalculation for a window. | |
| void | n_gui_window_autosize (N_GUI_CTX *ctx, int window_id) |
| Recompute and apply minimum-fit size for a window based on its current widgets. | |
| int | n_gui_window_get_flags (N_GUI_CTX *ctx, int window_id) |
| Get feature flags of a window. | |
| int | n_gui_window_get_resize_policy (N_GUI_CTX *ctx, int window_id) |
| Get per-window resize policy. | |
| int | n_gui_window_get_zorder (N_GUI_CTX *ctx, int window_id) |
| Get window z-order mode. | |
| int | n_gui_window_get_zvalue (N_GUI_CTX *ctx, int window_id) |
| Get window z-value (for N_GUI_ZORDER_FIXED mode). | |
| int | n_gui_window_is_open (N_GUI_CTX *ctx, int window_id) |
| Check if a window is currently visible. | |
| void | n_gui_window_set_autofit (N_GUI_CTX *ctx, int window_id, int autofit_flags, float border) |
| Configure auto-fit behavior for a dialog window. | |
| void | n_gui_window_set_bitmaps (N_GUI_CTX *ctx, int window_id, ALLEGRO_BITMAP *bg, ALLEGRO_BITMAP *titlebar, int bg_scale_mode) |
| Set optional bitmap overlays on a window's body and titlebar. | |
| void | n_gui_window_set_flags (N_GUI_CTX *ctx, int window_id, int flags) |
| Set feature flags on a window. | |
| void | n_gui_window_set_resize_policy (N_GUI_CTX *ctx, int window_id, int policy) |
| Set per-window resize policy (N_GUI_WIN_RESIZE_NONE / _MOVE / _SCALE). | |
| void | n_gui_window_set_zorder (N_GUI_CTX *ctx, int window_id, int z_mode, int z_value) |
| Set window z-order mode and value. | |
| void | n_gui_window_update_normalized (N_GUI_CTX *ctx, int window_id) |
| Recapture normalized coordinates for a window from its current absolute position/size. | |
GUI system: buttons, sliders, text areas, checkboxes, scrollbars, dropdown menus, windows.
Definition in file n_gui.c.
|
static |
helper: pick colour based on widget state
Definition at line 3221 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_slider(), and _draw_themed_rect().
Here is the caller graph for this function:
|
static |
Definition at line 3227 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().
Here is the caller graph for this function:
|
static |
helper: clamp a double between lo and hi
Definition at line 38 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().
Here is the caller graph for this function:
|
static |
helper: compute the bounding box of all open windows
Definition at line 4777 of file n_gui.c.
References 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().
Here is the caller graph for this function:
|
static |
helper: destroy a single widget (called by list destructor)
Definition at line 191 of file n_gui.c.
References N_GUI_WIDGET::data, N_GUI_DROPMENU_DATA::entries, FreeNoLog, N_GUI_LISTBOX_DATA::items, N_GUI_RADIOLIST_DATA::items, N_GUI_COMBOBOX_DATA::items, N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_DROPMENU, N_GUI_TYPE_LISTBOX, N_GUI_TYPE_RADIOLIST, N_GUI_TYPE_TEXTAREA, N_GUI_TEXTAREA_DATA::text, and N_GUI_WIDGET::type.
Referenced by n_gui_add_button(), n_gui_add_checkbox(), n_gui_add_combobox(), n_gui_add_dropmenu(), n_gui_add_image(), n_gui_add_label(), n_gui_add_listbox(), n_gui_add_radiolist(), n_gui_add_scrollbar(), n_gui_add_slider(), and n_gui_add_textarea().
Here is the caller graph for this function:
|
static |
helper: destroy a single window (called by list destructor)
Definition at line 218 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 2568 of file n_gui.c.
References mode, N_GUI_IMAGE_CENTER, and N_GUI_IMAGE_STRETCH.
Referenced by _draw_window().
Here is the caller graph for this function:
|
static |
draw a button widget
Definition at line 3258 of file n_gui.c.
References _draw_text_truncated(), _draw_themed_rect(), _text_for_state(), N_GUI_BUTTON_DATA::bitmap, N_GUI_BUTTON_DATA::bitmap_active, N_GUI_BUTTON_DATA::bitmap_hover, N_GUI_WIDGET::data, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_BUTTON_DATA::label, N_GUI_STYLE::label_padding, N_GUI_SHAPE_BITMAP, N_GUI_SHAPE_ROUNDED, N_GUI_STATE_ACTIVE, N_GUI_STATE_HOVER, N_GUI_BUTTON_DATA::shape, N_GUI_WIDGET::state, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw a checkbox widget
Definition at line 3778 of file n_gui.c.
References _draw_text_truncated(), _draw_themed_rect(), _min_thickness(), _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_WIDGET::data, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw a combobox widget (closed state)
Definition at line 4030 of file n_gui.c.
References _draw_text_truncated(), _draw_themed_rect(), _min_thickness(), _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, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_STYLE::item_text_padding, N_GUI_COMBOBOX_DATA::items, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw the combobox dropdown overlay (called after all windows)
Definition at line 4069 of file n_gui.c.
References _draw_text_truncated(), _find_widget_window(), _min_thickness(), _point_in_rect(), _text_w(), 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_STYLE::combobox_max_dropdown_width, N_GUI_WIDGET::data, N_GUI_CTX::default_font, N_GUI_CTX::display_w, N_GUI_STYLE::dropdown_border_thickness, N_GUI_COMBOBOX_DATA::flags, N_GUI_WIDGET::font, N_GUI_WIDGET::h, 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_COMBOBOX_DATA::max_visible, N_GUI_CTX::mouse_x, N_GUI_CTX::mouse_y, N_GUI_COMBOBOX_AUTO_WIDTH, n_gui_get_widget(), N_GUI_COMBOBOX_DATA::nb_items, N_GUI_CTX::open_combobox_id, N_GUI_COMBOBOX_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_color, N_GUI_STYLE::scrollbar_thumb_corner_r, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_STYLE::scrollbar_track_color, N_GUI_COMBOBOX_DATA::selected_index, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw a dropdown menu button (closed state)
Definition at line 4193 of file n_gui.c.
References _draw_text_truncated(), _draw_themed_rect(), _min_thickness(), _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, 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_STATE_ACTIVE, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw the dropdown menu panel overlay (called after all windows)
Definition at line 4223 of file n_gui.c.
References _draw_text_truncated(), _find_widget_window(), _min_thickness(), _point_in_rect(), N_GUI_THEME::bg_hover, 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_DROPMENU_DATA::entries, N_GUI_WIDGET::font, N_GUI_WIDGET::h, 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_DROPMENU_DATA::max_visible, N_GUI_CTX::mouse_x, N_GUI_CTX::mouse_y, n_gui_get_widget(), N_GUI_DROPMENU_DATA::nb_entries, 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_color, N_GUI_STYLE::scrollbar_thumb_corner_r, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_STYLE::scrollbar_track_color, N_GUI_CTX::style, N_GUI_DROPMENU_ENTRY::text, N_GUI_THEME::text_hover, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw an image widget
Definition at line 4311 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().
Here is the caller graph for this function:
|
static |
helper: draw selection highlight rectangles over justified/wrapped text.
Mirrors the word-wrap layout of _draw_text_justified.
Definition at line 3039 of file n_gui.c.
References _text_w(), and N_GUI_TEXT_MAX.
Referenced by _draw_label().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 4398 of file n_gui.c.
References _draw_justified_selection(), _draw_text_justified(), _draw_text_truncated(), _draw_widget_vscrollbar(), _label_content_height(), _min_thickness(), _set_clipping_rect_transformed(), _text_for_state(), _text_w(), N_GUI_LABEL_DATA::align, N_GUI_LABEL_DATA::bg_bitmap, N_GUI_WIDGET::data, 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_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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw a listbox widget
Definition at line 3876 of file n_gui.c.
References _draw_text_truncated(), 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, N_GUI_WIDGET::font, N_GUI_WIDGET::h, 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_LISTBOX_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw a radiolist widget
Definition at line 3949 of file n_gui.c.
References _min_thickness(), N_GUI_RADIOLIST_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, 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_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_RADIOLIST_DATA::scroll_offset, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_RADIOLIST_DATA::selected_index, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw a scrollbar widget
Definition at line 3826 of file n_gui.c.
References _draw_themed_rect(), _select_state_bitmap(), N_GUI_SCROLLBAR_DATA::content_size, N_GUI_WIDGET::data, N_GUI_WIDGET::h, N_GUI_SCROLLBAR_V, N_GUI_SHAPE_ROUNDED, N_GUI_STATE_IDLE, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw a slider widget (horizontal or vertical)
Definition at line 3301 of file n_gui.c.
References _bg_for_state(), _border_for_state(), _min_thickness(), _select_state_bitmap(), 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, 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_DATA::mode, N_GUI_SLIDER_PERCENT, N_GUI_SLIDER_V, N_GUI_SLIDER_DATA::orientation, N_GUI_STYLE::slider_handle_border_thickness, N_GUI_STYLE::slider_handle_edge_offset, N_GUI_STYLE::slider_handle_min_r, N_GUI_STYLE::slider_track_border_thickness, N_GUI_STYLE::slider_track_corner_r, N_GUI_STYLE::slider_track_size, N_GUI_STYLE::slider_value_label_offset, N_GUI_WIDGET::state, N_GUI_THEME::text_normal, N_GUI_WIDGET::theme, N_GUI_SLIDER_DATA::track_bitmap, N_GUI_SLIDER_DATA::value, N_GUI_WIDGET::w, N_GUI_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 2688 of file n_gui.c.
References _draw_text_truncated(), _text_w(), and N_GUI_TEXT_MAX.
Referenced by _draw_label().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 2656 of file n_gui.c.
References _text_w(), and N_GUI_TEXT_MAX.
Referenced by _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_combobox_dropdown(), _draw_dropmenu(), _draw_dropmenu_panel(), _draw_label(), _draw_listbox(), _draw_text_justified(), and _draw_window().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
draw a textarea widget
Definition at line 3544 of file n_gui.c.
References _draw_widget_vscrollbar(), _min_thickness(), _set_clipping_rect_transformed(), _text_w(), _textarea_content_height(), _textarea_has_selection(), _textarea_sel_range(), _utf8_char_len(), N_GUI_TEXTAREA_DATA::bg_bitmap, N_GUI_THEME::bg_normal, N_GUI_THEME::border_active, N_GUI_THEME::border_normal, N_GUI_THEME::border_thickness, N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_TEXTAREA_DATA::cursor_time, N_GUI_WIDGET::data, N_GUI_WIDGET::font, N_GUI_WIDGET::h, N_GUI_TEXTAREA_DATA::mask_char, N_GUI_TEXTAREA_DATA::multiline, N_GUI_STATE_FOCUSED, N_GUI_TEXT_MAX, 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_WIDGET::x, and N_GUI_WIDGET::y.
Referenced by _draw_widget().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 3243 of file n_gui.c.
References _bg_for_state(), _border_for_state(), _min_thickness(), N_GUI_THEME::border_thickness, N_GUI_THEME::corner_rx, and N_GUI_THEME::corner_ry.
Referenced by _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_dropmenu(), and _draw_scrollbar().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 4543 of file n_gui.c.
References _draw_button(), _draw_checkbox(), _draw_combobox(), _draw_dropmenu(), _draw_image(), _draw_label(), _draw_listbox(), _draw_radiolist(), _draw_scrollbar(), _draw_slider(), _draw_textarea(), N_GUI_WIDGET::enabled, N_GUI_WIDGET::h, N_GUI_STATE_IDLE, N_GUI_TYPE_BUTTON, N_GUI_TYPE_CHECKBOX, N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_DROPMENU, N_GUI_TYPE_IMAGE, N_GUI_TYPE_LABEL, N_GUI_TYPE_LISTBOX, N_GUI_TYPE_RADIOLIST, N_GUI_TYPE_SCROLLBAR, N_GUI_TYPE_SLIDER, N_GUI_TYPE_TEXTAREA, N_GUI_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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
helper: draw a mini vertical scrollbar inside a widget.
content_h = total content height, view_h = visible area height, scroll_y = current scroll offset. Draws at the right edge of the area [area_x .. area_x+area_w], [area_y .. area_y+view_h].
Definition at line 3180 of file n_gui.c.
References N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_color, N_GUI_STYLE::scrollbar_thumb_corner_r, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, and N_GUI_STYLE::scrollbar_track_color.
Referenced by _draw_label(), and _draw_textarea().
Here is the caller graph for this function:
|
static |
draw a window chrome + its widgets
Definition at line 4601 of file n_gui.c.
References _draw_bitmap_scaled(), _draw_text_truncated(), _draw_widget(), _min_thickness(), _set_clipping_rect_transformed(), _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::content_h, N_GUI_WINDOW::content_w, N_GUI_THEME::corner_rx, N_GUI_THEME::corner_ry, N_GUI_WINDOW::flags, 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, list_foreach, N_GUI_WIN_AUTO_SCROLLBAR, N_GUI_WIN_FRAMELESS, N_GUI_WIN_MINIMISED, N_GUI_WIN_OPEN, N_GUI_WIN_RESIZABLE, N_GUI_WINDOW::scroll_x, N_GUI_WINDOW::scroll_y, N_GUI_STYLE::scrollbar_size, N_GUI_STYLE::scrollbar_thumb_color, N_GUI_STYLE::scrollbar_thumb_corner_r, N_GUI_STYLE::scrollbar_thumb_min, N_GUI_STYLE::scrollbar_thumb_padding, N_GUI_STYLE::scrollbar_track_color, N_GUI_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_WINDOW::w, N_GUI_WINDOW::widgets, N_GUI_WINDOW::x, and N_GUI_WINDOW::y.
Referenced by n_gui_draw().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
helper: ensure dropmenu entries array has room for one more
Definition at line 2216 of file n_gui.c.
References FreeNoLog, and Malloc.
Referenced by n_gui_dropmenu_add_entry().
Here is the caller graph for this function:
|
static |
helper: find the window containing a focused widget
Definition at line 77 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().
Here is the caller graph for this function:
|
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 173 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(), and n_gui_process_event().
Here is the call graph for this function:
Here is the caller graph for this function:helper: find a window node in the context list by id
Definition at line 228 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().
Here is the caller graph for this function:
|
static |
helper: check if a widget type is focusable via Tab navigation
Definition at line 65 of file n_gui.c.
References N_GUI_TYPE_CHECKBOX, N_GUI_TYPE_COMBOBOX, N_GUI_TYPE_DROPMENU, N_GUI_TYPE_LISTBOX, N_GUI_TYPE_RADIOLIST, N_GUI_TYPE_SCROLLBAR, N_GUI_TYPE_SLIDER, and N_GUI_TYPE_TEXTAREA.
Referenced by n_gui_process_event().
Here is the caller graph for this function:
|
static |
helper: ensure items array has room for one more, returns 1 on success
Definition at line 248 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().
Here is the caller graph for this function:
|
static |
helper: add an RGBA colour as a JSON array [r,g,b,a] (0-255)
Definition at line 7371 of file n_gui.c.
Referenced by n_gui_save_theme_json().
Here is the caller graph for this function:
|
static |
helper: read an RGBA colour from a JSON array [r,g,b,a]
Definition at line 7383 of file n_gui.c.
Referenced by n_gui_load_theme_json().
Here is the caller graph for this function:
|
static |
helper: read a float from JSON, return fallback if missing
Definition at line 7394 of file n_gui.c.
Referenced by n_gui_load_theme_json().
Here is the caller graph for this function:
|
static |
helper: read an int from JSON, return fallback if missing
Definition at line 7401 of file n_gui.c.
Referenced by n_gui_load_theme_json().
Here is the caller graph for this function:
|
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 2920 of file n_gui.c.
References _text_w(), _utf8_char_len(), and N_GUI_TEXT_MAX.
Referenced by n_gui_process_event().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 4347 of file n_gui.c.
References _text_w(), _utf8_char_len(), N_GUI_TEXT_MAX, and N_GUI_LABEL_DATA::text.
Referenced by n_gui_process_event().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
helper: compute the total content height of justified/wrapped label text, in pixels.
Mirrors the _draw_text_justified word-wrap logic.
Definition at line 3140 of file n_gui.c.
References _text_w(), and N_GUI_TEXT_MAX.
Referenced by _draw_label(), and n_gui_process_event().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 4376 of file n_gui.c.
References N_GUI_LABEL_DATA::align, N_GUI_ALIGN_CENTER, N_GUI_ALIGN_RIGHT, and N_GUI_LABEL_DATA::text.
Referenced by n_gui_process_event().
Here is the caller graph for this function:
|
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 3207 of file n_gui.c.
Referenced by _draw_checkbox(), _draw_combobox(), _draw_combobox_dropdown(), _draw_dropmenu(), _draw_dropmenu_panel(), _draw_label(), _draw_radiolist(), _draw_slider(), _draw_textarea(), _draw_themed_rect(), and _draw_window().
Here is the caller graph for this function:
|
static |
Definition at line 7886 of file n_gui.c.
References n_gui_kvtable_add_row().
Referenced by n_gui_kvtable_create().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 7893 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 7905 of file n_gui.c.
References N_GUI_KV_ROW::active, N_GUI_KVTABLE::btn_add, N_GUI_KVTABLE::ctx, N_GUI_KV_ROW::desc_id, N_GUI_KV_ROW::enabled_id, N_GUI_KVTABLE::header_height, N_GUI_KV_ROW::key_id, n_gui_get_widget(), N_GUI_KVTABLE::nb_rows, N_GUI_KVTABLE::padding, N_GUI_KV_ROW::remove_id, N_GUI_KVTABLE::row_height, N_GUI_KVTABLE::rows, N_GUI_KV_ROW::value_id, and N_GUI_WIDGET::y.
Referenced by n_gui_kvtable_add_row(), and n_gui_kvtable_remove_row().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 7705 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 7788 of file n_gui.c.
References 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 7818 of file n_gui.c.
References N_GUI_TREE_NODE::expanded, N_GUI_TREE::nodes, and N_GUI_TREE_NODE::parent_index.
Referenced by n_gui_tree_rebuild().
Here is the caller graph for this function:
|
static |
capture normalized coords for a single widget relative to its parent window
Definition at line 564 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_add_button(), n_gui_add_checkbox(), n_gui_add_combobox(), n_gui_add_dropmenu(), n_gui_add_image(), n_gui_add_label(), n_gui_add_listbox(), n_gui_add_radiolist(), n_gui_add_scrollbar(), n_gui_add_slider(), and n_gui_add_textarea().
Here is the caller graph for this function:
|
static |
capture normalized coords for a window and its widgets from current absolutes
Definition at line 539 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_process_event(), n_gui_set_resize_mode(), n_gui_window_set_resize_policy(), and n_gui_window_update_normalized().
Here is the caller graph for this function:
|
static |
helper: allocate and initialise a base widget
Definition at line 266 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, 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::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_dropmenu(), n_gui_add_image(), n_gui_add_label(), n_gui_add_listbox(), n_gui_add_radiolist(), n_gui_add_scrollbar(), n_gui_add_slider(), and n_gui_add_textarea().
Here is the caller graph for this function:
|
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 92 of file n_gui.c.
Referenced by n_gui_add_label(), n_gui_label_set_text(), and n_gui_textarea_set_text().
Here is the caller graph for this function:
|
static |
helper: test if point is inside a rectangle
Definition at line 116 of file n_gui.c.
Referenced by _draw_combobox_dropdown(), _draw_dropmenu_panel(), n_gui_process_event(), and n_gui_wants_mouse().
Here is the caller graph for this function:
|
static |
helper: register a widget in the hash table
Definition at line 239 of file n_gui.c.
References __n_assert, 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_dropmenu(), n_gui_add_image(), n_gui_add_label(), n_gui_add_listbox(), n_gui_add_radiolist(), n_gui_add_scrollbar(), n_gui_add_slider(), and n_gui_add_textarea().
Here is the call graph for this function:
Here is the caller graph for this function:
|
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 131 of file n_gui.c.
Referenced by _scrollbar_calc_scroll_int(), and n_gui_process_event().
Here is the caller graph for this function:
|
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 154 of file n_gui.c.
References _scrollbar_calc_scroll().
Referenced by n_gui_process_event().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
handle scrollbar drag
Definition at line 5310 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().
Here is the caller graph for this function:
|
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 2589 of file n_gui.c.
References N_GUI_STATE_ACTIVE, and N_GUI_STATE_HOVER.
Referenced by _draw_scrollbar(), and _draw_slider().
Here is the caller graph for this function:
|
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 2601 of file n_gui.c.
Referenced by _draw_label(), _draw_textarea(), and _draw_window().
Here is the caller graph for this function:
|
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 47 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().
Here is the caller graph for this function:
|
static |
handle slider drag (horizontal or vertical)
Definition at line 5278 of file n_gui.c.
References _clamp(), _slider_snap_value(), 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Sort windows list by z-order: ALWAYS_BEHIND first, then FIXED (by z_value), then NORMAL, then ALWAYS_ON_TOP.
Within each group, preserve relative order. Uses stable insertion sort since window lists are typically small.
Definition at line 689 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_lower_window(), n_gui_raise_window(), and n_gui_window_set_zorder().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 3233 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(), and _draw_label().
Here is the caller graph for this function:
|
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).
Definition at line 105 of file n_gui.c.
Referenced by _draw_combobox_dropdown(), _draw_justified_selection(), _draw_label(), _draw_text_justified(), _draw_text_truncated(), _draw_textarea(), _justified_char_at_pos(), _label_char_at_x(), _label_content_height(), _textarea_content_height(), _textarea_handle_key(), _textarea_pos_from_mouse(), _window_update_content_size(), n_gui_process_event(), and n_gui_textarea_scroll_to_offset().
Here is the caller graph for this function:
|
static |
clear the selection (set both anchors to cursor_pos)
Definition at line 5370 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(), and _textarea_handle_key().
Here is the caller graph for this function:
|
static |
helper: compute the total content height of multiline textarea text (with line-wrap), in pixels.
Mirrors the drawing logic.
Definition at line 2777 of file n_gui.c.
References _text_w(), _utf8_char_len(), N_GUI_TEXTAREA_DATA::text, and N_GUI_TEXTAREA_DATA::text_len.
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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
copy selected text to clipboard.
Returns 1 on success.
Definition at line 5390 of file n_gui.c.
References _textarea_has_selection(), _textarea_sel_range(), display, FreeNoLog, Malloc, and N_GUI_TEXTAREA_DATA::text.
Referenced by _textarea_handle_key().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
delete the currently selected text, move cursor to selection start
Definition at line 5376 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
handle textarea key input.
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).
Definition at line 5408 of file n_gui.c.
References _text_w(), _textarea_clear_selection(), _textarea_content_height(), _textarea_copy_to_clipboard(), _textarea_delete_selection(), _textarea_has_selection(), _textarea_sel_range(), _utf8_char_len(), _utf8_encode(), N_GUI_TEXTAREA_DATA::char_limit, N_GUI_TEXTAREA_DATA::cursor_pos, N_GUI_TEXTAREA_DATA::cursor_time, N_GUI_WIDGET::data, N_GUI_CTX::display, N_GUI_WIDGET::h, N_GUI_WIDGET::id, N_GUI_TEXTAREA_DATA::multiline, N_GUI_TEXT_MAX, 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, and N_GUI_WIDGET::w.
Referenced by n_gui_process_event().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
return 1 if the textarea has an active selection
Definition at line 3528 of file n_gui.c.
References N_GUI_TEXTAREA_DATA::sel_end, and N_GUI_TEXTAREA_DATA::sel_start.
Referenced by _draw_textarea(), _textarea_copy_to_clipboard(), _textarea_delete_selection(), and _textarea_handle_key().
Here is the caller graph for this function:
|
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 3423 of file n_gui.c.
References _text_w(), _textarea_content_height(), _utf8_char_len(), display, 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().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
get the ordered selection range (lo, hi)
Definition at line 3533 of file n_gui.c.
References N_GUI_TEXTAREA_DATA::sel_end, and N_GUI_TEXTAREA_DATA::sel_start.
Referenced by _draw_textarea(), _textarea_copy_to_clipboard(), _textarea_delete_selection(), and _textarea_handle_key().
Here is the caller graph for this function:
|
static |
return the byte length of a UTF-8 character from its lead byte
Definition at line 2767 of file n_gui.c.
Referenced by _draw_textarea(), _justified_char_at_pos(), _label_char_at_x(), _textarea_content_height(), _textarea_handle_key(), _textarea_pos_from_mouse(), and n_gui_textarea_scroll_to_offset().
Here is the caller graph for this function:
|
static |
encode a Unicode code point into UTF-8, return the number of bytes written (0 on error)
Definition at line 5343 of file n_gui.c.
Referenced by _textarea_handle_key().
Here is the caller graph for this function:
|
static |
helper: effective title bar height (0 for frameless windows)
Definition at line 111 of file n_gui.c.
References N_GUI_WINDOW::flags, N_GUI_WIN_FRAMELESS, and N_GUI_WINDOW::titlebar_h.
Referenced by _find_widget_window(), n_gui_process_event(), n_gui_wants_mouse(), n_gui_window_apply_autofit(), and n_gui_window_autosize().
Here is the caller graph for this function:
|
static |
helper: recompute content extents for a window (for scrollbar support)
Definition at line 964 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, 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(), and n_gui_process_event().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Definition at line 670 of file n_gui.c.
References N_GUI_ZORDER_ALWAYS_BEHIND, N_GUI_ZORDER_ALWAYS_ON_TOP, N_GUI_ZORDER_FIXED, and N_GUI_WINDOW::z_order.
Referenced by _sort_windows_by_zorder().
Here is the caller graph for this function: