25namespace ZenitUI::ZMarkup
45 class VirtualList :
public TLayout<VirtualList, ScrollView>
48 VirtualList(std::string prefabName,
int itemCount,
float rowHeight = 32.0f);
49 ~VirtualList()
override;
57 static std::shared_ptr<VirtualList>
create(
58 std::string prefabName,
60 float rowHeight = 32.0f);
75 const std::string &
getPrefab() const noexcept {
return prefabName_; }
136 void arrange(
Rect space)
override;
137 Vec2 computeIntrinsicSize(
float availW,
float availH)
override;
142 std::shared_ptr<Layout> node;
143 std::shared_ptr<ZMarkup::BuildContext> buildCtx;
149 void bindSlot(RowSlot &slot,
int index);
150 void clearAllSlots();
152 std::string prefabName_;
154 float rowHeight_{32.0f};
156 bool needsRebindAll_{
false};
157 const ZMarkup::Registry *explicitRegistry_{
nullptr};
159 std::vector<RowSlot> active_;
160 std::deque<RowSlot> freePool_;
Centralized standard library includes used throughout ZenitUI.
The node class: tree structure, layout pass, style resolution, input dispatch, render orchestration,...
The base node type: tree, style, layout, input, scroll, render.
Definition Layout.hpp:154
TLayout(Args &&...args)
Definition Layout.hpp:1401
void onBuild() override
Hook: called once after create() finishes constructing the object.
std::function< void(int index, Layout *row)> onBindRow
Called whenever a row is (re)bound to index.
Definition VirtualList.hpp:117
size_t activeRowCount() const noexcept
Number of currently active (mounted) row nodes.
Definition VirtualList.hpp:103
void setBufferRows(int rows)
Set number of overscan rows buffered above and below the viewport (default: 2).
void setRegistry(const ZMarkup::Registry *reg) noexcept
Optionally pin an explicit ZMarkup::Registry for prefab instantiation.
Definition VirtualList.hpp:88
int getLastVisibleRow() const
Last visible row index (inclusive), or -1 if empty or not yet arranged.
void scrollToRow(int index)
Scroll so that index sits at the top of the viewport (clamped to valid range).
std::function< void(int index, ZMarkup::UINode &row)> onBindRowNode
Optional ZMarkup::UINode counterpart to onBindRow for @ref-based helpers.
Definition VirtualList.hpp:127
void refresh()
Force re-binding of all currently active rows on the next arrange pass.
int getItemCount() const noexcept
Current item count.
Definition VirtualList.hpp:65
void setPrefab(std::string prefabName)
Replace the prefab tag name, clearing any pooled/active rows.
float getRowHeight() const noexcept
Current fixed row height in pixels.
Definition VirtualList.hpp:70
std::function< void(ZMarkup::UINode &row)> onRowNodeCreated
Optional ZMarkup::UINode counterpart to onRowCreated.
Definition VirtualList.hpp:132
void removeAllChildren() override
Clear active rows, the recycle pool, and base children.
static std::shared_ptr< VirtualList > create(std::string prefabName, int itemCount, float rowHeight=32.0f)
Create a VirtualList backed by a registered ZMarkup prefab.
std::function< void(Layout *row)> onRowCreated
Called once per pooled row immediately after prefab instantiation.
Definition VirtualList.hpp:122
void setItemCount(int count)
Set total item count (clamped to >= 0).
void setRowHeight(float px)
Set fixed row height in pixels (clamped to >= 1.0f).
const std::string & getPrefab() const noexcept
Current prefab tag name.
Definition VirtualList.hpp:75
int getFirstVisibleRow() const
First visible row index, or -1 if empty or not yet arranged.
size_t pooledRowCount() const noexcept
Number of parked row nodes waiting in the FIFO recycle pool.
Definition VirtualList.hpp:106
int getBufferRows() const noexcept
Current overscan buffer size in rows.
Definition VirtualList.hpp:80
Tag → factory map plus the prefab table (either per-UIContext or standalone/global).
Definition ZMarkup.hpp:215
Root handle returned by build / instantiate: root node + build context + wiring helpers.
Definition ZMarkup.hpp:331
Axis-aligned rectangle in screen coordinates.
Definition CoreTypes.hpp:46
2D vector with component-wise arithmetic.
Definition CoreTypes.hpp:25
Per-build accumulator for #id, @ref, and runtime structural bindings.
Definition ZMarkup.hpp:166