Use group overlay for containers w/ children
This commit is contained in:
parent
3c866c15aa
commit
b2a3a85acb
2 changed files with 13 additions and 8 deletions
|
|
@ -91,7 +91,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
/// Obtains the first overlay [`Element`] found in the given children.
|
||||
/// Returns a [`Group`] of overlay [`Element`] children.
|
||||
///
|
||||
/// This method will generally only be used by advanced users that are
|
||||
/// implementing the [`Widget`](crate::Widget) trait.
|
||||
|
|
@ -104,12 +104,14 @@ pub fn from_children<'a, Message, Renderer>(
|
|||
where
|
||||
Renderer: crate::Renderer,
|
||||
{
|
||||
children
|
||||
let children = children
|
||||
.iter_mut()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.filter_map(|((child, state), layout)| {
|
||||
child.as_widget_mut().overlay(state, layout, renderer)
|
||||
})
|
||||
.next()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
(!children.is_empty()).then(|| Group::with_children(children).overlay())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ pub use iced_style::pane_grid::{Line, StyleSheet};
|
|||
use crate::event::{self, Event};
|
||||
use crate::layout;
|
||||
use crate::mouse;
|
||||
use crate::overlay;
|
||||
use crate::overlay::{self, Group};
|
||||
use crate::renderer;
|
||||
use crate::touch;
|
||||
use crate::widget;
|
||||
|
|
@ -450,14 +450,17 @@ where
|
|||
layout: Layout<'_>,
|
||||
renderer: &Renderer,
|
||||
) -> Option<overlay::Element<'_, Message, Renderer>> {
|
||||
self.contents
|
||||
let children = self
|
||||
.contents
|
||||
.iter_mut()
|
||||
.zip(&mut tree.children)
|
||||
.zip(layout.children())
|
||||
.filter_map(|(((_, pane), tree), layout)| {
|
||||
pane.overlay(tree, layout, renderer)
|
||||
.filter_map(|(((_, content), state), layout)| {
|
||||
content.overlay(state, layout, renderer)
|
||||
})
|
||||
.next()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
(!children.is_empty()).then(|| Group::with_children(children).overlay())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue