[Development] menu item right-to-left mode on Mac (WIP)
René J. V. Bertin
rjvbertin at gmail.com
Thu Jun 29 11:13:29 CEST 2017
I've been working on getting R2L rendering in context menus and menus belonging
to non-native menubars. I think I'm getting close, there may be only a single
thing left to tackle: aligning the actual menu item text. That's the main point
of the whole exercise and until now it has proven to be far less trivial than
the other modifications...
My assumption has been that the menuitem dimensions shouldn't change depending
on rendering direction: we're basically flipping the contents horizontally.
What does work is the alignment and placement of the checkmark, optional icon
and the shortcut mnemonic. I think those are at a reasonable and acceptable
location for a draft/PoC version, as far as one can judge that without having
the item text placed reliably.
What also works is the placement of the submenu indicator and the submenu
itself. That's not my doing which suggests hierarchical context menus might look
really weird in stock R2L mode on Mac.
I cannot get my finger around the placement of that item text. With the current
code it seems appropriate in some menus (at least when there's no icon), but
it's almost as if it gets misaligned towards the left the further left in the
(R2L) menubar you get. IOW, something unknown adds a dependency on an equally
unidentified property. That almost has to come from the contentRect data, but
how?
I'm using 2 test apps:
* https://github.com/RJVB/shortcut-test-qt5
* the oxygen-demo application from the KF5 Oxygen widget style with a few
tweaks.
Caveat: I'm doing this in a personalised version of the Macintosh widget style
(from Qt 5.9.0) that also adds support for texted separators. Evidently there's
overlap between that feature and R2L support in menus; I'm hoping we can ignore
that for now.
The code:
- the R2L changes:
https://github.com/RJVB/osx-integration/compare/1383c293a8ca40936b870c3c95afbfaa0b9abd8f...qt590-r2l#diff-8646d85d4040801efefec9e4a234bb65
- current WIP source:
https://github.com/RJVB/osx-integration/blob/qt590-r2l/src/qmacstyle/qmacstyle_mac.mm
Maybe we can use the github issue tracker until we come up with something that
works well enough to put it up for submission?
More information about the Development
mailing list