diff options
author | 2021-07-19 21:01:24 +0700 | |
---|---|---|
committer | 2021-07-19 21:01:24 +0700 | |
commit | a2f49a74d08a0cff2e892932b484a88a4034f627 (patch) | |
tree | d29b717203e1e9779c44b0f8a48442ef488f9953 | |
parent | 3099f3610003f513a386125d3cb81bfbf0ffe887 (diff) | |
download | iced-a2f49a74d08a0cff2e892932b484a88a4034f627.tar.gz iced-a2f49a74d08a0cff2e892932b484a88a4034f627.tar.bz2 iced-a2f49a74d08a0cff2e892932b484a88a4034f627.zip |
Replace `content` with `title` in `menu` module
-rw-r--r-- | core/src/menu.rs | 41 | ||||
-rw-r--r-- | winit/src/conversion.rs | 10 |
2 files changed, 22 insertions, 29 deletions
diff --git a/core/src/menu.rs b/core/src/menu.rs index e9d3d13a..3ad7b7a2 100644 --- a/core/src/menu.rs +++ b/core/src/menu.rs @@ -59,7 +59,7 @@ pub enum Entry<Message> { /// Item for a [`Menu`] Item { /// The title of the item - content: String, + title: String, /// The [`Hotkey`] to activate the item, if any hotkey: Option<Hotkey>, /// The message generated when the item is activated @@ -68,7 +68,7 @@ pub enum Entry<Message> { /// Dropdown for a [`Menu`] Dropdown { /// Title of the dropdown - content: String, + title: String, /// The submenu of the dropdown submenu: Menu<Message>, }, @@ -79,43 +79,40 @@ pub enum Entry<Message> { impl<Message> Entry<Message> { /// Creates an [`Entry::Item`]. pub fn item<S: Into<String>>( - content: S, + title: S, hotkey: impl Into<Option<Hotkey>>, on_activation: Message, ) -> Self { - let content = content.into(); + let title = title.into(); let hotkey = hotkey.into(); Self::Item { - content, + title, hotkey, on_activation, } } /// Creates an [`Entry::Dropdown`]. - pub fn dropdown<S: Into<String>>( - content: S, - submenu: Menu<Message>, - ) -> Self { - let content = content.into(); + pub fn dropdown<S: Into<String>>(title: S, submenu: Menu<Message>) -> Self { + let title = title.into(); - Self::Dropdown { content, submenu } + Self::Dropdown { title, submenu } } fn map<B>(self, f: &impl Fn(Message) -> B) -> Entry<B> { match self { Self::Item { - content, + title, hotkey, on_activation, } => Entry::Item { - content, + title, hotkey, on_activation: f(on_activation), }, - Self::Dropdown { content, submenu } => Entry::Dropdown { - content, + Self::Dropdown { title, submenu } => Entry::Dropdown { + title, submenu: submenu.map(f), }, Self::Separator => Entry::Separator, @@ -127,22 +124,20 @@ impl<Message> PartialEq for Entry<Message> { fn eq(&self, other: &Self) -> bool { match (self, other) { ( + Entry::Item { title, hotkey, .. }, Entry::Item { - content, hotkey, .. - }, - Entry::Item { - content: other_content, + title: other_title, hotkey: other_hotkey, .. }, - ) => content == other_content && hotkey == other_hotkey, + ) => title == other_title && hotkey == other_hotkey, ( - Entry::Dropdown { content, submenu }, + Entry::Dropdown { title, submenu }, Entry::Dropdown { - content: other_content, + title: other_title, submenu: other_submenu, }, - ) => content == other_content && submenu == other_submenu, + ) => title == other_title && submenu == other_submenu, (Entry::Separator, Entry::Separator) => true, _ => false, } diff --git a/winit/src/conversion.rs b/winit/src/conversion.rs index dc7f90ad..e61611aa 100644 --- a/winit/src/conversion.rs +++ b/winit/src/conversion.rs @@ -187,19 +187,17 @@ pub fn menu<Message>(menu: &Menu<Message>) -> winit::window::Menu { for item in menu.iter() { match item { - menu::Entry::Item { - content, hotkey, .. - } => { - converted.add_item(id, content, hotkey.map(self::hotkey)); + menu::Entry::Item { title, hotkey, .. } => { + converted.add_item(id, title, hotkey.map(self::hotkey)); id += 1; } - menu::Entry::Dropdown { content, submenu } => { + menu::Entry::Dropdown { title, submenu } => { let mut converted_submenu = winit::window::Menu::new(); let n_children = menu_i(&mut converted_submenu, id, submenu); - converted.add_dropdown(content, converted_submenu); + converted.add_dropdown(title, converted_submenu); id += n_children; } |