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

Pass cross-axis known_dimension when computing flex item min size #545

Merged

Conversation

nicoburns
Copy link
Collaborator

@nicoburns nicoburns commented Oct 2, 2023

Objective

Fixes bevyengine/bevy#9841

Pass cross-axis known_dimension when computing flex item min size
(fixes sizing of children that have inherent aspect ratio (e.g. images))

Context

I would like to add a gentest for this case. However, it requires extending the gentest harness to handle images, and I would like to avoid conflicts with #490 which also modifies that harness (and I suspect would be a pain to rebase on top of other changes). So I propose to create an issue (#546) for the test, merge just the fix, and then add the test once #490 lands.

I also intend to backport this to 0.3.x seeing as it's so small and it has been reported by a Bevy user. So I've stuck the changelog entry under 0.3.14.

Feedback wanted

Does this seem like a reasonable approach?

P.S. The only really meaningful change in this diff is the very bottom line. The rest is just moving code higher up the function to avoid recomputing a value. And removing a redundant .clamp() that was being called on an already-clamped value.

(fixes sizing of children that have inherent aspect ratio (e.g. images))
@nicoburns nicoburns added the bug Something isn't working label Oct 2, 2023
Copy link
Collaborator

@TimJentzsch TimJentzsch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I think it's fine to add the test in a later PR, but we should probably add it before we add a release/backport the fix, to validate that the bug is resolved.

@@ -628,6 +628,7 @@ fn determine_flex_base_size(

// Parent size for child sizing
let cross_axis_parent_size = constants.node_inner_size.cross(dir);
let child_parent_size = Size::NONE.with_cross(dir, cross_axis_parent_size);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really related to this PR, but perhaps we can introduce something like Size::cross in a later PR instead of using this pattern :)

Copy link
Collaborator

@alice-i-cecile alice-i-cecile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; let's add the gen tests in a different PR.

@alice-i-cecile alice-i-cecile merged commit 120bb7a into DioxusLabs:main Oct 2, 2023
17 checks passed
@nicoburns nicoburns deleted the inherent-aspect-ratio-fix-main branch October 2, 2023 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flex does not center the node and node does not respond to height change in window.
3 participants