|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
Allocation-free, independently nestable two/N-pane split container. More...
#include <stddef.h>#include <stdint.h>#include "input.h"#include "layout.h"#include "style_ext.h"#include "draw_target.h"#include "ui_context.h"Data Structures | |
| struct | rmgui_splitter_pane_t |
| A collapsed pane has size zero; otherwise minimum <= size <= maximum. More... | |
| struct | rmgui_splitter_t |
| All arrays are borrowed, mutually disjoint, and must outlive self. More... | |
Enumerations | |
| enum | rmgui_splitter_axis_t { RMGUI_SPLITTER_HORIZONTAL , RMGUI_SPLITTER_VERTICAL } |
| HORIZONTAL lays panes left-to-right (EW cursor); VERTICAL top-to-bottom. More... | |
Functions | |
| int | rmgui_splitter_init (rmgui_splitter_t *self, rmgui_splitter_axis_t axis, const rmgui_splitter_pane_t *panes, int *sizes, int *work, size_t count, size_t capacity, int gutter, int hit_slop, int snap, int step) |
| All status APIs return 0 or -1 without changing any output or borrowed storage on refusal. | |
| int | rmgui_splitter_resize (rmgui_splitter_t *self, int total) |
| Resize to total main-axis pixels INCLUDING count-1 gutters. | |
| int | rmgui_splitter_reset (rmgui_splitter_t *self, int total) |
| int | rmgui_splitter_set (rmgui_splitter_t *self, size_t divider, int leading_size) |
| Sets one divider's leading pane size using the same snap/min/max policy as input. | |
| rmgui_rect_t | rmgui_splitter_pane_rect (const rmgui_splitter_t *self, rmgui_rect_t rect, size_t pane) |
| Pane/divider rectangles use current sizes; rect's main extent must equal sum(sizes)+gutters. | |
| rmgui_rect_t | rmgui_splitter_divider_rect (const rmgui_splitter_t *self, rmgui_rect_t rect, size_t divider, int hit) |
| int | rmgui_splitter_layout (const rmgui_splitter_t *self, rmgui_layout_node_t *container, rmgui_layout_node_t *panes, size_t capacity) |
| Produces declarations for the existing caller tree: container becomes an unpadded HBOX/VBOX, gap=gutter, STRETCH/START/CLIP. | |
| rmgui_input_result_t | rmgui_splitter_input (rmgui_splitter_t *self, rmgui_rect_t rect, const rmgui_input_t *in) |
| POINTER and TOUCH drag only adjacent panes, preserving their sum and all other sizes. | |
| void | rmgui_splitter_paint_to (rmgui_target_t *target, const rmgui_style_ext_resolved_t *style, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_splitter_t *self) |
| Pure painters accept a caller-resolved extension class with COLOR property "line"; optional COLOR "background" fills gutters and "focus" outlines the active focused divider. | |
| void | rmgui_splitter_paint (rmgui_fb_t *fb, const rmgui_style_ext_resolved_t *style, rmgui_rect_t rect, rmgui_rect_t clip, const rmgui_splitter_t *self) |
| int | rmgui_splitter_draw (const rmgui_ui_t *ui, const rmgui_splitter_t *splitter, const rmgui_style_ext_resolved_t *style, rmgui_rect_t box) |
| Draw dividers in the current arranged box using a borrowed resolved extension style. | |
Allocation-free, independently nestable two/N-pane split container.
| int rmgui_splitter_init | ( | rmgui_splitter_t * | self, |
| rmgui_splitter_axis_t | axis, | ||
| const rmgui_splitter_pane_t * | panes, | ||
| int * | sizes, | ||
| int * | work, | ||
| size_t | count, | ||
| size_t | capacity, | ||
| int | gutter, | ||
| int | hit_slop, | ||
| int | snap, | ||
| int | step ) |
All status APIs return 0 or -1 without changing any output or borrowed storage on refusal.
Initial sizes INCLUDING gutters and preferred sum must fit INT_MAX; count is 2..INT_MAX; capacity covers sizes AND work elements. gutter >=1, hit_slop >=1 (hit area strictly wider than gutter), snap >=0, step >=1. Initial sizes must obey the pane contract, with at least one nonzero pane. active initially 0; states/capture clear. Storage must not alias self.
| int rmgui_splitter_resize | ( | rmgui_splitter_t * | self, |
| int | total ) |
Resize to total main-axis pixels INCLUDING count-1 gutters.
Collapsed panes remain collapsed. Distribute flexible space ABOVE minima proportionally to old_size-minimum: floor(remaining * weight / weight_sum), freezing capped panes and redistributing. If all eligible weights are zero, use equal weights. Final rounding pixels go to earlier eligible panes. Exact totals, deterministic ties, unchanged sizes at the same total, and no pixel loops. Refuses impossible totals. reset uses preferred-minimum, reopening all panes (so the preferred total restores the exact preferred sizes). A resize/reset cancels an in-flight drag.
| int rmgui_splitter_reset | ( | rmgui_splitter_t * | self, |
| int | total ) |
| int rmgui_splitter_set | ( | rmgui_splitter_t * | self, |
| size_t | divider, | ||
| int | leading_size ) |
Sets one divider's leading pane size using the same snap/min/max policy as input.
The adjacent pair's sum and every other pane are preserved. Requests outside the feasible range clamp to its limits; collapsible endpoints snap within snap pixels. Selects divider and cancels capture/PRESSED, without changing focus, hover, disabled state or scratch. Returns 0 (also for a no-op), or -1 unchanged for invalid self/divider or negative leading_size. Disabled controls may be changed programmatically.
| rmgui_rect_t rmgui_splitter_pane_rect | ( | const rmgui_splitter_t * | self, |
| rmgui_rect_t | rect, | ||
| size_t | pane ) |
Pane/divider rectangles use current sizes; rect's main extent must equal sum(sizes)+gutters.
Extents must be nonnegative and x+w/y+h <= INT_MAX. Invalid state/index/geometry yields an empty rectangle. Divider hit geometry expands by hit_slop, clipped to rect; painting uses only gutter. Overlapping hit areas choose the lower divider index.
| rmgui_rect_t rmgui_splitter_divider_rect | ( | const rmgui_splitter_t * | self, |
| rmgui_rect_t | rect, | ||
| size_t | divider, | ||
| int | hit ) |
| int rmgui_splitter_layout | ( | const rmgui_splitter_t * | self, |
| rmgui_layout_node_t * | container, | ||
| rmgui_layout_node_t * | panes, | ||
| size_t | capacity ) |
Produces declarations for the existing caller tree: container becomes an unpadded HBOX/VBOX, gap=gutter, STRETCH/START/CLIP.
Each pane's main-axis preferred/min/max becomes its exact size, flex=0 and margins=0. Identity, kind, cross size and subtree declarations remain intact; zero-size panes stay declared (not hidden), so gutters retain their positions. Use before add_root/add_child, or update existing declarations then arrange with the caller's ordinary layout storage. No kernel or snapshot is mutated here. Refuses gutter > INT16_MAX, insufficient capacity, overlapping outputs or overlap with splitter storage. BUTTON and INTEGER_SCALE IMAGE interpret maxima differently and are refused as direct panes; wrap them in a pane container. Other declaration validity is the caller's responsibility.
| rmgui_input_result_t rmgui_splitter_input | ( | rmgui_splitter_t * | self, |
| rmgui_rect_t | rect, | ||
| const rmgui_input_t * | in ) |
POINTER and TOUCH drag only adjacent panes, preserving their sum and all other sizes.
A single touch ID owns capture; unrelated touches are ignored. Press selects/focuses divider, double pointer press resets all panes. Matching arrows move active divider by step; HOME/END reach pair limits (collapse if allowed). Snap collapses within snap pixels of either edge; otherwise min/max apply. Keyboard is host-routed to the focused splitter. LEAVE/CANCEL/FOCUS_OUT cancel capture. Disabled press returns REFUSED; CHANGE.value is the active divider index. Hover/capture requests EW/NS. Invalid input returns zero without mutation. No pointer is retained.
| void rmgui_splitter_paint_to | ( | rmgui_target_t * | target, |
| const rmgui_style_ext_resolved_t * | style, | ||
| rmgui_rect_t | rect, | ||
| rmgui_rect_t | clip, | ||
| const rmgui_splitter_t * | self ) |
Pure painters accept a caller-resolved extension class with COLOR property "line"; optional COLOR "background" fills gutters and "focus" outlines the active focused divider.
The painted line is one pixel centered in gutter. Missing/wrong line type, NULL or invalid geometry paints nothing. Both destinations have identical clipping and pixels; RECORD failures latch.
| void rmgui_splitter_paint | ( | rmgui_fb_t * | fb, |
| const rmgui_style_ext_resolved_t * | style, | ||
| rmgui_rect_t | rect, | ||
| rmgui_rect_t | clip, | ||
| const rmgui_splitter_t * | self ) |
| int rmgui_splitter_draw | ( | const rmgui_ui_t * | ui, |
| const rmgui_splitter_t * | splitter, | ||
| const rmgui_style_ext_resolved_t * | style, | ||
| rmgui_rect_t | box ) |
Draw dividers in the current arranged box using a borrowed resolved extension style.
Returns -1 for invalid arguments or style, otherwise 0; paint errors latch on the target.