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
21
Cargo.toml
21
Cargo.toml
|
@ -12,14 +12,21 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]
|
|||
categories = ["gui"]
|
||||
|
||||
[features]
|
||||
default = ["wgpu"]
|
||||
# Enables the `iced_wgpu` renderer
|
||||
wgpu = ["iced_wgpu"]
|
||||
# Enables the `Image` widget
|
||||
image = ["iced_glow/image"]
|
||||
image = ["iced_wgpu/image"]
|
||||
# Enables the `Svg` widget
|
||||
svg = ["iced_glow/svg"]
|
||||
svg = ["iced_wgpu/svg"]
|
||||
# Enables the `Canvas` widget
|
||||
canvas = ["iced_glow/canvas"]
|
||||
canvas = ["iced_wgpu/canvas"]
|
||||
# Enables the `iced_glow` renderer. Overrides `iced_wgpu`
|
||||
glow = ["iced_glow", "iced_glutin"]
|
||||
# Enables the `Canvas` widget for `iced_glow`
|
||||
glow_canvas = ["iced_glow/canvas"]
|
||||
# Enables a debug view in native platforms (press F12)
|
||||
debug = ["iced_glutin/debug"]
|
||||
debug = ["iced_winit/debug"]
|
||||
# Enables `tokio` as the `executor::Default` on native platforms
|
||||
tokio = ["iced_futures/tokio"]
|
||||
# Enables `async-std` as the `executor::Default` on native platforms
|
||||
|
@ -68,8 +75,10 @@ iced_core = { version = "0.2", path = "core" }
|
|||
iced_futures = { version = "0.1", path = "futures" }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
iced_glutin = { version = "0.1", path = "glutin" }
|
||||
iced_glow = { version = "0.1", path = "glow" }
|
||||
iced_winit = { version = "0.1", path = "winit" }
|
||||
iced_glutin = { version = "0.1", path = "glutin", optional = true }
|
||||
iced_wgpu = { version = "0.2", path = "wgpu", optional = true }
|
||||
iced_glow = { version = "0.1", path = "glow", optional = true}
|
||||
|
||||
[target.'cfg(target_arch = "wasm32")'.dependencies]
|
||||
iced_web = { version = "0.2", path = "web" }
|
||||
|
|
|
@ -9,6 +9,7 @@ repository = "https://github.com/hecrj/iced"
|
|||
|
||||
[features]
|
||||
canvas = ["iced_graphics/canvas"]
|
||||
# Not supported yet!
|
||||
image = []
|
||||
svg = []
|
||||
|
||||
|
|
|
@ -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)]
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
//! ```
|
||||
//! use iced_wgpu::{button, Button};
|
||||
//! ```
|
||||
use crate::Renderer;
|
||||
|
||||
pub mod button;
|
||||
pub mod checkbox;
|
||||
pub mod container;
|
||||
|
@ -47,3 +49,8 @@ pub mod canvas;
|
|||
#[cfg(feature = "canvas")]
|
||||
#[doc(no_inline)]
|
||||
pub use canvas::Canvas;
|
||||
|
||||
pub use iced_native::Space;
|
||||
|
||||
pub type Column<'a, Message> = iced_native::Column<'a, Message, Renderer>;
|
||||
pub type Row<'a, Message> = iced_native::Row<'a, Message, Renderer>;
|
||||
|
|
Loading…
Reference in New Issue