Skip to content

Comments

GridLayout: implement support for nested for statements#10842

Open
dfaure-kdab wants to merge 2 commits intoslint-ui:masterfrom
dfaure-kdab:wip/dfaure/nested-for
Open

GridLayout: implement support for nested for statements#10842
dfaure-kdab wants to merge 2 commits intoslint-ui:masterfrom
dfaure-kdab:wip/dfaure/nested-for

Conversation

@dfaure-kdab
Copy link
Collaborator

This involved introducing a new way to access the caches (organization cache and coordinate cache), called GridRowCacheAccess, with two indices at runtime (row and column) instead of one.

Since the common case is that all rows have the same amount of columns, the cache is based on that assumption, and the generated code ensures that this is always the case, taking the max() of all rows and adding "padding cells" where needed. This allows to do direct jumps in the 2D parts of the cache, without needing a per-row jump table.

Fixes #10670

This involved introducing a new way to access the caches
(organization cache and coordinate cache), called GridRowCacheAccess,
with two indices at runtime (row and column) instead of one.

Since the common case is that all rows have the same amount
of columns, the cache is based on that assumption, and the generated
code ensures that this is always the case, taking the max() of all rows
and adding "padding cells" where needed. This allows to do direct
jumps in the 2D parts of the cache, without needing a per-row jump
table.

Fixes slint-ui#10670
Visually, it looks exactly like grid-with-repeated-rows.slint
but the model is an array of arrays instead of being an array of
structs.
@dfaure-kdab dfaure-kdab force-pushed the wip/dfaure/nested-for branch from 51aa27d to b5b41ec Compare February 20, 2026 22:05
@tronical
Copy link
Member

image

🤓

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.

GridLayout with nested for

2 participants