diff options
author | 2020-05-27 05:05:13 +0200 | |
---|---|---|
committer | 2020-05-27 05:05:13 +0200 | |
commit | 22ced3485eb6f295faaab1e31d8d1b8d61fc422b (patch) | |
tree | 5dde16d8a4a161995800acc482c13fc8dc697639 /src | |
parent | d6bf8955dbca03898e379aae376d91677bb4d223 (diff) | |
download | iced-22ced3485eb6f295faaab1e31d8d1b8d61fc422b.tar.gz iced-22ced3485eb6f295faaab1e31d8d1b8d61fc422b.tar.bz2 iced-22ced3485eb6f295faaab1e31d8d1b8d61fc422b.zip |
Introduce feature flags to enable `iced_glow`
Also keep `iced_wgpu` as the default renderer for the time being.
Diffstat (limited to 'src')
-rw-r--r-- | src/application.rs | 24 | ||||
-rw-r--r-- | src/element.rs | 2 | ||||
-rw-r--r-- | src/lib.rs | 29 | ||||
-rw-r--r-- | src/settings.rs | 8 | ||||
-rw-r--r-- | src/widget.rs | 15 |
5 files changed, 49 insertions, 29 deletions
diff --git a/src/application.rs b/src/application.rs index b6f2227e..19cab7da 100644 --- a/src/application.rs +++ b/src/application.rs @@ -188,21 +188,21 @@ pub trait Application: Sized { { #[cfg(not(target_arch = "wasm32"))] { - let glow_settings = iced_glow::Settings { + let renderer_settings = crate::renderer::Settings { default_font: settings.default_font, antialiasing: if settings.antialiasing { - Some(iced_glow::settings::Antialiasing::MSAAx4) + Some(crate::renderer::settings::Antialiasing::MSAAx4) } else { None }, - ..iced_glow::Settings::default() + ..crate::renderer::Settings::default() }; - iced_glutin::application::run::< + crate::runtime::application::run::< Instance<Self>, Self::Executor, - iced_glow::window::Compositor, - >(settings.into(), glow_settings); + crate::renderer::window::Compositor, + >(settings.into(), renderer_settings); } #[cfg(target_arch = "wasm32")] @@ -213,11 +213,11 @@ pub trait Application: Sized { struct Instance<A: Application>(A); #[cfg(not(target_arch = "wasm32"))] -impl<A> iced_glutin::Program for Instance<A> +impl<A> iced_winit::Program for Instance<A> where A: Application, { - type Renderer = iced_glow::Renderer; + type Renderer = crate::renderer::Renderer; type Message = A::Message; fn update(&mut self, message: Self::Message) -> Command<Self::Message> { @@ -230,7 +230,7 @@ where } #[cfg(not(target_arch = "wasm32"))] -impl<A> iced_glutin::Application for Instance<A> +impl<A> crate::runtime::Application for Instance<A> where A: Application, { @@ -246,10 +246,10 @@ where self.0.title() } - fn mode(&self) -> iced_glutin::Mode { + fn mode(&self) -> iced_winit::Mode { match self.0.mode() { - window::Mode::Windowed => iced_glutin::Mode::Windowed, - window::Mode::Fullscreen => iced_glutin::Mode::Fullscreen, + window::Mode::Windowed => iced_winit::Mode::Windowed, + window::Mode::Fullscreen => iced_winit::Mode::Fullscreen, } } diff --git a/src/element.rs b/src/element.rs index e7504615..6f47c701 100644 --- a/src/element.rs +++ b/src/element.rs @@ -3,7 +3,7 @@ /// This is an alias of an `iced_native` element with a default `Renderer`. #[cfg(not(target_arch = "wasm32"))] pub type Element<'a, Message> = - iced_glutin::Element<'a, Message, iced_glow::Renderer>; + crate::runtime::Element<'a, Message, crate::renderer::Renderer>; #[cfg(target_arch = "wasm32")] pub use iced_web::Element; @@ -197,6 +197,29 @@ pub mod window; #[cfg_attr(docsrs, doc(cfg(any(feature = "tokio", feature = "async-std"))))] pub mod time; +#[cfg(all( + not(target_arch = "wasm32"), + not(feature = "glow"), + feature = "wgpu" +))] +use iced_winit as runtime; + +#[cfg(all(not(target_arch = "wasm32"), feature = "glow"))] +use iced_glutin as runtime; + +#[cfg(all( + not(target_arch = "wasm32"), + not(feature = "glow"), + feature = "wgpu" +))] +use iced_wgpu as renderer; + +#[cfg(all(not(target_arch = "wasm32"), feature = "glow"))] +use iced_glow as renderer; + +#[cfg(target_arch = "wasm32")] +use iced_web as runtime; + #[doc(no_inline)] pub use widget::*; @@ -206,12 +229,6 @@ pub use executor::Executor; pub use sandbox::Sandbox; pub use settings::Settings; -#[cfg(not(target_arch = "wasm32"))] -use iced_glutin as runtime; - -#[cfg(target_arch = "wasm32")] -use iced_web as runtime; - pub use runtime::{ futures, Align, Background, Color, Command, Font, HorizontalAlignment, Length, Point, Rectangle, Size, Subscription, Vector, VerticalAlignment, diff --git a/src/settings.rs b/src/settings.rs index 36685763..01ad0ee0 100644 --- a/src/settings.rs +++ b/src/settings.rs @@ -51,10 +51,10 @@ impl<Flags> Settings<Flags> { } #[cfg(not(target_arch = "wasm32"))] -impl<Flags> From<Settings<Flags>> for iced_glutin::Settings<Flags> { - fn from(settings: Settings<Flags>) -> iced_glutin::Settings<Flags> { - iced_glutin::Settings { - window: iced_glutin::settings::Window { +impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> { + fn from(settings: Settings<Flags>) -> iced_winit::Settings<Flags> { + iced_winit::Settings { + window: iced_winit::settings::Window { size: settings.window.size, resizable: settings.window.resizable, decorations: settings.window.decorations, diff --git a/src/widget.rs b/src/widget.rs index eebf5f2a..3e4d4788 100644 --- a/src/widget.rs +++ b/src/widget.rs @@ -18,25 +18,28 @@ //! [`text_input::State`]: text_input/struct.State.html #[cfg(not(target_arch = "wasm32"))] mod platform { - pub use iced_glow::widget::{ + pub use crate::renderer::widget::{ button, checkbox, container, pane_grid, progress_bar, radio, scrollable, slider, text_input, Column, Row, Space, Text, }; - #[cfg(feature = "canvas")] - #[cfg_attr(docsrs, doc(cfg(feature = "canvas")))] - pub use iced_glow::widget::canvas; + #[cfg(any(feature = "canvas", feature = "glow_canvas"))] + #[cfg_attr( + docsrs, + doc(cfg(any(feature = "canvas", feature = "glow_canvas"))) + )] + pub use crate::renderer::widget::canvas; #[cfg_attr(docsrs, doc(cfg(feature = "image")))] pub mod image { //! Display images in your user interface. - pub use iced_glutin::image::{Handle, Image}; + pub use crate::runtime::image::{Handle, Image}; } #[cfg_attr(docsrs, doc(cfg(feature = "svg")))] pub mod svg { //! Display vector graphics in your user interface. - pub use iced_glutin::svg::{Handle, Svg}; + pub use crate::runtime::svg::{Handle, Svg}; } #[doc(no_inline)] |