[Feature Request] Grid Layout
I think this could be cool to have a grid layout as it's a layout "often" used in GUI apps.
@JulienLecoq Definitely agree! I think there's certainly a Grid and/or Table layout that would work well with the other features in clay.
For transparency around my priorities at the moment:
- Debug Tooling (https://github.com/nicbarker/clay/pull/15) - should ship today or tomorrow
- Zig bindings
- A "wrapping" container - think something like
flex-wrapin CSS. This is pretty important as it blocks the creation of "rich text", clickable links in text paragraphs etc. - Grid or table view
So likely it'll be a month or two before it starts to get looked at 🙂
I wrote an algorithm a few years ago for masonry layouts (grids where each element has fixed width but variable height, like a photo gallery with different aspect ratios ) that I haven't seen anywhere even in CSS: it solves a problem that if you have a particular ordering in mind (like search results, most relevant to least relevant), the algorithm CSS uses places the next object on the shortest column but that sometimes breaks the logical flow (see https://youtu.be/W91Wst6fMNU?t=447)
I don't know C, would it be at all useful to propose the algorithm in pseudocode or python?
I am really looking forward to Clay getting a grid layouting tool!
Would it have row/column spanning, too?
There are two possible approached to this, each of which has its own benefits and usecases:
- Simple grid layout where children are arranged in a grid as they are added.
- Width constraints on the children of multiple sibling elements.
In our game, we currently use the former, and then have a ton of hacky logic in a subclass (TableWithSelection) which implements the ability to "select" rows with the cursor and sort them:
But this is quite inflexible and error-prone. If we could instead have separate widgets for each row, whose children's min/max sizing is constrained based on the children of the sibling elements, then one could implement much more flexible behaviors on each row without being hardcoded to a single "selection" paradigm. This could also allow the insertion of rows whose children are not constrained, allowing for much more flexible layouts:
(apologies for the crude drawing)
In this example, the green rows have their children width-constrained so that they match one another, but the red row does not apply these constraints, allowing its children to have whatever sizes they wish.
The simple usecase of adding children to a container and that container laying them out in a grid is definitely the priority, but I would also love to see this alternative approach that could live alongside the traditional grid.
@raiguard is Factorio switching to Clay?
No, I just used it as an example.
Any news about this? Is wrapping support still planned to be added to Clay?