Skip to content

FlexboxLayout: fix too-short auto-sized window with a nested flexbox - #12811

Open
dfaure-kdab wants to merge 2 commits into
slint-ui:masterfrom
dfaure-kdab:wip/dfaure/too-short-autosized-window
Open

FlexboxLayout: fix too-short auto-sized window with a nested flexbox#12811
dfaure-kdab wants to merge 2 commits into
slint-ui:masterfrom
dfaure-kdab:wip/dfaure/too-short-autosized-window

Conversation

@dfaure-kdab

Copy link
Copy Markdown
Collaborator

FlexboxLayout: fix too-short auto-sized window with a nested flexbox

The window height comes from the root's vertical layout info at the
preferred width. That cross-axis info path ran taffy without a measure
callback, so a nested wrapping flexbox cell kept the height pre-measured
at the container width instead of the width taffy assigns it (its own
preferred width, where it wraps to more lines).

  • add flexbox_layout_info_cross_axis_with_measure and pass the same
    measure callback the solve path uses (interpreter only for now)
  • a (None, None) measure must return a self-consistent pair (the height
    at the returned width): taffy passes the assigned width in a later
    query, but serves it from its measure cache when the width matches the
    earlier probe's result, reusing the probe's stale height
  • only re-measure height-for-width builtins through the Item vtable;
    for others it returns trivial info and would drop element-level
    constraints like preferred-height

The generated-code info path has no measure callback yet, so the new test is ignored for rust and cpp
(will be fixed in a followup PR).

Easier to review the two commits separately, the first one is a no-op refactoring for code reuse.

No behavior change: move ChildElem, the child-element collection, and the
measure body out of solve_flexbox_layout into module-level functions, so
an upcoming change can reuse them for the layout-info path.
The window height comes from the root's vertical layout info at the
preferred width. That cross-axis info path ran taffy without a measure
callback, so a nested wrapping flexbox cell kept the height pre-measured
at the container width instead of the width taffy assigns it (its own
preferred width, where it wraps to more lines).

- add flexbox_layout_info_cross_axis_with_measure and pass the same
  measure callback the solve path uses (interpreter only for now)
- a (None, None) measure must return a self-consistent pair (the height
  at the returned width): taffy passes the assigned width in a later
  query, but serves it from its measure cache when the width matches the
  earlier probe's result, reusing the probe's stale height
- only re-measure height-for-width builtins through the Item vtable;
  for others it returns trivial info and would drop element-level
  constraints like preferred-height

The generated-code info path has no measure callback yet, so the new
test is ignored for rust and cpp.
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