ZenitUI
Retained-mode C++20 UI framework
Loading...
Searching...
No Matches
Core, Layout & Lifecycle

Base node types (Layout, TLayout), per-instance context (UIContext), units, input, Drag & Drop, cursors, and scrolling. More...

Namespaces

namespace  ZenitUI::Colors
 Named color constants.
namespace  ZenitUI::Key
 Global viewport metrics, updated once per frame from the platform.

Classes

struct  ZenitUI::Vec2
 2D vector with component-wise arithmetic. More...
struct  ZenitUI::Vec3
 3D vector. More...
struct  ZenitUI::Vec4
 4D vector with an implicit w = 1 default. More...
struct  ZenitUI::Rect
 Axis-aligned rectangle in screen coordinates. More...
struct  ZenitUI::EdgeInsets
 Four-sided edge inset (used for padding, margin, borders). More...
struct  ZenitUI::Color
 8-bit-per-channel RGBA color, non-premultiplied. More...
struct  ZenitUI::Vertex2D
 Interleaved 2D vertex passed to IRenderer::drawGeometry. More...
struct  ZenitUI::TextureHandle
 Opaque handle to a GPU/software texture owned by the asset provider. More...
struct  ZenitUI::FontHandle
 Opaque handle to a font loaded by TextEngine. More...
struct  ZenitUI::EffectHandle
 Opaque handle to a shader/effect owned by the asset provider. More...
struct  ZenitUI::TargetHandle
 Opaque handle to an off-screen render target. More...
struct  ZenitUI::NineSlice
 Nine-slice inset values for scalable textures. More...
struct  ZenitUI::Transform2D
 2D affine transform stored as pivot + translate + rotation + scale. More...
class  ZenitUI::FontStack
 Ordered list of font family names to try, first match wins. More...
struct  ZenitUI::ButtonState
 Per-button state snapshot for the current frame. More...
struct  ZenitUI::PointerState
 Pointer position, wheel delta, and per-button state for one frame. More...
struct  ZenitUI::ModifierState
 Keyboard modifier snapshot. More...
struct  ZenitUI::InputEvents
 One frame's worth of keyboard input. More...
struct  ZenitUI::InputController
 Stateless per-node input dispatcher. More...
struct  ZenitUI::NodeState
 Per-frame interaction flags derived from pointer / keyboard state. More...
struct  ZenitUI::NodeConfig
 Static configuration bits: interaction behaviour, render behaviour. More...
struct  ZenitUI::NodeInternal
 Transient bookkeeping bits used by the layout / style / culling passes. More...
struct  ZenitUI::DragHandlers
 Lazily allocated Drag & Drop callbacks owned by Layout (§5.22). More...
class  ZenitUI::Layout
 The base node type: tree, style, layout, input, scroll, render. More...
class  ZenitUI::TLayout< Derived, Base >
 CRTP base for components that want fluent builders and a static create() factory. More...
struct  ZenitUI::ScrollController
 Per-node overflow, scrolling and scrollbar state machine. More...
struct  ZenitUI::ScrollState
 Offset, bounds, velocity and drag anchors for one scroll container. More...
class  ZenitUI::SmallVector< T, N >
 A vector whose first N elements live inside the object. More...
struct  ZenitUI::FontMetrics
 Scaled vertical metrics for a font at a given logical pixel size. More...
struct  ZenitUI::TextMeasureSpec
 Typographic parameters governing shaping and measurement. More...
struct  ZenitUI::TextLayoutOptions
 Wrapping, truncation, and whitespace options for TextEngine::layout. More...
struct  ZenitUI::ShapedGlyph
 Single shaped glyph positioned along a laid-out line. More...
struct  ZenitUI::TextLine
 One visual line produced by TextEngine::layout. More...
struct  ZenitUI::TextLayout
 Complete laid-out text block ready for sizing, hit-testing, and rendering. More...
struct  ZenitUI::TextAtlasStats
 Diagnostic counters for the dynamic FreeType glyph atlas. More...
class  ZenitUI::TextEngine
 Per-context font store, HarfBuzz shaper, FreeType glyph atlas, and layout engine. More...
class  ZenitUI::IRenderer
 Abstract 2D rendering backend. More...
class  ZenitUI::IPlatform
 Abstract windowing, timing, input, and clipboard backend. More...
class  ZenitUI::IAssetProvider
 Abstract name-based lookup and runtime lifecycle for textures and shaders. More...
struct  ZenitUI::RenderStats
 Per-frame and live render-target / filter counters (Proposal 9, Step 0). More...
class  ZenitUI::TargetPool
 Shared, bucket-sized render-target pool owned by UIContext (§4.9 Step c). More...
struct  ZenitUI::DragPayload
 Opaque user payload carried during an active drag-and-drop operation. More...
struct  ZenitUI::ActiveDrag
 Per-context state tracking a pending or active drag operation. More...
struct  ZenitUI::UIContext
 Per-instance UI context: backends, theme, text engine, frame state, and routing. More...
struct  ZenitUI::Value
 8-byte tagged length expression: More...

Enumerations

enum class  ZenitUI::MouseButton : uint8_t { Left , Right , Middle , Count }
 Mouse buttons tracked by the input system. More...
enum class  ZenitUI::Align : uint8_t {
  Align::Auto , Align::Start , Align::Center , Align::End ,
  Align::Stretch
}
 Cross-axis alignment for flex items and content. More...
enum class  ZenitUI::Justify : uint8_t { Justify::Start , Justify::Center , Justify::End , Justify::SpaceBetween }
 Main-axis distribution for flex containers. More...
enum class  ZenitUI::Feature { Feature::Effects , Feature::NestedTargets , Feature::TargetSubRect }
 Optional renderer capabilities queried via IRenderer::supports. More...
enum class  ZenitUI::ShaderLanguage {
  ShaderLanguage::None , ShaderLanguage::GLSL330 , ShaderLanguage::GLSL300ES , ShaderLanguage::SPIRV ,
  ShaderLanguage::HLSL , ShaderLanguage::MSL , ShaderLanguage::WGSL
}
 Shading language consumed by an IRenderer that supports Feature::Effects. More...
enum class  ZenitUI::BlendMode { BlendMode::Alpha , BlendMode::Premultiplied , BlendMode::Replace }
 Color-blending mode used by IRenderer draw calls. More...
enum class  ZenitUI::LayoutType : uint8_t { LayoutType::Stack , LayoutType::Vertical , LayoutType::Horizontal , LayoutType::Grid }
 Positioning strategy applied to a Layout node's direct children. More...
enum class  ZenitUI::UIState : uint8_t { UIState::Idle , UIState::Hover , UIState::Pressed , UIState::Disabled }
 Interaction state computed per node and consumed by the style resolver to select pseudo-class overlays. More...
enum class  ZenitUI::CursorShape : uint8_t {
  CursorShape::Auto , CursorShape::Default , CursorShape::Pointer , CursorShape::Text ,
  CursorShape::Move , CursorShape::Grab , CursorShape::Grabbing , CursorShape::ResizeEW ,
  CursorShape::ResizeNS , CursorShape::ResizeNESW , CursorShape::ResizeNWSE , CursorShape::NotAllowed ,
  CursorShape::Crosshair , CursorShape::Wait
}
 Standard OS cursor shapes requested via ZStyle cursor: and IPlatform::setCursor. More...
enum class  ZenitUI::TextDirection : uint8_t { TextDirection::Auto , TextDirection::LTR , TextDirection::RTL }
 Inline / layout writing direction for Bidi text and RTL layout mirroring (§6.2). More...
enum class  Unit : int8_t {
  Auto = -1 , Number = 0 , Pixel = 1 , Percent = 2 ,
  VW = 3 , VH = 4 , PW = 5 , PH = 6
}
enum class  ValueOp : uint8_t {
  None , Add , Sub , Mul ,
  Div , Min , Max , Clamp ,
  Round , Floor , Ceil , Mod
}

Functions

Vec2 ZenitUI::operator+ (Vec2 a, Vec2 b)
Vec2 ZenitUI::operator- (Vec2 a, Vec2 b)
Vec2 ZenitUI::operator* (Vec2 a, float k)
Vec2 ZenitUI::applyTransform (const Transform2D &t, Vec2 p)
 Apply a Transform2D to a point.
Vec2 ZenitUI::applyInverseTransform (const Transform2D &t, Vec2 p)
 Invert a Transform2D and apply it to a point.
bool ZenitUI::nodeMatchesAtom (const Layout *node, SimpleSelector::Kind kind, const std::string &name, const std::vector< std::pair< SimpleSelector::Kind, std::string > > &extras, bool reqHover, bool reqPressed, bool reqFocus, bool reqDisabled, bool reqChecked)
bool ZenitUI::nodeMatchesSimple (const Layout *node, const SimpleSelector &ss)
 true if node matches the primary selector, all extras, and none of its :not() clauses.
const Layout * ZenitUI::previousStyleSibling (const Layout *node)
 Return the immediately preceding non-sentinel sibling of node, or nullptr.
bool ZenitUI::matchSelectorChainAt (const std::vector< SimpleSelector > &chain, size_t idx, const Layout *node)
bool ZenitUI::ruleMatches (const ThemeRule &r, const Layout *node, Vec2 viewport)
 true if node matches the full rule selector chain ( , >, +, ~, :not()).
Value ZenitUI::Auto () noexcept
Value ZenitUI::Px (float p) noexcept
Value ZenitUI::Percent (float p) noexcept
Value ZenitUI::VW (float p) noexcept
Value ZenitUI::VH (float p) noexcept
Value ZenitUI::PW (float p) noexcept
Value ZenitUI::PH (float p) noexcept
Value ZenitUI::Num (float p) noexcept

Detailed Description

Base node types (Layout, TLayout), per-instance context (UIContext), units, input, Drag & Drop, cursors, and scrolling.

Every UI element is a std::shared_ptr<ZenitUI::Layout>. Always allocate nodes through TLayout<Derived>::create() or std::make_shared<Layout> so shared_from_this() is valid.

Key concepts:

  • Layout strategies: LayoutType::Stack, LayoutType::Vertical, LayoutType::Horizontal, and 2D LayoutType::Grid (grid-template-columns, grid-template-rows, grid-column, grid-row, column-gap, row-gap) with gap, grow, shrink, wrap (with min-width clamping), align-items, justify, margin: auto, RTL mirroring (dir: rtl), and setVisible(false) (display: none).
  • Units: compact 8-byte Value supporting px, %, vw, vh, pw, ph, auto, and calc() / min() / max() / clamp() expressions.
  • Portals & stacking: setPortal(true) renders and hit-tests above ancestor clip rects; position + z-index create stacking contexts.
  • Drag & Drop and Cursors: opt-in draggable / droppable nodes with lazy Layout::drag() handlers and deduplicated OS CursorShape switching.
  • Custom components: inherit from TLayout<Derived> and override onBuild(), computeIntrinsicSize(), onUpdate(), or renderContent().

Live examples: 02_layout_flex · 15_grid_dashboard · 09_drag_drop · 10_overlays_cursors · 13_i18n_rtl

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

◆ Align

enum class ZenitUI::Align : uint8_t
strong

Cross-axis alignment for flex items and content.

Enumerator
Auto 

Defer to the parent's alignItems.

Start 

Pack at the leading edge.

Center 

Center within the available space.

End 

Pack at the trailing edge.

Stretch 

Stretch to fill the cross axis.

◆ BlendMode

enum class ZenitUI::BlendMode
strong

Color-blending mode used by IRenderer draw calls.

Enumerator
Alpha 

Standard straight-alpha compositing (default).

Premultiplied 

Premultiplied-alpha compositing for multi-draw cached FBO layers.

Replace 

Overwrite destination RGBA directly without blending (single-quad filter passes).

◆ CursorShape

enum class ZenitUI::CursorShape : uint8_t
strong

Standard OS cursor shapes requested via ZStyle cursor: and IPlatform::setCursor.

Enumerator
Auto 

Inherit or fall back to Default.

Default 

Standard arrow cursor.

Pointer 

Pointing hand (buttons, links, interactive controls).

Text 

I-beam (editable text fields).

Move 

Four-way move cursor.

Grab 

Open hand (draggable item).

Grabbing 

Closed hand (active drag).

ResizeEW 

Horizontal resize (ew-resize, col-resize).

ResizeNS 

Vertical resize (ns-resize, row-resize).

ResizeNESW 

Diagonal NE-SW resize (nesw-resize).

ResizeNWSE 

Diagonal NW-SE resize (nwse-resize).

NotAllowed 

Forbidden / disabled action (not-allowed).

Crosshair 

Precision crosshair (crosshair).

Wait 

Busy / loading indicator (wait, progress).

◆ Feature

enum class ZenitUI::Feature
strong

Optional renderer capabilities queried via IRenderer::supports.

Backends that only implement core 2D drawing can return false for all features; ZenitUI will skip shader and off-screen layer passes gracefully. See Writing a Custom Backend for details.

Enumerator
Effects 

Supports fragment shaders (pushEffect, popEffect, setEffect*).

NestedTargets 

Supports off-screen render targets (createTarget, pushTarget, popTarget, drawTarget).

TargetSubRect 

Supports sub-rectangle blitting via drawTarget(t, src, dst, tint) for pooled targets.

◆ Justify

enum class ZenitUI::Justify : uint8_t
strong

Main-axis distribution for flex containers.

Enumerator
Start 

Pack at the leading edge.

Center 

Center the whole set.

End 

Pack at the trailing edge.

SpaceBetween 

Distribute leftover space between items.

◆ LayoutType

enum class ZenitUI::LayoutType : uint8_t
strong

Positioning strategy applied to a Layout node's direct children.

Determines how Layout::measure, Layout::arrange and the flex-flow helpers interpret their children.

See also
Layout
Enumerator
Stack 

Children overlap each other; Z-order controls paint order.

Vertical 

Children flow top-to-bottom (column flex semantics).

Horizontal 

Children flow left-to-right (row flex semantics).

Grid 

2D CSS-style grid layout (grid-template-columns / grid-template-rows).

◆ MouseButton

enum class ZenitUI::MouseButton : uint8_t
strong

Mouse buttons tracked by the input system.

Count is the sentinel.

◆ ShaderLanguage

enum class ZenitUI::ShaderLanguage
strong

Shading language consumed by an IRenderer that supports Feature::Effects.

Enumerator
None 

Backend does not execute custom shaders.

GLSL330 

OpenGL 3.3 Core GLSL (.fs / .vs, Raylib & SDL3 GL convention).

GLSL300ES 

OpenGL ES 3.0 / WebGL 2 GLSL.

SPIRV 

Precompiled Vulkan / SDL_GPU SPIR-V binaries (.frag.spv).

HLSL 

Direct3D HLSL (.hlsl).

MSL 

Apple Metal Shading Language (.metal).

WGSL 

WebGPU Shading Language (.wgsl).

◆ TextDirection

enum class ZenitUI::TextDirection : uint8_t
strong

Inline / layout writing direction for Bidi text and RTL layout mirroring (§6.2).

Enumerator
Auto 

Infer paragraph direction from first strong Bidi character (fallback LTR).

LTR 

Explicit left-to-right direction.

RTL 

Explicit right-to-left direction.

◆ UIState

enum class ZenitUI::UIState : uint8_t
strong

Interaction state computed per node and consumed by the style resolver to select pseudo-class overlays.

The state is recomputed every frame in InputController::computeNextState. Transitions between states drive the :hover, :pressed and :disabled pseudo-classes in the theme stylesheet.

See also
InputController
StyleResolver
Enumerator
Idle 

No interaction is active.

Hover 

Pointer is currently over the node.

Pressed 

A pointer button is held down on the node.

Disabled 

The node is logically disabled (config.enabled == 0).

Function Documentation

◆ applyInverseTransform()

Vec2 ZenitUI::applyInverseTransform ( const Transform2D & t,
Vec2 p )
inline

Invert a Transform2D and apply it to a point.

Used by hit-testing: given the pointer position in destination space, recover the position in the transform's local space.

Precondition
t.scale != 0 (division by scale).

◆ applyTransform()

Vec2 ZenitUI::applyTransform ( const Transform2D & t,
Vec2 p )
inline

Apply a Transform2D to a point.

Parameters
tThe transform.
pPoint in the transform's local space.
Returns
Point in the transform's destination space.