When the state of menus are changed, the `muda` representation of menus is completely torn down and rebuilt. On Windows, this can create a slight flicker unless the act of redrawing the window is disabled. With this change, we use `WM_SETREDRAW` to disable redrawing while the menus are being reconstructed.
It isn't clear to me if other platforms have a similar problem.
`MenuEvent::set_event_handler()` seems to use a `OnceCell` internally. The implications of this is that `MenuEvent::set_event_handler()` can really only be called safely a single time. The previous `muda` code seemed to rely on being able to call `MenuEvent::set_event_handler()` at will (I think I missed this because I wasn't using a menu bar :-|). With these changes, we now only call `MenuEvent::set_event_handler()` a single time. This required encoding the `MudaType` onto `MenuId` rather than snaking it separately.
-- Problem: is using `vtable::VRc::borrow(&menubar)` the correct approach?
-- Problem: `VTableMetaDropInPlace` is not properly implemented for `MenuVTable`
-- Problem: Codegen for menus has not been updated yet
- Updated Context Menu code to use `VRc` so both sides are supported
- Removed `ContextMenuFromItemTree`
- Moved `MudaType` to `internal/backends/winit/muda.rs`
- Stopped unnecessary use of `Option` when creating `context_menu_item_tree`
This represents the better part of a day of trying to implement native context menu support with `muda`. I've been able to get a context menu to appear, with the following caveats:
- Only the Rust code generator is supported
- Only Windows is supported
- Menu activation is `todo!()`
- Root menu items seem to display a subitem whether they have items or not
I've been finding it challenging navigating the Slint object model, particularly in the context of code generation, and I'm sure in some cases I'm overlooking simpler solutions. So I was hoping that I could get some feedback (perhaps what objects I need to "lock on to") about how to pull this over the finish line.
Thanks in advance, I'm really looking forward to having a native context menu in Slint!
This adds an icon that is displayed to the left of the title, and is
also shown for Menus are inside of a parent menu.
Closes#7791
ChangeLog: Added icon property to MenuItem and Menu
Similar to the wgpu access, the `unstable-winit-030` feature exposes a
`slint::winit_030` module, which in turn re-exports `winit` but also
provides access to the `WinitWindowAccessor` trait. The
`BackendSelector` is extended to provide a way to hook into window
attribute creation as well as providing a custom event loop builder,
similar to what `i_slint_backend_winit::BackendBuilder` provides.
Only the interpreter is implemented so far
MacOs won't work yet because we don't disable the default winit menubar
The viewer don't support removing the MenuBar yet