Skip to content

Commit c18346f

Browse files
committed
Use default item instantiation method for lists with fixed item sizes
1 parent abe1e29 commit c18346f

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/widget/list_select.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,15 @@ impl<M, D, S> ListSelect<M, D, S>
247247
/// flowing. When a `List` is constructed with this method, all items will have a fixed, equal
248248
/// length.
249249
pub fn item_size(self, length: Scalar) -> ListSelect<M, D, widget::list::Fixed> {
250-
let ListSelect { common, num_items, mode, direction, style, item_instantiation, .. } = self;
250+
let ListSelect { common, num_items, mode, direction, style, .. } = self;
251251
ListSelect {
252252
common: common,
253253
num_items: num_items,
254254
mode: mode,
255255
direction: direction,
256256
item_size: widget::list::Fixed { length: length },
257257
style: style,
258-
item_instantiation: item_instantiation,
258+
item_instantiation: widget::list::ItemInstantiation::OnlyVisible,
259259
}
260260
}
261261
}
@@ -315,6 +315,10 @@ impl<M, D> ListSelect<M, D, widget::list::Fixed> {
315315
/// Indicates that an `Item` should be instatiated for every element in the list, regardless of
316316
/// whether or not the `Item` would be visible.
317317
///
318+
/// This is the default (and only) behaviour for `List`s with dynamic item sizes. This is
319+
/// because a `List` cannot know the total length of its combined items in advanced when each
320+
/// item is dynamically sized and their size is not given until they are set.
321+
///
318322
/// Note: This may cause significantly heavier CPU load for lists containing many items (100+).
319323
/// We only recommend using this when absolutely necessary as large lists may cause unnecessary
320324
/// bloating within the widget graph, and in turn result in greater traversal times.
@@ -327,7 +331,7 @@ impl<M, D> ListSelect<M, D, widget::list::Fixed> {
327331
/// avoid bloating the widget graph with unnecessary nodes and in turn keep traversal times to
328332
/// a minimum.
329333
///
330-
/// This is the default `List` behaviour.
334+
/// This is the default behaviour for `ListSelect`s with fixed item sizes.
331335
pub fn instantiate_only_visible_items(mut self) -> Self {
332336
self.item_instantiation = widget::list::ItemInstantiation::OnlyVisible;
333337
self

0 commit comments

Comments
 (0)