linebender / xilem

An experimental Rust native UI framework
Apache License 2.0
3.66k stars 115 forks source link

Implement `VerticalList` widget #607

Open PoignardAzur opened 1 month ago

PoignardAzur commented 1 month ago

Currently, people who want to create a new container widget look at the Flex widget for inspiration. That implementation is fairly complex, and not a great introduction for newcomers.

We should implement a container widget with a little code as possible. This widget would display its children vertically with a fixed amount of free space between them. It would have no customization parameters aside from that spacing constant. Its implementation would serve as a guide for people implementing custom widgets.

There should be non-doc comments in other widget files pointing newcomers to the VerticalList implementation.

To make sure the implementation doesn't bit-rot, we should:

DJMcNab commented 1 month ago

What is the use-case for this widget outside of this demonstration?

That is, could this instead be a masonry example? (examples can have tests, if they have test = true set on them)

PoignardAzur commented 1 month ago

I guess it could.

I think having it in the main widget folder would be better for discoverability, though.

Philipp-M commented 1 month ago

Yeah my first thought was also, that this may just be an example for masonry and possibly xilem as well, like a custom widget with children.

I think having it in the main widget folder would be better for discoverability, though.

I think regarding this, we should probably just start with proper (high-level) documentation.

jaredoconnell commented 1 month ago

This was partially my intention with the grid widget. I kept it as simple as possible so that it can be used as an example widget for layouts. It's literally a quarter the size of the Flex widget, and I added more documentation.

If you want to add a VerticalList widget, I think VerticalStack may be a more appropriate name. It helps differentiate it from the VirtualList, clarifying that you need to put it in a portal for scrolling, as it just stacks things vertically.