-
Notifications
You must be signed in to change notification settings - Fork 110
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
Enable correct image measure functions #661
Conversation
81be7ca
to
d3a2c11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a while since I looked at complex rust code & spent time looking at taffy so I'm a bit rusty, pun intended.
The code looks good, clean and structured 👍
The high level changes makes sense to me, as well as making the Maybe / Resolve
traits public.
I think the only thing missing may be an example showcasing how or when you would use this in practice, but that may also be part of a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Surprisingly many changes necessary, but it does make sense (and I suppose a lot of it is just docs reformatting).
Just to make sure I understand correctly: The measure function is only used (or rather, defined) by the clients like bevy, right?
I'm happy with the overall fix here. I'll let you handle the release process by default, but let me know if you'd like a hand at any point :) |
…zes (#13555) # Objective - Fixes #13155 - fixes #13517 - Supercedes #13381 - Requires DioxusLabs/taffy#661 ## Solution - Taffy has been updated to: - Apply size styles to absolutely positioned children - Pass the node's `Style` through to the measure function - Bevy's image measure function has been updated to make use of this style information ## Notes - This is currently using a git version of Taffy. If this is tested as fixing the issue then we can turn that into a Taffy 0.5 release (this would be the only change between Taffy 0.4 and Taffy 0.5 so upgrading is not expected to be an issue) - This implementation may not be completely correct. I would have preferred to extend Taffy's gentest infrastructure to handle images and used that to nail down the correct behaviour. But I don't have time for that atm so we'll have to iterate on this in future. This PR at least puts that under Bevy's control. ## Testing - I manually tested the game_menu_example (from #13155) - More testing is probably merited --- ## Changelog No changelog should be required as it fixes a regression on `main` that was not present in bevy 0.13. The changelog for "Taffy upgrade" may want to be changed from 0.4 to 0.5 if this change gets merged. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: François Mockers <francois.mockers@vleue.com>
Objective
Allow image measure functions to correctly apply their inherent aspect ratio to style sizes.
Context
Changes made
SizingMode::Inherent
when sizing absolute children of flexbox nodes. This basically turns on application of styles which is what we want.style: &Style
into measure functions. This allows measure functions to access a node's styles which is necessary if they are to apply their aspect ratio to those styles.MaybeMath
,MaybeResolve
andResolveOrZero
traits public. These were previously private to keep Taffy's API surface area smaller, but they're very useful when implementing the image measure function as above.Notes
Display::Replaced
mode that knows about aspect ratios). This is the quick fix targeting the upcoming Bevy 0.14 release.known_size
but this breaks some other use cases that I can't remember right now)