4 ms·
native_view is just a NSView which is where you have to render your stuff on macOS, whatever the toolkit used. But the actual widget implementation is custom: t
by jcelerier 9y ago
native_view is just a NSView which is where you have to render your stuff on macOS, whatever the toolkit used. But the actual widget implementation is custom: take for instance QComboBox.
It is painted here:
https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b91381608c6/src/gui/widgets/qcombobox.cpp#L2805 https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b...
This calls at some point QStyle::drawControl which ends up here on mac : https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b91381608c6/src/gui/styles/qmacstyle_mac.mm#L3165 https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b...
this ends up here in this big switch :
https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b91381608c6/src/gui/styles/qmacstyle_mac.mm#L4892 https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b...
which leads us here, in the drawComboBox function where mostly everything is done by hand:
https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b91381608c6/src/gui/styles/qmacstyle_mac.mm#L1227 https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b...
and also here: tadam, actually it just uses the "windows" (actually fairly generic and themeable) style for drawing :
https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b91381608c6/src/gui/styles/qmacstyle_mac.mm#L3528 https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b...
See also this qt blog: http://blog.qt.io/blog/2017/02/06/native-look-feel/ http://blog.qt.io/blog/2017/02/06/native-look-feel/
- LeoNatan25 9y agoI see a lot of HIToolbox calls, which is what AppKit uses internally to draw. So from that third to last link, it seems like a hybrid solution. Not optimal but still better than Electron or Flutter.
- jcelerier 9y ago> I see a lot of HIToolbox calls, which is what AppKit uses internally to draw. sure, but that's not the same as using a NSComboBox directly, and that's not using Apple's layout engine (based on cassowary, wasn't it) either. Not that I think that this is a bad solution : it allows software with a strong identity to have fairly custom UIs that are consistent across platforms.