Merge remote-tracking branch 'origin/master' into feat/multi-window-support

# Conflicts:
#	examples/events/src/main.rs
#	glutin/src/application.rs
#	native/src/window.rs
#	winit/src/window.rs
This commit is contained in:
Bingus 2023-01-18 15:01:17 -08:00
commit 70d487ba20
No known key found for this signature in database
GPG key ID: 5F84D2AA40A9F170
57 changed files with 815 additions and 446 deletions

View file

@ -1,11 +1,12 @@
use iced::alignment;
use iced::executor;
use iced::widget::{button, checkbox, container, text, Column};
use iced::window;
use iced::{
Alignment, Application, Command, Element, Length, Settings, Subscription,
Theme,
};
use iced_native::{window, Event};
use iced_native::Event;
pub fn main() -> iced::Result {
Events::run(Settings {
@ -18,14 +19,13 @@ pub fn main() -> iced::Result {
struct Events {
last: Vec<iced_native::Event>,
enabled: bool,
should_exit: bool,
}
#[derive(Debug, Clone)]
enum Message {
EventOccurred(iced_native::Event),
Toggled(bool),
Exit,
Exit(window::Id),
}
impl Application for Events {
@ -50,31 +50,29 @@ impl Application for Events {
if self.last.len() > 5 {
let _ = self.last.remove(0);
}
Command::none()
}
Message::EventOccurred(event) => {
if let Event::Window(_, window::Event::CloseRequested) = event {
self.should_exit = true;
if let Event::Window(id, window::Event::CloseRequested) = event {
window::close(id)
} else {
Command::none()
}
}
Message::Toggled(enabled) => {
self.enabled = enabled;
}
Message::Exit => {
self.should_exit = true;
}
};
Command::none()
Command::none()
}
Message::Exit(id) => window::close(id),
}
}
fn subscription(&self) -> Subscription<Message> {
iced_native::subscription::events().map(Message::EventOccurred)
}
fn should_exit(&self) -> bool {
self.should_exit
}
fn view(&self) -> Element<Message> {
let events = Column::with_children(
self.last