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

A list row is an independently styled/selectable element. More...

#include <stddef.h>
#include <stdint.h>
#include "fb.h"
#include "font.h"
#include "geom.h"
#include "input.h"
#include "style.h"
#include "draw_target.h"
#include "ui_context.h"
#include "model.h"
#include "style_ext.h"

Data Structures

struct  rmgui_list_row_t
 Retained selection state over a column of rows, built by rmgui_list_row_init. More...
struct  rmgui_list_row_view_t
 Caller-owned row selection state and optional borrowed labels, one per row. More...
struct  rmgui_model_style_t
 Resolved view colours. More...
struct  rmgui_model_painter_t
struct  rmgui_model_appearance_t
 Borrowed device-pixel style and optional painter for an indexed model. More...

Macros

#define RMGUI_LIST_ROW_NONE   UINT32_MAX
 The row-index value meaning "no row"; never a valid index.

Typedefs

typedef void(*) rmgui_model_icon_paint_fn(void *, rmgui_target_t *, uint64_t icon, rmgui_rect_t, rmgui_rect_t)
 Hooks paint only inside clip.
typedef void(*) rmgui_model_row_paint_fn(void *, rmgui_target_t *, rmgui_font_t *, const rmgui_model_row_t *, size_t row, size_t column, rmgui_rect_t, rmgui_rect_t, const rmgui_model_style_t *)
typedef int(*) rmgui_model_claim_fn(void *, const rmgui_model_row_t *, size_t row, size_t column, rmgui_rect_t cell, int x, int y)
typedef int(*) rmgui_model_prepare_fn(void *, const rmgui_ui_t *, const rmgui_model_row_t *, size_t row, size_t column, rmgui_rect_t box, rmgui_rect_t clip, const rmgui_model_style_t *)
 Prepare only the glyphs emitted by a custom row or icon painter.

Functions

int rmgui_list_row_init (rmgui_list_row_t *self, size_t count, size_t selected)
 Initializes self over count rows with selected selected (or RMGUI_LIST_ROW_NONE), no hover/press, focus on the selected row (0 when none) and an empty state set.
rmgui_size_t rmgui_list_row_measure (const rmgui_font_t *font, const rmgui_style_resolved_t *rs, const char *label)
 Minimum outer size of one row showing label (NULL = empty) in font: the label's single-line width plus padding_x and the one-pixel stroke on both sides, by rs->min_height.
void rmgui_list_row_paint (rmgui_fb_t *fb, rmgui_font_t *font, const rmgui_style_resolved_t *rs, rmgui_rect_t rect, rmgui_rect_t clip, const char *label)
 Paints one row in rect: rs->background fill, one-pixel rs->border stroke, then label in font and rs->text with its line box's top-left at (rect.x + padding_x, rect.y + padding_y).
void rmgui_list_row_paint_to (rmgui_target_t *, rmgui_font_t *, const rmgui_style_resolved_t *, rmgui_rect_t, rmgui_rect_t, const char *)
 Explicit row destination with identical skin, text and clipping semantics.
rmgui_style_states_t rmgui_list_row_states (const rmgui_list_row_t *self, size_t row)
 The state set to paint row row with: SELECTED when selected, HOVER when hovered, PRESSED when pressed and hovered (never while DISABLED), FOCUSED when the column is FOCUSED and row is the focus row, DISABLED from the column.
rmgui_input_result_t rmgui_list_row_input (rmgui_list_row_t *self, const rmgui_rect_t *rows, const rmgui_input_t *in)
 Applies one event to the column whose rows are arranged at rows[0..count).
int rmgui_list_row_prepare (const rmgui_ui_t *, const rmgui_list_row_view_t *, size_t row)
 Prepare one row's NUL-terminated label before recording commands.
int rmgui_list_row_draw (const rmgui_ui_t *, const rmgui_list_row_view_t *, size_t row, rmgui_rect_t box)
 Draw one row with its current state-derived style at box.
int rmgui_model_style (const rmgui_style_ext_resolved_t *, rmgui_model_style_t *)
 Converts the eight named extension properties; all must exist with COLOR, LENGTH kinds respectively.
int rmgui_list_view_paint_to (rmgui_target_t *, rmgui_font_t *, rmgui_model_view_t *, const rmgui_model_style_t *, rmgui_rect_t, rmgui_rect_t, const rmgui_model_painter_t *)
 Paints only visible rows; no allocation or implicit glyph preparation.
void rmgui_list_view_cell_to (rmgui_target_t *, rmgui_font_t *, const rmgui_model_view_t *, const rmgui_model_style_t *, const rmgui_model_row_t *, size_t row, size_t column, rmgui_rect_t, rmgui_rect_t, const rmgui_model_painter_t *)
 Paint a single model cell with the same list background/content semantics.
int rmgui_list_view_prepare (const rmgui_ui_t *, rmgui_model_view_t *, const rmgui_model_appearance_t *, rmgui_rect_t viewport)
 Prepare visible list labels before recording; CPU targets do no work.
int rmgui_list_view_draw (const rmgui_ui_t *, rmgui_model_view_t *, const rmgui_model_appearance_t *, rmgui_rect_t viewport)
 Draw the indexed list in viewport using its resolved appearance.

Detailed Description

A list row is an independently styled/selectable element.

A list view is a virtual column of these rows over an indexed model; its selection, focus and scroll window live in separate caller-owned rmgui_model_view_t state.

Macro Definition Documentation

◆ RMGUI_LIST_ROW_NONE

#define RMGUI_LIST_ROW_NONE   UINT32_MAX

The row-index value meaning "no row"; never a valid index.

Typedef Documentation

◆ rmgui_model_icon_paint_fn

typedef void(*) rmgui_model_icon_paint_fn(void *, rmgui_target_t *, uint64_t icon, rmgui_rect_t, rmgui_rect_t)

Hooks paint only inside clip.

icon=0 conventionally means no icon; a NULL icon hook reserves no icon space. A row hook replaces default text/icon content, not selection/alternating backgrounds or the focus ring.

◆ rmgui_model_row_paint_fn

typedef void(*) rmgui_model_row_paint_fn(void *, rmgui_target_t *, rmgui_font_t *, const rmgui_model_row_t *, size_t row, size_t column, rmgui_rect_t, rmgui_rect_t, const rmgui_model_style_t *)

◆ rmgui_model_claim_fn

typedef int(*) rmgui_model_claim_fn(void *, const rmgui_model_row_t *, size_t row, size_t column, rmgui_rect_t cell, int x, int y)

◆ rmgui_model_prepare_fn

typedef int(*) rmgui_model_prepare_fn(void *, const rmgui_ui_t *, const rmgui_model_row_t *, size_t row, size_t column, rmgui_rect_t box, rmgui_rect_t clip, const rmgui_model_style_t *)

Prepare only the glyphs emitted by a custom row or icon painter.

The callback receives the same user data, box and clip as that painter and appends no commands. Return 0 on success or -1 on error.

Function Documentation

◆ rmgui_list_row_init()

int rmgui_list_row_init ( rmgui_list_row_t * self,
size_t count,
size_t selected )

Initializes self over count rows with selected selected (or RMGUI_LIST_ROW_NONE), no hover/press, focus on the selected row (0 when none) and an empty state set.

Returns 0, or -1 with self unchanged when self is NULL, count is 0 or above INT_MAX, or selected is neither below count nor RMGUI_LIST_ROW_NONE.

◆ rmgui_list_row_measure()

rmgui_size_t rmgui_list_row_measure ( const rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
const char * label )

Minimum outer size of one row showing label (NULL = empty) in font: the label's single-line width plus padding_x and the one-pixel stroke on both sides, by rs->min_height.

rs is resolved for LIST_ROW; NULL yields {0, 0}.

◆ rmgui_list_row_paint()

void rmgui_list_row_paint ( rmgui_fb_t * fb,
rmgui_font_t * font,
const rmgui_style_resolved_t * rs,
rmgui_rect_t rect,
rmgui_rect_t clip,
const char * label )

Paints one row in rect: rs->background fill, one-pixel rs->border stroke, then label in font and rs->text with its line box's top-left at (rect.x + padding_x, rect.y + padding_y).

Writes only pixels inside the intersection of rect and clip. NULL fb or rs paints nothing; NULL label or font paints no label.

◆ rmgui_list_row_paint_to()

void rmgui_list_row_paint_to ( rmgui_target_t * ,
rmgui_font_t * ,
const rmgui_style_resolved_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const char *  )

Explicit row destination with identical skin, text and clipping semantics.

RECORD requires prepared label glyphs and latches bounded-storage failures.

◆ rmgui_list_row_states()

rmgui_style_states_t rmgui_list_row_states ( const rmgui_list_row_t * self,
size_t row )

The state set to paint row row with: SELECTED when selected, HOVER when hovered, PRESSED when pressed and hovered (never while DISABLED), FOCUSED when the column is FOCUSED and row is the focus row, DISABLED from the column.

0 for a NULL self or row >= count.

◆ rmgui_list_row_input()

rmgui_input_result_t rmgui_list_row_input ( rmgui_list_row_t * self,
const rmgui_rect_t * rows,
const rmgui_input_t * in )

Applies one event to the column whose rows are arranged at rows[0..count).

Pointer: the first row rect containing the pointer is hovered; PRESS on a row holds it (captured); RELEASE on the held row selects it and moves the focus row to it. KEY: UP/DOWN move by one row, PAGE_UP/PAGE_DOWN by max(1, count / 10), HOME/END to the first/last row, clamped; the focus row moves and becomes the selection; ENTER/SPACE report ACTIVATE with the focus row. A selection change reports CHANGE with the new row. LEAVE clears hover and the held press; FOCUS_IN/FOCUS_OUT set/clear column FOCUSED. While DISABLED, an inside PRESS reports REFUSED (value 0, consumed 1, captured 0); other events report NONE, selection/focus do not move and hover/FOCUSED still track. NULL self, rows or in, or a zero count, returns an all-zero result.

Virtual lists borrow the indexed model; existing single-row painters above retain their byte-for-byte face/label contract.

◆ rmgui_list_row_prepare()

int rmgui_list_row_prepare ( const rmgui_ui_t * ,
const rmgui_list_row_view_t * ,
size_t row )

Prepare one row's NUL-terminated label before recording commands.

CPU targets and unlabelled rows need no preparation. Returns 0 or -1 on error.

◆ rmgui_list_row_draw()

int rmgui_list_row_draw ( const rmgui_ui_t * ,
const rmgui_list_row_view_t * ,
size_t row,
rmgui_rect_t box )

Draw one row with its current state-derived style at box.

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

◆ rmgui_model_style()

int rmgui_model_style ( const rmgui_style_ext_resolved_t * ,
rmgui_model_style_t *  )

Converts the eight named extension properties; all must exist with COLOR, LENGTH kinds respectively.

Failure leaves output unchanged.

◆ rmgui_list_view_paint_to()

int rmgui_list_view_paint_to ( rmgui_target_t * ,
rmgui_font_t * ,
rmgui_model_view_t * ,
const rmgui_model_style_t * ,
rmgui_rect_t ,
rmgui_rect_t ,
const rmgui_model_painter_t *  )

Paints only visible rows; no allocation or implicit glyph preparation.

NULL/invalid inputs refuse (-1); callbacks must not mutate the model. Accessor/record errors may leave a painted prefix; discard failed RECORD streams. CPU and RECORD emit the same clipped primitives.

◆ rmgui_list_view_cell_to()

void rmgui_list_view_cell_to ( rmgui_target_t * ,
rmgui_font_t * ,
const rmgui_model_view_t * ,
const rmgui_model_style_t * ,
const rmgui_model_row_t * ,
size_t row,
size_t column,
rmgui_rect_t ,
rmgui_rect_t ,
const rmgui_model_painter_t *  )

Paint a single model cell with the same list background/content semantics.

Used by table/tree and custom painters; depth is not applied here.

◆ rmgui_list_view_prepare()

int rmgui_list_view_prepare ( const rmgui_ui_t * ,
rmgui_model_view_t * ,
const rmgui_model_appearance_t * ,
rmgui_rect_t viewport )

Prepare visible list labels before recording; CPU targets do no work.

Updates view's visible-range counters on the record path. Returns 0 on success or -1 on invalid arguments, model or glyph preparation failure.

◆ rmgui_list_view_draw()

int rmgui_list_view_draw ( const rmgui_ui_t * ,
rmgui_model_view_t * ,
const rmgui_model_appearance_t * ,
rmgui_rect_t viewport )

Draw the indexed list in viewport using its resolved appearance.

Returns -1 for invalid arguments or model errors, otherwise 0; paint errors latch on the target. Route input with rmgui_model_input.