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

Caller-owned style declarations and resolved paint data. More...

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

Data Structures

struct  rmgui_style_spacing_t
 All declaration metrics are logical px at 100% unless named _pct or _ms. More...
struct  rmgui_style_colors_t
struct  rmgui_style_font_size_delta_t
struct  rmgui_style_motion_t
 Every class carries the same flat eleven motion fields; zero amplitudes disable shake. More...
struct  rmgui_button_style_t
struct  rmgui_dropdown_style_t
struct  rmgui_slider_style_t
struct  rmgui_choice_style_t
struct  rmgui_list_row_style_t
struct  rmgui_text_field_style_t
struct  rmgui_tab_style_t
struct  rmgui_window_style_t
 Window chrome metrics: title_height=0 inherits line height plus extra height; control size=0 and gap=-1 inherit title-button size/gap. More...
struct  rmgui_context_menu_style_t
struct  rmgui_chart_style_t
 Palette indices are 0..5; all chart colours are authored independently. More...
struct  rmgui_progress_style_t
 Orientation-neutral progress metrics; periods are ms and fill_mode is 0..2. More...
struct  rmgui_scrollbar_style_t
 Scrollbar metrics and independent part colours; durations are unscaled ms. More...
struct  rmgui_desktop_style_t
struct  rmgui_style_snapshot_t
 Plain caller-owned value. More...
struct  rmgui_style_motion_resolved_t
 Resolved motion, in device px except durations (ms) and fixed-point scales. More...
struct  rmgui_style_resolved_t
 One class at a state, font size and UI scale; unused roles are zero. More...
struct  rmgui_desktop_style_resolved_t
 Shell-owned roles; no painted-state parameter. More...

Macros

#define RMGUI_STYLE_SCHEMA_VERSION   3u
 Output schema version; the decoder also accepts schema-2 input.
#define RMGUI_STYLE_ERROR_CAP   160u
#define RMGUI_STYLE_DEFAULT_MAX_BYTES   262144u
 Zero per-call codec limit selects this default; callers may choose larger.
#define RMGUI_STYLE_STATE_NORMAL   0u
#define RMGUI_STYLE_STATE_FLAG_COUNT   7u
#define RMGUI_STYLE_STATE_ALL   ((1u << RMGUI_STYLE_STATE_FLAG_COUNT) - 1u)

Typedefs

typedef unsigned rmgui_style_states_t

Enumerations

enum  rmgui_style_class_t {
  RMGUI_STYLE_CLASS_BUTTON , RMGUI_STYLE_CLASS_DROPDOWN , RMGUI_STYLE_CLASS_SLIDER , RMGUI_STYLE_CLASS_CHOICE ,
  RMGUI_STYLE_CLASS_LIST_ROW , RMGUI_STYLE_CLASS_TEXT_FIELD , RMGUI_STYLE_CLASS_TAB , RMGUI_STYLE_CLASS_WINDOW ,
  RMGUI_STYLE_CLASS_CONTEXT_MENU , RMGUI_STYLE_CLASS_CHART , RMGUI_STYLE_CLASS_PROGRESS , RMGUI_STYLE_CLASS_SCROLLBAR ,
  RMGUI_STYLE_CLASS_COUNT
}
 Twelve paintable template classes, in schema section order. More...
enum  rmgui_style_state_t {
  RMGUI_STYLE_STATE_HOVER = 1u << 0 , RMGUI_STYLE_STATE_PRESSED = 1u << 1 , RMGUI_STYLE_STATE_FOCUSED = 1u << 2 , RMGUI_STYLE_STATE_DISABLED = 1u << 3 ,
  RMGUI_STYLE_STATE_SELECTED = 1u << 4 , RMGUI_STYLE_STATE_DEFAULT = 1u << 5 , RMGUI_STYLE_STATE_INACTIVE = 1u << 6
}
 Paint states are a bit set; NORMAL is empty, DISABLED overrides interaction. More...
enum  rmgui_style_text_t { RMGUI_STYLE_TEXT_BODY , RMGUI_STYLE_TEXT_HEADING , RMGUI_STYLE_TEXT_CONTROL , RMGUI_STYLE_TEXT_COUNT }
 Font-size-delta token chosen by a text-bearing class. More...
enum  rmgui_style_spring_t { RMGUI_STYLE_SPRING_BALANCED , RMGUI_STYLE_SPRING_SPRINGY , RMGUI_STYLE_SPRING_SOFT , RMGUI_STYLE_SPRING_COUNT }
 Preset spring response for a class's authorable motion. More...
enum  rmgui_style_scheme_t {
  RMGUI_STYLE_SCHEME_DEFAULT , RMGUI_STYLE_SCHEME_GRUVBOX_DARK , RMGUI_STYLE_SCHEME_GRUVBOX_LIGHT , RMGUI_STYLE_SCHEME_SOLARIZED_DARK ,
  RMGUI_STYLE_SCHEME_SOLARIZED_LIGHT , RMGUI_STYLE_SCHEME_TOKYO_NIGHT , RMGUI_STYLE_SCHEME_NORD , RMGUI_STYLE_SCHEME_DRACULA ,
  RMGUI_STYLE_SCHEME_CATPPUCCIN_MOCHA , RMGUI_STYLE_SCHEME_CATPPUCCIN_LATTE , RMGUI_STYLE_SCHEME_AQUA = 10 , RMGUI_STYLE_SCHEME_AERO = 11 ,
  RMGUI_STYLE_SCHEME_COUNT = 12
}
 Named preset palette; DEFAULT is the builtin token palette. More...
enum  rmgui_style_syntax_t {
  RMGUI_STYLE_SYNTAX_PLAIN , RMGUI_STYLE_SYNTAX_KEYWORD , RMGUI_STYLE_SYNTAX_TYPE , RMGUI_STYLE_SYNTAX_FUNCTION ,
  RMGUI_STYLE_SYNTAX_STRING , RMGUI_STYLE_SYNTAX_NUMBER , RMGUI_STYLE_SYNTAX_COMMENT , RMGUI_STYLE_SYNTAX_PREPROCESSOR ,
  RMGUI_STYLE_SYNTAX_PUNCTUATION , RMGUI_STYLE_SYNTAX_COUNT
}
 Syntax-highlight role, painted over the scheme's background token. More...

Functions

size_t rmgui_style_states_name (rmgui_style_states_t states, char *out, size_t cap)
 Formats a state set into out, snprintf-style; invalid bits are ignored.
const rmgui_style_snapshot_t * rmgui_style_builtin (void)
 Immutable builtin declaration; copy by value before editing.
const char * rmgui_style_scheme_name (rmgui_style_scheme_t scheme)
 Static lowercase kebab-case scheme name, NULL for invalid scheme.
int rmgui_style_scheme_apply (rmgui_style_snapshot_t *snapshot, rmgui_style_scheme_t scheme)
 Changes only the eleven named colour tokens and scheme metadata; invalid arguments return -1 leaving snapshot unchanged.
int rmgui_style_scheme_syntax (rmgui_style_scheme_t scheme, rmgui_style_syntax_t role, rmgui_color_t *out)
 Writes an opaque scheme syntax colour to out; invalid arguments return -1 without changing out.
int rmgui_style_validate (const rmgui_style_snapshot_t *snapshot, char *error, size_t error_cap)
 Validates all 379 fields, references, metadata, and cross-field invariants; null/invalid returns -1 with bounded error; success writes empty error.
int rmgui_style_resolve (const rmgui_style_snapshot_t *snapshot, rmgui_style_class_t class_id, rmgui_style_states_t states, int font_px, int scale_percent, rmgui_style_resolved_t *out)
 Resolve a validated snapshot at positive font_px and scale_percent 1..400; invalid inputs return -1 without changing out.
int rmgui_style_resolve_desktop (const rmgui_style_snapshot_t *snapshot, int scale_percent, rmgui_desktop_style_resolved_t *out)
 Resolve host-owned shell metrics at UI scale 1..400 into out; invalid inputs return -1 without changing out.

Detailed Description

Caller-owned style declarations and resolved paint data.

Macro Definition Documentation

◆ RMGUI_STYLE_SCHEMA_VERSION

#define RMGUI_STYLE_SCHEMA_VERSION   3u

Output schema version; the decoder also accepts schema-2 input.

◆ RMGUI_STYLE_ERROR_CAP

#define RMGUI_STYLE_ERROR_CAP   160u

◆ RMGUI_STYLE_DEFAULT_MAX_BYTES

#define RMGUI_STYLE_DEFAULT_MAX_BYTES   262144u

Zero per-call codec limit selects this default; callers may choose larger.

◆ RMGUI_STYLE_STATE_NORMAL

#define RMGUI_STYLE_STATE_NORMAL   0u

◆ RMGUI_STYLE_STATE_FLAG_COUNT

#define RMGUI_STYLE_STATE_FLAG_COUNT   7u

◆ RMGUI_STYLE_STATE_ALL

#define RMGUI_STYLE_STATE_ALL   ((1u << RMGUI_STYLE_STATE_FLAG_COUNT) - 1u)

Typedef Documentation

◆ rmgui_style_states_t

typedef unsigned rmgui_style_states_t

Enumeration Type Documentation

◆ rmgui_style_class_t

Twelve paintable template classes, in schema section order.

Enumerator
RMGUI_STYLE_CLASS_BUTTON 
RMGUI_STYLE_CLASS_DROPDOWN 
RMGUI_STYLE_CLASS_SLIDER 
RMGUI_STYLE_CLASS_CHOICE 
RMGUI_STYLE_CLASS_LIST_ROW 
RMGUI_STYLE_CLASS_TEXT_FIELD 
RMGUI_STYLE_CLASS_TAB 
RMGUI_STYLE_CLASS_WINDOW 
RMGUI_STYLE_CLASS_CONTEXT_MENU 
RMGUI_STYLE_CLASS_CHART 
RMGUI_STYLE_CLASS_PROGRESS 
RMGUI_STYLE_CLASS_SCROLLBAR 
RMGUI_STYLE_CLASS_COUNT 

◆ rmgui_style_state_t

Paint states are a bit set; NORMAL is empty, DISABLED overrides interaction.

DEFAULT marks the host's default action; INACTIVE is orthogonal window state.

Enumerator
RMGUI_STYLE_STATE_HOVER 
RMGUI_STYLE_STATE_PRESSED 
RMGUI_STYLE_STATE_FOCUSED 
RMGUI_STYLE_STATE_DISABLED 
RMGUI_STYLE_STATE_SELECTED 
RMGUI_STYLE_STATE_DEFAULT 
RMGUI_STYLE_STATE_INACTIVE 

◆ rmgui_style_text_t

Font-size-delta token chosen by a text-bearing class.

Enumerator
RMGUI_STYLE_TEXT_BODY 
RMGUI_STYLE_TEXT_HEADING 
RMGUI_STYLE_TEXT_CONTROL 
RMGUI_STYLE_TEXT_COUNT 

◆ rmgui_style_spring_t

Preset spring response for a class's authorable motion.

Enumerator
RMGUI_STYLE_SPRING_BALANCED 
RMGUI_STYLE_SPRING_SPRINGY 
RMGUI_STYLE_SPRING_SOFT 
RMGUI_STYLE_SPRING_COUNT 

◆ rmgui_style_scheme_t

Named preset palette; DEFAULT is the builtin token palette.

Enumerator
RMGUI_STYLE_SCHEME_DEFAULT 
RMGUI_STYLE_SCHEME_GRUVBOX_DARK 
RMGUI_STYLE_SCHEME_GRUVBOX_LIGHT 
RMGUI_STYLE_SCHEME_SOLARIZED_DARK 
RMGUI_STYLE_SCHEME_SOLARIZED_LIGHT 
RMGUI_STYLE_SCHEME_TOKYO_NIGHT 
RMGUI_STYLE_SCHEME_NORD 
RMGUI_STYLE_SCHEME_DRACULA 
RMGUI_STYLE_SCHEME_CATPPUCCIN_MOCHA 
RMGUI_STYLE_SCHEME_CATPPUCCIN_LATTE 
RMGUI_STYLE_SCHEME_AQUA 
  • Light Tiger role palette; skin materials remain scheme-derived.
RMGUI_STYLE_SCHEME_AERO 
  • Light Vista role palette with blue-teal accent/surface relationships.
RMGUI_STYLE_SCHEME_COUNT 

◆ rmgui_style_syntax_t

Syntax-highlight role, painted over the scheme's background token.

Enumerator
RMGUI_STYLE_SYNTAX_PLAIN 
RMGUI_STYLE_SYNTAX_KEYWORD 
RMGUI_STYLE_SYNTAX_TYPE 
RMGUI_STYLE_SYNTAX_FUNCTION 
RMGUI_STYLE_SYNTAX_STRING 
RMGUI_STYLE_SYNTAX_NUMBER 
RMGUI_STYLE_SYNTAX_COMMENT 
RMGUI_STYLE_SYNTAX_PREPROCESSOR 
RMGUI_STYLE_SYNTAX_PUNCTUATION 
RMGUI_STYLE_SYNTAX_COUNT 

Function Documentation

◆ rmgui_style_states_name()

size_t rmgui_style_states_name ( rmgui_style_states_t states,
char * out,
size_t cap )

Formats a state set into out, snprintf-style; invalid bits are ignored.

◆ rmgui_style_builtin()

const rmgui_style_snapshot_t * rmgui_style_builtin ( void )

Immutable builtin declaration; copy by value before editing.

◆ rmgui_style_scheme_name()

const char * rmgui_style_scheme_name ( rmgui_style_scheme_t scheme)

Static lowercase kebab-case scheme name, NULL for invalid scheme.

◆ rmgui_style_scheme_apply()

int rmgui_style_scheme_apply ( rmgui_style_snapshot_t * snapshot,
rmgui_style_scheme_t scheme )

Changes only the eleven named colour tokens and scheme metadata; invalid arguments return -1 leaving snapshot unchanged.

◆ rmgui_style_scheme_syntax()

int rmgui_style_scheme_syntax ( rmgui_style_scheme_t scheme,
rmgui_style_syntax_t role,
rmgui_color_t * out )

Writes an opaque scheme syntax colour to out; invalid arguments return -1 without changing out.

◆ rmgui_style_validate()

int rmgui_style_validate ( const rmgui_style_snapshot_t * snapshot,
char * error,
size_t error_cap )

Validates all 379 fields, references, metadata, and cross-field invariants; null/invalid returns -1 with bounded error; success writes empty error.

◆ rmgui_style_resolve()

int rmgui_style_resolve ( const rmgui_style_snapshot_t * snapshot,
rmgui_style_class_t class_id,
rmgui_style_states_t states,
int font_px,
int scale_percent,
rmgui_style_resolved_t * out )

Resolve a validated snapshot at positive font_px and scale_percent 1..400; invalid inputs return -1 without changing out.

DISABLED paints from the declaration: a text-bearing class's text is its text_disabled, or the border_strong token for one that declares none (button, dropdown, tab), which is also its text_disabled; a dropdown's chevron and a choice's mark take that ink too, an unfocused choice ring the border token, a slider's filled track and thumb its thumb_border colour, a list row's face, a context-menu item's face and a window's title band the background token, and a window's title-button bevel highlight its text_disabled.

◆ rmgui_style_resolve_desktop()

int rmgui_style_resolve_desktop ( const rmgui_style_snapshot_t * snapshot,
int scale_percent,
rmgui_desktop_style_resolved_t * out )

Resolve host-owned shell metrics at UI scale 1..400 into out; invalid inputs return -1 without changing out.