Introduce feature flags to enable iced_glow
Also keep `iced_wgpu` as the default renderer for the time being.
This commit is contained in:
parent
d6bf8955db
commit
22ced3485e
8 changed files with 72 additions and 35 deletions
|
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
29
src/lib.rs
29
src/lib.rs
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue