Expand description
facett-menu — a uniform, theme-aware overlay menu system that sits
above any facet: right-click context_menus, a floating CommandPalette
overlay (Ctrl-K / Ctrl-Shift-P), and classic dropdown menu_bars. See
.nornir/design/facett-menu.md.
§One command set, three surfaces
A single Command type drives all three: the same action is reachable by
right-click, by typing in the palette, and by id from a headless test
(CommandPalette::invoke) — the house rule that nothing is pointer-only.
Commands carry a stable id, a label, a group (section / top-level menu),
an optional shortcut hint, an optional icon glyph, and an enabled flag.
§Theming
Every surface reads the facett Theme from the egui
context ([facett_core::theme]) — panel_bg / panel_stroke / accent /
glow / text / text_dim — so menus match every component and the sci-fi
look. The selected palette row is painted with the theme accent plus a
layered glow bloom; nothing is hardcoded.
let cmds = vec![
Command::new("copy", "Copy", "Edit"),
Command::new("case.new", "New case", "Case"),
];
let mut palette = CommandPalette::default();
// each frame, after drawing the deck:
if let Some(id) = palette.ui(&ctx, &cmds) {
// dispatch `id` ...
}Structs§
- Command
- A user-invokable action. The same command appears in context menus, the command palette, and menu bars — and can be fired by id from a headless test.
- Command
Palette - A floating, theme-aware command palette overlay. Opened by Ctrl-K /
Ctrl-Shift-P (or
CommandPalette::open), it paints a scrim + a centered search box + a fuzzy-filtered, keyboard-navigable command list above everything (Order::Foreground). Pure data between frames; draw it once per frame after your deck so it lands on top.
Functions§
- attach_
context_ menu - Attach a theme-aware right-click
context_menuto anyResponse, threading the picked command id out throughon_pick. The closure fires at most once, on the frame an item is clicked. - context_
menu - A right-click context menu built from the same
Commandset. Call from insideresponse.context_menu(|ui| { … })— or useattach_context_menuto wrap aResponsedirectly. Commands are grouped by theirgroupwith separators between groups; disabled commands render dimmed and unclickable. Returns the chosen id (and closes the menu) when one is picked. - menu_
bar - A classic menu bar from grouped commands: each distinct
groupbecomes a top-level dropdown (File/Edit/ …) holding its commands, in first-seen order. Theme-aware via the facettTheme. Returns the chosen id, if any. Call inside anegui::menu::bar(ui, |ui| { … })or a top panel. - rank
- The commands an enabled palette query matches, best-ranked first. Public so a host (or a headless test) can reproduce exactly what the palette would show. Ties keep registry order (stable sort) so the layout is deterministic.