Merged
Conversation
It can be used to stack elements on top of each other!
5acda41 to
9492da1
Compare
tarkah
reviewed
Apr 25, 2024
| let limits = layout::Limits::new(Size::ZERO, size); | ||
|
|
||
| let nodes = std::iter::once(base) | ||
| .chain(self.children[1..].iter().zip(&mut tree.children[1..]).map( |
Member
There was a problem hiding this comment.
Possible index error? We only check is_empty
Member
Author
There was a problem hiding this comment.
It'll just return an empty slice, which is what we want.
Member
There was a problem hiding this comment.
How did I not know this? I guess the spread operator here protects it
Member
Author
There was a problem hiding this comment.
Yep, it's a range equivalent to 1..self.children.len(). Thus, empty with a single child.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR implements a simple
Stackwidget that can be used to display elements on top of each other.The
Stackuses the first element as its base layer and every consecutive element is displayed on top of the previous one. The base element defines the intrinsic size of theStack, so the elements on top can easily position themselves using other existing widgets (e.g.container).Like
columnandrow, it comes with both its function and macro helpers.The
bezier_toolexample showcases how we can use this new widget to show the "Clear" button at the top right corner of theCanvas:This produces (amazing art not included!):