4 ms·
A couple of corrections: 1) Mac OS X does not store a bitmap for every widget, that's iOS's architecture. It stores a bitmap for every window. Having a layer
by mpweiher 11y ago
A couple of corrections:
1)
Mac OS X does not store a bitmap for every widget, that's iOS's architecture. It stores a bitmap for every window. Having a layer (GPU-stored bitmap) was only introduced once CoreAnimation was ported to OS X. It was and is optional.
2)
OS X Views also have a -drawRect: method that works the same way.
3)
In fact that's how MVC works. See http://blog.metaobject.com/2015/04/model-widget-controller-mwc-aka-apple.html http://blog.metaobject.com/2015/04/model-widget-controller-m...
And react and frameworks like it just duplicated this, see http://blog.metaobject.com/2015/04/reactnative-isn.html http://blog.metaobject.com/2015/04/reactnative-isn.html In fact, when I first read about react (non-native), my first thought was "hey, finally they came up with a good equivalent of NSView + drawRect:
- mwcampbell 11y agoIsn't drawRect: working at a different level of abstraction than React? In React, the view function constructs a virtual DOM tree, which can contain links, buttons, form fields, tables, etc. The equivalent on OS X would construct NSControls or NSCells, or objects that ultimately got translated into those, rather than just drawing on a canvas.
- mpweiher 11y agoI saw this as react choosing the obvious way to implement drawRect: inside a browser: painting with HTML. You could easily have a "graphics context" that accepts high-level objects, or a variant of drawRect: that creates subviews and then tells those subviews to draw themselves. I don't see this as being fundamentally/structurally different, though there is a slight difference in the implementation.