pub struct DropdownMenu;
#[derive(Clone)]
pub enum MenuItem {
Item {
label: String,
shortcut: Option<String>,
selected: bool,
enabled: bool,
},
Separator,
}
impl MenuItem {
pub fn label(label: impl Into<String>) -> Self {
Self::Item {
label: label.into(),
shortcut: None,
selected: false,
enabled: true,
}
}
pub fn with_shortcut(label: impl Into<String>, shortcut: impl Into<String>) -> Self {
Self::Item {
label: label.into(),
shortcut: Some(shortcut.into()),
selected: false,
enabled: true,
}
}
#[must_use]
pub fn selected(mut self, selected: bool) -> Self {
if let Self::Item { selected: sel, .. } = &mut self {
*sel = selected;
}
self
}
pub fn full(label: impl Into<String>, shortcut: Option<String>, enabled: bool) -> Self {
Self::Item {
label: label.into(),
shortcut,
selected: false,
enabled,
}
}
#[must_use]
pub fn separator() -> Self {
Self::Separator
}
}