Rough implementation of selected menu items for gtk backend#2251
Rough implementation of selected menu items for gtk backend#2251xarvic merged 5 commits intolinebender:masterfrom
Conversation
I think it would make sense to change this in druid. |
|
The advantage of that would be conforming to GTK standards. I don't believe Windows or macOS employ visual distinction between standard and unchecked checkbox menu entries so it would only benefit linux builds. The disadvantage is that the change will either break existing code or only weakly enforce the distinction (which IMO is worse than not having a distinction in the first place). Thoughts? |
|
I am not sure i understand what you mean by "only weakly enforcing the distincition".
I agree, this would be a breaking change, at least at the druid-shell layer, but since druid is one of the only libraries depending on druid-shell this is probably fine. |
|
By "weakly enforce the distinction" I mean deprecating
I initially assumed you meant splitting the current This is slightly off topic but |
|
I thought about this again. Maybe we dont need to deprecate MenuItem::selected at all. We already have three states. We could do the following: If the selected closure is some, its return value chooses between selected and unselected. If there is no closure, the item is unselectable. This means changing MenuBuildCtx and druid-shells Menu, but the public api of druid will stay the same, which is good.
What is the expected behaviour here? Should the Menu just close after selecting the option? |
Sure enough! That works beautifully. Just pushed a gtk version via 63f9562, will add fixes for the other platforms when I can test them.
That's certainly what I expected, but if not that then I would at least expect that the menu would stay open with only the checkmark updating. |
|
Still haven't had a chance to test anything beyond GTK, but this should at least build for the other platforms now. I don't think macOS has a distinct unchecked MenuItem, and while I have seen them in Windows I don't believe they're a first party element. Might be worth adding in Windows along with MenuItem icons, at some point in the future unless someone really wants them now. |
|
Sorry, sliped |
|
No worries. Might have just fixed that x11 stub issue the test caught but like most of the other-platform commits here I'm doing it blind as I can't currently verify. |
xarvic
left a comment
There was a problem hiding this comment.
I finally got some time to take a closer look. It works great, thanks! :)

If there's a way to make a
gtk::prelude::IsA<gtk::MenuItem> + gtk::prelude::IsA<gtk::Widget>trait object then this could be a lot shorter, but I couldn't get that to work.Technically checkbox menu entries should have a distinct unchecked state (at least in GTK), but I didn't see a distinction in druid's MenuItem which would allow for that so these do not.