-
Notifications
You must be signed in to change notification settings - Fork 566
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
Introducing intrinsics #2172
Introducing intrinsics #2172
Conversation
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.
Here's a review of this PR; once we've talked through these suggestions, I'll be happy to review again and approve for merging. I'm excited to have this functionality.
I do wonder - is 'max' redundant in the function names? As we've defined it, the intrinsic width is width a widget wishes to be if it has no width constraint - max or min, given the height constraint it has, and vice-versa for height... I'm not sure it's a maximum or a minimum?
@Zarenor I agree with your naming suggestions. Actually, anything than what I have makes sense. Im horrible at naming. |
I forgot to address this point
|
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.
Nice! I only have nitpicking things left. I think @Zarenor was also taking a look so I'm not marking as "Approved" just yet, but it looks fine to me.
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.
Looks good to me! Excited to have this feature implemented.
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.
I did a quick review for some polish. I didn't really do deep analysis of the algorithms though.
Most of my comments are about use
import ordering. Sorry about that. I would love to have this automated in the future. There has been a rustfmt proposal for this since 2018 but nobody has invested the time to get it fully done yet. There does seem to be some progress in that rustfmt now has a group_imports option, but it's still unstable. I'll see if we can have a better solution to this, or at least some sort of style guide document. But yeah, for now just remember that the general grouping/ordering of imports should be:
use std::foo;
use some_extrnal_crate::foo;
use crate::my_foo;
Please also add a changelog entry. |
I'll also add for the record, that for me personally So I don't think this is a blocker to get this merged. We can bikeshed over the name later, perhaps as part of the Xilem API rework. |
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.
Thanks for your continued effort to get this in!
This PR adds
compute_max_intrinsic
function toWidget
trait. Along with the usuallayout
params, this method also takes anAxis
param that controls which intrinsic is expected.Axis::Horizontal
= Max width intrinsic is expected.Axis::Vertical
= Max height intrinsic is expected.Each widget gets to decide what its intrinsic max width/height is.
For some non-container widgets like
Label
it is the width the label would take without any line breaks.For container widget like
AspectRatioBox
it depends on its width/height irrespective of child's intrinsic width/height. Child's intrinsic is calculated only ifAspectRatioBox
width/height is infinite.There are sometodo
s Im planning to fix before I mark this ready for review. But I wanted to get other main points across with this draft PR.Addressed all
todo
s.