ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
StyleAttr.hpp File Reference

Parse a single CSS-like declaration (key: value) into a Style. More...

#include "Common.hpp"
#include "Logger.hpp"
#include "CoreTypes.hpp"
#include "Easing.hpp"
#include "Unit.hpp"
#include "Style.hpp"
#include "StyleSpecs.hpp"
#include <charconv>
#include <cctype>
#include <optional>
#include <sstream>

Go to the source code of this file.

Functions

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.

Detailed Description

Parse a single CSS-like declaration (key: value) into a Style.

Two entry points:

  • applyStyleAttr(st, key, value): the low-level dispatch, handles both attribute-style markup (width="50") and CSS declarations (width: 50px).
  • resolveUnresolvedProps(unresolved, customProps): late-binding of var(--name) references, called from StyleResolver::resolveFor after the cascade has resolved which custom properties are in scope.

The detail namespace contains the calc()-style expression parser and a few small string helpers that are not part of the public API but are used by applyStyleAttr.