Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LayoutComponent shrink wrapping #3509

Open
1 task done
livtanong opened this issue Feb 25, 2025 · 1 comment
Open
1 task done

LayoutComponent shrink wrapping #3509

livtanong opened this issue Feb 25, 2025 · 1 comment
Assignees

Comments

@livtanong
Copy link
Contributor

livtanong commented Feb 25, 2025

Problem to solve

In situations where you need a linear list of elements (which you would use LayoutComponent for) but would prefer this list to expand or shrink as defined by its children, the current experimental LayoutComponent is insufficient.

For example, a long scrollable list (expanding) or a short list that is centered (shrinking)

The calculation of inherent size is not a problem: it can be determined by iterating over the children, and taking into consideration the direction of the layout, the various alignment settings, and the gaps. The tricky part is in deciding when to perform this calculation, and when not to.

To wit: setting size automatically triggers a layout. If the layout itself calculates the inherent size and resizes, it'll trigger layout again, and we end up with a stack overflow.

Proposal

Add an encapsulated boolean property: shrinkWrap, defaulting to false.

Add a function syncSizeListener, which adds layoutChildren as a size listener, if shrinkWrap is false, and removes it otherwise.

In both the constructor body and the setter for shrinkWrap, call syncSizeListener.

More information

Related to #1944

Other

  • Are you interested in working on a PR for this?
@spydon
Copy link
Member

spydon commented Feb 26, 2025

Sounds good! I'll assign you to the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants