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

The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration, and scroll handling. More...

#include "Common.hpp"
#include "Style.hpp"
#include "Theme.hpp"
#include "UIContext.hpp"
#include "AnimPrimitives.hpp"
#include "Logger.hpp"
#include "ScrollState.hpp"
#include "StyleResolver.hpp"
#include "AnimationPlayer.hpp"
#include "InputController.hpp"
#include "ScrollController.hpp"
#include "UIEnums.hpp"
#include "Media.hpp"
#include "SmallVector.hpp"

Go to the source code of this file.

Classes

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...
struct  ZenitUI::Layout::ResolvedBgTexture
 Result of resolveBgTexture: a texture plus its nine-slice insets. More...
class  ZenitUI::TLayout< Derived, Base >
 CRTP base for components that want fluent builders and a static create() factory. More...

Functions

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()).

Detailed Description

The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration, and scroll handling.

Layout is the single node type in ZenitUI. There is no separate "widget" base class: every visual element is a Layout subclass (either directly, via TLayout<Derived>, or by composition). The node owns or co-owns:

  • Tree structure: parent, children, dirty flags, removal requests.
  • Style subsystem (as style_): resolution, transitions, caching.
  • Animation subsystem (as anim_): imperative and CSS animations.
  • Input subsystem (as input_): hover/press/focus dispatch.
  • Scroll subsystem (as scroll_): offset, inertia, scrollbars.

The public API mirrors the four-pass frame cycle, each function called from Layout::runFrame:

  1. update — input state, style transitions, animations, culling.
  2. measure — compute intrinsic sizes bottom-up.
  3. arrange — assign screen rects top-down.
  4. draw — render with style overlays and clip/effect stacks.

Subclasses hook in via the virtuals (computeIntrinsicSize, renderContent, renderChrome, onLayout, onUpdate, …) rather than by overriding the four main passes, except in rare cases (VirtualView, Canvas, Popup, Tooltip override arrange or draw).

Note
enable_shared_from_this is required: addChild checks weak_from_this() and warns if a node is stack-allocated. Always create nodes through TLayout<Derived>::create or std::make_shared<Layout>.