Skip to main content

Crate facett_menu

Crate facett_menu 

Source
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.
CommandPalette
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_menu to any Response, threading the picked command id out through on_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 Command set. Call from inside response.context_menu(|ui| { … }) — or use attach_context_menu to wrap a Response directly. Commands are grouped by their group with 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 group becomes a top-level dropdown (File / Edit / …) holding its commands, in first-seen order. Theme-aware via the facett Theme. Returns the chosen id, if any. Call inside an egui::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.