Repository navigation
Native macOS menu bar - #599
RiccardoTancredi wants to merge 1 commit into
Conversation
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>
af495fb to
222d2a5
Compare
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
left a comment
There was a problem hiding this comment.
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.
|
Thanks for the read. On the points raised: Dependencies. The lock gains two packages,
Staying in step with the commands. The menu bar is built from One shared menu layer. Agreed that this would be better. Each app has its own |
|
A correction to my last comment: the shared menu layer already exists. If the maintainers agree, I'll port this PR to |
There was a problem hiding this comment.
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.
|
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. |
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
SlideApp::runexactly 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 ownenabledcheck.unsafe.Tests
Notes for maintainers
457406a; happy to rebase.muda(macOS target only), reusing the tree'sobjc2.