linux: Implement Menus (#21873)

Closes #19837

This PR implements menus for Linux and Windows, inspired by JetBrains
IDEs. Thanks to @notpeter for the inspiration.


https://github.com/user-attachments/assets/7267fcdf-fec5-442e-a53b-281f89471095

I plan to complete this in multiple parts. While this PR delivers a
fully functional menus, there are many UX improvements that can be done.
So, this is part 1 of 3.

**This PR**:
- [x] Clicking the application menu opens the first menu popup. This
also shows other available menus.
- [x] While a menu is open, hovering over other menus opens them without
needing a click.
- [x] Up/down arrow keys works out of the box. Thanks GPUI. 

**Future - Part 2**:
- Add keybinding support to open specific menus using `Option + first
character of menu item`.
- Add support for left/right arrow keys to move between menus.

**Future - Part 3**:
- Implement nested context menus in GPUI for submenus. (I haven't
checked if this already exists).

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
tims 2024-12-19 03:57:25 +05:30 committed by GitHub
parent 298b9df589
commit f7a7866d4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 189 additions and 135 deletions

View file

@ -38,8 +38,11 @@ pub fn app_menus() -> Vec<Menu> {
MenuItem::action("Extensions", zed_actions::Extensions),
MenuItem::action("Install CLI", install_cli::Install),
MenuItem::separator(),
#[cfg(target_os = "macos")]
MenuItem::action("Hide Zed", super::Hide),
#[cfg(target_os = "macos")]
MenuItem::action("Hide Others", super::HideOthers),
#[cfg(target_os = "macos")]
MenuItem::action("Show All", super::ShowAll),
MenuItem::action("Quit", Quit),
],