|
There's a lot of stuff we get for free in the typical gui toolkit when we say, make a window, put some widgets in it and draw it, like how a button might have a callback function and you pass the function into the constructor so when the button gets clicked the function gets called. Thanks to what goes on behind the scenes (mostly, now) we don't have to implement hit-testing the mouse xy with every rectangle bounds to get an id to index into the array of callbacks... This old gui toolkit made you do all that and more. Imagine if the entirety of your 'layout engine' was a helper function that told you how much width and height you had available. Every widget needed xy coords for top left / bottom right and man if that sounds annoying, you're right. The convention was to assume a certain minimum amount of space and hard-code everything, literally get out the calculator and graph paper to start laying out widgets, but of course there were various copy-pasted solutions people used to page through larger interfaces than what would fit in some tiny rectangle. Nothing much like what you would call 'dynamic'. I tried to do something like this what you have but very rudimentary and instead of comments it was an attempt to make GUIs based off function signatures. A string was parsed containing brackets around names of functions to inspect, those functions' comments parsed for labels/tooltips etc, and for each argument to the function it just did basic duck typing to figure out what kind of widget to associate. A function without any arguments was just a button, a function that took a string and a number turned into a button a text field, and a number input, for example. Anyway, this particular part I'm trying to get at here, the thing that I was kind of proud of for being a novel way to do dynamic layout, was really only the concept of doing alternating rows and columns based on modulo the nesting depth. say you had 300x300 pixels to work with and you had defined some functions foo, bar, and baz somewhere, you could build a ui for them like '[foo,bar,baz]' to have a row of three buttons or instead if you wanted columns then '[[foo,bar,baz]]' |