|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
| Attribute | Rule |
|---|---|
| Storage | Caller-owned arrays, including two snapshot buffers. Sizes are not compile-time limits. |
| Borrowed data | Grid columns stay immutable until reset; text and retained lines outlive every snapshot that uses them. |
| Refusal | Exhausted records or scratch return -1 without changing outputs or replacing a published snapshot. |
| Invalidation | Setters invalidate affected declarations and ancestor measurements. Setting text invalidates even when the pointer is unchanged. Invalid setters do not mutate. |
| Damage | Repaint the scene clipped to kernel.damage[0..damage_count), not just the changed node. No changes means zero rectangles; exhaustion collapses to one union and sets damage_collapsed. |
RMGUI_LAYOUT_STORAGE(arena, 3, 0, 0, 0, 128, 256, 8) reserves three nodes, no grid/scroll/overlay records, 128 integer work slots, 256 text scratch bytes and eight damage rectangles. Initialize with rmgui_layout_init(&kernel, &arena.storage) and check its result.
Layout contract · Layout storage / damage in the showcase
Three cross-module edges to know. core/image.h includes core/layout.h to paint published IMAGE artwork. core/layout.h includes effects/layer.h and embeds its rmgui_layer_transform_t / rmgui_layer_shadow_t by value in every layout node's visual record — those two types are shared value types, part of the layout ABI wherever they are declared. Size layer and layout storage from matching headers, using sizeof or the storage macros rather than hard-coded byte counts. effects/element_motion.h includes core/style.h: it turns a class's resolved record (rmgui_style_resolved_t) into a layer transform and shadow, and a dragged element's sway into a layer rotation. rmgui.h includes core, then elements, then effects.
Text flow has no library text-length ceiling. rmgui_text_flow_line and rmgui_text_flow_line_prefix take char *scratch, size_t scratch_capacity before the output line. Fallback measurement needs enough disjoint caller scratch for the remaining paragraph through its next newline plus NUL; insufficient scratch returns -1 with the output unchanged. An exact prefix provider needs no scratch (NULL, 0), including for layout ellipsis. Retained paragraph line-array exhaustion likewise refuses rather than truncating. Text fields retain their separate editable-buffer capacity.
Optional bidi, fallback and shaping modules provide the explicit text_shape.h pipeline; legacy font/text calls are unchanged. Unicode 17.0.0 UAX #9 resolves embeddings, isolates, brackets and per-line visual ordering. Fonts are borrowed in priority order, with complete-cluster coverage, optional sticky preference and a host resolver. rmgui_shaper_t accepts a borrowed UTF-8 run, script, direction and language and returns face glyph ids, logical byte clusters and integer positions into caller storage. The built-in adapter preserves Latin cmap/kerning rounding; Arabic joining and complex scripts need a host shaper such as HarfBuzz, which is not bundled.
rmgui_text_options_t borrows all workspace arrays. Capacity exhaustion returns -1 without publishing a result; workspace contents may change even on refusal. Prepare shaped layouts for their CPU/record target before painting; shaping and painting allocate nothing, while glyph preparation uses the existing raster cache. Carets carry boundary affinity; logical arrows skip whole clusters and visual arrows follow reordered edges. Selection returns caller-owned lists of visual rectangles, while offsets remain logical UTF-8 bytes. The optional a11y_text module exposes the same mapping through a11y_shaped_text.h. Fields opt in through rmgui_field_t.text_options and borrow selection-rectangle storage; hint and IME composition use a separate auxiliary workspace. The 65,534-byte field ceiling remains. Check every layout result: a refused shaping call leaves the result struct unchanged but invalidates borrowed workspace content, including previously returned shaped results. The SHAPING showcase generates its RTL box font in caller storage and demonstrates fallback, mirroring and a host fi ligature adapter.
Use rmgui_layout_set_font(&kernel, &font) for the built-in font, or rmgui_layout_set_font_metrics(&kernel, &metrics) to share a caller-owned cache between measurement and painting. Custom providers install their measure callback, optional prefix callback, default userdata and optional paint cache together with rmgui_layout_set_text_binding. Paragraph painting shares the cache's 1024 exact pair advances and 256 codepoint-to-glyph tokens with measurement instead of repeating font-table walks; retained line breaks still avoid paint-time wrapping. rmgui_font_draw_with_metrics and its _to form opt standalone runs into the same cache. Pair lookups probe at most 16 slots before eviction; tokens are direct mapped. Eviction recomputes exact values, never changes output or allocates. The context is single-owner through measurement and painting, must outlive snapshots using it, and must be reinitialized after reinstalling a font. Font/size changes invalidate cached values automatically. Build consumers with matching headers.
<rmgui/a11y.h> provides plain, deterministic accessibility data for a host bridge to AT-SPI, UIA, NSAccessibility or another platform. It makes no OS calls and allocates no memory. Metadata carries roles, borrowed UTF-8 names, descriptions/value text, integer numeric ranges, states, orientation, set position, live-region politeness and borrowed node-ID relations.
Opt a layout into semantic publication by supplying two disjoint a11y_records banks in rmgui_layout_storage_t, each with node_capacity records. Existing storage without these banks remains valid; attachment refuses until both are supplied. rmgui_layout_set_a11y attaches a borrowed source record or detaches with NULL. Arrange copies it transactionally into the snapshot; source records may be rewritten immediately before calling the setter, but strings and relation arrays must outlive snapshots using them. Metadata-only changes do not invalidate measurements or pixel damage. Arrange after layout focus changes before reading semantic focus.
rmgui_a11y_walk visits annotated visible nodes in paint/reading order, flattening unannotated containers; parent IDs and ordered visits define children and siblings. Hidden/unarranged nodes and semantic HIDDEN subtrees are excluded. Rectangles are clipped device coordinates; the host adds its screen-origin transform. Focus and hit queries use that same snapshot. Element builders derive supported states/values from public element state. rmgui_a11y_perform dispatches host actions through caller bindings and public element operations, or reports unsupported. Refresh element records and layout after mutation. Text-range/line helpers expose UTF-8 byte offsets, not UTF-16 indices, from a current field layout, including offscreen rows. The host owns platform registration, announcements and event delivery.
<rmgui/dock.h> arranges docked and floating panels. The host supplies storage, labels, content, eligibility, persistence and native windows.
| Attribute | Rule |
|---|---|
| Identity | Nonzero stable ID; unique docked-tab or floating-group membership. |
| Header | A single window gets a title_height strip and zero tab rect; a group gets a tab_height strip. Paint only the one strip. |
| Aspect | 0:0 unlocks. Fit the largest whole multiple of the reduced ratio inside the available client, centred; return an empty fit if no step fits. |
| Float frame | Use rmgui_window_frame_drag for movement and sizing; apply with rmgui_dock_float_frame. |
| Drag | Hover previews a destination; commit refuses a stale model. Cancel leaves membership, order, ratio and frame unchanged. |
| Placement | TAB merges, an edge splits a docked group, outside floats to a visible frame. An empty root offers TAB. A group cannot split against itself. |
| Refusal | Invalid IDs, capacity, placement or geometry do not mutate the model. Removing the last tab collapses its group and parent split. |
Try the DOCKING page in the showcase. For group dragging, placement, storage and edge cases, see the dock contract.
Storage belongs to the host; painters and element kernels do not allocate it. Docking borrows nodes, per-node tab IDs and per-window aspect records. Tabs borrow identities, saved-focus entries and disabled bytes; choice groups borrow selection bytes. Window catalogs borrow declarations and output arrays for windows, taskbar cells/labels/separators and tray cells. Their capacities are explicit, and exhaustion refuses without changing published state. List rows and dropdowns retain only indexed state, not collection data; their counts, like tab and choice counts, fit the input result's int index. Flame charts walk the supplied frame array without a fixed depth bound; parents use int32_t. Axis ticks stream without a scratch array.
Backdrop palettes borrow stop arrays; particle emitters borrow color arrays and use caller-owned particle slots. Patterns render into caller surfaces. Layer surfaces use caller-chosen dimensions and an explicit device-pixel blur allowance; sampling coordinates must fit unsigned 32-bit Q16. Skin declarations borrow sheet names; asset decoding writes names and entries into caller arenas. Mesh models and poses use caller-owned, max_align_t-aligned contiguous arenas sized by the measure and instance-size queries; loading and initialization receive explicit byte capacities. Mesh input budgets are caller supplied; zero budgets select the corresponding integer representation ceilings. CPU mesh scratch is sized for the model and target dimensions.