backup of https://www.reddit.com/r/cpp/comments/dcwq61/how_you_can_create_c_gui_framework_and_maybe_earn/
Story about C++ UI framework what deserves to exist
I just wanted portable and small alternative to electron, without javascript. So small and portable that it can be used as browser game GUI. A lot of games use C++... and C++ can be run in browser via emscripten! Bingo!
I started searching for opensource or free-for-indie-devs C++ UI solutions.
-
QT - is is great. But QT widgets are not such style & animation friendly as HTML/CSS. QT qml = javascript overhead = not suitable for browser game.
-
CoherentGT - awesome. But no browser support + javascript overhead.
-
flutter - uses Dart and GC. flutter engine is C++ and uses SKIA
-
... (you can continue this list)
Wait - flutter engine is C++? SKIA? SKIA is used by chromium, flutter, android. Fast and cross-platform. So small and portable that it can be used as browser game GUI! Why we don`t have (production ready) SKIA based C++ UI frameworks?
Lets extract HTML/CSS engine from cobalt.foo (chromium fork), add ui (widgets) from chromium https://github.com/blockspacer/skia-opengl-emscripten/blob/master/src/skia_ui_demo.cc#L520, add CMake and emscripten support https://groups.google.com/forum/#!topic/cobalt-dev/USoNfkEurTg
hooray! - we created something similar to CoherentGT and QT. Someone can start company and earn money from that approach! (have you heard about Ultralight?)
Wait - we have our own HTML/CSS engine, so we can customize it! Lets add some features from angular / vue.js / etc. 3f3dd20
Lets start small and just render box as custom HTML Node https://github.com/blockspacer/skia-opengl-emscripten/blob/master/src/extended_html/input_box/input_node.cc#L28
Now we want to add click callback, like so https://github.com/blockspacer/skia-opengl-emscripten/blob/master/resources/html/index.html#L74
I use ugly EXT__on-click-print__EXT syntax, but you can make it better.
We can run it in browser via emscripten (WASM) and it uses tiny HTML engine under hood. It means that we can add https://github.com/mbasso/asm-dom support and build web pages using C++! (tiny HTML engine can be used for shadow dom). So we can create trully cross-platform UI solution that can be not only rendered using SKIA on native platform, but even run in browser/electron as usual web page! Soon browsers will add WASM DOM modification support and it will become fast and with C++ lifetime checks ( see lifetime branch of https://github.com/mgehre/llvm-project ) we will help to create safe C++ web apps / SPA.
Note what now cobalt.foo supports flexbox and can render using opengl, so it can be even faster and smaller (through i used only SKIA because of awesome SKOTTIE/lottie animation support)
I hope someone will find that ideas and code from blockspacer/skia-opengl-emscripten useful.
Again - Why we don`t have (production ready) SKIA based C++ UI frameworks?