From b896e41c6e03f1447419194ce41d15fb0db39d96 Mon Sep 17 00:00:00 2001 From: Richard Date: Fri, 1 Apr 2022 17:39:08 -0300 Subject: Unify `Application` and `Program` Instead of creating a separate `multi_window::Program`, the new `multi_window::Application` unifies both traits --- src/multi_window/application.rs | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) (limited to 'src/multi_window') 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::Executor, crate::renderer::window::Compositor, @@ -142,28 +142,14 @@ pub trait Application: Sized { struct Instance(A); -impl iced_winit::Program for Instance +impl crate::runtime::multi_window::Application for Instance where A: Application, { + type Flags = A::Flags; type Renderer = crate::Renderer; type Message = A::Message; - fn update(&mut self, message: Self::Message) -> Command { - self.0.update(message) - } - - fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { - self.0.view() - } -} - -impl crate::runtime::Application for Instance -where - A: Application, -{ - type Flags = A::Flags; - fn new(flags: Self::Flags) -> (Self, Command) { let (app, command) = A::new(flags); @@ -174,6 +160,14 @@ where self.0.title() } + fn update(&mut self, message: Self::Message) -> Command { + self.0.update(message) + } + + fn view(&self) -> Element<'_, Self::Message, Self::Renderer> { + self.0.view() + } + fn theme(&self) -> A::Theme { self.0.theme() } -- cgit