kxgames / glooey

An object-oriented GUI library for pyglet.
MIT License
91 stars 6 forks source link

Allow an Object to span multiple cells In Grids #45

Open marky1991 opened 3 years ago

marky1991 commented 3 years ago

I'm trying to implement a gui with a bar along the top and a separate bar along the right side. So I would like something like this:

______________
|_________|  |
|         |  |
|_________|_ |

(hopefully my ascii art doesn't get mangled) So when going to implement this design, one obvious approach is to design it as a grid, with 2 rows and 2 columns. The top bar would simply go in (1,1), but the right bar would need to extend from (1 to 2, 2). This doesn't seem possible presently. It would be nice if grid supported this.

Lacking this functionality, the simplest approach seems to be to fall back on Board and just place the two bars relative to the top left, but this approach is also hitting issues. Any other suggestions on implementing this ui would be great if I"m missing something simple.

marky1991 commented 3 years ago

If it is all helpful, the latest commit on https://hg.sr.ht/~marky1991/eden/ is my attempt at achieving this, though using board instead. (It also doesn't work, complaining about the contents being too big for the GUI, trying to figure out why right now)

kalekundert commented 3 years ago

I'll have to think more closely about how/whether to do this, but a quick comment I can make is that you can get the layout described above by nesting a VBox inside of an HBox. I think that'd be easier and more robust than trying to use Board.

I wasn't able to access the commit you linked (I got a 401 Unauthorized error).

marky1991 commented 3 years ago

I didn't think of that, that's probably a workable solution. I still think that grid supporting this would be nice, but it does seem that all complicated cell-merging designs can probably be implemented as some combination of vboxes and hboxes, so at least it's doable with no changes.

I've since gotten the board strategy to work, though I had to work around lots of things that seemed like bugs (e.g. adding to the board relative to the top left failed when starting from the buttom left worked), though it's possible that I was misunderstanding how the board was supposed to use.

Once I get some time, I'll try to reimplement the gui as suggested and see how that goes.