You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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 addslayoutChildren
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
The text was updated successfully, but these errors were encountered: