Skip to main content

teksilo_widgets/
menu.rs

1// SPDX-License-Identifier: MPL-2.0
2// SPDX-FileCopyrightText: 2026 FernTech
3
4//! Declarative menu model — a single source of truth for both the in-window
5//! [`MenuBar`](crate::menu_bar::MenuBar) and the platform's native menu bar
6//! (`NSMenu` on macOS).
7//!
8//! A [`MenuModel`] describes the whole menu tree as data — titles, intents,
9//! shortcut ids, enabled state, check / radio bindings, submenus, separators —
10//! with no built widgets. [`MenuBar::from_model`](crate::menu_bar::MenuBar::from_model)
11//! renders it as the usual in-window dropdown bar, and the same model is mirrored
12//! into the OS menu bar via the `native_on_macos` flag. Reactive `Signal`s drive
13//! both: a toggled check mark flips in the in-window menu and the native menu
14//! alike.
15//!
16//! ```ignore
17//! use teksilo::widgets::menu::{MenuModel, MenuEntry};
18//! let model = MenuModel::new()
19//!     .menu(tr!(file()), |m| m
20//!         .item(MenuEntry::new(tr!(new())).intent("app.new").shortcut("app.new"))
21//!         .separator()
22//!         .item(MenuEntry::new(tr!(quit())).intent("app.quit")))
23//!     .menu(tr!(view()), |m| m
24//!         .item(MenuEntry::new(tr!(show_grid())).tri_checkable(grid_state)));
25//! ```
26
27pub mod model;
28pub mod native;
29
30pub use model::{MenuEntry, MenuItemState, MenuItems, MenuModel, MenuNode, StandardMenu};
31pub use native::NativeMenuMode;
32
33// Re-export the platform standard-menu roles so apps name them through the
34// widget surface without a direct `teksilo-platform` dependency.
35pub use teksilo_platform::native_menu::StandardMenuRole;