summaryrefslogtreecommitdiffstats
path: root/native/src/shell.rs
diff options
context:
space:
mode:
Diffstat (limited to 'native/src/shell.rs')
-rw-r--r--native/src/shell.rs20
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
}
}