Menu: align tree items with menu roots in MenuBar::layout

This commit is contained in:
Jeremy Soller 2023-12-06 08:05:58 -07:00
parent 3608675358
commit fb4669591a
2 changed files with 8 additions and 3 deletions

View file

@ -55,7 +55,7 @@ pub fn resolve<'a, E, Message, Renderer>(
spacing: f32, spacing: f32,
align_items: Alignment, align_items: Alignment,
items: &[E], items: &[E],
tree: &mut [Tree], tree: &mut [&mut Tree],
) -> Node ) -> Node
where where
E: std::borrow::Borrow<Element<'a, Message, Renderer>>, E: std::borrow::Borrow<Element<'a, Message, Renderer>>,

View file

@ -288,6 +288,12 @@ where
.iter() .iter()
.map(|root| &root.item) .map(|root| &root.item)
.collect::<Vec<_>>(); .collect::<Vec<_>>();
// the first children of the tree are the menu roots items
let mut tree_children = tree
.children
.iter_mut()
.map(|t| &mut t.children[0])
.collect::<Vec<_>>();
flex::resolve( flex::resolve(
&flex::Axis::Horizontal, &flex::Axis::Horizontal,
renderer, renderer,
@ -296,8 +302,7 @@ where
self.spacing, self.spacing,
Alignment::Center, Alignment::Center,
&children, &children,
// the children of the tree are the menu roots &mut tree_children,
&mut tree.children,
) )
} }