refactor: popups for nav bar / segmented buttons
This commit is contained in:
parent
f5fc392ba4
commit
cde1989e78
13 changed files with 544 additions and 57 deletions
|
|
@ -230,7 +230,7 @@ where
|
|||
path_highlight: Some(PathHighlight::MenuActive),
|
||||
menu_roots,
|
||||
style: <crate::Theme as StyleSheet>::Style::default(),
|
||||
window_id: window::Id::NONE,
|
||||
window_id: window::Id::RESERVED,
|
||||
#[cfg(all(
|
||||
feature = "multi-window",
|
||||
feature = "wayland",
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@ impl<'b, Message: Clone + 'static> Menu<'b, Message> {
|
|||
);
|
||||
let node_size = children_node.size();
|
||||
intrinsic_size.height += node_size.height;
|
||||
|
||||
intrinsic_size.width = intrinsic_size.width.max(node_size.width);
|
||||
|
||||
nodes.push(children_node);
|
||||
|
|
|
|||
|
|
@ -401,3 +401,19 @@ pub fn menu_items<
|
|||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Create a menu tree from a widget and a vector of sub trees
|
||||
pub fn nav_context<
|
||||
A: MenuAction<Message = Message>,
|
||||
L: Into<Cow<'static, str>> + From<&'static str> + 'static,
|
||||
Message: 'static + std::clone::Clone,
|
||||
>(
|
||||
key_binds: &HashMap<KeyBind, A>,
|
||||
children: Vec<Vec<MenuItem<A, L>>>,
|
||||
) -> Vec<MenuTree<Message>> {
|
||||
let menus = children
|
||||
.into_iter()
|
||||
.map(|m| MenuItem::<A, L>::Folder(L::from(""), m));
|
||||
let root = vec![MenuItem::<A, L>::Folder(L::from(""), menus.collect())];
|
||||
menu_items(key_binds, root)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue