summaryrefslogtreecommitdiffstats
path: root/lazy
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-11-29 16:22:01 +0700
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2021-11-29 16:22:01 +0700
commitbbd9355450bc2df3a2c0e37cc900ba00b26255af (patch)
treea6cf758c934638e3dd9586781dfb62e1cf028572 /lazy
parentf7792d89d64c39cdde9da030bec80fb6f461a0e3 (diff)
downloadiced-bbd9355450bc2df3a2c0e37cc900ba00b26255af.tar.gz
iced-bbd9355450bc2df3a2c0e37cc900ba00b26255af.tar.bz2
iced-bbd9355450bc2df3a2c0e37cc900ba00b26255af.zip
Introduce `Shell` type in `iced_native`
Widgets now can invalidate the current layout of the application on demand.
Diffstat (limited to 'lazy')
-rw-r--r--lazy/src/component.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/lazy/src/component.rs b/lazy/src/component.rs
index 6d57a2a9..aa5b847e 100644
--- a/lazy/src/component.rs
+++ b/lazy/src/component.rs
@@ -4,7 +4,7 @@ use iced_native::mouse;
use iced_native::overlay;
use iced_native::renderer;
use iced_native::{
- Clipboard, Element, Hasher, Length, Point, Rectangle, Widget,
+ Clipboard, Element, Hasher, Length, Point, Rectangle, Shell, Widget,
};
use ouroboros::self_referencing;
@@ -91,9 +91,10 @@ where
cursor_position: Point,
renderer: &Renderer,
clipboard: &mut dyn Clipboard,
- messages: &mut Vec<Message>,
+ shell: &mut Shell<'_, Message>,
) -> event::Status {
let mut local_messages = Vec::new();
+ let mut local_shell = Shell::new(&mut local_messages);
let event_status =
self.state.as_mut().unwrap().with_cache_mut(|cache| {
@@ -103,7 +104,7 @@ where
cursor_position,
renderer,
clipboard,
- &mut local_messages,
+ &mut local_shell,
)
});
@@ -111,11 +112,12 @@ where
let mut component =
self.state.take().unwrap().into_heads().component;
- messages.extend(
- local_messages
- .into_iter()
- .filter_map(|message| component.update(message)),
- );
+ for message in local_messages
+ .into_iter()
+ .filter_map(|message| component.update(message))
+ {
+ shell.publish(message);
+ }
self.state = Some(
StateBuilder {
@@ -128,7 +130,7 @@ where
.build(),
);
- // TODO: Invalidate layout (!)
+ shell.invalidate_layout();
}
event_status