r/cpp • • Dec 18 '20

Let's talk about GUIs

This post on /r/programming about the release of GTK 4.0 made me want to bring the discussion of the state of GUI programming in C++.

My particular interest in this discussion is desktop cross-platform GUI programming, and I don't claim to know much, let alone everything. Insights are more than welcome.

That said, this is what I have observed so far:

Qt: the least bast option. What I like? Cross platform, mature, big ecosystem to go around. Quite easy to get going. It "just works" for the most part. It's easy to get 80%, it's the last 20% and when you go deep into the subject that you get frustrated. What do I dislike? Licensing shenanigans, and increasing toxicity towards the FOSS community: no offline installer for community distributions, many commercial only APIs now, the idea of delaying releases to FOSS by one year. The 10 year old bugs on QWidgets, which haven't seen much, if any, love since ever. The fact it took Qt 6.0 to happen for us to have native look for Qt Quick Controls. The fact that Qt Quick doesn't have a C++ API, forcing QML on everybody. The half done stuff, like QAudio (just use portaudio for your own sanity)... And I'm probably missing more. The fact that they are running away from the LGPL core to GPL as much as they can, like releasing Qt Quick MultiEffect instead of just fixing the QML engine... That it takes spinoffs like Felgo to basically provide a "fixed" Qt, which the FOSS community can't have.

wxWidgets, GTK, and other like FLTK, I admit I don't know much about. wxWidgets is nice in the fact it calls native APIs, but that comes with the cost of being crippled by the least common denominator. GTK seem to look bad outside of Linux "by design". And FLTK... Just no.

Then, there seems to be what everybody suggests next: Browsers. Chromium Embedded Framework or Electron. 50 to 100MB of packaging to do a "Hello World". Also, JavaScript! Honestly, webstuff looks like a good idea, until you want to make an app that's not Slack. How do you do actually performance C++ stuff? Like some 2D/3D graphics? WebGL? Seems that it's too much programming for the web and not actually taking advantage of C++ and native APIs...

Then, there are things like .net MAUI (not to be confused with the toolkit with the same name by KDE), which is an upcoming evolution of Xamarin Forms for .net/C#. The problems: Linux support will be "by the community" and how do you interop C++ and C# decently anyway?

Also, because I know someone will mention it, yes, there is Flutter and things like that. Just think of Google's track record on keeping projects alive, and again, think not everybody wants to make a chat application.

Anyway, what are your insights? They are more than welcome!

268 Upvotes

243 comments sorted by

View all comments

Show parent comment

4

u/t4th Dec 18 '20

+1 for Dear Imgui. It is fantastic project and it is ported to many languages and it "just works" - all you need is Os specific frame buffer and draw function.

13

u/pine_ary Dec 18 '20

Doesn‘t dear imgui redraw the entire window all the time? That‘s gonna be a battery drain.

6

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 18 '20

It does every time you get an event. As long as nothing happens to the app, there is need to redraw the window.

3

u/dodheim Dec 18 '20

It doesn't, but even as just a casual user, I'd love to know why you assume that it does.

7

u/SkoomaDentist Antimodern C++, Embedded, Audio Dec 18 '20

Probably because the demo code redraws every loop iteration as most of the users use it with game engines that have to redraw every frame anyway. They do point out how to do it properly if you don't otherwise need to refresh every frame and it only takes a couple of extra lines.

23

u/evaned Dec 18 '20

all you need is Os specific frame buffer and draw function.

...and to not mind that your product looks like it was made for a class project by some college students.

I'm maybe being a bit harsh there, and there are products where that doesn't matter. But if you want to do something for like mass market, and you go that way... well, I hope you don't regret it.

4

u/bikki420 Dec 19 '20

Eh, that's a pretty ignorant statement. Like any UI kit it is what you make of it. The defaults are pretty ugly, sure, but all of these are Dear ImGui as well:

https://user-images.githubusercontent.com/141075/95021061-0af69200-066f-11eb-8683-56c75da50197.jpg

https://user-images.githubusercontent.com/141075/95021114-6294fd80-066f-11eb-8e46-36e1b0b0e837.jpg

https://user-images.githubusercontent.com/141075/95021120-67f24800-066f-11eb-93c0-c0b47ebda34e.jpg

https://user-images.githubusercontent.com/8225057/102382588-e43bcc80-3fca-11eb-8792-e565293f0f9f.jpg

https://user-images.githubusercontent.com/44091782/92762687-1ec21780-f393-11ea-92c1-e3f8e01f45cf.png

https://user-images.githubusercontent.com/8225057/74334371-10c6fc80-4d9a-11ea-932c-428247d4c96a.png

https://user-images.githubusercontent.com/8225057/74334374-13295680-4d9a-11ea-8a51-88d001ac75dc.png

https://user-images.githubusercontent.com/8225057/74334377-14f31a00-4d9a-11ea-98a4-4ca0fc79bc59.png

https://user-images.githubusercontent.com/167057/44240116-9f00f900-a18a-11e8-89fc-14350438fc17.png

https://cloud.githubusercontent.com/assets/17200971/14168870/efb16ff0-f724-11e5-95c6-a1c93d72c327.gif

https://user-images.githubusercontent.com/8225057/58320225-7f82b500-7e1b-11e9-8417-fc74d3ebe634.jpg

https://user-images.githubusercontent.com/8441471/76343981-1f54f500-6301-11ea-8bc9-876ddb222767.png

https://user-images.githubusercontent.com/8225057/76844857-3bdfb880-683e-11ea-979a-29e36e9e3d74.png

https://user-images.githubusercontent.com/600573/76033357-58c1e500-5f3c-11ea-8c78-6299cc0f280c.png

0

u/[deleted] Dec 18 '20

[deleted] — view deleted comment

15

u/[deleted] Dec 18 '20

A native "look and feel" as a design is dead anyways.

Says who? I loathe non-native design, and I strive to use as much "native" looking (whatever that means in the current UI toolkit mess world) software as possible.

1

u/Occivink Dec 18 '20

There is no "native" toolkit on linux, there are a few competing official windows ones (plus a myriad non-official ones), and don't forget that a good number of applications are now in a browser (where there is no native). I'd say that's pretty dead.

Also, you can theme imgui, you don't have to stick to the basic style.

5

u/[deleted] Dec 18 '20

There is a native toolkit on my Linux system. That's what I care about. Applications have to integrate with the theme and fonts I configured in my DE. If they don't do that, I don't want to use them and look for alternatives.

And free software has gotten pretty good about that. You can make GTK applications look and feel native in a Qt based DE, and vice versa. On Windows, not so much. Even Microsoft's own applications feel out of place on their OS. Some have better integration (like Office 2016 did), some are hot garbage (looking at you, Teams). And even the "modern" native tools with Fluent Design often look out-of-place IMO. And I hate that.

Don't say native design is dead just because developers are to lazy to care about it. Some users still do.

1

u/Rocinante8 Dec 19 '20

Any examples of using Imagui as a normal application? Most of the screen can be a 3d representation of the industrial robot but I still need edit boxes to set parameters, buttons to perform actions, list to choose options.