diff options
author | 2020-05-21 04:27:31 +0200 | |
---|---|---|
committer | 2020-05-21 04:27:31 +0200 | |
commit | ae5e2c6c734894d71b2034a498a858b7997c5d3d (patch) | |
tree | 19d416e08287542fc17496ab58d2d16d6704a6e6 /src/application.rs | |
parent | d77492c0c37dec1207049b340a318e263cb96b82 (diff) | |
download | iced-ae5e2c6c734894d71b2034a498a858b7997c5d3d.tar.gz iced-ae5e2c6c734894d71b2034a498a858b7997c5d3d.tar.bz2 iced-ae5e2c6c734894d71b2034a498a858b7997c5d3d.zip |
Introduce `Program` and `State`
Diffstat (limited to 'src/application.rs')
-rw-r--r-- | src/application.rs | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/application.rs b/src/application.rs index 644a4824..b6f2227e 100644 --- a/src/application.rs +++ b/src/application.rs @@ -198,10 +198,11 @@ pub trait Application: Sized { ..iced_glow::Settings::default() }; - <Instance<Self> as iced_glutin::Application>::run( - settings.into(), - glow_settings, - ); + iced_glutin::application::run::< + Instance<Self>, + Self::Executor, + iced_glow::window::Compositor, + >(settings.into(), glow_settings); } #[cfg(target_arch = "wasm32")] @@ -212,14 +213,28 @@ pub trait Application: Sized { struct Instance<A: Application>(A); #[cfg(not(target_arch = "wasm32"))] +impl<A> iced_glutin::Program for Instance<A> +where + A: Application, +{ + type Renderer = iced_glow::Renderer; + type Message = A::Message; + + fn update(&mut self, message: Self::Message) -> Command<Self::Message> { + self.0.update(message) + } + + fn view(&mut self) -> Element<'_, Self::Message> { + self.0.view() + } +} + +#[cfg(not(target_arch = "wasm32"))] impl<A> iced_glutin::Application for Instance<A> where A: Application, { - type Compositor = iced_glow::window::Compositor; - type Executor = A::Executor; type Flags = A::Flags; - type Message = A::Message; fn new(flags: Self::Flags) -> (Self, Command<A::Message>) { let (app, command) = A::new(flags); @@ -238,17 +253,9 @@ where } } - fn update(&mut self, message: Self::Message) -> Command<Self::Message> { - self.0.update(message) - } - fn subscription(&self) -> Subscription<Self::Message> { self.0.subscription() } - - fn view(&mut self) -> Element<'_, Self::Message> { - self.0.view() - } } #[cfg(target_arch = "wasm32")] |