Hacker News new | ask | show | jobs
by byuu 3966 days ago
> I kind of wonder why nobody has written a library that acts as a thin layer around and abstraction of native UI toolkits

That's what I'm working on. Targeting C++, calling it hiro. So far, I have Windows, GTK, Qt and a dormant Cocoa layer. It truly uses native widgets (although I had no choice but to use custom draw on the Windows ListView), it compiles to ~50-100KB, it uses a fully shared memory model (reference counted) so you never have to call new or delete on anything, uses C++11 so you can bind lambda callbacks, and it uses UTF-8 ubiquitously, even on Windows. So no more L"foo" strings and W function variants.

I've been working on it for several years now, but it's still somewhat in flux. I hope to get a stable API version along with documentation out this year. If anyone really wants to see it right now, take a look at higan and the source to its UI.

2 comments

I actually downloaded and tried it out as a test. It worked pretty well (for the window and button I created). Keep up the good work! Modern C++ makes a lot of old things new again. Also, although you probably know of it, look up fltk, it was originally written with same goals (and it accomplished them) albeit in C.
Neat, thank you for trying it! It's in a bad state right now with zero examples/documentation. Plus the move to shared ownership was done this year, and has required massive rewrites (Windows/GTK finished, Qt underway, Cocoa not started.)

(I can't begin to express how unbelievably difficult it was to force a fully shared ownership model onto Windows, GTK, Qt, etc. That took several months of effort and is really complex behind the scenes.)

So I don't have much to show off, but I'd really like to get feedback on making the API cleaner and more consistent; as once a stable 1.x series is released, we'll be stuck with any poor choices that were missed for a long time.

I'll try and finish the Qt port, get some basic documentation up, and share it on HN then as a 0.x beta release.

FLTK definitely seems interesting, but seems to use its own widgets instead of being a wrapper around the native platform ones. This has pros (consistency and flexibility) and cons (they stand out as looking non-native.)

I've strongly considered a raster-based backend to my toolkit as well (for things like running apps directly on a framebuffer, or what have you), but have held off so far because it's undoubtedly a massive undertaking. Even if I do go this route, I'll surely write a hiro wrapper for this as well.

FLTK is written in C++ (though not C++11 style).
FLTK is C++ library not C.CMIIW
Did you consider a web layer?