diff options
author | 2022-01-13 15:42:40 +0700 | |
---|---|---|
committer | 2022-01-13 15:42:40 +0700 | |
commit | 15a13a76b4b0534d08afc0328b90267048e41b9d (patch) | |
tree | dd5fa045c9fd3f8f116f230c3e70dcba2d32d011 /native/src/shell.rs | |
parent | 1a31aefab401712e44cd613fc1337ab90579d926 (diff) | |
parent | f6c436aec1acb674078bf7e878b9e49f28e947a7 (diff) | |
download | iced-15a13a76b4b0534d08afc0328b90267048e41b9d.tar.gz iced-15a13a76b4b0534d08afc0328b90267048e41b9d.tar.bz2 iced-15a13a76b4b0534d08afc0328b90267048e41b9d.zip |
Merge pull request #1193 from iced-rs/responsive-widget
`Responsive` widget
Diffstat (limited to 'native/src/shell.rs')
-rw-r--r-- | native/src/shell.rs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/native/src/shell.rs b/native/src/shell.rs index e916f52d..4a0aa9c6 100644 --- a/native/src/shell.rs +++ b/native/src/shell.rs @@ -8,6 +8,7 @@ pub struct Shell<'a, Message> { messages: &'a mut Vec<Message>, is_layout_invalid: bool, + are_widgets_invalid: bool, } impl<'a, Message> Shell<'a, Message> { @@ -16,12 +17,13 @@ impl<'a, Message> Shell<'a, Message> { Self { messages, is_layout_invalid: false, + are_widgets_invalid: false, } } /// Triggers the given function if the layout is invalid, cleaning it in the /// process. - pub fn with_invalid_layout(&mut self, f: impl FnOnce()) { + pub fn revalidate_layout(&mut self, f: impl FnOnce()) { if self.is_layout_invalid { self.is_layout_invalid = false; @@ -41,6 +43,13 @@ impl<'a, Message> Shell<'a, Message> { self.is_layout_invalid = true; } + /// Invalidates the current application widgets. + /// + /// The shell will rebuild and relayout the widget tree. + pub fn invalidate_widgets(&mut self) { + self.are_widgets_invalid = true; + } + /// Merges the current [`Shell`] with another one by applying the given /// function to the messages of the latter. /// @@ -50,5 +59,14 @@ impl<'a, Message> Shell<'a, Message> { self.is_layout_invalid = self.is_layout_invalid || other.is_layout_invalid; + + self.are_widgets_invalid = + self.are_widgets_invalid || other.are_widgets_invalid; + } + + /// Returns whether the widgets of the current application have been + /// invalidated. + pub fn are_widgets_invalid(&self) -> bool { + self.are_widgets_invalid } } |