124 std::span<const uint32_t> indices,
324 std::string_view = {})
479 std::string_view = {})
487 std::string_view = {})
498 std::string_view baseDir,
499 std::string_view fileStem,
502 std::string dir(baseDir);
503 if (!dir.empty() && dir.back() !=
'/' && dir.back() !=
'\\')
510 path = dir + std::string(fileStem) +
".fs";
513 path = dir +
"es300/" + std::string(fileStem) +
".fs";
516 path = dir +
"spv/" + std::string(fileStem) +
".frag.spv";
519 path = dir +
"hlsl/" + std::string(fileStem) +
".hlsl";
522 path = dir +
"msl/" + std::string(fileStem) +
".metal";
525 path = dir +
"wgsl/" + std::string(fileStem) +
".wgsl";
544 uint32_t targetsCreated{0};
545 uint32_t targetsDestroyed{0};
546 uint32_t liveTargets{0};
547 uint32_t pushTargetCalls{0};
548 uint32_t filterPasses{0};
553 targetsDestroyed = 0;
572 static constexpr int BUCKET_SIZE = 64;
573 static constexpr int MAX_DIM = 4096;
575 static int bucketDim(
int v)
577 int rounded = ((v + BUCKET_SIZE - 1) / BUCKET_SIZE) * BUCKET_SIZE;
578 return rounded < MAX_DIM ? rounded : MAX_DIM;
583 if (w <= 0 || h <= 0)
587 const int reqW = useSubRect ? bucketDim(w) : w;
588 const int reqH = useSubRect ? bucketDim(h) : h;
591 for (
auto it = entries_.rbegin(); it != entries_.rend(); ++it)
593 if (!it->inUse && it->handle.width == reqW && it->handle.height == reqH)
596 it->lastUsedFrame = frameIndex_;
605 entries_.push_back({hnd,
true, frameIndex_});
608 stats->targetsCreated++;
609 stats->liveTargets++;
618 for (
auto it = entries_.rbegin(); it != entries_.rend(); ++it)
620 if (it->handle.id == t.id)
623 it->lastUsedFrame = frameIndex_;
631 const uint64_t grace = graceFrames > 0 ?
static_cast<uint64_t
>(graceFrames) : 1u;
632 for (
auto it = entries_.begin(); it != entries_.end();)
634 if (!it->inUse && (frameIndex_ - it->lastUsedFrame) >= grace)
639 stats->targetsDestroyed++;
640 if (stats->liveTargets > 0)
641 stats->liveTargets--;
643 it = entries_.erase(it);
655 for (
auto &e : entries_)
657 if (e.handle.valid())
662 stats->targetsDestroyed++;
663 if (stats->liveTargets > 0)
664 stats->liveTargets--;
673 size_t liveCount()
const {
return entries_.size(); }
686 uint64_t lastUsedFrame{0};
688 std::vector<Entry> entries_;
689 uint64_t frameIndex_{0};
690 uint64_t generation_{1};
709 std::weak_ptr<Layout> source;
710 std::weak_ptr<Layout> ghost;
712 Vec2 startPos{0.0f, 0.0f};
713 Vec2 currentPos{0.0f, 0.0f};
714 Vec2 grabOffset{0.0f, 0.0f};
715 Layout *hoverTarget{
nullptr};
727 UIContext() =
default;
730 UIContext(
const UIContext &) =
delete;
731 UIContext &operator=(
const UIContext &) =
delete;
732 UIContext(UIContext &&) =
delete;
733 UIContext &operator=(UIContext &&) =
delete;
748 UIContext **ownerSlot =
nullptr)
754 backendOwnerSlot_ = ownerSlot;
756 cursorInitialized_ =
false;
758 if (backendOwnerSlot_)
759 *backendOwnerSlot_ =
this;
770 targetPool.clear(*renderer, &renderStats);
776 cursorInitialized_ =
false;
778 if (backendOwnerSlot_)
780 *backendOwnerSlot_ =
nullptr;
781 backendOwnerSlot_ =
nullptr;
796 return textEngine.loadFontFromMemory(name, data, size);
826 return assets ? assets->loadTexture(name, path) :
TextureHandle{};
832 return assets ? assets->loadTextureFromMemory(name, data, size) :
TextureHandle{};
839 assets->unloadTexture(name);
850 std::string_view fsPath,
851 std::string_view vsPath = {})
858 std::string_view fsSource,
859 std::string_view vsSource = {})
869 std::string_view baseDir,
870 std::string_view fileStem)
872 if (!assets || !renderer)
874 return assets->loadEffectAsset(name, baseDir, fileStem, renderer->shaderLanguage());
881 assets->unloadEffect(name);
887 return assets ? assets->getEffect(name) :
EffectHandle{};
894 float dpiScale{1.0f};
896 ModifierState modifiers;
897 bool wheelConsumedThisFrame{
false};
898 std::array<bool, (size_t)MouseButton::Count> buttonConsumed{};
907 std::weak_ptr<Layout> focusedNode;
908 std::weak_ptr<Layout> pointerCapture;
925 uint32_t viewportGeneration{0};
931 Layout *topmostConsumer{
nullptr};
932 Layout *hoverTarget{
nullptr};
933 Layout *pressTarget{
nullptr};
934 Layout *releaseTarget{
nullptr};
943 return pressTarget && releaseTarget && pressTarget == releaseTarget;
948 float dragThreshold{5.0f};
949 std::function<std::shared_ptr<Layout>(
const DragPayload &)> dragGhostFactory;
952 bool isDragging() const noexcept {
return activeDrag.active; }
959 std::shared_ptr<Layout>
dragGhost()
const {
return dragGhost_; }
965 if (cursorInitialized_ && activeCursor == resolved)
967 activeCursor = resolved;
968 cursorInitialized_ =
true;
970 platform->setCursor(resolved);
976 const bool valid = (inputRect.width > 0.0f && inputRect.height > 0.0f);
977 if (!valid && !imeRectInitialized_)
979 imeRectInitialized_ =
true;
983 imeRectUpdatedThisFrame_ =
true;
985 const Rect norm = valid ? inputRect :
Rect{0.0f, 0.0f, 0.0f, 0.0f};
986 const float normCursor = valid ? cursorXOffset : 0.0f;
987 if (imeRectInitialized_ &&
988 std::abs(activeImeRect_.x - norm.x) < 0.5f &&
989 std::abs(activeImeRect_.y - norm.y) < 0.5f &&
990 std::abs(activeImeRect_.width - norm.width) < 0.5f &&
991 std::abs(activeImeRect_.height - norm.height) < 0.5f &&
992 std::abs(activeImeCursorOffset_ - normCursor) < 0.5f)
996 activeImeRect_ = norm;
997 activeImeCursorOffset_ = normCursor;
998 imeRectInitialized_ =
true;
1000 platform->setTextInputRect(norm, normCursor);
1006 activeImeRect_ = {0.0f, 0.0f, 0.0f, 0.0f};
1007 activeImeCursorOffset_ = 0.0f;
1008 imeRectInitialized_ =
false;
1009 imeRectUpdatedThisFrame_ =
false;
1013 std::vector<std::weak_ptr<Layout>> activePortals;
1014 std::vector<std::weak_ptr<Layout>> framePortals;
1023 std::vector<Rect> cullingClipStack;
1024 std::vector<float> targetScaleStack_;
1029 if (!cullingClipStack.empty())
1030 return cullingClipStack.front();
1031 return renderer ? renderer->getClipRect()
1041 targetScaleStack_.push_back(targetScale);
1043 renderer->pushTarget(t);
1044 renderStats.pushTargetCalls++;
1052 renderer->popTarget();
1053 if (!cullingClipStack.empty())
1054 cullingClipStack.pop_back();
1055 if (!targetScaleStack_.empty())
1056 targetScaleStack_.pop_back();
1057 textEngine.setTargetDpiScale(targetScaleStack_.empty() ? 1.0f : targetScaleStack_.back());
1073 wheelConsumedThisFrame =
false;
1074 buttonConsumed.fill(
false);
1075 topmostConsumer =
nullptr;
1076 hoverTarget =
nullptr;
1077 releaseTarget =
nullptr;
1078 cullingClipStack.clear();
1079 targetScaleStack_.clear();
1081 renderStats.beginFrame();
1082 activePortals = std::move(framePortals);
1083 framePortals.clear();
1086 Vec2 newVp = platform->viewportSize();
1089 newSafe != safeArea)
1091 viewportGeneration++;
1095 pointer = platform->pointer();
1096 modifiers = platform->modifiers();
1097 inputEvents = platform->pollInputEvents();
1098 dpiScale = platform->dpiScale();
1102 renderer->setDpiScale(dpiScale);
1111 targetPool.trim(*renderer, &renderStats);
1119 void mount(
const std::shared_ptr<Layout> &root)
1127 void unmount(
const std::shared_ptr<Layout> &root)
1159 auto sp = focusedNode.lock();
1160 return sp && sp.get() == n;
1166 void registerRoot(
Layout *root)
1170 if (std::find(attachedRoots_.begin(), attachedRoots_.end(), root) == attachedRoots_.end())
1171 attachedRoots_.push_back(root);
1174 void unregisterRoot(Layout *root)
1176 if (primaryRoot_ == root)
1177 primaryRoot_ =
nullptr;
1178 auto it = std::find(attachedRoots_.begin(), attachedRoots_.end(), root);
1179 if (it != attachedRoots_.end())
1180 attachedRoots_.erase(it);
1183 std::vector<Layout *> attachedRoots_;
1184 Layout *primaryRoot_{
nullptr};
1185 UIContext **backendOwnerSlot_{
nullptr};
1186 std::shared_ptr<ZMarkup::Registry> markupRegistry_;
1187 bool cursorInitialized_{
false};
1188 Rect activeImeRect_{0.0f, 0.0f, 0.0f, 0.0f};
1189 float activeImeCursorOffset_{0.0f};
1190 bool imeRectInitialized_{
false};
1191 bool imeRectUpdatedThisFrame_{
false};
1192 std::shared_ptr<Layout> dragGhost_;
Centralized standard library includes used throughout ZenitUI.
Small value types shared by the layout, rendering and input layers.
Post-processing filter registry and the filter execution context.
Shared zero-allocation 2D tessellation helpers for IRenderer backends.
Backend-independent text shaping (HarfBuzz), glyph rasterization (FreeType), dynamic atlas packing,...
Global stylesheet storage and rule matching.
Small enumerations describing layout strategy and interaction state.
Per-context map from CSS filter name to FilterDef.
Definition FilterRegistry.hpp:130
Abstract name-based lookup and runtime lifecycle for textures and shaders.
Definition UIContext.hpp:449
virtual TextureHandle loadTexture(std::string_view, std::string_view)
Optional runtime hook to load a 2D texture from disk under name.
Definition UIContext.hpp:460
virtual void unloadEffect(std::string_view)
Optional runtime hook to unload a shader effect by logical name.
Definition UIContext.hpp:535
virtual EffectHandle loadEffect(std::string_view, std::string_view, std::string_view={})
Optional runtime hook to load a fragment (and optional vertex) shader from disk under name.
Definition UIContext.hpp:477
virtual TextureHandle getTexture(std::string_view name)=0
Look up a loaded 2D texture by logical name; returns {0} if not found.
virtual EffectHandle getEffect(std::string_view name)=0
Look up a loaded shader effect by logical name; returns {0} if not found.
EffectHandle loadEffectAsset(std::string_view name, std::string_view baseDir, std::string_view fileStem, ShaderLanguage lang)
Load a shader effect by stem fileStem under baseDir, resolving the file extension from lang (e....
Definition UIContext.hpp:497
virtual EffectHandle loadEffectFromMemory(std::string_view, std::string_view, std::string_view={})
Optional runtime hook to load a shader effect from in-memory source strings.
Definition UIContext.hpp:485
virtual void unloadTexture(std::string_view)
Optional runtime hook to unload a texture by logical name.
Definition UIContext.hpp:474
virtual TextureHandle loadTextureFromMemory(std::string_view, const void *, size_t)
Optional runtime hook to load a 2D texture from encoded image bytes in memory.
Definition UIContext.hpp:466
Abstract 2D rendering backend.
Definition UIContext.hpp:106
virtual void popEffect()=0
Pop the active shader effect and restore the previous one (if any).
virtual void popTarget()=0
Finish drawing into the active target and restore the previous target (or main framebuffer) and stack...
virtual TextureHandle createTexture(int, int, const uint8_t *=nullptr)
Allocate a dynamic RGBA8 2D texture of w x h pixels.
Definition UIContext.hpp:217
virtual void strokeRoundedRect(Rect r, float radiusPx, float thickness, Color c)
Stroke a rounded border strictly inside r (CSS border-box).
Definition UIContext.hpp:174
virtual void fillCircle(Vec2 center, float radius, Color c)
Fill a circle centered at center with the given logical radius.
Definition UIContext.hpp:148
virtual void endFrame()=0
Called at the end of Layout::renderFrame after all draw calls and portals have rendered.
virtual void drawTarget(TargetHandle t, Rect dst, Color tint)=0
Composite the entire render target t into logical destination rect dst, multiplied by tint.
virtual bool supports(Feature f) const =0
Query whether this backend implements an optional Feature.
virtual bool inTarget() const =0
Return true while a pushTarget is active without a matching popTarget.
virtual Rect getClipRect() const =0
Return the active screen-space clip rectangle in logical pixels (used for culling).
virtual void clearTarget(TargetHandle t, Color c)=0
Clear render target t to solid color c.
virtual EffectHandle createEffect(std::string_view, std::string_view={})
Compile and allocate a shader effect from GLSL/backend source strings.
Definition UIContext.hpp:323
virtual void drawTarget(TargetHandle t, Rect, Rect dst, Color tint)
Composite sub-rectangle src (target pixels) of t into logical rect dst.
Definition UIContext.hpp:302
virtual void fillBorder(Rect r, EdgeInsets sides, Color c)
Draw a rectangular ring with per-edge widths in a single indexed draw call.
Definition UIContext.hpp:184
virtual void destroyTarget(TargetHandle t)=0
Release a render target previously allocated by createTarget.
virtual void pushEffect(EffectHandle e)=0
Bind shader effect e and push it onto the effect stack (used when Feature::Effects is supported).
virtual void drawTexture(TextureHandle t, Rect src, Rect dst, Color tint)
Draw sub-rectangle src (texture pixels) of texture t into logical rect dst, multiplied by tint.
Definition UIContext.hpp:196
virtual void destroyEffect(EffectHandle)
Release a shader effect previously created by createEffect.
Definition UIContext.hpp:330
virtual ShaderLanguage shaderLanguage() const
Return the shading language expected by IAssetProvider::loadEffect on this renderer.
Definition UIContext.hpp:361
virtual void beginFrame()=0
Called at the start of Layout::renderFrame before any draw calls (e.g.
virtual void drawNineSlice(TextureHandle t, NineSlice s, Rect dst, Color tint)
Draw texture t stretched into dst using the 9-slice insets s (fixed corners, stretched edges/center).
Definition UIContext.hpp:204
virtual void pushTransform(const Transform2D &t)=0
Push a 2D pivot-based transform onto the transform stack.
virtual void destroyTexture(TextureHandle)
Release a dynamic texture previously created by createTexture.
Definition UIContext.hpp:230
virtual void setEffectFloat(EffectHandle e, const char *name, float value)=0
Set a float uniform named name on effect e.
virtual void pushClip(Rect r)=0
Push a local-space clip rectangle r, intersecting it with the current clip.
virtual void updateTexture(TextureHandle, Rect, const uint8_t *)
Upload tightly-packed RGBA8 pixels into sub-rectangle region of texture t.
Definition UIContext.hpp:227
virtual void setEffectVec4f(EffectHandle e, const char *name, Vec4 value)=0
Set a vec4 uniform named name on effect e.
virtual void setEffectVec4(EffectHandle e, const char *name, Color value)=0
Set a normalized RGBA vec4 uniform (0..1 per channel) named name on effect e.
virtual void strokeRect(Rect r, float thickness, Color c)
Stroke a rectangular border strictly inside r (CSS border-box).
Definition UIContext.hpp:161
virtual void fillRect(Rect r, Color c)
Fill an axis-aligned rectangle r with solid color c.
Definition UIContext.hpp:132
virtual void setBlendMode(BlendMode)
Switch the active color-blending mode.
Definition UIContext.hpp:256
virtual void pushTarget(TargetHandle t)=0
Redirect subsequent draw calls to target t and clear it to transparent black.
virtual void fillRoundedRect(Rect r, float radiusPx, Color c)
Fill a rectangle r with corner radius radiusPx (clamped to half the shorter side).
Definition UIContext.hpp:140
virtual void setDpiScale(float scale)=0
Notify the renderer of the active logical-to-physical DPI scale factor for the current frame.
virtual TargetHandle createTarget(int w, int h)=0
Allocate an off-screen RGBA render target of w x h pixels (used when Feature::NestedTargets is suppor...
virtual void setEffectVec2(EffectHandle e, const char *name, Vec2 value)=0
Set a vec2 uniform named name on effect e.
virtual void drawGeometry(std::span< const Vertex2D > vertices, std::span< const uint32_t > indices, TextureHandle tex={})=0
Draw an indexed triangle list in logical screen coordinates.
virtual void setEffectVec3(EffectHandle e, const char *name, Vec3 value)=0
Set a vec3 uniform named name on effect e.
virtual void popClip()=0
Pop the current clip rectangle and restore the previous scissor region.
virtual void popTransform()=0
Pop the most recently pushed transform from the stack.
The base node type: tree, style, layout, input, scroll, render.
Definition Layout.hpp:154
Shared, bucket-sized render-target pool owned by UIContext (§4.9 Step c).
Definition UIContext.hpp:570
uint64_t generation() const
Monotonic generation counter incremented whenever clear() destroys all targets.
Definition UIContext.hpp:676
uint64_t frameIndex() const
Current frame counter advanced once per trim() call.
Definition UIContext.hpp:679
Per-context font store, HarfBuzz shaper, FreeType glyph atlas, and layout engine.
Definition TextEngine.hpp:142
Per-context stylesheet: rules, keyframes, and root style.
Definition Theme.hpp:164
Tag → factory map plus the prefab table (either per-UIContext or standalone/global).
Definition ZMarkup.hpp:215
NineSliceMesh buildNineSlice(TextureHandle t, NineSlice s, Rect dst, Color tint)
Build a 9-slice mesh (up to 9 quads, single indexed draw call).
Definition Geometry2D.hpp:185
RectStrokeMesh buildRectStroke(Rect r, float thickness, Color c)
Build a CSS border-box rectangular stroke strictly inside r without corner overdraw.
Definition Geometry2D.hpp:240
RoundedFillMesh buildRoundedRectFill(Rect r, float radiusPx, Color c)
Build a filled rounded rectangle (fast-paths to a 4-vertex quad when radiusPx <= 0....
Definition Geometry2D.hpp:323
BorderMesh buildBorder(Rect r, EdgeInsets sides, Color c)
Build per-edge rectangular borders in a single indexed draw call.
Definition Geometry2D.hpp:282
CircleMesh buildCircle(Vec2 center, float radius, Color c)
Build a filled circle with adaptive segment count (16..kCircleMaxSegments).
Definition Geometry2D.hpp:417
QuadMesh buildQuad(Rect r, Color c)
Build a solid-color axis-aligned quad.
Definition Geometry2D.hpp:146
RoundedStrokeMesh buildRoundedRectStroke(Rect r, float radiusPx, float thickness, Color c)
Build a CSS border-box rounded stroke mesh strictly inside r.
Definition Geometry2D.hpp:379
QuadMesh buildTexturedQuad(TextureHandle t, Rect src, Rect dst, Color tint)
Build a textured quad mapping pixel sub-rect src onto logical dst.
Definition Geometry2D.hpp:162
ShaderLanguage
Shading language consumed by an IRenderer that supports Feature::Effects.
Definition UIContext.hpp:73
MouseButton
Mouse buttons tracked by the input system.
Definition CoreTypes.hpp:361
BlendMode
Color-blending mode used by IRenderer draw calls.
Definition UIContext.hpp:88
CursorShape
Standard OS cursor shapes requested via ZStyle cursor: and IPlatform::setCursor.
Definition UIEnums.hpp:61
Feature
Optional renderer capabilities queried via IRenderer::supports.
Definition UIContext.hpp:62
@ MSL
Apple Metal Shading Language (.metal).
Definition UIContext.hpp:79
@ WGSL
WebGPU Shading Language (.wgsl).
Definition UIContext.hpp:80
@ SPIRV
Precompiled Vulkan / SDL_GPU SPIR-V binaries (.frag.spv).
Definition UIContext.hpp:77
@ None
Backend does not execute custom shaders.
Definition UIContext.hpp:74
@ GLSL300ES
OpenGL ES 3.0 / WebGL 2 GLSL.
Definition UIContext.hpp:76
@ GLSL330
OpenGL 3.3 Core GLSL (.fs / .vs, Raylib & SDL3 GL convention).
Definition UIContext.hpp:75
@ HLSL
Direct3D HLSL (.hlsl).
Definition UIContext.hpp:78
@ Replace
Overwrite destination RGBA directly without blending (single-quad filter passes).
Definition UIContext.hpp:91
@ Premultiplied
Premultiplied-alpha compositing for multi-draw cached FBO layers.
Definition UIContext.hpp:90
@ Alpha
Standard straight-alpha compositing (default).
Definition UIContext.hpp:89
@ Auto
Inherit or fall back to Default.
Definition UIEnums.hpp:62
@ Default
Standard arrow cursor.
Definition UIEnums.hpp:63
@ NestedTargets
Supports off-screen render targets (createTarget, pushTarget, popTarget, drawTarget).
Definition UIContext.hpp:64
@ TargetSubRect
Supports sub-rectangle blitting via drawTarget(t, src, dst, tint) for pooled targets.
Definition UIContext.hpp:65
@ Effects
Supports fragment shaders (pushEffect, popEffect, setEffect*).
Definition UIContext.hpp:63
Per-context state tracking a pending or active drag operation.
Definition UIContext.hpp:708
8-bit-per-channel RGBA color, non-premultiplied.
Definition CoreTypes.hpp:78
Opaque user payload carried during an active drag-and-drop operation.
Definition UIContext.hpp:698
std::string typeTag
User-defined discriminator (e.g. "list-item", "card", "file").
Definition UIContext.hpp:700
Four-sided edge inset (used for padding, margin, borders).
Definition CoreTypes.hpp:62
Opaque handle to a shader/effect owned by the asset provider.
Definition CoreTypes.hpp:142
Opaque handle to a font loaded by TextEngine.
Definition CoreTypes.hpp:135
Keyboard modifier snapshot.
Definition CoreTypes.hpp:390
Nine-slice inset values for scalable textures.
Definition CoreTypes.hpp:163
Pointer position, wheel delta, and per-button state for one frame.
Definition CoreTypes.hpp:378
Axis-aligned rectangle in screen coordinates.
Definition CoreTypes.hpp:46
Per-frame and live render-target / filter counters (Proposal 9, Step 0).
Definition UIContext.hpp:543
Opaque handle to an off-screen render target.
Definition CoreTypes.hpp:155
Opaque handle to a GPU/software texture owned by the asset provider.
Definition CoreTypes.hpp:127
bool wasConsumed(MouseButton b) const
true if b was already consumed this frame.
Definition UIContext.hpp:904
void setDefaultFont(FontHandle h)
Set the fallback font used when a node specifies no font or an unknown font name.
Definition UIContext.hpp:812
void mount(Layout &root)
Attach a root Layout subtree to this context and set it as the primary root.
void detachBackend()
Flush pooled render targets while the renderer is still valid and clear backend pointers.
Definition UIContext.hpp:765
std::shared_ptr< Layout > dragGhost() const
Return the currently active drag ghost node, or nullptr if none.
Definition UIContext.hpp:959
FilterRegistry filters
Per-context post-processing filter definitions (preloaded with builtins).
Definition UIContext.hpp:910
EffectHandle loadEffect(std::string_view name, std::string_view fsPath, std::string_view vsPath={})
Load a fragment (and optional vertex) shader from disk under logical name.
Definition UIContext.hpp:849
void requestFocus(std::shared_ptr< Layout > n)
Set n as the focused node; null clears focus.
void unmount()
Detach the currently mounted primary root, if any.
void consumeClick(MouseButton b)
Mark b as consumed; subsequent handlers in the same frame will skip it.
Definition UIContext.hpp:902
TextureHandle loadTexture(std::string_view name, std::string_view path)
Load a 2D texture from disk under logical name.
Definition UIContext.hpp:824
bool hasPendingDrag() const noexcept
true while a press on a draggable node is waiting to cross dragThreshold.
Definition UIContext.hpp:954
FontHandle defaultFont() const
Return the current default font handle ({0} if none).
Definition UIContext.hpp:818
void renderFrame()
Render the mounted primary root (beginFrame, draw, endFrame).
TextureHandle loadTextureFromMemory(std::string_view name, const void *data, size_t size)
Load a 2D texture from encoded image bytes (PNG/JPG/BMP/...) under logical name.
Definition UIContext.hpp:830
void unmount(Layout &root)
Detach a previously mounted root Layout subtree from this context.
TextureHandle getTexture(std::string_view name) const
Look up a loaded 2D texture by logical name ({0} if not found).
Definition UIContext.hpp:843
void runFrame(float dt)
Run one full update/measure/arrange frame on the mounted primary root.
void unloadFont(std::string_view name)
Unload a font by logical name.
Definition UIContext.hpp:800
void releaseFocus()
Clear focus.
Definition UIContext.hpp:1155
Rect getCullingClip() const
Active screen-space clip rect used by Layout::draw() for off-screen culling.
Definition UIContext.hpp:1027
void clearDragState()
Reset all pending/active drag state and destroy any active drag ghost without invoking callbacks.
void invalidateStyles()
Force style-cache invalidation across the tree.
Definition UIContext.hpp:928
FontHandle getFont(std::string_view name) const
Look up a loaded font by logical name ({0} if not found).
Definition UIContext.hpp:806
void applyCursor(CursorShape shape)
Apply shape to the active platform backend, deduplicating unchanged requests.
Definition UIContext.hpp:962
void unloadEffect(std::string_view name)
Unload a shader effect by logical name.
Definition UIContext.hpp:878
void endFrame()
End-of-frame housekeeping (trims idle pooled render targets).
Definition UIContext.hpp:1108
bool isValidClick() const
true if press and release targets agree (a valid click).
Definition UIContext.hpp:941
void attachBackend(IRenderer *r, IPlatform *p, IAssetProvider *a, UIContext **ownerSlot=nullptr)
Attach renderer, platform, and asset backends to this context.
Definition UIContext.hpp:747
void unloadTexture(std::string_view name)
Unload a 2D texture by logical name.
Definition UIContext.hpp:836
FontHandle loadFont(std::string_view name, std::string_view path)
Load a TTF/OTF font from disk under logical name.
Definition UIContext.hpp:788
TextEngine textEngine
Per-context FreeType/HarfBuzz shaper, glyph atlas, and layout cache.
Definition UIContext.hpp:912
void resetImeRectState()
Clear cached IME rect state (e.g.
Definition UIContext.hpp:1004
void detachAllRoots()
Detach every root currently attached to this context.
FontHandle loadFontFromMemory(std::string_view name, const void *data, size_t size)
Load a TTF/OTF font from memory under logical name (copies bytes).
Definition UIContext.hpp:794
Vec2 viewport
Current logical viewport dimensions.
Definition UIContext.hpp:899
ZMarkup::Registry & markupRegistry()
Return this context's isolated ZMarkup::Registry, lazily initialized with built-in widgets.
void runFrame(Layout &root, float dt)
Run one full update/measure/arrange frame on root using this context.
Theme theme
Per-context stylesheet (rules, keyframes, and :root style).
Definition UIContext.hpp:911
const ZMarkup::Registry * markupRegistryPtr() const noexcept
Return this context's ZMarkup::Registry if initialized, or nullptr without allocating.
Definition UIContext.hpp:923
void renderFrame(Layout &root)
Render root (beginFrame, draw, endFrame) using this context.
bool isDragging() const noexcept
true while a drag gesture has crossed dragThreshold and is active.
Definition UIContext.hpp:952
void setTextInputRect(Rect inputRect, float cursorXOffset=0.0f)
Forward the active text-input IME rect to the platform, deduplicating unchanged rects.
Definition UIContext.hpp:974
EffectHandle getEffect(std::string_view name) const
Look up a loaded shader effect by logical name ({0} if not found).
Definition UIContext.hpp:885
void beginFrame(float delta_time)
Advance the frame: pull platform state and reset one-shot flags.
Definition UIContext.hpp:1069
EffectHandle loadEffectFromMemory(std::string_view name, std::string_view fsSource, std::string_view vsSource={})
Load a shader effect from in-memory source strings under logical name.
Definition UIContext.hpp:857
EffectHandle loadEffectAsset(std::string_view name, std::string_view baseDir, std::string_view fileStem)
Load a shader effect by stem fileStem under baseDir, automatically resolving the file extension for t...
Definition UIContext.hpp:868
bool hasFocus(const Layout *n) const
true if n is the current focused node.
Definition UIContext.hpp:1157
void popLayerTarget()
Pop an off-screen target pushed via pushLayerTarget.
Definition UIContext.hpp:1048
void pushLayerTarget(TargetHandle t, float targetScale=1.0f)
Push an off-screen target while preserving the root screen-space culling clip.
Definition UIContext.hpp:1036
Layout * mountedRoot() const
Return the primary root set by mount(), or nullptr if none.
Definition UIContext.hpp:1137
bool isPressTarget(const Layout *n) const
true if n is the current press target.
Definition UIContext.hpp:939
2D vector with component-wise arithmetic.
Definition CoreTypes.hpp:25
3D vector.
Definition CoreTypes.hpp:34
4D vector with an implicit w = 1 default.
Definition CoreTypes.hpp:40