Add and cleanup new leaf-nodes methods#181
Conversation
|
The breaking change needs a note in RELEASES.md. |
It is, unless you want me to rephrase it more "loudly"? |
alice-i-cecile
left a comment
There was a problem hiding this comment.
This is a much more sensible API!
We should change all of the style argument names to layout while we're here.
| let mut taffy = Taffy::new(); | ||
| let node = taffy | ||
| .new_leaf(FlexboxLayout::default(), MeasureFunc::Raw(|_| Size { width: 200.0, height: 200.0 })) | ||
| .new_leaf_with_measure(FlexboxLayout::default(), MeasureFunc::Raw(|_| Size { width: 200.0, height: 200.0 })) |
There was a problem hiding this comment.
This can be migrated to the new method.
There was a problem hiding this comment.
Would anything with MeasureFunc::Raw(|_| .. ) be a candidate for migration? If the measure func constraints are discarded, it would make sense that it's not used?
There was a problem hiding this comment.
It was this, then two other occurrences of this; however those were specifically testing the MeasureFunc so migrating those does not make sense.
There was a problem hiding this comment.
Update: This test is specifically testing the behaviour of first setting one MeasureFunc, then setting a different, hence this should not be changed.
There was a problem hiding this comment.
Alright, sounds good.
My bad; I'd glossed over this. |
It is a bit of a sneaky change, as the method exists (in the new form) though compiler will complain that you are trying to supply too many arguments. Is the RELEASES good as is or should we add a note that is a bit more clear on this? |
TimJentzsch
left a comment
There was a problem hiding this comment.
I like this, much better than just always providing an empty slice.
In the future I'd really like some kind of building pattern to set the styles and everything, but that could also be done directly on the layout instead of the node itself.
I'm happy with this; the problem was that the Github UI misled my eye since I didn't see RELEASES.md in any of the folders 😅 |
* Rename and add method * formatting * Migrate test to use new method * Rename arguments `style` -> `layout`
Objective
Taffy::new_node()method to add new node without children #180taffy::node::Taffy.new_leaf()which allows the creation of new leaf-nodes without having to supply a measure functiontaffy::node::Taffy.new_leaf()->taffy::node::Taffy.new_leaf_with_measure()