-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Global menu bar support #898
Comments
Ubuntu Unity is discontinued, so we only need to support OSX now. |
The problem here is that on OSX menu bar is global for the application, there is no such thing as window menu. GTK merely emulates "window-owned" menus by appending them to the global menu bar on window activation. I'm not quite sure if we need to have the same behavior. It might be quite handy since it's the way menus usually work on OSX, so people won't have to add menu items to each window. On the other hand Windows doesn't have the concept of "application" menu. If we decide to use per-window menus, we need a way to sync menu bar items from our own menu system and a fallback for platforms that don't have global menu. For the user it would look like: <Window>
<MainMenu>
<MenuItem Header="Top level item">
<MenuItem Header="Item"/>
<Separator/>
<MenuItem>
</MainMenu>
</Window> It would be displayed in Which brings another problem here: we can't really express items with complex controls inside. Our current way of adding checkboxes to menu items is setting We could try to create a separate NSView for each NSMenuItem, but that will make said items to look in a non-native way, since we have to do all the drawing manually. What we could also do is to draw Another approach would be to create a completely separate control hierarchy:
Those (except for GlobalMenuBar) won't even be controls, they would inherit from That will solve the mentioned issues, but will limit the user in what they can express with such menus. |
It seems that Linux global menu is still alive alive and well across non-Unity desktop environments. Here is the definition file for DBus interface: |
Mkay, since this feature is getting a lot of interest lately, here is a proposal: General export procedureWe introduce
We make SimpleMenuItem and Separator implement a "marker" interface
Then we add IWindowImpl should now have Then we would have A separate exporter class is needed for implementing exported tray icon menus later. Application-global menuLater we can make |
https://github.com/KDE/kwayland/blob/master/src/client/protocols/appmenu.xml - KDE's global menu protocol for Wayland. Uses the same DBus menu protocol, this replaces Registar object since wayland doesn't have global window identifiers. |
For #898, we're going to need data templates that return types that are non-`IControl`s. This PR : - Relaxes the constraints on the `ITemplate.Build` method to allow building any type - Adds an `IDataTemplate<TParam, TControl>` which can be used to build any type - Makes the existing `IDataTemplate` interface be shorthand for `IDataTemplate<object, IControl>`
Whats the status on this? |
Implemented ages ago |
Can you point me to the documentation? I didn't see it anywhere in the docs. |
It looks like the docs somehow were lost alongside with the 0.9 release announcement. You can define native menu items using Avalonia/samples/ControlCatalog/MainWindow.xaml Lines 17 to 55 in fd64440
To avoid copy-pasting the same items to a regular menu bar you can use |
OK thanks, hope the docs get back up soon! |
Currently there are at least two global menubars that we need to support: OS X and Ubuntu ones.
Preferably we should synchronize items from our own menubar. To do that we probably want to create a property for that menu bar in
Window
and alterWindow
's template.GTK has various ways of submitting items to the menu bar.
For OS X there is gtk_mac_menu_set_menu_bar that should be followed by
gtk_mac_menu_sync
calls when toplevel menu item list is changed.Ubuntu provides
GtkMenuProxy
module that does some voodoo to detect window's menu, hide it and offload contents to system menubar. That voodoo doesn't always properly work, so it's disabled for some applications (notable example is MonoDevelop).Starting from GTK3 there is gtk_application_set_app_menu which sets "application" menu, which seems to be shown before any other menu items (at least on Ubuntu, according to docs).
We might want to stick to using
gtk_application_set_app_menu
, since on OS Xgtk_mac_menu_set_menu_bar
operates on application level anyway. In this scenario we need to update menubar on window activation.The text was updated successfully, but these errors were encountered: