clay icon indicating copy to clipboard operation
clay copied to clipboard

[Feature Request] Grid Layout

Open JulienLecoq opened this issue 1 year ago • 7 comments

I think this could be cool to have a grid layout as it's a layout "often" used in GUI apps.

JulienLecoq avatar Sep 15 '24 12:09 JulienLecoq

@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:

  1. Debug Tooling (https://github.com/nicbarker/clay/pull/15) - should ship today or tomorrow
  2. Zig bindings
  3. A "wrapping" container - think something like flex-wrap in CSS. This is pretty important as it blocks the creation of "rich text", clickable links in text paragraphs etc.
  4. Grid or table view

So likely it'll be a month or two before it starts to get looked at 🙂

nicbarker avatar Sep 15 '24 21:09 nicbarker

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?

Greedquest avatar Dec 20 '24 20:12 Greedquest

I am really looking forward to Clay getting a grid layouting tool!

Would it have row/column spanning, too?

TechnicJelle avatar Mar 29 '25 00:03 TechnicJelle

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:

Image

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)

Image

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 avatar May 20 '25 20:05 raiguard

@raiguard is Factorio switching to Clay?

BrandonDyer-Disney avatar Jun 23 '25 15:06 BrandonDyer-Disney

No, I just used it as an example.

raiguard avatar Jun 23 '25 17:06 raiguard

Any news about this? Is wrapping support still planned to be added to Clay?

mkeiser avatar Oct 01 '25 08:10 mkeiser