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,
align_items: Alignment,
items: &[E],
tree: &mut [Tree],
tree: &mut [&mut Tree],
) -> Node
where
E: std::borrow::Borrow<Element<'a, Message, Renderer>>,

View file

@ -288,6 +288,12 @@ where
.iter()
.map(|root| &root.item)
.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::Axis::Horizontal,
renderer,
@ -296,8 +302,7 @@ where
self.spacing,
Alignment::Center,
&children,
// the children of the tree are the menu roots
&mut tree.children,
&mut tree_children,
)
}