atomCAD / atomCAD

Mozilla Public License 2.0
30 stars 8 forks source link

Bug: Menus not visible on Windows #31

Open maaku opened 1 year ago

maaku commented 1 year ago

When I tried the new menubar code on my windows system, I got a blank menubar. There is a menu attached to the window, as I see a beige ribbon across the top. However the ribbon is featureless: there's no menus to click on. I'll post screenshots when I'm back at that machine. I have not yet had time to investigate this any further.

Pinging @ch1n3du

ch1n3du commented 1 year ago

Cause of the problem

This is because of how the menubar MenuSpec is currently being made, it creates a menu with APP_NAME as it's title, then a menu with no title and then that blank named submenu this looks like this in the code:

│
└───── Menu("AtomCAD") 🔴
   └───── SubMenu("") Acts as a pop-up window on MacOS) 🔵
      ├── Services
      ├── Separator
      ├── Hide atomCAD
      ├── Hide Others
      └── Show All

Current MacOS menubar: image

On MacOS the root menu (🔴) is an entry in the menubar and the blank-named menu (🔵) serves as a pop-up.

Current Windows menubar: image

On windows the root menu (🔴) is the menubar and the blank-named submenu (🔵) is an item on the menubar, the core issue is the MenuSpec type is adds a blank menu to support MacOS.

Possible Solutions

There are two possible solutions:

  1. Modify the existing MacOS implementation to insert a blank menu before all submenus of the root menu. This was my first idea, it has the minimum amount of code change but would the make the MacOS implementation larger overall.
  2. Reimplement the MacOS menubar using muda, Muda already handles creating a pop-up menus for menubar sub-menus and would greatly simplify the MacOS implementation, making it very approachable (the current implementation uses a lot of obj_c stuff that might make it hard to read) and exactly identical to the windows implementation. I think this is the best option and opened an issue for it yesterday #30

I reimplemented the MacOS menu using muda while working on #21 and it looked like this: image

The new menu would look like:

│
├─── AtomCAD (MacOS-specific stuff added in the macos platform_impl)
│  ├── Services
│  ├── Separator
│  ├── Hide atomCAD
│  ├── Hide Others
│  └── Show All
├─── File
│  ├── New
│  ├── Open File
│  ├── Separator
│  ├── Settings...  (CMD ,)
│  ├── Separator
│  └── Quit atomCAD (CMD Q)
├─── Window
│  └── Minimize     (CMD H)
└── Help
   └── About atomCAD
ch1n3du commented 1 year ago

tldr: I didn't modify the default MenuSpec when implementing the windows menubar because that would require changes in the MacOS menubar and that would have been out of scope for that issue.

crtag commented 5 months ago

@maaku @ch1n3du is it still relevant?

ch1n3du commented 4 months ago

I don't think so, I made a change that fixed the issue but since @maaku has ported the project to Bevy I don't think there's a windows menubar yet and with Bevy there's probably a better solution.

maaku commented 4 months ago

It is still relevant. When we switched from our own framework to bevy, most of the codebase changed. In particular we lost control over the main message loop, so whatever mechanism we use for adding application menus will probably be different. We will need it though, so this issue remains open.