Skip to content

Commit

Permalink
Tweaks to features to make it closer to current setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Teddy DeRego committed Sep 4, 2020
1 parent 034282e commit f2ea6ae
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 29 deletions.
10 changes: 4 additions & 6 deletions Cargo.toml
Expand Up @@ -12,13 +12,11 @@ keywords = ["gui", "ui", "graphics", "interface", "widgets"]
categories = ["gui"]

[features]
default = ["wgpu", "winit", "default_system_font"]
default = ["wgpu", "web", "default_system_font"]
# Enables the `iced_wgpu` renderer
wgpu = ["iced_wgpu"]
# Enables the `iced_web` renderer
winit = ["iced_winit", "iced_web_winit"]
# Enables the `iced_web` renderer
#web = ["iced_web"]
web = ["iced_web"]
# Enables the `Image` widget
image = ["iced_wgpu/image"]
# Enables the `Svg` widget
Expand Down Expand Up @@ -92,9 +90,9 @@ iced_wgpu = { version = "0.2", path = "wgpu", optional = true }

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-timer = "0.2"
iced_web = { version = "0.2", path = "web" }
iced_web_winit = { version = "0.1", path = "web_winit" }
iced_web = { version = "0.2", path = "web", optional = true }
iced_winit = { version = "0.1", path = "winit", optional = true }
iced_web_winit = { version = "0.1", path = "web_winit", optional = true }

[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
Expand Down
4 changes: 2 additions & 2 deletions futures/src/time.rs
Expand Up @@ -30,7 +30,7 @@ pub fn every<H: std::hash::Hasher, E>(

struct Every(std::time::Duration);

#[cfg(feature = "async-std")]
#[cfg(all(feature = "async-std", not(target_arch = "wasm32")))]
impl<H, E> subscription::Recipe<H, E> for Every
where
H: std::hash::Hasher,
Expand All @@ -56,7 +56,7 @@ where
}
}

#[cfg(all(feature = "tokio", not(feature = "async-std")))]
#[cfg(all(feature = "tokio", not(feature = "async-std"), not(target_arch = "wasm32")))]
impl<H, E> subscription::Recipe<H, E> for Every
where
H: std::hash::Hasher,
Expand Down
1 change: 0 additions & 1 deletion glow/src/program.rs
Expand Up @@ -17,7 +17,6 @@ pub unsafe fn create(
gl.compile_shader(shader);

if !gl.get_shader_compile_status(shader) {
panic!("{}", shader_source);
panic!(gl.get_shader_info_log(shader));
}

Expand Down
10 changes: 5 additions & 5 deletions src/application.rs
Expand Up @@ -213,7 +213,7 @@ pub trait Application: Sized {
where
Self: 'static,
{
#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
{
let renderer_settings = crate::renderer::Settings {
default_font: settings.default_font,
Expand All @@ -233,14 +233,14 @@ pub trait Application: Sized {
>(settings.into(), renderer_settings);
}

#[cfg(feature = "web")]
#[cfg(all(feature = "web", target_arch = "wasm32"))]
<Instance<Self> as iced_web::Application>::run(settings.flags);
}
}

struct Instance<A: Application>(A);

#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
impl<A> iced_winit::Program for Instance<A>
where
A: Application,
Expand All @@ -257,7 +257,7 @@ where
}
}

#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
impl<A> crate::runtime::Application for Instance<A>
where
A: Application,
Expand Down Expand Up @@ -294,7 +294,7 @@ where
}
}

#[cfg(feature = "web")]
#[cfg(all(feature = "web", target_arch = "wasm32"))]
impl<A> iced_web::Application for Instance<A>
where
A: Application,
Expand Down
4 changes: 2 additions & 2 deletions src/element.rs
@@ -1,9 +1,9 @@
/// A generic widget.
///
/// This is an alias of an `iced_native` element with a default `Renderer`.
#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
pub type Element<'a, Message> =
crate::runtime::Element<'a, Message, crate::renderer::Renderer>;

#[cfg(feature = "web")]
#[cfg(all(feature = "web", target_arch = "wasm32"))]
pub use iced_web::Element;
6 changes: 3 additions & 3 deletions src/lib.rs
Expand Up @@ -202,6 +202,8 @@ pub mod time;
feature = "wgpu"
))]
use iced_winit as runtime;
#[cfg(all(target_arch = "wasm32", not(feature = "web")))]
use iced_web_winit as runtime;

#[cfg(all(not(target_arch = "wasm32"), feature = "glow"))]
use iced_glutin as runtime;
Expand All @@ -215,10 +217,8 @@ use iced_wgpu as renderer;

#[cfg(feature = "glow")]
use iced_glow as renderer;
#[cfg(all(target_arch = "wasm32", feature = "winit"))]
use iced_web_winit as runtime;

#[cfg(feature = "web")]
#[cfg(all(feature = "web", target_arch = "wasm32"))]
use iced_web as runtime;

#[doc(no_inline)]
Expand Down
2 changes: 1 addition & 1 deletion src/settings.rs
Expand Up @@ -71,7 +71,7 @@ where
}
}

#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
impl<Flags> From<Settings<Flags>> for iced_winit::Settings<Flags> {
fn from(settings: Settings<Flags>) -> iced_winit::Settings<Flags> {
iced_winit::Settings {
Expand Down
4 changes: 2 additions & 2 deletions src/widget.rs
Expand Up @@ -16,7 +16,7 @@
//!
//! [`TextInput`]: text_input/struct.TextInput.html
//! [`text_input::State`]: text_input/struct.State.html
#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
mod platform {
pub use crate::renderer::widget::{
button, checkbox, container, pane_grid, pick_list, progress_bar, radio,
Expand Down Expand Up @@ -55,7 +55,7 @@ mod platform {
pub use canvas::Canvas;
}

#[cfg(feature = "web")]
#[cfg(all(feature = "web", target_arch = "wasm32"))]
mod platform {
pub use iced_web::widget::*;
}
Expand Down
12 changes: 6 additions & 6 deletions src/window/icon.rs
Expand Up @@ -3,18 +3,18 @@ use std::fmt;
use std::io;

/// The icon of a window.
#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
#[derive(Debug, Clone)]
pub struct Icon(iced_winit::winit::window::Icon);

/// The icon of a window.
#[cfg(feature = "web")]
#[cfg(all(feature = "web", target_arch = "wasm32"))]
#[derive(Debug, Clone)]
pub struct Icon;

impl Icon {
/// Creates an icon from 32bpp RGBA data.
#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
pub fn from_rgba(
rgba: Vec<u8>,
width: u32,
Expand All @@ -27,7 +27,7 @@ impl Icon {
}

/// Creates an icon from 32bpp RGBA data.
#[cfg(feature = "web")]
#[cfg(all(feature = "web", target_arch = "wasm32"))]
pub fn from_rgba(
_rgba: Vec<u8>,
_width: u32,
Expand Down Expand Up @@ -62,7 +62,7 @@ pub enum Error {
OsError(io::Error),
}

#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
impl From<iced_winit::winit::window::BadIcon> for Error {
fn from(error: iced_winit::winit::window::BadIcon) -> Self {
use iced_winit::winit::window::BadIcon;
Expand All @@ -86,7 +86,7 @@ impl From<iced_winit::winit::window::BadIcon> for Error {
}
}

#[cfg(not(feature = "web "))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
impl From<Icon> for iced_winit::winit::window::Icon {
fn from(icon: Icon) -> Self {
icon.0
Expand Down
2 changes: 1 addition & 1 deletion src/window/settings.rs
Expand Up @@ -39,7 +39,7 @@ impl Default for Settings {
}
}

#[cfg(not(feature = "web"))]
#[cfg(not(all(feature = "web", target_arch = "wasm32")))]
impl From<Settings> for iced_winit::settings::Window {
fn from(settings: Settings) -> Self {
Self {
Expand Down

0 comments on commit f2ea6ae

Please sign in to comment.