Why is GUI programming such an obscure and undocumented field?

Home Forums Science & tech Why is GUI programming such an obscure and undocumented field?

Viewing 22 reply threads
  • Author
    Posts
    • #181100
      Anonymous
      Guest

      Why is GUI programming such an obscure and undocumented field? I mean programming a GUI library from scratch, implementing things like textboxes, buttons, dynamic layouts etc..
      Everyone seems to be content with just using a library, except for games, but those UIs are usually limited.

    • #181101
      Anonymous
      Guest

      It 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

    • #181102
      Anonymous
      Guest

      Because 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.

    • #181104
      Anonymous
      Guest

      GUI 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

      • #181108
        Anonymous
        Guest

        >GUI programming is a very complex subject
        That’s why the lack of theory on it surprises me

        I’ve used imGui before but i really want to write my own. Don’t really care about making it fully cross platform/device.

        I 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

        >There’s no "GUI theory" to study
        if there was maybe today’s GUIs wouldn’t be such a mess

        • #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

          • #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

            • #181111
              Anonymous
              Guest

              graphics library and gui library are two different things but I have tons of experience doing both and I can answer questions

              • #181118
                Anonymous
                Guest

                meant 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

                • #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

                  • #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?

                    • #181136
                      Anonymous
                      Guest

                      GUI 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

                      • #181145
                        Anonymous
                        Guest
                      • #181156
                        Anonymous
                        Guest

                        You 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 much

                        There’s no way that code does what you claim it does. For one it doesn’t handle wrapping at all.

                      • #181159
                        Anonymous
                        Guest

                        wrapping? 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

                      • #181165
                        Anonymous
                        Guest

                        https://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.

                      • #181167
                        Anonymous
                        Guest

                        Like 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"

                      • #181171
                        Anonymous
                        Guest

                        https://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.

                      • #181172
                        Anonymous
                        Guest

                        I 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

                      • #181173
                        Anonymous
                        Guest

                        This 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.

                      • #181175
                        Anonymous
                        Guest

                        I 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

                      • #181177
                        Anonymous
                        Guest

                        Wrapping 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

                      • #181178
                        Anonymous
                        Guest

                        none of that makes it hard. those are problems solved through basic procedural programming

                      • #181179
                        Anonymous
                        Guest

                        would you go with recursion or loops for updating elements?

                      • #181181
                        Anonymous
                        Guest

                        Everything in a GUI should be recursive

                        It’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.

                        >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

                      • #181180
                        Anonymous
                        Guest

                        It’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.

          • #181113
            Anonymous
            Guest

            maybe 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

            • #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

          • #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

            • #181122
              Anonymous
              Guest

              There really isn’t any theory. Name something theoretical about GUI programming that can’t be summed up in less than a paragraph

              • #181123
                Anonymous
                Guest

                Basically everything about any programming task can be "summed up in less than a paragraph".

                • #181124
                  Anonymous
                  Guest

                  wrong

                  • #181126
                    Anonymous
                    Guest

                    wrong

                    • #181127
                      Anonymous
                      Guest

                      I 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

                      • #181133
                        Anonymous
                        Guest

                        Containers 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.

                      • #181137
                        Anonymous
                        Guest

                        There’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

                      • #181139
                        Anonymous
                        Guest

                        It’s only less than a paragraph, just write it out.

                      • #181140
                        Anonymous
                        Guest

                        I have code for an element that does exactly that and it’s less than 100 lines

                      • #181143
                        Anonymous
                        Guest

                        Show it or shut the fuck up.

                      • #181148
                        Anonymous
                        Guest

                        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

                        thanks, that explains a lot
                        i was also curious about implementing "flexboxes" as […] mentions
                        is it as easy as having normalized dimensions for your rectangles and updating them woke af on their parents dimensions?

                        >is it as easy as having normalized dimensions for your rectangles and updating them woke af on their parents dimensions?
                        pretty much

    • #181106
      Anonymous
      Guest

      Same 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.

    • #181107
      Anonymous
      Guest

      Well 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

      • #181150
        Anonymous
        Guest

        That 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.

    • #181112
      Anonymous
      Guest

      i’ve written my own gui before. protip: immediate mode

    • #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?

    • #181121
      Anonymous
      Guest

      Bros what’s the deal with the Demo, it’s some eerie stuff
      Also basically taking credit for the invention of the mouse

    • #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

    • #181128
      Anonymous
      Guest

      did 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.

    • #181138
      Anonymous
      Guest

      what 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

    • #181142
      Anonymous
      Guest

      Because globohomo wants everything to be in (((cloud))) and as an individual you get no financial incentive to start such a large project.

    • #181146
      Anonymous
      Guest

      Maybe you can check JavaFX code.
      https://github.com/openjdk/jfx

    • #181147
      Anonymous
      Guest

      we have gender theory but not GUI theory
      ugh…. how the west has fallen

    • #181149
      Anonymous
      Guest

      GUI 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.

      • #181151
        Anonymous
        Guest

        >Realistically you’re better off using QT, JavaFX, or Element.
        sorry, not racist just dont like them

        • #181157
          Anonymous
          Guest

          Then 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>

    • #181152
      Anonymous
      Guest

      I’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.

    • #181155
      Anonymous
      Guest

      if 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?

      • #181158
        Anonymous
        Guest

        All GUI libraries are shit.

        • #181160
          Anonymous
          Guest

          Some are worse than others though. Webshit on the desktop should result in murder of the developer.

          • #181163
            Anonymous
            Guest

            I 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.

            • #181174
              Anonymous
              Guest

              On 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

              • #181176
                Anonymous
                Guest

                The 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.

    • #181161
      Anonymous
      Guest

      if 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?

      • #181164
        Anonymous
        Guest

        I 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

    • #181169
      Anonymous
      Guest

      guis were a mistake

      • #181170
        Anonymous
        Guest

        Sage

    • #181182
      Bulls suck my dick
      Guest

      Modern GUIs are user unfriendly and disgusting to look at.

    • #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.

    • #181184
      Anonymous
      Guest

      >GUI programming such an obscure and undocumented field?
      because it isnt programming, it’s actually mostly scripting

      • #181185
        Anonymous
        Guest

        Sounds like programming doesn’t even exist, everything is just scripting.

Viewing 22 reply threads
  • You must be logged in to reply to this topic.
startno id