summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Cargo.toml21
-rw-r--r--glow/Cargo.toml1
-rw-r--r--src/application.rs24
-rw-r--r--src/element.rs2
-rw-r--r--src/lib.rs29
-rw-r--r--src/settings.rs8
-rw-r--r--src/widget.rs15
-rw-r--r--wgpu/src/widget.rs7
8 files changed, 72 insertions, 35 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 9339f4ed..4dd7d1e8 100644
--- a/Cargo.toml
+++ b/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" }
diff --git a/glow/Cargo.toml b/glow/Cargo.toml
index 53952608..dd6bbefc 100644
--- a/glow/Cargo.toml
+++ b/glow/Cargo.toml
@@ -9,6 +9,7 @@ repository = "https://github.com/hecrj/iced"
[features]
canvas = ["iced_graphics/canvas"]
+# Not supported yet!
image = []
svg = []
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;
diff --git a/src/lib.rs b/src/lib.rs
index 58cc141d..d08b39cf 100644
--- a/src/lib.rs
+++ b/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,
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)]
diff --git a/wgpu/src/widget.rs b/wgpu/src/widget.rs
index 32ccad17..ac741118 100644
--- a/wgpu/src/widget.rs
+++ b/wgpu/src/widget.rs
@@ -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>;