pub enum MenuRole {
About,
Hide,
HideOthers,
ShowAll,
Minimize,
CloseWindow,
Quit,
}Expand description
The desktop app’s identity and native-integration vocabulary, re-exported
from the desktop core so app code never names a shell crate:
DesktopConfig (the whole declaration — app name, reverse-DNS id, window
icon, menu bar, last-window-close policy — handed to App::desktop,
run_desktop_config or app!’s desktop = { .. } argument),
MenuSpec/MenuItemSpec/MenuRole (the platform-independent native
menu tree a per-OS shell translates into an NSApp menu bar or an HMENU),
DesktopIconData (decoded, tightly-packed RGBA8 — decoding a
PNG/ICO/ICNS is the caller’s job), and DEFAULT_APP_NAME (the window
title a config that names nothing still gets).
frust-shell-desktop‘s IconData is re-exported renamed: the facade
already carries frust-widgets’ IconData, an in-UI vector icon, and the
two are unrelated (one is a BezPath a widget paints, the other is the
window/taskbar bitmap the OS shows). The Desktop prefix matches
DesktopConfig, whose with_window_icon is its only consumer.
use frust::{DesktopConfig, MenuItemSpec, MenuRole, MenuSpec};
let file = MenuSpec::new()
.with_item(MenuItemSpec::item("file.open", "Open…").with_accelerator("CmdOrCtrl+O"))
.with_item(MenuItemSpec::separator())
.with_item(MenuItemSpec::role(MenuRole::Quit));
let config = DesktopConfig::new()
.with_app_name("Huddle")
.with_app_id("dev.frust.huddle")
.with_menu_spec(MenuSpec::new().with_item(MenuItemSpec::submenu("File", file)));Desktop-only, unlike the menu_events read side: these types are
defined in frust-shell-desktop, which is not in a mobile build’s or a
wasm32 build’s dependency graph at all (see this crate’s Cargo.toml).
Code shared with a mobile or wasm32 target keeps a DesktopConfig behind
its own
#[cfg(not(any(target_os = "android", target_os = "ios", target_arch = "wasm32")))]
— or, more simply, writes it inline in app!’s desktop = { .. }
argument, which the macro already emits only on the targets that have it.
A platform-standard menu action the host implements itself.
The set is the one a macOS application menu is expected to carry (the platform whose menu conventions are strictest); a host that has no notion of a given role simply omits the item rather than faking it.
Variants§
About
Show the standard about panel.
Hide
Hide the application.
HideOthers
Hide every other application.
ShowAll
Show every hidden application.
Minimize
Minimize the focused window.
CloseWindow
Close the focused window (which is a close request — see
DesktopExtensions::on_close_requested).
Quit
Quit the application.
Trait Implementations§
impl Copy for MenuRole
impl Eq for MenuRole
impl StructuralPartialEq for MenuRole
Auto Trait Implementations§
impl Freeze for MenuRole
impl RefUnwindSafe for MenuRole
impl Send for MenuRole
impl Sync for MenuRole
impl Unpin for MenuRole
impl UnsafeUnpin for MenuRole
impl UnwindSafe for MenuRole
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.