ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
ZMarkup, Prefabs & Data Binding

Declarative UI construction, reusable components, and reactive bindings. More...

Classes

class  ZenitUI::Bindable< T >
 Observable single-value container. More...
struct  ZenitUI::ZMarkup::Element
 Parsed representation of one markup node. More...
class  ZenitUI::ZMarkup::Parser
 Single-pass recursive-descent parser for ZMarkup source. More...
struct  ZenitUI::ZMarkup::SlotFrame
 Per-prefab-invocation slot routing table. More...
struct  ZenitUI::ZMarkup::ConditionBinding
 Runtime state for a structural If@ref block. More...
struct  ZenitUI::ZMarkup::IKeyedStore
 Type-erased storage base for keyed Each reconciliation. More...
struct  ZenitUI::ZMarkup::EachBinding
 Runtime state for a structural Each@ref prefab="..." slice. More...
struct  ZenitUI::ZMarkup::BuildContext
 Per-build accumulator for #id, @ref, and runtime structural bindings. More...
struct  ZenitUI::ZMarkup::KeyedStore< KeyT >
class  ZenitUI::ZMarkup::Registry
 Tag → factory map plus the prefab table (either per-UIContext or standalone/global). More...
class  ZenitUI::ZMarkup::UINode
 Root handle returned by build / instantiate: root node + build context + wiring helpers. More...
class  ZenitUI::ZMarkup::WeakUINode
 Non-owning handle to a UINode, safe to capture inside child callbacks. More...
struct  ZenitUI::ZMarkup::AttrDoc
 Metadata and single-source default for one tag attribute. More...
struct  ZenitUI::ZMarkup::TagDoc
 Metadata of one ZMarkup tag (only tag-specific attributes live in attrs). More...
struct  ZenitUI::ZMarkup::MarkupSyntaxDoc
 Documentation entry for basic ZMarkup syntax constructs (#id, .class, @ref, ...). More...
class  ZenitUI::ZMarkup::Attrs
 Pre-parsed, type-safe attribute bag passed to factories registered via Registry::tag(). More...
class  ZenitUI::ZMarkup::TagBuilder
 Fluent builder returned by Registry::tag(name). More...

Typedefs

using ZenitUI::ZMarkup::AttrValue = std::variant<std::string, float, int, bool, std::vector<std::string>>
 Typed storage for a parsed or default attribute value.

Enumerations

enum class  ZenitUI::ZMarkup::AttrType {
  String , Float , Int , Bool ,
  AttrType::List
}
 Value type of a declared ZMarkup attribute. More...

Functions

Element ZenitUI::ZMarkup::parse (std::string_view src, std::string fileName="")
 Parse src into a single root Element.
void ZenitUI::ZMarkup::registerBuiltins (Registry &r)
 Register the built-in widgets into r.
Registry & ZenitUI::ZMarkup::getGlobalRegistry ()
 Return the global registry, initializing built-ins on first call.
void ZenitUI::ZMarkup::registerPrefab (const std::string &tagName, const std::string &markupSource)
bool ZenitUI::ZMarkup::registerPrefabFile (const std::string &tagName, const std::filesystem::path &path)
bool ZenitUI::ZMarkup::hasPrefab (const std::string &tagName)
UINode ZenitUI::ZMarkup::build (std::string_view source, DiagnosticSink *sink=nullptr)
UINode ZenitUI::ZMarkup::loadMarkupFile (const std::filesystem::path &path, DiagnosticSink *sink=nullptr)
UINode ZenitUI::ZMarkup::instantiate (const std::string &tagName, const std::vector< std::string > &extraClasses={}, const std::string &id="", const std::string &ref="")
void ZenitUI::ZMarkup::registerPrefab (UIContext &ctx, const std::string &tagName, const std::string &markupSource)
 Register a prefab scoped to ctx's ZMarkup::Registry.
bool ZenitUI::ZMarkup::registerPrefabFile (UIContext &ctx, const std::string &tagName, const std::filesystem::path &path)
 Register a prefab from file into ctx's ZMarkup::Registry.
bool ZenitUI::ZMarkup::hasPrefab (const UIContext &ctx, const std::string &tagName)
 true if ctx's ZMarkup::Registry has a prefab named tagName (never allocates lazily).
UINode ZenitUI::ZMarkup::build (std::string_view source, const Registry &registry, DiagnosticSink *sink=nullptr)
 Build markup source using an explicit registry.
UINode ZenitUI::ZMarkup::build (std::string_view source, UIContext &ctx, DiagnosticSink *sink=nullptr)
 Build markup source using ctx's ZMarkup::Registry.
UINode ZenitUI::ZMarkup::loadMarkupFile (const std::filesystem::path &path, const Registry &registry, DiagnosticSink *sink=nullptr)
 Load and build markup from path using an explicit registry.
UINode ZenitUI::ZMarkup::loadMarkupFile (const std::filesystem::path &path, UIContext &ctx, DiagnosticSink *sink=nullptr)
 Load and build markup from path using ctx's ZMarkup::Registry.
UINode ZenitUI::ZMarkup::instantiate (const Registry &registry, const std::string &tagName, const std::vector< std::string > &extraClasses={}, const std::string &id="", const std::string &ref="")
 Instantiate prefab tagName from an explicit registry.
UINode ZenitUI::ZMarkup::instantiate (UIContext &ctx, const std::string &tagName, const std::vector< std::string > &extraClasses={}, const std::string &id="", const std::string &ref="")
 Instantiate prefab tagName from ctx's ZMarkup::Registry.
const char * ZenitUI::ZMarkup::toString (AttrType t) noexcept
const std::vector< AttrDoc > & ZenitUI::ZMarkup::universalAttrDocs ()
 Attributes accepted by every tag (besides ZStyle properties).
const std::vector< TagDoc > & ZenitUI::ZMarkup::structuralTagDocs ()
 Documentation of the structural pseudo-tags Slot, If, Each.
const std::vector< MarkupSyntaxDoc > & ZenitUI::ZMarkup::markupSyntaxDocs ()
 Documentation of basic ZMarkup syntax constructs (#id, .class, @ref, ...).

Detailed Description

Declarative UI construction, reusable components, and reactive bindings.

Key concepts:

  • Building trees: parse inline strings with ZMarkup::build(src, ctx) or files with ZMarkup::loadMarkupFile(path, ctx) using the context's isolated UIContext::markupRegistry() (with // and /* ... */ comments and structured syntax diagnostics).
  • Addressing nodes: prefer @ref local template handles (UINode::ref, UINode::refAll, onClickRef, setTextRef, onToggleRef) over #id global selectors.
  • Prefabs & slots: register reusable templates with ZMarkup::registerPrefab(ctx, ...) and route caller children through anonymous or named <Slot> elements with default fallbacks.
  • Structural & reactive UI: combine If@ref / Each@ref (with keyed reconciliation via bindEachKeyed) with Bindable<T> and WeakUINode for cycle-free updates.

Live examples: 01_hello_markup · 05_data_binding · 06_prefabs_slots · 07_dynamic_lists Full reference: ZMarkup 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.

Enumeration Type Documentation

◆ AttrType

enum class ZenitUI::ZMarkup::AttrType
strong

Value type of a declared ZMarkup attribute.

Enumerator
List 

Comma-separated list (e.g. Dropdown options).