Home › Forums › Science & tech › Why is GUI programming such an obscure and undocumented field?
- This topic has 85 replies, 1 voice, and was last updated 7 months, 3 weeks ago by
Anonymous.
-
AuthorPosts
-
-
October 8, 2021 at 8:44 pm #181100
Anonymous
Guest -
October 8, 2021 at 8:45 pm #181101
Anonymous
GuestIt doesn’t need documentation because it’s pretty freaking simple and is something an intermediate programmer can figure out on their own with no issue
-
October 8, 2021 at 8:48 pm #181103
Anonymous
Guest-
October 8, 2021 at 8:49 pm #181105
Anonymous
GuestI have written several GUI systems
They have no inherent complexity, any complexity that arises is an implementation detail like being cross platform
There’s no "GUI theory" to study-
October 8, 2021 at 10:01 pm #181153
Anonymous
GuestAs long as you consider little things like: documentation, intuitive design, extensibility, etc "implementation detail" then yes. If you want to see an example of a badly written UI framework look at WxWidgets or FLTK. Filled with out parameters, bad documentation, interfaces look like shit(FLTK)
-
-
-
-
October 8, 2021 at 8:47 pm #181102
Anonymous
GuestBecause it’s extremely complex and inflexible especially when you want to start writing cross-platform UI code.
It’s why webshit is such a popular way to create a UI these days.-
October 8, 2021 at 9:18 pm #181116
Anonymous
GuestThe only thing that will change across platforms is the input system, which can be abstracted to be the same as far as your UI is concerned.
This scrote has no idea what he’s talking about, or he has never made any remotely complex UIs.
As someone who actually has made fairly complex HTML/CSS-like GUIs from scratch without any external libraries aside a text renderer, there’s a lot of things to consider in the design and a lot of different ways you can architect things.
-
-
October 8, 2021 at 8:49 pm #181104
Anonymous
GuestGUI programming is a very complex subject anon, that’s why people use either gtk or qt.
>Input handling
>Rendering
>Different input devices (phone/pc)
>Different screen resolutions
>Container layout
Check out https://github.com/ocornut/imgui-
October 8, 2021 at 8:53 pm #181108
Anonymous
Guest>GUI programming is a very complex subject
That’s why the lack of theory on it surprises meI’ve used imGui before but i really want to write my own. Don’t really care about making it fully cross platform/device.
>There’s no "GUI theory" to study
if there was maybe today’s GUIs wouldn’t be such a mess-
October 8, 2021 at 8:55 pm #181109
Anonymous
Guest>if there was maybe today’s GUIs wouldn’t be such a mess
No, it’s not that theory exists and that it hasn’t been documented, there literally is no theory. There’s nothing to it. You click a button and it does something. It’s simple. There is theory behind designing GUIs, not programming them-
October 8, 2021 at 9:09 pm #181110
Anonymous
Guest>There is theory behind designing GUIs
Maybe that’s what i’m looking for
I don’t really have problems programming buttons and graphics, more curious about the general composition of a graphics library, what kind of data structures are used, memory management etc-
October 8, 2021 at 9:11 pm #181111
Anonymous
Guestgraphics library and gui library are two different things but I have tons of experience doing both and I can answer questions
-
October 8, 2021 at 9:22 pm #181118
Anonymous
Guestmeant GUI library, i need sleep
>I can answer questions
what do your data structures look like
as in, do you have some kind of base element, maybe a rectangle, from which more specific things "inherit"?
do you dynamically allocate memory or preallocate?
this leaks into graphics, but is it worth optimizing rendering for a simple GUI, like culling unvisible rectangles or is it just unnecessary complexity?
i have so many questions but they usually pop up when i’m programming-
October 8, 2021 at 9:27 pm #181119
Anonymous
Guest>what do your data structures look like
that’s way too broad of a question to answer, narrow it down
>as in, do you have some kind of base element, maybe a rectangle, from which more specific things "inherit"?
yes, OOP is great for GUIs, despite what hipsters will tell you
>do you dynamically allocate memory or preallocate?
depends what you’re doing, generally there’s no reason you would need to preallocate memory, GUIs aren’t demanding on the system
>this leaks into graphics, but is it worth optimizing rendering for a simple GUI, like culling unvisible rectangles or is it just unnecessary complexity?
depends. software or hardware rendering? Is it for an exclusive application like a game or is it something more lightweight? Generally there’s two types of GUIs, one where you redraw it every frame and one where you only redraw when it updates. Culling inivisble rectangles is an irrelevant optimization to make with hardware rendering-
October 8, 2021 at 9:40 pm #181132
Anonymous
Guest>that’s way too broad of a question to answer, narrow it down
do you use something like a linked list or some fancy datastructure other then a simple arrays for your gui elements
>depends. software or hardware rendering?
software
>Generally there’s two types of GUIs, one where you redraw it every frame and one where you only redraw when it updates.
are there actually any disadvantages to only redraw on updates?-
October 8, 2021 at 9:43 pm #181136
Anonymous
GuestGUI elements are a tree, so they each node has a list of their child elements. It’s a good idea to have each element contain its own collision rectangle, if rectangles are the only shape you need
The disadvantage to "only redraw on update" is you might have animated GUI elements that need redrawing every frame. If you don’t, that’s not an issue-
October 8, 2021 at 9:49 pm #181145
Anonymous
Guestthanks, that explains a lot
i was also curious about implementing "flexboxes" asBasically HTML flexboxes.
mentions
is it as easy as having normalized dimensions for your rectangles and updating them woke af on their parents dimensions? -
October 8, 2021 at 10:03 pm #181156
Anonymous
GuestYou need to propagate minimum/maximum sizes for nodes to determine how they fit, keep track of the rows that the nodes wrap into (so you can match the heights per row), and loop through all the nodes at least twice to "fix" all the positions and sizes after you figure out the final wrapping of things.
https://pastebin.com/PMnAbiWe
This takes the top-down approach where the container will resize it children (which can also include other resizable containers) whereas you’re describing the bottom-up approach where a container resizes itself woke af on its children, but it’s the same thing[…]
>is it as easy as having normalized dimensions for your rectangles and updating them woke af on their parents dimensions?
pretty muchThere’s no way that code does what you claim it does. For one it doesn’t handle wrapping at all.
-
October 8, 2021 at 10:04 pm #181159
Anonymous
Guestwrapping? as in text wrapping? the text elements handle the text wrapping
no minimum or maximum size parameters for elements, but that’s a few extra lines, you can see that it’s a simple solution to a simple problem -
October 8, 2021 at 10:19 pm #181165
Anonymous
Guesthttps://i.4cdn.org/g/1633731541922.webm
It doesn’t wrap anything at all. If you just want to fit a bunch of shit in a row then of course it’s easy. Webm related is flexboxes.
-
October 8, 2021 at 10:20 pm #181167
Anonymous
GuestLike I said, my text elements handle the text wrapping, which are seperate from my aligner elements or "flexboxes". Your webm is "fitting a bunch of shit in a row"
-
October 8, 2021 at 10:24 pm #181171
Anonymous
Guesthttps://i.4cdn.org/g/1633731874250.webm
It’s not wrapping text, are you freaking blind? It’s wrapping all the elements, and stretching their heights and widths woke af on how they wrap and what their content sizes are. Also here’s a better webm since it has a node with different horizontal content size.
-
October 8, 2021 at 10:25 pm #181172
Anonymous
GuestI understand what you mean now, yeah, it doesn’t wrap elements. Wrapping elements would make it more complex, but we’re talking about moving from 100 lines of code to 200 lines of code at most. None of this shit is complicated
-
October 8, 2021 at 10:28 pm #181173
Anonymous
GuestThis is literally exactly what I described, you’re the one who said you can do it in 100 lines of code. And since I’ve actually implemented this, I highly doubt you can do it in 200 either.
-
October 8, 2021 at 10:30 pm #181175
Anonymous
GuestI misunderstood what you were saying, I thought you were talking about text wrapping
My class that does row/column alignments is 100 LoC. Making it wrap elements would be 200 LoC at most -
October 8, 2021 at 10:36 pm #181177
Anonymous
GuestWrapping isn’t hard. What makes it hard is that
1. all the nodes in a row must be the same height, as determined by the tallest node in that row
2. if there’s any vertical space left then all the rows need to stretch equally to fill it
3. if there’s anything inside of those nodes, then the child nodes may also need to stretch and re-position themselves, which means you’ll need to re-solve or retain information about the rows since the height needs to be shared per-row, not per-node -
October 8, 2021 at 10:39 pm #181178
Anonymous
Guestnone of that makes it hard. those are problems solved through basic procedural programming
-
October 8, 2021 at 10:40 pm #181179
Anonymous
Guestwould you go with recursion or loops for updating elements?
-
October 8, 2021 at 10:43 pm #181181
Anonymous
GuestEverything in a GUI should be recursive
>if you want to do it efficiently then it’s not a 200 lines of code solution.
I disagree, but that depends on the language and how efficient your architecture is. In my system I could do it in 200 lines of code, but depending on your specification it may require all element types to have extra properties to determine how they stretch -
October 8, 2021 at 10:40 pm #181180
Anonymous
GuestIt’s not like you need a research paper for it, but if you want to do it efficiently then it’s not a 200 lines of code solution.
-
-
-
-
-
-
-
October 8, 2021 at 9:13 pm #181113
Anonymous
Guestmaybe you’re not thinking low level enough?
not the anon, but there is a lot of theory that goes into programming the low level of GUI interfaces.
how do you want to go about handling the pixel arrays, how you layer objects, what does your render cycle look like? what order do you update states? keep track of states? efficient use of memory?
get these wrong and you’ll have a buggy, slow, glitchy mess
then you have to write an API for it-
October 8, 2021 at 9:15 pm #181114
Anonymous
Guest>there is a lot of theory that goes into programming the low level of GUI interfaces.
I have made countless GUIs and no there is not
But you’re talking about rendering, that’s different, rendering is more general and there’s alot of graphics theory but GUIs themselves have simple rendering requirements
-
-
October 8, 2021 at 9:29 pm #181120
Anonymous
Guest>there literally is no theory
Why didn’t you tell the truth for once?
>I can’t be bothered to find the books describing the theory from the 1970s so it doesn’t exist because I’m a lazy stupid shit-
October 8, 2021 at 9:31 pm #181122
Anonymous
GuestThere really isn’t any theory. Name something theoretical about GUI programming that can’t be summed up in less than a paragraph
-
October 8, 2021 at 9:32 pm #181123
Anonymous
GuestBasically everything about any programming task can be "summed up in less than a paragraph".
-
October 8, 2021 at 9:33 pm #181124
Anonymous
Guestwrong
-
October 8, 2021 at 9:34 pm #181126
Anonymous
Guestwrong
-
October 8, 2021 at 9:36 pm #181127
Anonymous
GuestI really shouldn’t say summed up, I mean you can communicate all relevant information about the topic in less than a paragraph. Nothing about GUIs is complex. I challenge you name one area of "GUI theory", because there isn’t one
-
October 8, 2021 at 9:42 pm #181133
Anonymous
GuestContainers whose size is automatic woke af on it’s contents, that stretch to fill the remaining available vertical/horizontal space (with other elements who also want to do the same), share their vertical size with other things in the same row, and the text wrapping inside of them (and thus the container’s vertical size) changes woke af on how big the container is.
Basically HTML flexboxes.
-
October 8, 2021 at 9:45 pm #181137
Anonymous
GuestThere’s nothing theoretical or complex about that
The only sticking point really is elements whos size depend on their children, and elements whos size depend on their parent, and resolving those in the right order -
October 8, 2021 at 9:46 pm #181139
Anonymous
GuestIt’s only less than a paragraph, just write it out.
-
October 8, 2021 at 9:47 pm #181140
Anonymous
GuestI have code for an element that does exactly that and it’s less than 100 lines
-
October 8, 2021 at 9:47 pm #181143
Anonymous
GuestShow it or shut the fuck up.
-
October 8, 2021 at 9:54 pm #181148
Anonymous
Guesthttps://pastebin.com/PMnAbiWe
This takes the top-down approach where the container will resize it children (which can also include other resizable containers) whereas you’re describing the bottom-up approach where a container resizes itself woke af on its children, but it’s the same thing>is it as easy as having normalized dimensions for your rectangles and updating them woke af on their parents dimensions?
pretty much
-
-
-
-
-
-
-
-
-
-
October 8, 2021 at 8:51 pm #181106
Anonymous
GuestSame reason most game devs use tried and true engines, it’s a lot of work.
Also portability is important, that’s most of the reason for using a library is that they have already sorted that out.
Personally I enjoy making terminal interfaces. -
October 8, 2021 at 8:53 pm #181107
Anonymous
GuestWell you implement it from scratch just like you would do for a video game. You figure out how to draw pixels, how to draw rectangles, how to, put textures on them, simple function coming together in more complex ones, eventually resulting in a powerful GUI library abstracting away all the math and rendering
-
October 8, 2021 at 9:57 pm #181150
Anonymous
GuestThat sounds like you’re trying to create an immediate mode GUI. That’s a good option for something like a video game editor or a non-linear video editor, but for most applications immediate mode UIs are probably best avoided.
-
-
October 8, 2021 at 9:12 pm #181112
Anonymous
Guesti’ve written my own gui before. protip: immediate mode
-
October 8, 2021 at 9:18 pm #181115
Anonymous
Guest>Everyone seems to be content with just using a library
Would you rather use a library that works universally on most major desktop operating systems, or would you rather write a separate codebase for Win32, Cocoa, and X11? -
October 8, 2021 at 9:31 pm #181121
Anonymous
GuestBros what’s the deal with the Demo, it’s some eerie stuff
Also basically taking credit for the invention of the mouse -
October 8, 2021 at 9:34 pm #181125
Anonymous
Guest>Why is GUI programming such an obscure and undocumented field?
the GUI libraries I’ve used have had tons of detailed documentation. and most GUI programming isn’t hard it’s just very tedious and boring
> I mean programming a GUI library from scratch
why would someone spend all kinds of time creating tutorials and guides to create a GUI library from scratch? something that is rarely ever done? making a good GUI framework that’s cross-platform is not easy, so people use the good ones that already exist, stop re-inventing the wheel.
and if your skills are to the level they need to be to even do this, you wouldn’t need tutorials to tell you, most of what needs done is obvious, it’s just work to write it all.
not to mention all of this relying on graphics primatives and keyboard/mouse input handling, both of which are heavily dependent on the OS being used, so again, there can’t be a generic tutorial for it, it’s platform dependent, and even further depends on what OS subsystems, or graphics and input frameworks you build on top of-
October 8, 2021 at 9:36 pm #181129
Anonymous
Guest>good GUI framework that’s cross-platform
Give me a single thing that’s more difficult about making a GUI library cross-platform than making anything else cross-platform.-
October 8, 2021 at 9:38 pm #181130
Anonymous
GuestOSes have their own GUI systems so when you write a cross-platform GUI library you’re essentially making a compatibility layer between all of them, unless you want to make your own GUI system
-
October 8, 2021 at 9:43 pm #181134
Anonymous
GuestYou’re not making a GUI library if you’re using the operating system’s GUI library, you’re just creating an abstraction for another GUI library.
-
October 8, 2021 at 10:20 pm #181166
Anonymous
GuestThe problem with this reasoning is that some platforms (X11 in particular) lack a lot of high level features.
-
-
-
October 8, 2021 at 9:40 pm #181131
Anonymous
GuestI can write a decent console app that’s cross platform in C++ with not a ton of effort
doing the same for a GUI application without using something like Qt is next to impossible
good freaking luck doing that from scratch. every OS has its own graphics and input systems, they have zero in common, you have to handle each one completely separately, which means you basically have to re-implement all of that stuff over again-
October 8, 2021 at 9:43 pm #181135
Anonymous
Guestif ur smart you make a platform layer for your library that gives you sound and video buffers, input and whatever the fuck else you need from whatever OS you’re building for, then abstract that away so you don’t ever have to touch it again
-
October 8, 2021 at 9:47 pm #181141
Anonymous
Guestthank you captain obvious, no one else has ever thought to do that, you should win a software patent for your novel idea
this in no way changes how much freaking work it is to do -
October 8, 2021 at 10:02 pm #181154
Anonymous
Guestthis dude just figured it all out in post, you should work for qt.
-
-
-
-
-
October 8, 2021 at 9:36 pm #181128
Anonymous
Guestdid you know a smalltalk system is ‘reflective’? you can browse the code that every thing you see is implemented with, and it’s implemented in itself. Pharo is a popular one, woke af on the smalltalk dialect Squeak.
P.S. the pic is from 1968 (‘the mother of all demos’) . smalltalk had windows in the 70’s. then windows and mac copied in the 80’s.
-
October 8, 2021 at 9:45 pm #181138
Anonymous
Guestwhat do you deranged autists who argue about gui libraries think of terminal interfaces?
been playing around with curses recently and though it’s a pain to work with stuff designed to display on a terminal, it’s kind of elegant in a way
theoretically can run my software without booting up an OS. not quite sure how to do that but I’d like to-
October 8, 2021 at 9:49 pm #181144
Anonymous
Guest>terminal interface
is best interface -
October 8, 2021 at 10:17 pm #181162
Anonymous
GuestI like text interfaces (TUIs) a lot. If you’re using C++ or a language that can use bindings to C++ consider using
https://github.com/a-n-t-h-o-n-y/TermOx
https://github.com/fmtlib/fmt
-
-
October 8, 2021 at 9:47 pm #181142
Anonymous
GuestBecause globohomo wants everything to be in (((cloud))) and as an individual you get no financial incentive to start such a large project.
-
October 8, 2021 at 9:52 pm #181146
Anonymous
GuestMaybe you can check JavaFX code.
https://github.com/openjdk/jfx -
October 8, 2021 at 9:54 pm #181147
-
October 8, 2021 at 9:56 pm #181149
Anonymous
GuestGUI programming covers a wide area of subjects and requires a lot of background knowledge to implement properly. Realistically you’re better off using QT, JavaFX, or Element. None of these are great options, but they’re much more viable than a homebrew library that only has been tested on your computer.
-
October 8, 2021 at 9:58 pm #181151
Anonymous
Guest>Realistically you’re better off using QT, JavaFX, or Element.
sorry, not racist just dont like them-
October 8, 2021 at 10:03 pm #181157
Anonymous
GuestThen suffer. There really aren’t any "good" options for GUI programming.
<insert autistic project created by someone named "bob" and his dog without documentation or github commits in 5 years>
-
-
-
October 8, 2021 at 10:01 pm #181152
Anonymous
GuestI’d imagine that part of this is because it is truly thankless work. I’ve seen a lot of threads over the years bashing GUI toolkits, yet none celebrating them.
-
October 8, 2021 at 10:03 pm #181155
Anonymous
Guestif there is no official GUI theory, is there at least some established library we can all agree is of quality and could be used as reference for personal projects?
-
October 8, 2021 at 10:04 pm #181158
Anonymous
GuestAll GUI libraries are shit.
-
October 8, 2021 at 10:08 pm #181160
Anonymous
GuestSome are worse than others though. Webshit on the desktop should result in murder of the developer.
-
October 8, 2021 at 10:18 pm #181163
Anonymous
GuestI understand both sides of this argument though. (If implemented well) It does create one single interface between multiple platforms. Coinbase has moved to using a similar UI for its applications.
-
October 8, 2021 at 10:30 pm #181174
Anonymous
GuestOn the other hand, browser technology is deliberately overengineered so it entirely controlled by corporations. No one should have to run software as complex as the Linux kernel to have a GUI.
https://drewdevault.com/2020/03/18/Reckless-limitless-scope.html-
October 8, 2021 at 10:34 pm #181176
Anonymous
GuestThe bench mark provided in that article is beyond useless. Humans have always abstracted things. A detailed discussion of how to manufacture generators to power a computer was suspiciously lacking.
But I definitely don’t disagree that web frameworks are overkill from an engineering perspective. From a business perspective though they fit perfectly. There is a reason why people have migrated to web technology.
-
-
-
-
-
-
October 8, 2021 at 10:14 pm #181161
Anonymous
Guestif the guidev is still in thread i also wanted to ask if you made some graphical tool to assist in designing your gui, (saving the layout to a file perhaps) or do you lay everything out in code?
-
October 8, 2021 at 10:18 pm #181164
Anonymous
GuestI lay things out in code using aligner elements. They’re rectangle containers where I specify the alignment and padding of the contents and it lays them out automatically in rows and columns. I posted the source in a previous post although I just realized that’s the wrong code and doesn’t do rows and columns properly. This was the easiest way to do things for my particular case, laying things out in a VB-style editor is pointlessly tedious when you generally want things to be aligned but your milage may vary
-
-
October 8, 2021 at 10:21 pm #181169
Anonymous
Guestguis were a mistake
-
October 8, 2021 at 10:23 pm #181170
Anonymous
GuestSage
-
-
October 8, 2021 at 10:47 pm #181182
Bulls suck my dick
GuestModern GUIs are user unfriendly and disgusting to look at.
-
October 8, 2021 at 11:07 pm #181183
Anonymous
Guest>Why is GUI programming such an obscure and undocumented field?
Because only Apple can do GUI right, and they’re not sharing their secrets. You could study Gtk or Qt source code if you’re looking for the technical aspects. -
October 8, 2021 at 11:38 pm #181184
Anonymous
Guest>GUI programming such an obscure and undocumented field?
because it isnt programming, it’s actually mostly scripting-
October 8, 2021 at 11:42 pm #181185
Anonymous
GuestSounds like programming doesn’t even exist, everything is just scripting.
-
-
-
AuthorPosts
- You must be logged in to reply to this topic.