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

Declarative schema-3 fields: read-only row metadata and typed accessors. More...

#include <stddef.h>
#include <stdint.h>
#include "style.h"

Data Structures

struct  rmgui_style_field_t
 Read-only row; offset addresses a declared snapshot member. More...
struct  rmgui_style_value_t

Macros

#define RMGUI_STYLE_FIELD_LITERAL   0x01u
 Only literal integer accepted, not a spacing reference.
#define RMGUI_STYLE_FIELD_PALETTE   0x02u
 Colour belongs to a desktop indexed sprite palette.

Typedefs

typedef int(*) rmgui_style_visit_fn(void *user, const char *section, const char *name, const rmgui_style_field_t *row, const rmgui_style_value_t *value)
 A visitor receives scheme first ("", "scheme", NULL), then every schema row once in schema order.

Enumerations

enum  rmgui_style_section_t {
  RMGUI_STYLE_SECTION_SPACING , RMGUI_STYLE_SECTION_FONT_SIZE_DELTA , RMGUI_STYLE_SECTION_COLORS , RMGUI_STYLE_SECTION_BUTTON ,
  RMGUI_STYLE_SECTION_DROPDOWN , RMGUI_STYLE_SECTION_SLIDER , RMGUI_STYLE_SECTION_CHOICE , RMGUI_STYLE_SECTION_LIST_ROW ,
  RMGUI_STYLE_SECTION_TEXT_FIELD , RMGUI_STYLE_SECTION_TAB , RMGUI_STYLE_SECTION_WINDOW , RMGUI_STYLE_SECTION_CONTEXT_MENU ,
  RMGUI_STYLE_SECTION_CHART , RMGUI_STYLE_SECTION_PROGRESS , RMGUI_STYLE_SECTION_SCROLLBAR , RMGUI_STYLE_SECTION_DESKTOP ,
  RMGUI_STYLE_SECTION_COUNT
}
 Three top-level token groups, twelve class templates, one shell section. More...
enum  rmgui_style_field_kind_t { RMGUI_STYLE_FIELD_KIND_INT , RMGUI_STYLE_FIELD_KIND_COLOR , RMGUI_STYLE_FIELD_KIND_TEXT_STYLE , RMGUI_STYLE_FIELD_KIND_SPRING }
 Storage kind; text and spring are named int16 enum values. More...
enum  rmgui_style_value_kind_t {
  RMGUI_STYLE_VALUE_INT , RMGUI_STYLE_VALUE_COLOR , RMGUI_STYLE_VALUE_REFERENCE , RMGUI_STYLE_VALUE_TEXT_STYLE ,
  RMGUI_STYLE_VALUE_SPRING , RMGUI_STYLE_VALUE_SCHEME
}
 Front-end-neutral tagged value. More...

Functions

size_t rmgui_style_schema_field_count (void)
 Number of schema rows (379), including eleven motion rows per class.
const rmgui_style_field_t * rmgui_style_schema_field (size_t index)
 Row at index, NULL if out of range.
const rmgui_style_field_t * rmgui_style_schema_section_fields (rmgui_style_section_t section, size_t *count)
 Contiguous rows in a section, NULL with zero count if invalid.
const char * rmgui_style_schema_section_name (rmgui_style_section_t section)
 Dashed KDL section spelling, or empty string if invalid.
rmgui_style_section_t rmgui_style_schema_class_section (rmgui_style_class_t class_id)
 Template section for class, COUNT if invalid; desktop is not a class.
const char * rmgui_style_field_name (const rmgui_style_field_t *field)
 Dashed KDL leaf name.
const rmgui_style_field_t * rmgui_style_field_reference (const rmgui_style_snapshot_t *style, const rmgui_style_field_t *field)
 Referenced token row, NULL when literal/invalid.
int rmgui_style_field_set_reference (rmgui_style_snapshot_t *style, const rmgui_style_field_t *field, const rmgui_style_field_t *token)
 Link a template metric/colour to matching token, or unlink with token=NULL; 0 on success; -1 and no mutation if incompatible/invalid.
int rmgui_style_field_int (const rmgui_style_snapshot_t *style, const rmgui_style_field_t *field)
 Effective integer of an INT/TEXT_STYLE/SPRING row; zero if invalid kind or NULL argument; references read current spacing tokens.
int rmgui_style_field_set_int (rmgui_style_snapshot_t *style, const rmgui_style_field_t *field, int value)
 Clamp/store literal integer; unlink even when equal to linked value; returns 1 on semantic change, 0 for unchanged/invalid arguments.
rmgui_color_t rmgui_style_field_color (const rmgui_style_snapshot_t *style, const rmgui_style_field_t *field)
 Effective colour of a COLOR row; transparent black for invalid arguments; references read current colour tokens.
int rmgui_style_field_set_color (rmgui_style_snapshot_t *style, const rmgui_style_field_t *field, rmgui_color_t color)
 Store literal colour, unlink even when equal to linked value; return 1 on semantic change, 0 for unchanged/invalid arguments.
const rmgui_style_field_t * rmgui_style_schema_find (const char *section, const char *name)
 Find a row by section/leaf or exactly one dotted separator.
const rmgui_style_field_t * rmgui_style_schema_path (const char *path)
int rmgui_style_value_get (const rmgui_style_snapshot_t *snapshot, const rmgui_style_field_t *row, rmgui_style_value_t *out, char *error, size_t error_cap)
 Read an authored value (preserving references), or scheme when row=NULL.
int rmgui_style_value_set (rmgui_style_snapshot_t *snapshot, const rmgui_style_field_t *row, const rmgui_style_value_t *value, char *error, size_t error_cap)
 Store a typed value, or apply a named scheme when row=NULL.
int rmgui_style_walk (const rmgui_style_snapshot_t *snapshot, rmgui_style_visit_fn visitor, void *user, char *error, size_t error_cap)
 Validated snapshot/visitor required; 0 succeeds, -1 reports invalid input or visitor refusal.

Detailed Description

Declarative schema-3 fields: read-only row metadata and typed accessors.

Macro Definition Documentation

◆ RMGUI_STYLE_FIELD_LITERAL

#define RMGUI_STYLE_FIELD_LITERAL   0x01u

Only literal integer accepted, not a spacing reference.

◆ RMGUI_STYLE_FIELD_PALETTE

#define RMGUI_STYLE_FIELD_PALETTE   0x02u

Colour belongs to a desktop indexed sprite palette.

Typedef Documentation

◆ rmgui_style_visit_fn

typedef int(*) rmgui_style_visit_fn(void *user, const char *section, const char *name, const rmgui_style_field_t *row, const rmgui_style_value_t *value)

A visitor receives scheme first ("", "scheme", NULL), then every schema row once in schema order.

Values are borrowed during the callback; returning nonzero stops the walk. The snapshot must not be mutated during a walk.

Enumeration Type Documentation

◆ rmgui_style_section_t

Three top-level token groups, twelve class templates, one shell section.

Enumerator
RMGUI_STYLE_SECTION_SPACING 
RMGUI_STYLE_SECTION_FONT_SIZE_DELTA 
RMGUI_STYLE_SECTION_COLORS 
RMGUI_STYLE_SECTION_BUTTON 
RMGUI_STYLE_SECTION_DROPDOWN 
RMGUI_STYLE_SECTION_SLIDER 
RMGUI_STYLE_SECTION_CHOICE 
RMGUI_STYLE_SECTION_LIST_ROW 
RMGUI_STYLE_SECTION_TEXT_FIELD 
RMGUI_STYLE_SECTION_TAB 
RMGUI_STYLE_SECTION_WINDOW 
RMGUI_STYLE_SECTION_CONTEXT_MENU 
RMGUI_STYLE_SECTION_CHART 
RMGUI_STYLE_SECTION_PROGRESS 
RMGUI_STYLE_SECTION_SCROLLBAR 
RMGUI_STYLE_SECTION_DESKTOP 
RMGUI_STYLE_SECTION_COUNT 

◆ rmgui_style_field_kind_t

Storage kind; text and spring are named int16 enum values.

Enumerator
RMGUI_STYLE_FIELD_KIND_INT 
RMGUI_STYLE_FIELD_KIND_COLOR 
RMGUI_STYLE_FIELD_KIND_TEXT_STYLE 
RMGUI_STYLE_FIELD_KIND_SPRING 

◆ rmgui_style_value_kind_t

Front-end-neutral tagged value.

Names are borrowed NUL-terminated strings; REFERENCE stores a schema token row, not its effective literal value.

Enumerator
RMGUI_STYLE_VALUE_INT 
RMGUI_STYLE_VALUE_COLOR 
RMGUI_STYLE_VALUE_REFERENCE 
RMGUI_STYLE_VALUE_TEXT_STYLE 
RMGUI_STYLE_VALUE_SPRING 
RMGUI_STYLE_VALUE_SCHEME 

Function Documentation

◆ rmgui_style_schema_field_count()

size_t rmgui_style_schema_field_count ( void )

Number of schema rows (379), including eleven motion rows per class.

◆ rmgui_style_schema_field()

const rmgui_style_field_t * rmgui_style_schema_field ( size_t index)

Row at index, NULL if out of range.

◆ rmgui_style_schema_section_fields()

const rmgui_style_field_t * rmgui_style_schema_section_fields ( rmgui_style_section_t section,
size_t * count )

Contiguous rows in a section, NULL with zero count if invalid.

◆ rmgui_style_schema_section_name()

const char * rmgui_style_schema_section_name ( rmgui_style_section_t section)

Dashed KDL section spelling, or empty string if invalid.

◆ rmgui_style_schema_class_section()

rmgui_style_section_t rmgui_style_schema_class_section ( rmgui_style_class_t class_id)

Template section for class, COUNT if invalid; desktop is not a class.

◆ rmgui_style_field_name()

const char * rmgui_style_field_name ( const rmgui_style_field_t * field)

Dashed KDL leaf name.

field must be a row of this schema.

◆ rmgui_style_field_reference()

const rmgui_style_field_t * rmgui_style_field_reference ( const rmgui_style_snapshot_t * style,
const rmgui_style_field_t * field )

Referenced token row, NULL when literal/invalid.

row must belong to schema.

◆ rmgui_style_field_set_reference()

int rmgui_style_field_set_reference ( rmgui_style_snapshot_t * style,
const rmgui_style_field_t * field,
const rmgui_style_field_t * token )

Link a template metric/colour to matching token, or unlink with token=NULL; 0 on success; -1 and no mutation if incompatible/invalid.

◆ rmgui_style_field_int()

int rmgui_style_field_int ( const rmgui_style_snapshot_t * style,
const rmgui_style_field_t * field )

Effective integer of an INT/TEXT_STYLE/SPRING row; zero if invalid kind or NULL argument; references read current spacing tokens.

◆ rmgui_style_field_set_int()

int rmgui_style_field_set_int ( rmgui_style_snapshot_t * style,
const rmgui_style_field_t * field,
int value )

Clamp/store literal integer; unlink even when equal to linked value; returns 1 on semantic change, 0 for unchanged/invalid arguments.

◆ rmgui_style_field_color()

rmgui_color_t rmgui_style_field_color ( const rmgui_style_snapshot_t * style,
const rmgui_style_field_t * field )

Effective colour of a COLOR row; transparent black for invalid arguments; references read current colour tokens.

◆ rmgui_style_field_set_color()

int rmgui_style_field_set_color ( rmgui_style_snapshot_t * style,
const rmgui_style_field_t * field,
rmgui_color_t color )

Store literal colour, unlink even when equal to linked value; return 1 on semantic change, 0 for unchanged/invalid arguments.

◆ rmgui_style_schema_find()

const rmgui_style_field_t * rmgui_style_schema_find ( const char * section,
const char * name )

Find a row by section/leaf or exactly one dotted separator.

Dashed names and underscore aliases are accepted; NULL/unknown names return NULL.

◆ rmgui_style_schema_path()

const rmgui_style_field_t * rmgui_style_schema_path ( const char * path)

◆ rmgui_style_value_get()

int rmgui_style_value_get ( const rmgui_style_snapshot_t * snapshot,
const rmgui_style_field_t * row,
rmgui_style_value_t * out,
char * error,
size_t error_cap )

Read an authored value (preserving references), or scheme when row=NULL.

Invalid arguments return -1 with bounded optional error and out unchanged. Returned names and references have static lifetime. Success clears error.

◆ rmgui_style_value_set()

int rmgui_style_value_set ( rmgui_style_snapshot_t * snapshot,
const rmgui_style_field_t * row,
const rmgui_style_value_t * value,
char * error,
size_t error_cap )

Store a typed value, or apply a named scheme when row=NULL.

Wrong kinds, unknown names, incompatible references and out-of-range integers refuse with -1, bounded optional diagnostic and snapshot unchanged; never clamps. Success returns 0 and clears error. Cross-field validation is separate.

◆ rmgui_style_walk()

int rmgui_style_walk ( const rmgui_style_snapshot_t * snapshot,
rmgui_style_visit_fn visitor,
void * user,
char * error,
size_t error_cap )

Validated snapshot/visitor required; 0 succeeds, -1 reports invalid input or visitor refusal.

The library allocates no memory and never mutates input.