Pass a RenderContext to UniformList
In some cases, we need to render during layout. Previously, we were rendering with a LayoutContext in some cases, but this commit adds the ability to retrieve a render context with a given handle and we use that feature in UniformList. Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
d69776585d
commit
2ea085b178
8 changed files with 193 additions and 135 deletions
|
@ -123,7 +123,6 @@ impl View for Select {
|
|||
.boxed(),
|
||||
);
|
||||
if self.is_open {
|
||||
let handle = self.handle.clone();
|
||||
result.add_child(
|
||||
Overlay::new(
|
||||
Container::new(
|
||||
|
@ -131,9 +130,8 @@ impl View for Select {
|
|||
UniformList::new(
|
||||
self.list_state.clone(),
|
||||
self.item_count,
|
||||
move |mut range, items, cx| {
|
||||
let handle = handle.upgrade(cx).unwrap();
|
||||
let this = handle.read(cx);
|
||||
cx,
|
||||
move |this, mut range, items, cx| {
|
||||
let selected_item_ix = this.selected_item_ix;
|
||||
range.end = range.end.min(this.item_count);
|
||||
items.extend(range.map(|ix| {
|
||||
|
@ -141,7 +139,7 @@ impl View for Select {
|
|||
ix,
|
||||
cx,
|
||||
|mouse_state, cx| {
|
||||
(handle.read(cx).render_item)(
|
||||
(this.render_item)(
|
||||
ix,
|
||||
if ix == selected_item_ix {
|
||||
ItemType::Selected
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue