pub struct MenuSpec {
pub items: Vec<MenuItemSpec>,
}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 native menu, as a platform-independent tree: the top-level value is the
menu bar (whose items are conventionally MenuItemSpec::Submenus), and
the same type describes each submenu below it.
Nothing here is rendered by Frust — a per-OS shell translates it into the
host’s own menu API, and reports an activation back through
frust_reactive::push_menu_event keyed by the activated item’s
id.
Fields§
§items: Vec<MenuItemSpec>The menu’s items, in display order.
Implementations§
Trait Implementations§
impl Eq for MenuSpec
impl StructuralPartialEq for MenuSpec
Auto Trait Implementations§
impl Freeze for MenuSpec
impl RefUnwindSafe for MenuSpec
impl Send for MenuSpec
impl Sync for MenuSpec
impl Unpin for MenuSpec
impl UnsafeUnpin for MenuSpec
impl UnwindSafe for MenuSpec
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<T> Brush for 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.