RMGui 0.15.0
C11 retained-mode UI library: layout kernel, style schema, widget painters, fonts, software framebuffer
Loading...
Searching...
No Matches
combo.h File Reference

Editable, caller-owned combobox. More...

#include "field.h"
#include "a11y_types.h"
#include "style_ext.h"
#include "ui_context.h"

Data Structures

struct  rmgui_combo_t
 Zero-initialize before bind. More...
struct  rmgui_combo_view_t
 A combo and its borrowed, device-resolved field, normal row and active row styles. More...

Macros

#define RMGUI_COMBO_NONE   SIZE_MAX
 No committed or active entry.
#define RMGUI_COMBO_FREE_TEXT   1u
 Permit unmatched commits, or paint the first matching prefix as ghost text.
#define RMGUI_COMBO_AUTOCOMPLETE   2u

Typedefs

typedef int(*) rmgui_combo_match_fn(const char *label, const char *query, size_t query_bytes, void *user)
 Return nonzero to include label.

Enumerations

enum  rmgui_combo_match_t { RMGUI_COMBO_PREFIX , RMGUI_COMBO_SUBSTRING }
 Built-in matching modes; custom matcher overrides either mode. More...

Functions

int rmgui_combo_prepare (const rmgui_ui_t *, const rmgui_combo_view_t *, const rmgui_field_layout_t *)
 Stage the laid-out field, completion suffix and visible popup labels before recording.
int rmgui_combo_draw (const rmgui_ui_t *, const rmgui_combo_view_t *, rmgui_rect_t row, rmgui_rect_t popup, const rmgui_field_layout_t *, rmgui_field_caret_t)
 Draw using the explicit field layout and popup box in target coordinates.
int rmgui_combo_bind (rmgui_combo_t *, const rmgui_field_t *, const char *const *entries, size_t count, size_t *matches, size_t match_capacity, char *committed, size_t committed_capacity, size_t visible_rows)
 Bind an already bound single-line field.
int rmgui_combo_filter (rmgui_combo_t *)
 Rebuild matches for current text; active becomes the first match.
int rmgui_combo_open (rmgui_combo_t *, int open)
 Open/close without changing the committed value.
int rmgui_combo_commit (rmgui_combo_t *, size_t entry)
 Commit entry, or NONE to resolve the first exact label, otherwise free text.
int rmgui_combo_revert (rmgui_combo_t *)
 Restore the last committed bytes, close, and refilter.
const char * rmgui_combo_suggestion (const rmgui_combo_t *)
 Borrowed inline completion suffix, or NULL without a prefix suggestion.
rmgui_input_result_t rmgui_combo_input (rmgui_combo_t *, rmgui_field_layout_t *, rmgui_rect_t row, rmgui_rect_t popup, const rmgui_input_t *)
 row is the text field, popup is a virtual list of visible_rows equal-height rows.
void rmgui_combo_paint_to (rmgui_target_t *, rmgui_font_t *, const rmgui_style_resolved_t *field_style, const rmgui_style_resolved_t *row_style, const rmgui_style_resolved_t *active_style, rmgui_rect_t row, rmgui_rect_t popup, rmgui_rect_t clip, const rmgui_combo_t *, const rmgui_field_layout_t *, rmgui_field_caret_t)
 Paint caller-resolved extension styles: field_style, row_style and active style.
int rmgui_combo_style_register (rmgui_style_ext_t *, size_t *class_id)
 Register extension class "combo": background,text,border COLOR properties.
void rmgui_combo_paint (rmgui_fb_t *, rmgui_font_t *, const rmgui_style_resolved_t *, const rmgui_style_resolved_t *, const rmgui_style_resolved_t *, rmgui_rect_t, rmgui_rect_t, rmgui_rect_t, const rmgui_combo_t *, const rmgui_field_layout_t *, rmgui_field_caret_t)
 CPU equivalent of paint_to.
int rmgui_a11y_from_combo (const rmgui_combo_t *, const char *name, uint64_t active_id, rmgui_a11y_record_t *out)
 Build COMBOBOX semantics with expanded and caller-supplied active node id (zero when no active item).

Detailed Description

Editable, caller-owned combobox.

Matching is bytewise and locale-free.

Macro Definition Documentation

◆ RMGUI_COMBO_NONE

#define RMGUI_COMBO_NONE   SIZE_MAX

No committed or active entry.

Counts are limited to INT_MAX by input results.

◆ RMGUI_COMBO_FREE_TEXT

#define RMGUI_COMBO_FREE_TEXT   1u

Permit unmatched commits, or paint the first matching prefix as ghost text.

◆ RMGUI_COMBO_AUTOCOMPLETE

#define RMGUI_COMBO_AUTOCOMPLETE   2u

Typedef Documentation

◆ rmgui_combo_match_fn

typedef int(*) rmgui_combo_match_fn(const char *label, const char *query, size_t query_bytes, void *user)

Return nonzero to include label.

Borrowed arguments last only for the call.

Enumeration Type Documentation

◆ rmgui_combo_match_t

Built-in matching modes; custom matcher overrides either mode.

Enumerator
RMGUI_COMBO_PREFIX 
RMGUI_COMBO_SUBSTRING 

Function Documentation

◆ rmgui_combo_prepare()

int rmgui_combo_prepare ( const rmgui_ui_t * ,
const rmgui_combo_view_t * ,
const rmgui_field_layout_t *  )

Stage the laid-out field, completion suffix and visible popup labels before recording.

CPU targets need no staging. Returns 0 on success or -1 on error.

◆ rmgui_combo_draw()

int rmgui_combo_draw ( const rmgui_ui_t * ,
const rmgui_combo_view_t * ,
rmgui_rect_t row,
rmgui_rect_t popup,
const rmgui_field_layout_t * ,
rmgui_field_caret_t  )

Draw using the explicit field layout and popup box in target coordinates.

Returns -1 for invalid arguments, otherwise 0; paint failures latch on the target.

◆ rmgui_combo_bind()

int rmgui_combo_bind ( rmgui_combo_t * ,
const rmgui_field_t * ,
const char *const * entries,
size_t count,
size_t * matches,
size_t match_capacity,
char * committed,
size_t committed_capacity,
size_t visible_rows )

Bind an already bound single-line field.

Requires non-NULL buffers, entries when count>0, valid NUL-terminated labels fitting field.capacity, positive visible_rows, and count<=INT_MAX. -1 leaves self and buffers unchanged.

◆ rmgui_combo_filter()

int rmgui_combo_filter ( rmgui_combo_t * )

Rebuild matches for current text; active becomes the first match.

0 or -1 for unbound/invalid configuration, unchanged on refusal.

◆ rmgui_combo_open()

int rmgui_combo_open ( rmgui_combo_t * ,
int open )

Open/close without changing the committed value.

0 or -1 for NULL/unbound.

◆ rmgui_combo_commit()

int rmgui_combo_commit ( rmgui_combo_t * ,
size_t entry )

Commit entry, or NONE to resolve the first exact label, otherwise free text.

Restricted unmatched text refuses. Copies the value into the field and saved commit, closes the popup; -1 leaves everything unchanged on invalid index/text or insufficient capacity.

◆ rmgui_combo_revert()

int rmgui_combo_revert ( rmgui_combo_t * )

Restore the last committed bytes, close, and refilter.

0 or -1 unbound.

◆ rmgui_combo_suggestion()

const char * rmgui_combo_suggestion ( const rmgui_combo_t * )

Borrowed inline completion suffix, or NULL without a prefix suggestion.

◆ rmgui_combo_input()

row is the text field, popup is a virtual list of visible_rows equal-height rows.

UP/DOWN open/navigate, ENTER commits active/free text, ESC reverts. Focus loss reverts restricted drafts; editing uses field_input unchanged. Results CHANGE mean draft edits; SUBMIT means commit (value=-1 free text). NULL/malformed geometry yields a zero result.

◆ rmgui_combo_paint_to()

void rmgui_combo_paint_to ( rmgui_target_t * ,
rmgui_font_t * ,
const rmgui_style_resolved_t * field_style,
const rmgui_style_resolved_t * row_style,
const rmgui_style_resolved_t * active_style,
rmgui_rect_t row,
rmgui_rect_t popup,
rmgui_rect_t clip,
const rmgui_combo_t * ,
const rmgui_field_layout_t * ,
rmgui_field_caret_t  )

Paint caller-resolved extension styles: field_style, row_style and active style.

Prepare text for RECORD. No allocation; target failures latch.

◆ rmgui_combo_style_register()

int rmgui_combo_style_register ( rmgui_style_ext_t * ,
size_t * class_id )

Register extension class "combo": background,text,border COLOR properties.

0 or -1 invalid/capacity/duplicate, registry and class_id unchanged.

◆ rmgui_combo_paint()

CPU equivalent of paint_to.

◆ rmgui_a11y_from_combo()

int rmgui_a11y_from_combo ( const rmgui_combo_t * ,
const char * name,
uint64_t active_id,
rmgui_a11y_record_t * out )

Build COMBOBOX semantics with expanded and caller-supplied active node id (zero when no active item).

0 or -1 for NULL/unbound, out unchanged.