RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
ui.h File Reference
#include "button.h"
#include "choice.h"
#include "slider.h"
#include "ui_context.h"

Data Structures

struct  rmgui_button_view_t
 A zero-initialized button with an optional borrowed, NUL-terminated label. More...
struct  rmgui_slider_view_t
 A retained slider with optional borrowed tick marks (not snap points). More...
struct  rmgui_choice_view_t
 A checkbox or radio group with optional borrowed labels, one per option. More...

Functions

int rmgui_slider_view_init (rmgui_slider_view_t *slider, int64_t minimum, int64_t maximum, int64_t value)
 Initialize the range and value, clearing state, capture and detents on success.
int rmgui_slider_view_set_value (rmgui_slider_view_t *slider, int64_t value)
 Clamp a host-assigned value to the initialized range.
rmgui_input_result_t rmgui_button_event (rmgui_button_view_t *button, rmgui_rect_t box, const rmgui_input_t *event)
 Route one event to the button at box; the host owns focus and capture routing.
rmgui_input_result_t rmgui_slider_event (const rmgui_ui_t *ui, rmgui_slider_view_t *slider, rmgui_rect_t box, const rmgui_input_t *event)
 Route one event to the slider at box.
int rmgui_button_prepare (const rmgui_ui_t *ui, const rmgui_button_view_t *button)
 Prepare the current button label before recording any commands.
int rmgui_button_draw (const rmgui_ui_t *ui, const rmgui_button_view_t *button, rmgui_rect_t box)
 Draw the button with its current style.
int rmgui_slider_draw (const rmgui_ui_t *ui, const rmgui_slider_view_t *slider, rmgui_rect_t box)
 Draw the slider with its current style; nonzero detent_count requires detents.
int rmgui_choice_view_init (rmgui_choice_view_t *choice, rmgui_choice_kind_t kind, size_t count, uint8_t *selected, size_t capacity, const char *const *labels)
 Initialize a choice group.
rmgui_input_result_t rmgui_choice_event (rmgui_choice_view_t *choice, const rmgui_rect_t *boxes, const rmgui_input_t *event)
 Route one event to the group using count arranged boxes in option order.
int rmgui_choice_prepare (const rmgui_ui_t *ui, const rmgui_choice_view_t *choice, size_t option)
 Prepare one option's label before recording any commands.
int rmgui_choice_draw (const rmgui_ui_t *ui, const rmgui_choice_view_t *choice, size_t option, rmgui_rect_t box)
 Draw one option with its current state-derived style.

Function Documentation

◆ rmgui_slider_view_init()

int rmgui_slider_view_init ( rmgui_slider_view_t * slider,
int64_t minimum,
int64_t maximum,
int64_t value )

Initialize the range and value, clearing state, capture and detents on success.

Returns 0, or -1 without changing the slider if the arguments are invalid.

◆ rmgui_slider_view_set_value()

int rmgui_slider_view_set_value ( rmgui_slider_view_t * slider,
int64_t value )

Clamp a host-assigned value to the initialized range.

Return 1 if it changed, otherwise 0. Does not synthesize an input event or change focus or capture.

◆ rmgui_button_event()

rmgui_input_result_t rmgui_button_event ( rmgui_button_view_t * button,
rmgui_rect_t box,
const rmgui_input_t * event )

Route one event to the button at box; the host owns focus and capture routing.

◆ rmgui_slider_event()

rmgui_input_result_t rmgui_slider_event ( const rmgui_ui_t * ui,
rmgui_slider_view_t * slider,
rmgui_rect_t box,
const rmgui_input_t * event )

Route one event to the slider at box.

Use the same valid theme and scale as for drawing. NULL ui uses default input metrics. Pointer events with a scale outside 1..400 (other than the default sentinel 0) report REFUSED without changing state; keyboard and focus events do not consult ui.

◆ rmgui_button_prepare()

int rmgui_button_prepare ( const rmgui_ui_t * ui,
const rmgui_button_view_t * button )

Prepare the current button label before recording any commands.

CPU targets and unlabelled buttons need no preparation. Returns 0 on success, -1 on error.

◆ rmgui_button_draw()

int rmgui_button_draw ( const rmgui_ui_t * ui,
const rmgui_button_view_t * button,
rmgui_rect_t box )

Draw the button with its current style.

A NULL font omits text. Returns -1 for invalid arguments or style, otherwise 0; check the target for paint errors.

◆ rmgui_slider_draw()

int rmgui_slider_draw ( const rmgui_ui_t * ui,
const rmgui_slider_view_t * slider,
rmgui_rect_t box )

Draw the slider with its current style; nonzero detent_count requires detents.

Returns -1 for invalid arguments or style, otherwise 0; check the target for paint errors.

◆ rmgui_choice_view_init()

int rmgui_choice_view_init ( rmgui_choice_view_t * choice,
rmgui_choice_kind_t kind,
size_t count,
uint8_t * selected,
size_t capacity,
const char *const * labels )

Initialize a choice group.

Selection bytes remain caller-owned and writable; radio groups require exactly one selected option. The labels, if supplied, are count pointers to NUL-terminated strings or NULL. Both arrays must outlive use of the group and must not alias choice. Returns 0, or -1 leaving choice and the arrays unchanged.

◆ rmgui_choice_event()

rmgui_input_result_t rmgui_choice_event ( rmgui_choice_view_t * choice,
const rmgui_rect_t * boxes,
const rmgui_input_t * event )

Route one event to the group using count arranged boxes in option order.

Input updates the selection bytes; the host still routes focus and capture.

◆ rmgui_choice_prepare()

int rmgui_choice_prepare ( const rmgui_ui_t * ui,
const rmgui_choice_view_t * choice,
size_t option )

Prepare one option's label before recording any commands.

CPU targets and unlabelled options need no preparation. Returns 0 on success, -1 on error.

◆ rmgui_choice_draw()

int rmgui_choice_draw ( const rmgui_ui_t * ui,
const rmgui_choice_view_t * choice,
size_t option,
rmgui_rect_t box )

Draw one option with its current state-derived style.

A NULL font omits text. Returns -1 for invalid arguments or style, otherwise 0; check the target for paint errors.