|
ZenitUI
Retained-mode C++20 UI framework
|
A fixed-height virtualized list that recycles ZMarkup prefab rows. More...
#include <VirtualList.hpp>
Public Member Functions | |
| VirtualList (std::string prefabName, int itemCount, float rowHeight=32.0f) | |
| void | setItemCount (int count) |
| Set total item count (clamped to >= 0). | |
| int | getItemCount () const noexcept |
| Current item count. | |
| void | setRowHeight (float px) |
| Set fixed row height in pixels (clamped to >= 1.0f). | |
| float | getRowHeight () const noexcept |
| Current fixed row height in pixels. | |
| void | setPrefab (std::string prefabName) |
| Replace the prefab tag name, clearing any pooled/active rows. | |
| const std::string & | getPrefab () const noexcept |
| Current prefab tag name. | |
| void | setBufferRows (int rows) |
| Set number of overscan rows buffered above and below the viewport (default: 2). | |
| int | getBufferRows () const noexcept |
| Current overscan buffer size in rows. | |
| void | setRegistry (const ZMarkup::Registry *reg) noexcept |
| Optionally pin an explicit ZMarkup::Registry for prefab instantiation. | |
| void | refresh () |
| Force re-binding of all currently active rows on the next arrange pass. | |
| void | scrollToRow (int index) |
Scroll so that index sits at the top of the viewport (clamped to valid range). | |
| int | getFirstVisibleRow () const |
| First visible row index, or -1 if empty or not yet arranged. | |
| int | getLastVisibleRow () const |
| Last visible row index (inclusive), or -1 if empty or not yet arranged. | |
| size_t | activeRowCount () const noexcept |
| Number of currently active (mounted) row nodes. | |
| size_t | pooledRowCount () const noexcept |
| Number of parked row nodes waiting in the FIFO recycle pool. | |
| void | removeAllChildren () override |
| Clear active rows, the recycle pool, and base children. | |
| Public Member Functions inherited from ZenitUI::TLayout< VirtualList, ScrollView > | |
| TLayout (Args &&...args) | |
Forward constructor arguments to Base. | |
| std::shared_ptr< VirtualList > | cls (const std::string &name) |
| Fluent addClass; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< VirtualList > | id (const std::string &node_id) |
| Fluent setId; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< VirtualList > | withRef (const std::string &r) |
| Fluent setRef; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< VirtualList > | size (Value w, Value h) |
| Fluent setSize; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< VirtualList > | passThrough (bool p=true) |
| Fluent setPassThrough; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< VirtualList > | with (std::shared_ptr< Layout > c) |
| Fluent addChild; returns typed shared_ptr<Derived>. | |
| std::shared_ptr< VirtualList > | self () |
| Return shared_from_this() statically cast to Derived. | |
Static Public Member Functions | |
| static std::shared_ptr< VirtualList > | create (std::string prefabName, int itemCount, float rowHeight=32.0f) |
| Create a VirtualList backed by a registered ZMarkup prefab. | |
| Static Public Member Functions inherited from ZenitUI::TLayout< VirtualList, ScrollView > | |
| static std::shared_ptr< VirtualList > | create (Args &&...args) |
| Construct a shared_ptr<Derived> and call onBuild(). | |
Public Attributes | |
| std::function< void(int index, Layout *row)> | onBindRow |
Called whenever a row is (re)bound to index. | |
| std::function< void(Layout *row)> | onRowCreated |
| Called once per pooled row immediately after prefab instantiation. | |
| std::function< void(int index, ZMarkup::UINode &row)> | onBindRowNode |
| Optional ZMarkup::UINode counterpart to onBindRow for @ref-based helpers. | |
| std::function< void(ZMarkup::UINode &row)> | onRowNodeCreated |
| Optional ZMarkup::UINode counterpart to onRowCreated. | |
Protected Member Functions | |
| void | onBuild () override |
| Hook: called once after create() finishes constructing the object. | |
| void | arrange (Rect space) override |
| Vec2 | computeIntrinsicSize (float availW, float availH) override |
A fixed-height virtualized list that recycles ZMarkup prefab rows.
Style tag: "VirtualList". ZMarkup tag: VirtualList prefab="RowPrefab" items="10000" row-height="24".
|
static |
Create a VirtualList backed by a registered ZMarkup prefab.
| prefabName | Name of the prefab registered in the active UIContext or global ZMarkup::Registry. |
| itemCount | Total number of items in the model (clamped to >= 0). |
| rowHeight | Fixed row height in logical pixels (clamped to >= 1.0f). |
|
overrideprotectedvirtual |
Hook: called once after create() finishes constructing the object.
Reimplemented from ZenitUI::TLayout< VirtualList, ScrollView >.
|
inlinenoexcept |
Optionally pin an explicit ZMarkup::Registry for prefab instantiation.
When nullptr (default), VirtualList checks context()->markupRegistryPtr() first and falls back to ZMarkup::getGlobalRegistry().
| std::function<void(int index, Layout *row)> ZenitUI::UI::VirtualList::onBindRow |
Called whenever a row is (re)bound to index.
Runs before the row is measured and arranged. Mutate text, classes, or callbacks here; do not add or remove structural children on row.