Skip to content

Native macOS menu bar - #599

Closed
RiccardoTancredi wants to merge 1 commit into
storytold:mainfrom
RiccardoTancredi:feat/macos-menu-bar
Closed

RiccardoTancredi wants to merge 1 commit into
storytold:mainfrom
RiccardoTancredi:feat/macos-menu-bar

Conversation

@RiccardoTancredi

Copy link
Copy Markdown

Native macOS menu bar

What

A real macOS menu bar built from the existing menus::menu_tree (DeckCraft, File, Edit, View, Insert, Format, Arrange, Slide Show, Window, Help), with Open Recent.

Why

DeckCraft defined a menu tree "shared with the native macOS menu bar" but had no bar wired up; this adds it.

How it stays safe

  • Items run through SlideApp::run exactly as the command palette does. Cut/Copy/Paste/Select All reach a focused text field as the keyboard would. Items whose command can't run right now (nothing selected, nothing to undo) are greyed out via the engine's own enabled check.
  • No key equivalents: the keyboard is unchanged.
  • macOS-only; no unsafe.

Tests

  • Every menu item runs on the sample presentation (skipping the ones that open system dialogs or start a full-screen show), so no item is unknown or fails for want of parameters.

Notes for maintainers

  • Branched from 457406a; happy to rebase.
  • New dependency: muda (macOS target only), reusing the tree's objc2.

Adds a real macOS menu bar built from the existing menus::menu_tree
(DeckCraft, File, Edit, View, Insert, Format, Arrange, Slide Show,
Window, Help), with Open Recent. Items run through SlideApp::run as the
command palette does; Cut/Copy/Paste/Select All reach a focused text
field as the keyboard would; items whose command can't run right now are
greyed out. No key equivalents, so the keyboard is unchanged.

Tests: every menu item runs on the sample presentation (skipping the ones
that open system dialogs or start a show).

Co-Authored-By: Claude <noreply@anthropic.com>
anishguduru pushed a commit to anishguduru/deckcraft that referenced this pull request Oct 16, 2026
 follow-up) (storytold#1123)

* M10.5: Restore architectural paper presets and PDF scale controls

Port the missing paper catalog and scale controls from PR storytold#599 onto the merged Windows printing implementation. Keep the spooler and background discovery from storytold#847/storytold#1007. Document the feature-by-feature audit and verification limits.

Assisted-by: OpenAI Codex

* Drop the provenance write-up and the screenshot example (the kittest covers the dialog)

* Refresh catalog hashes

---------

Co-authored-by: Brandon Thomas <echelon@gmail.com>

@FredApps FredApps left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReviewerA — source-read COMMENT (not an approval)

I read the head of the diff: a native macOS menu bar. The lock gains muda (a cross-platform menu crate from the Tauri project), keyboard-types 0.8.3 and objc2 0.6.5. A native menu bar is expected by macOS users and PowerPoint has one. muda is a maintained crate, but it brings a tree of its own, and the menu module in gridcraft already has a native menu (the native_menu module in gridcraft's main.rs), so the suite should share one menu layer. The menu is built from the command registry, and every command's enabled state and shortcut must stay in step with it, which needs a test. unsafe for AppKit calls would fall under the organisation's rule unless it is behind the crate. I have not run it (macOS), and no exact-head CI result exists for this head. Nothing was run.

I ran nothing and have no exact-head CI result for this PR, so this is not an approval. Where a diff was long I read its code hunks rather than every generated or documentation line.

Status: waiting_author.

@RiccardoTancredi

Copy link
Copy Markdown
Author

Thanks for the read. On the points raised:

Dependencies. The lock gains two packages, muda and keyboard-types; objc2 was already in the tree through rfd. It is the same muda 0.21 (with default-features = false) that vectorcraft's menu bar already uses, so the suite stays on one menu crate.

unsafe. There is none in this PR; every AppKit call goes through muda. The only occurrence of the word is in the Cargo.toml comment explaining that.

Staying in step with the commands. The menu bar is built from deckcraft_ui_egui::menus::menu_tree(), the same tree as the in-app menus, and each item runs through SlideApp::run as the command palette does, so there is no second list to drift. Enabled state comes from each command's own enabled check in the engine's command registry (command_specs()), so items that can't run are greyed out. There are no key equivalents in this PR, so the keyboard is unchanged and there are no shortcuts to keep in sync. The test every_menu_item_runs_on_the_sample_presentation runs every menu item on the sample presentation and fails on any unknown command or any command that errors (skipping only the ones that open system dialogs, close the presentation or start a show).

One shared menu layer. Agreed that this would be better. Each app has its own native_menu today (gridcraft's included), so extracting a shared layer is a suite-wide refactor that I'd rather do as a separate change once the maintainers decide where it should live, instead of growing this PR.

@RiccardoTancredi

RiccardoTancredi commented Nov 2, 2026 •

Copy link
Copy Markdown
Author

A correction to my last comment: the shared menu layer already exists. craft-menu in storytold/craft-libs (crates/menu) builds a Craft app's menus from its command tree, with a muda backend for the macOS menu bar and an in-window egui bar elsewhere, and pdfcraft has used it since storytold/pdfcraft#4752. So the suite does have one menu layer, and this PR uses muda directly instead of going through it.

If the maintainers agree, I'll port this PR to craft-menu rather than land a deckcraft-only menu bar.

@aiongg aiongg added missing feature The reference application has it and we do not, or only part of it needs decision Needs a product or scope decision by a maintainer labels Nov 4, 2026

@autocraft-bot autocraft-bot Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-generated review (Opus). Not a maintainer decision.

Changes needed:

This adds a native macOS menu bar built from menus::menu_tree(), with Open Recent. Items run through SlideApp::run and are greyed out by each command's own enabled check, and there are no key equivalents.

  • apps/deckcraft/src/native_menu.rs drives muda directly. The Craft apps share a menu layer, craft-menu (craft-libs crates/menu), which has a muda backend, and the same feature built on it is open in #828. Porting to craft-menu, as offered, would avoid two menu layers.
  • apps/deckcraft/src/native_menu.rs:152-175: clicks run whatever state the app is in, including while a dialog, the palette or the File tab holds the window. Items are not greyed in that state.
  • apps/deckcraft/src/native_menu.rs:164: a click runs in logic(), before the frame's UI. An edit pending in a focused text field may not be committed before Save or Close runs.
  • apps/deckcraft/src/native_menu.rs:~229: Edit › Undo is also sent to a focused text field as Cmd+Z. The description only lists Cut, Copy, Paste and Select All.
  • The Window menu is added in native_menu.rs:120-127, not taken from menu_tree() as the description suggests.
  • No unsafe: AppKit is reached only through muda, and MainThreadMarker::new() keeps installation on the main thread (native_menu.rs:65).

Claims checked:

  • verified: The menu bar is built from menus::menu_tree() (File, Edit, View, Insert, Format, Arrange, Slide Show, Help) with an Open Recent submenu. (apps/deckcraft/src/native_menu.rs:97-118 iterates menu_tree() and inserts the recent submenu after app.openDialog. native_menu.rs:~189-202 rebuilds it from app.u…
  • contradicted: The Window menu is part of the existing menu tree. (crates/ui-egui/src/menus.rs:147 menu_tree() has no Window entry. Window is built separately in apps/deckcraft/src/native_menu.rs:120-127.)
  • verified: Items run through SlideApp::run exactly as the command palette does, and errors show in the status bar. (apps/deckcraft/src/native_menu.rs:164 calls app.run(id, json!({})). crates/ui-egui/src/lib.rs:284-295 run sets the status on error.)
  • verified: Cut/Copy/Paste/Select All reach a focused text field as the keyboard would. (apps/deckcraft/src/native_menu.rs:158-161 queues text_field_events when a widget has focus. main.rs raw_input_hook appends menu.input. Undo is also routed this way (native_menu.rs:~229).)
  • verified: Items whose command cannot run are greyed out via the engine's own enabled check. (apps/deckcraft/src/native_menu.rs:~237-240 available() uses command_specs().enabled (crates/engine/src/cmd/mod.rs:38). native_menu.rs:177-183 calls set_enabled on changes.)
  • verified: No key equivalents; the keyboard is unchanged. (apps/deckcraft/src/native_menu.rs:55 MenuItem::with_id(..., None) and :~197 use no accelerator. The keyboard path in main.rs is untouched apart from appending menu events.)
  • unverified: macOS-only, no unsafe; muda is the only new dependency, on the macOS target only. (apps/deckcraft/Cargo.toml adds muda and objc2 under cfg(target_os = "macos"). native_menu.rs has no unsafe block. The lock also gains keyboard-types through muda.)

Reviewed at 222d2a5.

Recommendation: update the pull request; it will be reviewed again.

@RiccardoTancredi

Copy link
Copy Markdown
Author

Closing in favour of #828, which builds the same menu bar on craft-menu and already covers what the review here asks for: menus greyed while a dialog or the palette holds the window, clicks run after the frame's UI so a field's edit is committed, and the suite's muda version. Porting this PR would repeat that work. Thanks @hajdukste, and thanks to the reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing feature The reference application has it and we do not, or only part of it needs decision Needs a product or scope decision by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants