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

@ -11,7 +11,7 @@ use crate::text::{self, Text};
use crate::touch;
use crate::{
Clipboard, Element, Hasher, Layout, Length, Padding, Point, Rectangle,
Size, Widget,
Shell, Size, Widget,
};
use std::borrow::Cow;
@ -245,7 +245,7 @@ where
cursor_position: Point,
_renderer: &Renderer,
_clipboard: &mut dyn Clipboard,
messages: &mut Vec<Message>,
shell: &mut Shell<'_, Message>,
) -> event::Status {
match event {
Event::Mouse(mouse::Event::ButtonPressed(mouse::Button::Left))
@ -271,7 +271,7 @@ where
};
if let Some(last_selection) = self.last_selection.take() {
messages.push((self.on_selected)(last_selection));
shell.publish((self.on_selected)(last_selection));
*self.is_open = false;
@ -312,7 +312,7 @@ where
};
if let Some(next_option) = next_option {
messages.push((self.on_selected)(next_option.clone()));
shell.publish((self.on_selected)(next_option.clone()));
}
event::Status::Captured