ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
ZStyle, Theme & Diagnostics

CSS-like style cascade, .zstyle parser, custom properties, and media queries. More...

Classes

struct  ZenitUI::SourceSpan
 Source location for a diagnostic. More...
struct  ZenitUI::ZStyleDiagnostic
 A fully-formed diagnostic record. More...
class  ZenitUI::DiagnosticSink
 Abstract destination for diagnostics. More...
class  ZenitUI::NullDiagnosticSink
 Sink that discards every diagnostic. More...
class  ZenitUI::CollectingDiagnosticSink
 Sink that accumulates diagnostics in insertion order. More...
struct  ZenitUI::MediaCondition
 A single condition inside a @media query. More...
struct  ZenitUI::MediaQuery
 A conjunction of media conditions. More...
struct  ZenitUI::Opt< T >
 Optional wrapper with value semantics used for all style fields. More...
class  ZenitUI::SharedPropMap
 8-byte Copy-on-Write wrapper around std::unordered_map<std::string, std::string>. More...
class  ZenitUI::SharedVector< T >
 8-byte Copy-on-Write wrapper around std::vector<T> for cold style arrays. More...
struct  ZenitUI::Spacing
 Four-sided Value tuple used for padding, margin and border-width. More...
struct  ZenitUI::TransitionSpec
 One entry in the transitions list of a Style. More...
struct  ZenitUI::AnimationRef
 One entry in the animations list of a Style. More...
struct  ZenitUI::ZIndex
 CSS z-index with an explicit "auto" state. More...
struct  ZenitUI::TextureRef
 Reference to a texture asset with optional nine-slice insets. More...
struct  ZenitUI::SimpleSelector
 One component of a CSS selector chain. More...
struct  ZenitUI::FilterRef
 One filter in the filters list of a Style. More...
struct  ZenitUI::BoxShadow
 CSS box-shadow payload. More...
struct  ZenitUI::GridTrack
 One track definition in grid-template-columns or grid-template-rows. More...
struct  ZenitUI::GridPlacement
 Item placement along one grid axis (grid-column or grid-row). More...
struct  ZenitUI::Style
 Sparse style: every property is Opt<T>, unset by default. More...
struct  ZenitUI::ComputedStyle
 Dense style: every property has a concrete value. More...
struct  ZenitUI::PropDesc
struct  ZenitUI::ZMarkup::Declaration
 One parsed key: value; declaration, with source location. More...
struct  ZenitUI::ZMarkup::StyleSheet
 Intermediate representation: parsed rules, keyframes and root vars. More...
class  ZenitUI::ZMarkup::StyleParser
 Hand-written recursive-descent CSS-like parser. More...
struct  ZenitUI::ZMarkup::StyleLintOptions
 Options controlling static semantic linting in lintStyleSheet(). More...
struct  ZenitUI::StyleResolver
 Resolves, caches, and transitions the style of a single node. More...
struct  ZenitUI::ParseCtx
 Context passed to executable property parsers. More...
struct  ZenitUI::PropSpec
 Executable + documentation descriptor for one ZStyle key. More...
struct  ZenitUI::StyleNameDoc
 Documentation entry for a language construct (value syntax, selector, pseudo-class, media feature). More...
struct  ZenitUI::PseudoClassSpec
 Executable + documentation descriptor for a pseudo-class (:hover, :not(), ...). More...
struct  ZenitUI::MediaFeatureSpec
 Executable + documentation descriptor for a @media feature. More...
struct  ZenitUI::Specificity
 CSS-style specificity triple used to sort matching rules. More...
struct  ZenitUI::ThemeRule
 A single selector-plus-declarations entry in the stylesheet. More...
class  ZenitUI::Theme
 Per-context stylesheet: rules, keyframes, and root style. More...

Macros

#define BUBBLE_STYLE_PROPS(X)

Typedefs

using ZenitUI::PropValue
using ZenitUI::StyleApplyFn = ParseResult (*)(Style &, std::string_view, const ParseCtx &)

Enumerations

enum class  ZenitUI::DiagnosticSeverity { Info , Warning , Error }
 Diagnostic severity level.
enum class  ZenitUI::DiagnosticCode {
  UnterminatedString , UnbalancedBrace , UnexpectedToken , UnknownProperty ,
  InvalidValue , UnknownPseudo , UnknownPart , UnresolvedVariable ,
  UnusedVariable , UnknownSelectorTag , SelectorMatchesNothing , DuplicateRule ,
  UnknownTag , UnknownAttribute
}
 Machine-readable diagnostic identifier. More...
enum class  ZenitUI::Position : uint8_t { Static , Relative , Absolute }
 CSS-style position modes supported by the layout system.
enum class  ZenitUI::Overflow : uint8_t { Visible , Hidden , Scroll , Auto }
 CSS overflow modes for one axis.
enum class  ZenitUI::WhiteSpace : uint8_t { Normal , Nowrap }
 CSS white-space values relevant to text layout.
enum class  ZenitUI::TextOverflow : uint8_t { Visible , Ellipsis }
 CSS text-overflow modes supported by the text renderer.
enum class  ZenitUI::SelectorCombinator : uint8_t { SelectorCombinator::Descendant , SelectorCombinator::Child , SelectorCombinator::AdjacentSibling , SelectorCombinator::GeneralSibling }
 Relationship between a selector and the preceding selector in a chain. More...
enum class  Direction : uint8_t { Auto , Row , Column }
enum class  ZenitUI::ParseResult { ParseResult::Ok , ParseResult::Invalid , ParseResult::Reported }
 Outcome of applying a single property value via a PropSpec. More...
enum class  ZenitUI::MediaFeatureId {
  MinWidth , MaxWidth , MinHeight , MaxHeight ,
  Orientation , MinAspectRatio , MaxAspectRatio
}
 Canonical identifier for each supported @media feature.

Functions

const char * ZenitUI::toString (DiagnosticSeverity s) noexcept
const char * ZenitUI::toString (DiagnosticCode c) noexcept
ZStyleDiagnostic ZenitUI::makeDiagnostic (DiagnosticCode code, DiagnosticSeverity severity, SourceSpan span, std::string message, std::string hint={})
 Build a diagnostic record.
std::size_t ZenitUI::editDistance (std::string_view a, std::string_view b)
 Levenshtein edit distance between a and b.
std::vector< std::string > ZenitUI::suggestSimilar (std::string_view unknown, const std::vector< std::string_view > &candidates, std::size_t maxDistance=2, std::size_t maxSuggestions=3)
 Suggest candidates within maxDistance edits of unknown.
void ZenitUI::formatDiagnostic (const ZStyleDiagnostic &d, std::ostream &os)
 Write a diagnostic to os in file:line:col: severity: message [code] format.
const std::vector< std::string_view > & ZenitUI::getKnownStyleProperties ()
 Return the list of style property names known to the parser.
bool ZenitUI::evaluateMedia (const MediaQuery &q, Vec2 viewport)
 Evaluate a MediaQuery against a viewport size.
std::ostream & ZenitUI::operator<< (std::ostream &os, const FontStack &stack)
 std::ostream operator for FontStack, used by debug output.
bool ZenitUI::operator== (const std::vector< FilterRef > &a, const std::vector< FilterRef > &b)
bool ZenitUI::operator!= (const std::vector< FilterRef > &a, const std::vector< FilterRef > &b)
bool ZenitUI::operator== (const std::vector< GridTrack > &a, const std::vector< GridTrack > &b)
bool ZenitUI::operator!= (const std::vector< GridTrack > &a, const std::vector< GridTrack > &b)
bool ZenitUI::isInheritedProp (std::string_view name)
 true if the named property inherits from parent to child.
bool ZenitUI::clearStyleProp (Style &s, std::string_view name)
 Clear the property named name on s.
std::string ZenitUI::kebabToCamel (std::string_view s)
std::string ZenitUI::camelToKebab (std::string_view s)
bool ZenitUI::operator== (const ComputedStyle &a, const ComputedStyle &b)
 Field-wise equality; used to detect layout-affecting style changes.
bool ZenitUI::operator!= (const ComputedStyle &a, const ComputedStyle &b)
float ZenitUI::lerpProp (float a, float b, float t)
Color ZenitUI::lerpProp (const Color &a, const Color &b, float t)
FontStack ZenitUI::lerpProp (const FontStack &a, const FontStack &b, float t)
Value ZenitUI::lerpProp (const Value &a, const Value &b, float t)
Spacing ZenitUI::lerpProp (const Spacing &a, const Spacing &b, float t)
template<typename E, typename = std::enable_if_t<std::is_enum_v<E>>>
E ZenitUI::lerpProp (E a, E b, float t)
ZIndex ZenitUI::lerpProp (const ZIndex &a, const ZIndex &b, float t)
std::string ZenitUI::lerpProp (const std::string &a, const std::string &b, float t)
SharedVector< FilterRef > ZenitUI::lerpProp (const SharedVector< FilterRef > &a, const SharedVector< FilterRef > &b, float t)
TextureRef ZenitUI::lerpProp (const TextureRef &a, const TextureRef &b, float t)
BoxShadow ZenitUI::lerpProp (const BoxShadow &a, const BoxShadow &b, float t)
SharedVector< GridTrack > ZenitUI::lerpProp (const SharedVector< GridTrack > &a, const SharedVector< GridTrack > &b, float t)
GridPlacement ZenitUI::lerpProp (const GridPlacement &a, const GridPlacement &b, float t)
ComputedStyle ZenitUI::lerpStyle (const ComputedStyle &a, const ComputedStyle &b, float t)
 Field-wise lerp of two ComputedStyle.
ComputedStyle ZenitUI::lerpStyleTimed (const ComputedStyle &a, const ComputedStyle &b, float realElapsed)
 Field-wise lerp using per-property durations from b's transition list.
bool ZenitUI::stylesDiffer (const Style &a, const Style &b)
 Compare two sparse Style values for "would this change anything".
template<typename T>
Opt< T > ZenitUI::lerpOpt (const Opt< T > &a, const Opt< T > &b, float t)
Style ZenitUI::lerpStyleParts (const Style &a, const Style &b, float t)
void ZenitUI::overlayComputed (ComputedStyle &dst, const Style &src)
template<typename F>
void ZenitUI::forEachSetStyleProp (const Style &s, F &&fn)
bool ZenitUI::copyStyleProp (Style &dst, const Style &src, std::string_view name)
bool ZenitUI::hasStyleProp (const Style &s, std::string_view name)
const std::vector< PropDesc > & ZenitUI::propTable ()
const PropDesc * ZenitUI::findProp (std::string_view name)
PropValue ZenitUI::lerpValue (const PropValue &a, const PropValue &b, float t)
std::optional< Value > ZenitUI::parseValueToken (std::string_view s)
 Parse a single Value token.
std::optional< Color > ZenitUI::parseColorToken (std::string_view s)
 Parse a color token.
std::optional< Spacing > ZenitUI::parseSpacingToken (std::string_view s)
 Parse a 1-4 value shorthand.
std::optional< Align > ZenitUI::parseAlignToken (std::string_view s)
std::optional< Direction > ZenitUI::parseDirectionToken (std::string_view s)
std::optional< TextDirection > ZenitUI::parseTextDirectionToken (std::string_view s)
std::optional< Justify > ZenitUI::parseJustifyToken (std::string_view s)
std::optional< WhiteSpace > ZenitUI::parseWhiteSpaceToken (std::string_view s)
std::optional< TextOverflow > ZenitUI::parseTextOverflowToken (std::string_view s)
std::optional< CursorShape > ZenitUI::parseCursorToken (std::string_view s)
bool ZenitUI::applyStyleAttr (Style &st, std::string_view key, std::string_view val)
 Apply a single key: value declaration to st.
std::string ZenitUI::substituteVarRefs (std::string v, const std::unordered_map< std::string, std::string > &customProps)
 Recursively substitute var(--name) references in v.
Style ZenitUI::resolveUnresolvedProps (const std::unordered_map< std::string, std::string > &unresolved, const std::unordered_map< std::string, std::string > &customProps)
 Resolve every pending var(...) declaration in unresolved.
std::string_view ZenitUI::ZMarkup::trim (std::string_view s)
 Trim leading and trailing ASCII whitespace.
std::string ZenitUI::ZMarkup::stripComments (std::string_view src)
 Strip // line and block comments from src.
std::vector< std::string_view > ZenitUI::ZMarkup::splitBy (std::string_view s, char sep)
 Split s on every occurrence of sep.
std::vector< std::string_view > ZenitUI::ZMarkup::splitWs (std::string_view s)
 Split s on any ASCII whitespace.
float ZenitUI::ZMarkup::parseDurationSec (std::string_view s)
 Parse a CSS duration ("200ms" → 0.2, "1.5s" → 1.5).
void ZenitUI::ZMarkup::applyStyleDeclaration (Style &st, std::string_view keyRaw, std::string_view valRaw, const SourceSpan &loc, DiagnosticSink *sink=nullptr, bool strict=false)
 Apply one declaration to st.
void ZenitUI::ZMarkup::normalizeKeyframes (KeyframeAnimation &anim, const SourceSpan &loc)
 Fill missing properties in every keyframe from neighbouring frames.
void ZenitUI::ZMarkup::applyStyleSheet (const StyleSheet &sheet, Theme &theme, DiagnosticSink *sink=nullptr, bool strict=false)
 Apply a parsed StyleSheet to a Theme.
void ZenitUI::ZMarkup::lintStyleSheet (const StyleSheet &sheet, DiagnosticSink &sink, const StyleLintOptions &opts={})
 Run static semantic checks on a parsed StyleSheet.
bool ZenitUI::ZMarkup::loadStyleString (std::string_view src, Theme &theme, const std::string &fileName="<string>", DiagnosticSink *sink=nullptr, bool strict=false, const Registry *registry=nullptr)
 Parse src and apply it to theme.
bool ZenitUI::ZMarkup::loadStyleFile (const std::filesystem::path &path, Theme &theme, DiagnosticSink *sink=nullptr, bool strict=false, const Registry *registry=nullptr)
 Load a stylesheet from a file and apply it to theme.
const std::vector< PropSpec > & ZenitUI::stylePropSpecs ()
 All documented & executable ZStyle keys (properties, shorthands, aliases).
const PropSpec * ZenitUI::findStylePropSpec (std::string_view key)
 O(1) lookup by ZStyle key; returns nullptr if unknown.
std::size_t ZenitUI::countUnmigratedStyleSpecs ()
 Number of specs whose apply pointer is still nullptr (migration audit).
const std::vector< StyleNameDoc > & ZenitUI::styleValueSyntaxDocs ()
 Shared value types (<value>, <color>, <time>, <easing>).
const std::vector< StyleNameDoc > & ZenitUI::styleSelectorDocs ()
 Selector syntax (Button, .cls, #id, >, +, ~, *, ::part).
const std::vector< StyleNameDoc > & ZenitUI::styleConstructDocs ()
 Top-level ZStyle constructs (:root, --custom, var(), @keyframes, @media, ::part).
const std::vector< StyleNameDoc > & ZenitUI::stylePseudoClassDocs ()
 Supported pseudo-classes (:hover, :pressed, :focus, :disabled, :checked, :not()).
const std::vector< StyleNameDoc > & ZenitUI::styleMediaFeatureDocs ()
 Supported @media features (min-width, orientation, ...).
const std::vector< PseudoClassSpec > & ZenitUI::stylePseudoClassSpecs ()
const PseudoClassSpec * ZenitUI::findPseudoClassSpec (std::string_view name)
const std::vector< MediaFeatureSpec > & ZenitUI::styleMediaFeatureSpecs ()
const MediaFeatureSpec * ZenitUI::findMediaFeatureSpec (std::string_view name)
Specificity ZenitUI::computeNegatedItemSpecificity (const SimpleSelector::NegatedItem &item)
Specificity ZenitUI::computeSpecificity (const std::vector< SimpleSelector > &chain)
 Compute the specificity of a full selector chain.

Detailed Description

CSS-like style cascade, .zstyle parser, custom properties, and media queries.

Load stylesheets into a context's UIContext::theme via ZMarkup::loadStyleFile(path, ctx.theme) or ZMarkup::loadStyleString(src, ctx.theme) (optionally passing &ctx.markupRegistry() to validate custom widget ::part names). Resolution follows specificity (#id > .class > Tag), supports descendant ( ), child (>), adjacent sibling (+), and general sibling (~) combinators, * and :not(...), interaction pseudo-classes (:hover, :pressed, :focus, :checked, :disabled), live Copy-on-Write custom properties (--token / var(--token)), @media queries, dir: / cursor:, and structured parse + lint diagnostics with typo suggestions.

Live examples: 03_selectors_theme · 02_layout_flex · 15_grid_dashboard · 13_i18n_rtl Full reference: ZStyle Reference

Live examples
  • 00_demo — Flagship ZenitUI showcase: live Dark/Light theming, ZMarkup prefabs & keyed Each, Bindable<T>, UTF-8 TextArea, 10k-row VirtualView, portals, filters, and CanvasLayout.

Typedef Documentation

◆ PropValue

using ZenitUI::PropValue
Initial value:
std::variant<bool, float, Value, Color, Spacing, Align, Justify,
std::string, FontStack, TextureRef,
Ordered list of font family names to try, first match wins.
Definition CoreTypes.hpp:194
8-byte Copy-on-Write wrapper around std::vector<T> for cold style arrays.
Definition Style.hpp:294
TransitionFunction
Timing function applied between two keyframe values.
Definition Easing.hpp:28
Justify
Main-axis distribution for flex containers.
Definition CoreTypes.hpp:462
Align
Cross-axis alignment for flex items and content.
Definition CoreTypes.hpp:452
TextDirection
Inline / layout writing direction for Bidi text and RTL layout mirroring (§6.2).
Definition UIEnums.hpp:83
CursorShape
Standard OS cursor shapes requested via ZStyle cursor: and IPlatform::setCursor.
Definition UIEnums.hpp:61
TextOverflow
CSS text-overflow modes supported by the text renderer.
Definition Style.hpp:595
Overflow
CSS overflow modes for one axis.
Definition Style.hpp:579
WhiteSpace
CSS white-space values relevant to text layout.
Definition Style.hpp:588
Position
CSS-style position modes supported by the layout system.
Definition Style.hpp:552
CSS box-shadow payload.
Definition Style.hpp:705
8-bit-per-channel RGBA color, non-premultiplied.
Definition CoreTypes.hpp:78
Item placement along one grid axis (grid-column or grid-row).
Definition Style.hpp:765
Four-sided Value tuple used for padding, margin and border-width.
Definition Style.hpp:486
Reference to a texture asset with optional nine-slice insets.
Definition Style.hpp:604
8-byte tagged length expression:
Definition Unit.hpp:58
CSS z-index with an explicit "auto" state.
Definition Style.hpp:562

Enumeration Type Documentation

◆ DiagnosticCode

enum class ZenitUI::DiagnosticCode
strong

Machine-readable diagnostic identifier.

Grouped by subsystem:

  • Lexical / syntactic: UnterminatedString, UnbalancedBrace, UnexpectedToken
  • Declaration-level: UnknownProperty, InvalidValue, UnknownPseudo, UnknownPart, UnresolvedVariable, UnusedVariable
  • Selector-level: UnknownSelectorTag, SelectorMatchesNothing, DuplicateRule

Tools can switch on code without matching localized message strings.

◆ ParseResult

enum class ZenitUI::ParseResult
strong

Outcome of applying a single property value via a PropSpec.

Enumerator
Ok 

Value parsed and applied cleanly.

Invalid 

Value malformed; caller should emit InvalidValue.

Reported 

Parser already emitted a specific diagnostic (e.g. missing prelude).

◆ SelectorCombinator

enum class ZenitUI::SelectorCombinator : uint8_t
strong

Relationship between a selector and the preceding selector in a chain.

Enumerator
Descendant 

A B (any ancestor).

Child 

A > B (direct parent).

AdjacentSibling 

A + B (immediately preceding sibling).

GeneralSibling 

A ~ B (any preceding sibling).

Function Documentation

◆ applyStyleAttr()

bool ZenitUI::applyStyleAttr ( Style & st,
std::string_view key,
std::string_view val )
inline

Apply a single key: value declaration to st.

Returns
true if the key was recognized, even if the value failed to parse. Returns false for unknown keys.

◆ applyStyleDeclaration()

void ZenitUI::ZMarkup::applyStyleDeclaration ( Style & st,
std::string_view keyRaw,
std::string_view valRaw,
const SourceSpan & loc,
DiagnosticSink * sink = nullptr,
bool strict = false )

Apply one declaration to st.

Handles:

  • --name: value (custom properties) → st.customProps.
  • Values containing var(...) → st.unresolvedProps for late binding.
  • transition / transition-* shorthands and longhands.
  • animation / animation-* shorthands and longhands.
  • filter / box-shadow / overflow / overflow-x / overflow-y.
  • Everything else → applyStyleAttr.

Reports an UnknownProperty warning (or error in strict mode) when applyStyleAttr returns false, with "did you mean" suggestions drawn from getKnownStyleProperties.

Parameters
stDestination style.
keyRawProperty name (trimmed internally).
valRawValue string (trimmed internally).
locSource location for diagnostics.
sinkOptional diagnostic sink; if null, warnings go to logWarn.
strictIf true, unknown properties become errors instead of warnings.

◆ applyStyleSheet()

void ZenitUI::ZMarkup::applyStyleSheet ( const StyleSheet & sheet,
Theme & theme,
DiagnosticSink * sink = nullptr,
bool strict = false )

Apply a parsed StyleSheet to a Theme.

Order of operations:

  1. Merge rootDecls into theme.root.
  2. For each rule, build a ThemeRule (selector chain + part + media) by applying its declarations to a fresh Style, then addRule.
  3. For each keyframes block, validate uniqueness (warn on duplicate), sort frames by time, normalize, and addKeyframes.
Parameters
sheetParsed stylesheet.
themeDestination theme.
sinkOptional diagnostic sink.
strictWhen true, unknown properties become errors.

◆ clearStyleProp()

bool ZenitUI::clearStyleProp ( Style & s,
std::string_view name )
inline

Clear the property named name on s.

Returns
true if a property was matched and cleared.

◆ editDistance()

std::size_t ZenitUI::editDistance ( std::string_view a,
std::string_view b )
nodiscard

Levenshtein edit distance between a and b.

O(n*m) time, O(min(n,m)) space. Used by suggestSimilar for "did you mean" hints; strings of length > 100 are rare in this codebase.

◆ evaluateMedia()

bool ZenitUI::evaluateMedia ( const MediaQuery & q,
Vec2 viewport )
inline

Evaluate a MediaQuery against a viewport size.

Parameters
qThe query to evaluate.
viewportCurrent viewport in logical pixels.
Returns
true if every condition holds (vacuously true for an empty query).

◆ formatDiagnostic()

void ZenitUI::formatDiagnostic ( const ZStyleDiagnostic & d,
std::ostream & os )

Write a diagnostic to os in file:line:col: severity: message [code] format.

Appends the hint: line when non-empty, and the note: see … line when related is set.

◆ getKnownStyleProperties()

const std::vector< std::string_view > & ZenitUI::getKnownStyleProperties ( )
nodiscard

Return the list of style property names known to the parser.

Used by suggestSimilar when producing UnknownProperty hints.

◆ lintStyleSheet()

void ZenitUI::ZMarkup::lintStyleSheet ( const StyleSheet & sheet,
DiagnosticSink & sink,
const StyleLintOptions & opts = {} )

Run static semantic checks on a parsed StyleSheet.

Emits UnresolvedVariable, UnusedVariable, UnknownSelectorTag, and (when opts.markupRoot is provided) SelectorMatchesNothing.

◆ loadStyleFile()

bool ZenitUI::ZMarkup::loadStyleFile ( const std::filesystem::path & path,
Theme & theme,
DiagnosticSink * sink = nullptr,
bool strict = false,
const Registry * registry = nullptr )

Load a stylesheet from a file and apply it to theme.

Returns
false if the file could not be read or a parse error occurred.
Examples
00_demo/main.cpp.

◆ loadStyleString()

bool ZenitUI::ZMarkup::loadStyleString ( std::string_view src,
Theme & theme,
const std::string & fileName = "<string>",
DiagnosticSink * sink = nullptr,
bool strict = false,
const Registry * registry = nullptr )

◆ makeDiagnostic()

ZStyleDiagnostic ZenitUI::makeDiagnostic ( DiagnosticCode code,
DiagnosticSeverity severity,
SourceSpan span,
std::string message,
std::string hint = {} )
nodiscard

Build a diagnostic record.

Parameters
codeMachine-readable identifier.
severitySeverity level.
spanPrimary source location.
messageHuman-readable message.
hintOptional suggestion text.

◆ normalizeKeyframes()

void ZenitUI::ZMarkup::normalizeKeyframes ( KeyframeAnimation & anim,
const SourceSpan & loc )

Fill missing properties in every keyframe from neighbouring frames.

CSS animations that declare a property only at the start and end still need all keyframes to hold a value for that property, so that the evaluator can interpolate uniformly. This function fills gaps by copying from the previous keyframe, or from the next if the gap is at the beginning. Emits a logWarn for each auto-filled property to make authoring errors visible.

◆ parseColorToken()

std::optional< Color > ZenitUI::parseColorToken ( std::string_view s)
inline

Parse a color token.

Returns
nullopt on parse failure.

◆ parseDurationSec()

float ZenitUI::ZMarkup::parseDurationSec ( std::string_view s)

Parse a CSS duration ("200ms" → 0.2, "1.5s" → 1.5).

Bare numbers are treated as seconds. Used by both transition and animation shorthands.

◆ parseSpacingToken()

std::optional< Spacing > ZenitUI::parseSpacingToken ( std::string_view s)
inline

Parse a 1-4 value shorthand.

Returns
nullopt if any value fails to parse.

◆ parseValueToken()

std::optional< Value > ZenitUI::parseValueToken ( std::string_view s)
inline

Parse a single Value token.

Returns
nullopt on parse failure or unknown unit.

◆ splitBy()

std::vector< std::string_view > ZenitUI::ZMarkup::splitBy ( std::string_view s,
char sep )

Split s on every occurrence of sep.

Empty parts are preserved.

◆ splitWs()

std::vector< std::string_view > ZenitUI::ZMarkup::splitWs ( std::string_view s)

Split s on any ASCII whitespace.

Empty parts are skipped.

◆ stripComments()

std::string ZenitUI::ZMarkup::stripComments ( std::string_view src)

Strip // line and block comments from src.

Respects string literals: a // inside a "..." is not treated as a comment. Preserves newlines for accurate line numbering in diagnostics.

◆ suggestSimilar()

std::vector< std::string > ZenitUI::suggestSimilar ( std::string_view unknown,
const std::vector< std::string_view > & candidates,
std::size_t maxDistance = 2,
std::size_t maxSuggestions = 3 )
nodiscard

Suggest candidates within maxDistance edits of unknown.

Parameters
unknownThe misspelled identifier.
candidatesList of valid identifiers.
maxDistanceMaximum edit distance to consider.
maxSuggestionsMaximum number of suggestions to return.
Returns
Suggestions sorted by (distance, alphabetical).