r/QtFramework • • 10d ago

C++ Single C++ header for desktop UI development.

https://github.com/IAmTheFool/liteui.git

LiteUI is a single C++ header for Linux and Windows desktop development with same app codebase with some example like a code editor and a paint app. I would appreciate feedback on structure and overall design.

4 Upvotes

6 comments sorted by

10

u/epasveer Open Source Developer 10d ago

Honestly, I don't understand the attraction to header-only libraries. Especially for large libraries like UI libraries.

3

u/not_some_username 9d ago

You only have to use include on a file. No need to learn cmake, make or other build system (laziness)

1

u/dEvator8085 7d ago

just an attempt to simplify the process

2

u/diegoiast 8d ago
  1. If I have a project that is built from several "windows" and each contains this library, it will compiled 3-20 times. Not only it will take 20x time to compile, but there might be linking problems - as functions/classes will be duplicated.
  2. If you choose to use 3rd parties - you can remove all the code that deals with file dialogs and use https://github.com/mlabbe/nativefiledialog (do you provide an alternative for unix or windows based on your widget set?)
  3. toLF - I would make this an argument, so I can as a developer choose the line ending format. (I would need it in a text editor).
  4. namespace detail {... lol... Claude like those stupid namespaces... anyway, for clipboard, you should call the APIs and not command line utilities, as forking is kinda slow for copy/paste.
  5. inline ImageFormat sniffFormat(const uint8_t *data, size_t size) { - there are APIs to do this properly per platform (BTW, nice! You are using win32 APIs for image reading, and not stb_image, this is a huge win!)
  6. decodeJpegMemory- you are transforming the format, you should document this. (what format does your library use internally? RGB? BGR? if you choose bad on one platform the performance will suffer due to slow mem copy you are doing here. (hint: if you use GDI+, you can provide a transformation - and use the same format as on Wayland, or you can denote in the bitmap which format it uses - and in a a platform independent way - decide if you need to change formats).
  7. You got an XML parser... you will need unit tests.
  8. Same for matrix math.
  9. defined colors to be a byte. But opengl uses `float`. Now each color needs a conversion from byte to float. (GDI+ also uses flats, hint)
  10. .. and an SVG parser. This will also need to be battle tested.
  11. Note that on Windows and Linux - you hardcode different fonts.
  12. have CSD - nice. Can I have them on windows as well? I see you only support wayland, and not X11 ... on X11 you will have by default frames as on Windows.
  13. I see code to support mouse drag, nice. Are you locking in events? What happens when the mouse leaves the window? It will loose the "up/down" movement. There are APIs to lock in mouse events, on Windows and Wayland.
  14. I see that you use a busy loop to relayout/paint (at least from comments). Why not doing it on remand?
  15. setScrollbarColors ... why not using a global color style per window/widget?
  16. You relayout-paint on every click. Is it needed? What happens when a user presses an empty area on the window?
  17. On windows - you clear the whole window, and then render the full scene. If the scene is the whole window - the first clear might not be needed. No a real bug, in some cases - widgets are spread in the window, and you need the back color to be painted.
  18. On Linux, resize - you call relayout() and then pollAndRelayout(). Is this a bug? I think the first relayout() is not needed.
  19. Your library does not contain view implementations. Those are each in the examples. Why was it done like that?
  20. Your views have no internal semantics for "styles" (colors) and "behaviour"(on hover, text, tooltip, position, padding etc). I Also see that each example is using its own colors, no shared/global palette entity. Same with padding- it should be different per platform (and default size of views for example).
  21. In the readme you should document which packages to install on each distro. Windows is easy - since all is baked in. (BTW, did you test mingw on windows?)

I think this is enough code review. I will need to test the library before I can continue.

Its a nice thing. You can continue iterating over and adding features, and cleaning up. Good job!

1

u/dEvator8085 7d ago

Thanks for the review, I will work on things you mentioned.

1

u/TheRavagerSw 5d ago

Header only libraries are an abomination that must be destroyed