diff options
author | 2022-04-01 17:39:08 -0300 | |
---|---|---|
committer | 2023-01-09 11:27:04 -0800 | |
commit | b896e41c6e03f1447419194ce41d15fb0db39d96 (patch) | |
tree | bf2717e9a880a0f78e0151890d0c9a27525bdb06 /src | |
parent | 287306e1ebec610c31e37782320fe00d20a6c9ac (diff) | |
download | iced-b896e41c6e03f1447419194ce41d15fb0db39d96.tar.gz iced-b896e41c6e03f1447419194ce41d15fb0db39d96.tar.bz2 iced-b896e41c6e03f1447419194ce41d15fb0db39d96.zip |
Unify `Application` and `Program`
Instead of creating a separate `multi_window::Program`, the new
`multi_window::Application` unifies both traits
Diffstat (limited to '')
-rw-r--r-- | src/multi_window/application.rs | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/multi_window/application.rs b/src/multi_window/application.rs index db41d54a..fa0c15b1 100644 --- a/src/multi_window/application.rs +++ b/src/multi_window/application.rs @@ -132,7 +132,7 @@ pub trait Application: Sized { ..crate::renderer::Settings::from_env() }; - Ok(crate::runtime::application::run::< + Ok(crate::runtime::multi_window::run::< Instance<Self>, Self::Executor, crate::renderer::window::Compositor<Self::Theme>, @@ -142,28 +142,14 @@ pub trait Application: Sized { struct Instance<A: Application>(A); -impl<A> iced_winit::Program for Instance<A> +impl<A> crate::runtime::multi_window::Application for Instance<A> where A: Application, { + type Flags = A::Flags; type Renderer = crate::Renderer<A::Theme>; type Message = A::Message; - fn update(&mut self, message: Self::Message) -> Command<Self::Message> { - self.0.update(message) - } - - fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { - self.0.view() - } -} - -impl<A> crate::runtime::Application for Instance<A> -where - A: Application, -{ - type Flags = A::Flags; - fn new(flags: Self::Flags) -> (Self, Command<A::Message>) { let (app, command) = A::new(flags); @@ -174,6 +160,14 @@ where self.0.title() } + fn update(&mut self, message: Self::Message) -> Command<Self::Message> { + self.0.update(message) + } + + fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { + self.0.view() + } + fn theme(&self) -> A::Theme { self.0.theme() } |