Unify Application and Program

Instead of creating a separate `multi_window::Program`, the new
`multi_window::Application` unifies both traits
This commit is contained in:
Richard 2022-04-01 17:39:08 -03:00 committed by bungoboingo
parent 287306e1eb
commit b896e41c6e
2 changed files with 36 additions and 22 deletions

View file

@ -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,27 +142,13 @@ pub trait Application: Sized {
struct Instance<A: Application>(A);
impl<A> iced_winit::Program for Instance<A>
where
A: Application,
{
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>
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 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()
}