floem_winit/
menu.rs

1use crate::platform_impl;
2
3pub struct Menu(pub(crate) platform_impl::Menu);
4
5impl Menu {
6    /// Create a new empty window or application menu.
7    pub fn new() -> Menu {
8        Menu(platform_impl::Menu::new())
9    }
10
11    /// Create a new empty context menu.
12    pub fn new_for_popup() -> Menu {
13        Menu(platform_impl::Menu::new_for_popup())
14    }
15
16    /// Consume this `Menu`, returning the platform menu object.
17    pub(crate) fn into_inner(self) -> platform_impl::Menu {
18        self.0
19    }
20
21    /// Add the provided `Menu` as a submenu of self, with the provided title.
22    pub fn add_dropdown(&mut self, menu: Menu, text: &str, enabled: bool) {
23        self.0.add_dropdown(menu.0, text, enabled)
24    }
25
26    /// Add an item to this menu.
27    pub fn add_item(&mut self, id: u32, text: &str, selected: Option<bool>, enabled: bool) {
28        self.0.add_item(id, text, selected, enabled)
29    }
30
31    /// Add a separator to the menu.
32    pub fn add_separator(&mut self) {
33        self.0.add_separator()
34    }
35}
36
37impl Default for Menu {
38    fn default() -> Self {
39        Self::new()
40    }
41}