Introduce Shell type in iced_native

Widgets now can invalidate the current layout of the application on demand.
This commit is contained in:
Héctor Ramón Jiménez 2021-11-29 16:22:01 +07:00
parent f7792d89d6
commit bbd9355450
No known key found for this signature in database
GPG key ID: 140CC052C94F138E
26 changed files with 218 additions and 130 deletions

View file

@ -8,7 +8,7 @@ use crate::renderer;
use crate::touch;
use crate::{
Background, Clipboard, Color, Element, Hasher, Layout, Length, Point,
Rectangle, Size, Widget,
Rectangle, Shell, Size, Widget,
};
use std::hash::Hash;
@ -191,7 +191,7 @@ where
cursor_position: Point,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
messages: &mut Vec<Message>,
shell: &mut Shell<'_, Message>,
) -> event::Status {
let is_dragging = self.state.is_dragging;
@ -220,7 +220,7 @@ where
};
if (self.value.into() - new_value.into()).abs() > f64::EPSILON {
messages.push((self.on_change)(new_value));
shell.publish((self.on_change)(new_value));
self.value = new_value;
}
@ -241,7 +241,7 @@ where
| Event::Touch(touch::Event::FingerLost { .. }) => {
if is_dragging {
if let Some(on_release) = self.on_release.clone() {
messages.push(on_release);
shell.publish(on_release);
}
self.state.is_dragging = false;