refactor(menu): add menu::bar as shorthand for MenuBar::new

This commit is contained in:
Michael Aaron Murphy 2024-05-20 00:28:02 +02:00
parent 709ab268a0
commit b3bce0740e
No known key found for this signature in database
GPG key ID: B2732D4240C9212C
2 changed files with 10 additions and 3 deletions

View file

@ -59,10 +59,11 @@ pub use action::MenuAction as Action;
mod flex;
pub mod key_bind;
pub use key_bind::KeyBind;
mod menu_bar;
pub use menu_bar::MenuBar;
pub(crate) use menu_bar::MenuBarState;
pub use menu_bar::{menu_bar as bar, MenuBar};
mod menu_inner;
mod menu_tree;

View file

@ -19,6 +19,13 @@ use iced_widget::core::{
Alignment, Clipboard, Element, Layout, Length, Padding, Rectangle, Shell, Widget,
};
/// A `MenuBar` collects `MenuTree`s and handles all the layout, event processing, and drawing.
pub fn menu_bar<Message, Renderer: iced_core::Renderer>(
menu_roots: Vec<MenuTree<Message, Renderer>>,
) -> MenuBar<Message, Renderer> {
MenuBar::new(menu_roots)
}
pub(crate) struct MenuBarState {
pub(crate) pressed: bool,
pub(crate) view_cursor: Cursor,
@ -56,8 +63,7 @@ impl Default for MenuBarState {
}
}
/// A `MenuBar` collects `MenuTree`s and handles
/// all the layout, event processing and drawing
/// A `MenuBar` collects `MenuTree`s and handles all the layout, event processing, and drawing.
#[allow(missing_debug_implementations)]
pub struct MenuBar<'a, Message, Renderer = crate::Renderer>
where