|
RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
|
Caller-owned encoded-RGBA colour picker; no allocation or OS calls. More...
Data Structures | |
| struct | rmgui_colorpicker_hsva_t |
| Hue is tenths of a degree [0,3599], S/V tenths of a percent [0,1000]. More... | |
| struct | rmgui_colorpicker_fields_t |
| Optional caller-owned fields, independently arranged by the host. More... | |
| struct | rmgui_colorpicker_t |
| struct | rmgui_colorpicker_view_t |
| A picker with a borrowed device-resolved extension style and, when component fields are bound, a borrowed device-resolved text field style. More... | |
| struct | rmgui_colorpicker_geometry_t |
| Top: SV square, vertical hue/alpha strips. More... | |
Macros | |
| #define | RMGUI_COLORPICKER_SWATCH_BASE 5u |
| #define | RMGUI_COLORPICKER_NONE SIZE_MAX |
| #define | RMGUI_COLORPICKER_ACTION_EYEDROPPER 1 |
| ACTION result value: host starts its screen sampler, then calls set_rgba. | |
| #define | RMGUI_COLORPICKER_STYLE_PROPERTIES 9u |
| Extension class "colorpicker": gap, strip-width, swatch-size, checker-size (LENGTH), background, border, marker, checker-light, checker-dark (COLOR). | |
Caller-owned encoded-RGBA colour picker; no allocation or OS calls.
| #define RMGUI_COLORPICKER_SWATCH_BASE 5u |
| #define RMGUI_COLORPICKER_NONE SIZE_MAX |
| #define RMGUI_COLORPICKER_ACTION_EYEDROPPER 1 |
ACTION result value: host starts its screen sampler, then calls set_rgba.
The library never reads a screen/framebuffer or assumes a colour profile.
| #define RMGUI_COLORPICKER_STYLE_PROPERTIES 9u |
Extension class "colorpicker": gap, strip-width, swatch-size, checker-size (LENGTH), background, border, marker, checker-light, checker-dark (COLOR).
Register needs one class and nine property slots; resolve normally through rmgui_style_resolve_class into nine caller-owned resolved properties.
| int rmgui_colorpicker_rgb_to_hsv | ( | rmgui_color_t | , |
| rmgui_colorpicker_hsva_t * | out ) |
| int rmgui_colorpicker_hsv_to_rgb | ( | rmgui_colorpicker_hsva_t | , |
| rmgui_color_t * | out ) |
| int rmgui_colorpicker_draw | ( | const rmgui_ui_t * | , |
| const rmgui_colorpicker_view_t * | , | ||
| rmgui_rect_t | ) |
Draw the picker, excluding the optional fields.
Returns -1 for invalid arguments or style, otherwise 0; paint failures latch on the target.
| rmgui_input_result_t rmgui_colorpicker_event | ( | rmgui_colorpicker_view_t * | , |
| rmgui_rect_t | , | ||
| const rmgui_input_t * | ) |
Route one event to the picker with its bound style.
Invalid arguments produce an empty result. The host still handles eyedropper actions.
| rmgui_input_result_t rmgui_colorpicker_field_event | ( | rmgui_colorpicker_view_t * | , |
| size_t | field, | ||
| const rmgui_field_metrics_t * | , | ||
| rmgui_rect_t | , | ||
| const rmgui_input_t * | ) |
Route one event to a bound component field using its current metrics and box.
Invalid arguments produce an empty result. The host owns routing.
| int rmgui_colorpicker_fields_prepare | ( | const rmgui_ui_t * | , |
| const rmgui_colorpicker_view_t * | ) |
Stage the laid-out component fields before recording.
CPU targets need no staging. Returns 0 on success or -1 on error.
| int rmgui_colorpicker_fields_draw | ( | const rmgui_ui_t * | , |
| const rmgui_colorpicker_view_t * | , | ||
| const rmgui_rect_t | rects[RMGUI_COLORPICKER_FIELD_COUNT], | ||
| rmgui_field_caret_t | ) |
Draw the bound and laid-out component fields using caller-owned boxes in component order.
A NULL font omits the fields. Returns -1 for invalid arguments, otherwise 0; paint failures latch on the target.
| int rmgui_colorpicker_init | ( | rmgui_colorpicker_t * | , |
| rmgui_color_t | , | ||
| const rmgui_color_t * | palette, | ||
| size_t | palette_count, | ||
| rmgui_color_t * | recent, | ||
| size_t | recent_capacity ) |
All status APIs return 0/-1; NULL required pointers, bad ranges/capacities refuse without changing state/output/storage.
Void painters refuse NULL. Arrays are borrowed, nonaliasing, and remain alive while attached. Counts are caller-defined (no fixed palette/recent limit), <= INT_MAX-5 in total. Empty arrays accept NULL; nonempty arrays require storage. Init clears the recent ring without touching its bytes. Only states DISABLED/host may be changed directly. Other members are read-only after init.
| int rmgui_colorpicker_set_rgba | ( | rmgui_colorpicker_t * | , |
| rmgui_color_t | ) |
| int rmgui_colorpicker_set_hsva | ( | rmgui_colorpicker_t * | , |
| rmgui_colorpicker_hsva_t | ) |
| int rmgui_colorpicker_remember | ( | rmgui_colorpicker_t * | ) |
Append current RGBA unless equal to newest.
Full rings overwrite oldest; newest index 0, then older. Zero capacity refuses, never silently allocates.
| int rmgui_colorpicker_recent | ( | const rmgui_colorpicker_t * | , |
| size_t | newest_index, | ||
| rmgui_color_t * | out ) |
| int rmgui_colorpicker_choose | ( | rmgui_colorpicker_t * | , |
| int | recent, | ||
| size_t | index ) |
| int rmgui_colorpicker_bind_fields | ( | rmgui_colorpicker_t * | , |
| rmgui_colorpicker_fields_t * | , | ||
| char *const | storage[RMGUI_COLORPICKER_FIELD_COUNT], | ||
| const size_t | capacity[RMGUI_COLORPICKER_FIELD_COUNT] ) |
Fields contain HEX R G B H S V A.
HEX is exactly #RRGGBBAA; decimal fields use integer units above (RGB/A 0..255). Commit also accepts #RRGGBB, preserving alpha. Invalid/partial drafts stay editable and commit refuses without changing the colour; hosts may annotate invalid drafts separately. Bind requires all eight buffers: capacity >=9 for HEX, >=4 others, excluding terminator, <=RMGUI_FIELD_CAPACITY_MAX. Existing bytes are replaced. The bank must be zero-initialized (or detached); host configuration is preserved. A picker may omit fields. Every accepted colour change synchronizes them.
| int rmgui_colorpicker_fields_sync | ( | rmgui_colorpicker_t * | ) |
| int rmgui_colorpicker_field_commit | ( | rmgui_colorpicker_t * | , |
| size_t | field ) |
| rmgui_input_result_t rmgui_colorpicker_field_input | ( | rmgui_colorpicker_t * | , |
| size_t | field, | ||
| const rmgui_field_metrics_t * | , | ||
| const rmgui_style_resolved_t * | , | ||
| rmgui_rect_t | , | ||
| const rmgui_input_t * | ) |
| int rmgui_colorpicker_fields_layout | ( | rmgui_colorpicker_t * | , |
| const rmgui_field_metrics_t * | , | ||
| const rmgui_style_resolved_t * | , | ||
| const rmgui_rect_t | rects[RMGUI_COLORPICKER_FIELD_COUNT] ) |
Layout all eight fields before painting, and after any colour change.
Metrics/style must match the field painter. Like field_layout, a failure may leave earlier layouts refreshed. RECORD requires each visible field, hint/action/preedit glyph prepared with rmgui_font_prepare_to beforehand; CPU follows field.h's existing glyph-cache contract.
| void rmgui_colorpicker_fields_paint_to | ( | rmgui_target_t * | , |
| rmgui_font_t * | , | ||
| const rmgui_style_resolved_t * | , | ||
| const rmgui_colorpicker_t * | , | ||
| const rmgui_rect_t | rects[RMGUI_COLORPICKER_FIELD_COUNT], | ||
| rmgui_rect_t | clip, | ||
| rmgui_field_caret_t | ) |
Paint all numeric fields; caret is a blink decision for the focused field only.
Unfocused fields never paint a caret.
| void rmgui_colorpicker_fields_paint | ( | rmgui_fb_t * | , |
| rmgui_font_t * | , | ||
| const rmgui_style_resolved_t * | , | ||
| const rmgui_colorpicker_t * | , | ||
| const rmgui_rect_t | rects[RMGUI_COLORPICKER_FIELD_COUNT], | ||
| rmgui_rect_t | clip, | ||
| rmgui_field_caret_t | ) |
| int rmgui_colorpicker_style_register | ( | rmgui_style_ext_t * | , |
| size_t * | class_id ) |
| int rmgui_colorpicker_geometry | ( | const rmgui_style_ext_resolved_t * | , |
| rmgui_rect_t | , | ||
| rmgui_colorpicker_geometry_t * | out ) |
| void rmgui_colorpicker_paint_to | ( | rmgui_target_t * | , |
| const rmgui_style_ext_resolved_t * | , | ||
| rmgui_rect_t | , | ||
| rmgui_rect_t | clip, | ||
| const rmgui_colorpicker_t * | ) |
CPU and explicit targets share byte-identical rendering.
RECORD stores value commands only (no borrowed picker/palette/recent pointers). The SV plane is one opaque rectangular command using the original, unclipped sampling coordinates; CPU replay and native rendering use the same integer HSV rounding. Strips and checkers use clipped runs. Bounded stream exhaustion latches and refuses the entire submission, never grows. Invalid geometry/style/state or NULL pointers paint nothing.
| void rmgui_colorpicker_paint | ( | rmgui_fb_t * | , |
| const rmgui_style_ext_resolved_t * | , | ||
| rmgui_rect_t | , | ||
| rmgui_rect_t | clip, | ||
| const rmgui_colorpicker_t * | ) |
| rmgui_input_result_t rmgui_colorpicker_input | ( | rmgui_colorpicker_t * | , |
| const rmgui_style_ext_resolved_t * | , | ||
| rmgui_rect_t | , | ||
| const rmgui_input_t * | ) |
Primary drag captures SV/hue/alpha, clamps outside coordinates, commits a recent colour on release.
LEAVE/focus loss cancel capture. TAB/SHIFT TAB cycles components and swatches. Arrows +/-1, PAGE +/-10, HOME/END bounds; in SV SHIFT UP/DOWN selects value, otherwise saturation. SPACE/ENTER on a swatch selects/remembers, on eyedropper emits ACTION. Disabled presses refuse; host cursor requests are synchronous and optional. Invalid/NULL input returns an all-zero result. No field event is implicitly routed.
| int rmgui_a11y_from_colorpicker | ( | const rmgui_colorpicker_t * | , |
| size_t | component, | ||
| const char * | name, | ||
| rmgui_a11y_record_t * | out ) |
Four slider nodes plus an eyedropper button.
Builder refuses invalid component/NULL, leaving output unchanged. Action operations: 0 SET_VALUE, 1 INCREMENT, -1 DECREMENT, 2 PRESS (eyedropper only); disabled refuses. Numeric SET_VALUE is range-checked, never clamped.
| int rmgui_colorpicker_accessibility_action | ( | rmgui_colorpicker_t * | , |
| size_t | component, | ||
| int | operation, | ||
| int64_t | value, | ||
| rmgui_input_result_t * | out ) |