58 using ItemFactory = std::function<std::shared_ptr<Layout>(
int index)>;
83 static std::shared_ptr<VirtualView>
create(
84 std::function<std::shared_ptr<Layout>()> factory,
90 itemFactory = std::move(factory);
92 cumulativeHeights.clear();
93 lastMeasuredWidth = -1.0f;
144 Vec2 measure(
float parent_w,
float parent_h)
override;
157 void arrange(
Rect space)
override;
158 Vec2 computeIntrinsicSize(
float availW,
float availH)
override;
163 float uniformHeight{0.0f};
164 float lastParentW_{0.0f};
165 float lastParentH_{0.0f};
167 std::vector<float> cumulativeHeights;
168 float lastMeasuredWidth{-1.0f};
173 std::shared_ptr<Layout> node;
175 float naturalWidth{0.0f};
176 float appliedWidth{-1.0f};
178 std::vector<Entry> materialized;
180 void rebuildCumulative(
float availW);
181 int itemAtY(
float y)
const;
182 bool updateMaterialization();
183 bool hasMaterialized(
int index)
const;
184 bool addMaterialized(
int index);
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
static std::shared_ptr< VirtualView > create(ItemFactory factory, int count)
Construct with an indexed factory.
void setItemFactory(ItemFactory factory)
Replace the item factory (useful when instantiating VirtualView from ZMarkup).
Definition VirtualView.hpp:88
VirtualView(ItemFactory factory, int itemCount)
Construct with a factory and an item count.
std::function< std::shared_ptr< Layout >(int index)> ItemFactory
Signature for an item factory: index → node.
Definition VirtualView.hpp:58
void onBuild() override
Hook: called once after create() finishes constructing the object.
int getFirstVisibleItem() const
First item whose range overlaps [scrollY, scrollY+height).
void setItemCount(int count)
Replace the item count.
void removeAllChildren() override
Clear the materialized children and the materialization bookkeeping.
float getUniformHeight() const noexcept
Return the uniform height, or 0 if variable heights are being measured.
Definition VirtualView.hpp:111
void setUniformHeight(float px)
Set a uniform height for all items.
int getItemCount() const noexcept
Number of items in the list.
Definition VirtualView.hpp:97
static std::shared_ptr< VirtualView > create(std::function< std::shared_ptr< Layout >()> factory, int count)
Construct with an index-agnostic factory.
int getLastVisibleItem() const
Last visible item, inclusive.
void scrollToItem(int index)
Scroll so that the given item is the first visible.
std::function< void(Layout *, int)> onItemCreated
Fired each time an item node is materialized.
Definition VirtualView.hpp:153
Axis-aligned rectangle in screen coordinates.
Definition CoreTypes.hpp:46
2D vector with component-wise arithmetic.
Definition CoreTypes.hpp:25