logoalt Hacker News

sirwhinesalotyesterday at 10:41 AM0 repliesview on HN

I've been working (very slowly) on a cross-platform UI library written in C. It uses as much as it can from the OS without outright using the native widgets for everything. Rather the focus is on letting the user of the library customize the look of the controls as they see fit.

It's unfortunate but native UI (as in, using the native controls with their native look) has mostly died off in my opinion, at least for complex cross-platform applications.

You can try to do it in a cross-platform manner but it never works well. Want to implement a tab bar like VSCode's? Win32 tab bars do not support close buttons (need to be custom rendered) and Cocoa tabs it doesn't even make sense for them to have a close button. In Cocoa you're supposed to use either the windowing system to do tabs (similar to Safari tabs) or custom render everything (like iWork).

So I say screw it, make it look as you wish.

The design of the API is somewhat DOM inspired (everything is built up of divs that can be styled). It's pure retained mode for now, I still need to think how I'll make reactivity work.

On macOS it uses a custom NSView to implement "divs". Drawing is done with CoreAnimation layers. Text editing is handled by a nested a NSTextView control with a transparent background. Could also host a web view in a similar manner. Context menus are native.

On Windows it uses a custom C++ class that stores Windows.UI.Composition surfaces for drawing (could also use DirectComposition + Direct2D). Text editing is handled by a windowless RichEdit control (ITextHost/ITextServices). Context menus are native Win32.

On Linux it uses a custom QWidget with a nested QTextEdit control for text editing. I'm thinking of experimenting with Qt Quick for hardware accelerated rendering like the other two.