Add the LifeCycle::Size event.#953
Merged
xStrom merged 1 commit intolinebender:masterfrom May 17, 2020
Merged
Conversation
luleyleo
approved these changes
May 17, 2020
Collaborator
luleyleo
left a comment
There was a problem hiding this comment.
Looks good, there seems to be a leftover typo in the docs you've edited.
cmyr
reviewed
May 17, 2020
Member
cmyr
left a comment
There was a problem hiding this comment.
Just some observations, no change necessary
| pub fn set_layout_rect(&mut self, ctx: &mut LayoutCtx, data: &T, env: &Env, layout_rect: Rect) { | ||
| let mut needs_merge = false; | ||
|
|
||
| let old_size = self.state.layout_rect.map(|r| r.size()); |
Member
There was a problem hiding this comment.
surprised clippy didn't want .map(Rect::size).
| let old_size = self.state.layout_rect.map(|r| r.size()); | ||
| let new_size = layout_rect.size(); | ||
|
|
||
| self.state.layout_rect = Some(layout_rect); |
Member
There was a problem hiding this comment.
this feels like an opportunity for Option::replace, maybe.
|
|
||
| self.state.layout_rect = Some(layout_rect); | ||
|
|
||
| if old_size.is_none() || old_size.unwrap() != new_size { |
Member
There was a problem hiding this comment.
and I'd have written this as if old_size != Some(new_size), probably
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.
There have been several occurrences now where a widget would like to know when its size changes and do some non-layout work. This was disccused in zulip and this would also help solve an animation issue with the
Scrollwidget as explained in #834.Thus this PR adds the
LifeCycle::Sizeevent which gets sent every time the size of the widget changes.