Commit 9ee5cd16 authored by Florian Blasius's avatar Florian Blasius 🤘

Fix image example for web.

parent 3825096e
......@@ -469,8 +469,6 @@ version = "0.3.0"
dependencies = [
"dces 0.1.7 (git+https://gitlab.redox-os.org/redox-os/dces-rust.git)",
"orbclient 0.3.22 (registry+https://github.com/rust-lang/crates.io-index)",
"orbfont 0.1.9 (git+https://gitlab.redox-os.org/redox-os/orbfont.git)",
"orbgl 0.1.0 (git+https://gitlab.redox-os.org/redox-os/orbgl.git)",
"orbgl_api 0.1.0 (git+https://gitlab.redox-os.org/redox-os/orbgl.git)",
"orbtk-css-engine 0.1.0",
"orbtk-shell 0.1.0",
......
......@@ -22,8 +22,6 @@ name = "orbtk"
path = "src/lib.rs"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
orbgl = { git = "https://gitlab.redox-os.org/redox-os/orbgl.git" }
orbfont = { git = "https://gitlab.redox-os.org/redox-os/orbfont.git" }
orbclient = "0.3.22"
[dependencies]
......
......@@ -10,7 +10,7 @@ fn main() {
.title("OrbTk - minimal example")
.position((100.0, 100.0))
.size(800.0, 420.0)
.child(ImageWidget::create().image("res/orbtk-space.png").build(ctx))
.child(ImageWidget::create().image("res/orbtk-space.png").build(ctx))
.build(ctx)
})
.run();
......
......@@ -2,8 +2,7 @@ use std::fmt;
#[cfg(not(target_arch = "wasm32"))]
use orbclient::Renderer;
use orbgl_api::Color;
use orbgl_api::Image as OrbImage;
use orbgl_api::{Color, Image as OrbImage, FromSource};
use crate::prelude::*;
......@@ -94,25 +93,13 @@ impl ImageExt for Image {
// --- Conversions ---
impl From<&str> for Image {
#[cfg(not(target_arch = "wasm32"))]
fn from(s: &str) -> Image {
Image::from(InnerImage::from(OrbImage::from_path(s).unwrap()))
}
#[cfg(target_arch = "wasm32")]
fn from(s: &str) -> Image {
Image::from(InnerImage::from(OrbImage::new()))
Image::from(InnerImage::from(OrbImage::from_source(s).unwrap()))
}
}
impl From<String> for Image {
#[cfg(not(target_arch = "wasm32"))]
fn from(s: String) -> Image {
Image::from(InnerImage::from(OrbImage::from_path(s).unwrap()))
}
#[cfg(target_arch = "wasm32")]
fn from(s: String) -> Image {
Image::from(InnerImage::from(OrbImage::new()))
Image::from(InnerImage::from(OrbImage::from_source(&s).unwrap()))
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment