Skip to content

Iterative stretch allocation and cross-stretch fix - #40

Merged
geom3trik merged 2 commits into
mainfrom
rtl-fix
Jun 16, 2026
Merged

geom3trik merged 2 commits into
mainfrom
rtl-fix

Conversation

@geom3trik

Copy link
Copy Markdown
Collaborator

Implement an iterative stretch allocation algorithm for main-axis stretch children: introduce a StretchAlloc record, track remaining_main and remaining_stretch_sum, and freeze items that hit min/max to re-distribute space until settled, then measure children with their computed sizes. Change cross-axis stretch resolution to a two-pass approach (resolve against current estimate, then against the settled line max) using helper closures so cross-stretch children properly adopt the line's final cross size even when min/max constraints determine it. Minor absolute-positioning cleanup: use is_rtl consistently and simplify cross_before/after selection. Tests updated: remove one RTL absolute test and add multiple wrap tests that validate stretch behavior across lines, parent padding, and large min constraints.

Implement an iterative stretch allocation algorithm for main-axis stretch children: introduce a StretchAlloc record, track remaining_main and remaining_stretch_sum, and freeze items that hit min/max to re-distribute space until settled, then measure children with their computed sizes. Change cross-axis stretch resolution to a two-pass approach (resolve against current estimate, then against the settled line max) using helper closures so cross-stretch children properly adopt the line's final cross size even when min/max constraints determine it. Minor absolute-positioning cleanup: use is_rtl consistently and simplify cross_before/after selection. Tests updated: remove one RTL absolute test and add multiple wrap tests that validate stretch behavior across lines, parent padding, and large min constraints.
Separate RTL checks for row vs column and apply mirroring to the correct axis. Introduce is_column_rtl and use is_row_rtl for main-axis swaps and is_column_rtl for cross-axis swaps when computing absolute child offsets, so only horizontal offsets are mirrored in RTL layouts. Added a clarifying comment and adjusted variable names accordingly.

Update layout.rs
@geom3trik
geom3trik merged commit 44f7236 into main Jun 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant