summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-21 00:37:47 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-21 00:44:35 +0200
commite0e4ee73feead3f05730625c7e1917b63f0b384e (patch)
tree5cd934cc474a5aacc60359f6fe69a5b9d31fe45b /examples
parenta1a5fcfd46622d5b18d1716aa2adb4659835ccf3 (diff)
downloadiced-e0e4ee73feead3f05730625c7e1917b63f0b384e.tar.gz
iced-e0e4ee73feead3f05730625c7e1917b63f0b384e.tar.bz2
iced-e0e4ee73feead3f05730625c7e1917b63f0b384e.zip
Implement `iced_glutin` :tada:
Diffstat (limited to 'examples')
-rw-r--r--examples/custom_widget/Cargo.toml2
-rw-r--r--examples/custom_widget/src/main.rs18
-rw-r--r--examples/geometry/Cargo.toml2
-rw-r--r--examples/geometry/src/main.rs24
-rw-r--r--examples/todos/Cargo.toml2
-rw-r--r--examples/tour/Cargo.toml3
-rw-r--r--examples/tour/src/main.rs40
7 files changed, 47 insertions, 44 deletions
diff --git a/examples/custom_widget/Cargo.toml b/examples/custom_widget/Cargo.toml
index 30747dc0..3942538d 100644
--- a/examples/custom_widget/Cargo.toml
+++ b/examples/custom_widget/Cargo.toml
@@ -8,4 +8,4 @@ publish = false
[dependencies]
iced = { path = "../.." }
iced_native = { path = "../../native" }
-iced_wgpu = { path = "../../wgpu" }
+iced_graphics = { path = "../../graphics" }
diff --git a/examples/custom_widget/src/main.rs b/examples/custom_widget/src/main.rs
index f096fb54..bcf896b0 100644
--- a/examples/custom_widget/src/main.rs
+++ b/examples/custom_widget/src/main.rs
@@ -9,11 +9,11 @@ mod circle {
// Of course, you can choose to make the implementation renderer-agnostic,
// if you wish to, by creating your own `Renderer` trait, which could be
// implemented by `iced_wgpu` and other renderers.
+ use iced_graphics::{Backend, Defaults, Primitive, Renderer};
use iced_native::{
layout, mouse, Background, Color, Element, Hasher, Layout, Length,
Point, Size, Widget,
};
- use iced_wgpu::{Defaults, Primitive, Renderer};
pub struct Circle {
radius: u16,
@@ -25,7 +25,10 @@ mod circle {
}
}
- impl<Message> Widget<Message, Renderer> for Circle {
+ impl<Message, B> Widget<Message, Renderer<B>> for Circle
+ where
+ B: Backend,
+ {
fn width(&self) -> Length {
Length::Shrink
}
@@ -36,7 +39,7 @@ mod circle {
fn layout(
&self,
- _renderer: &Renderer,
+ _renderer: &Renderer<B>,
_limits: &layout::Limits,
) -> layout::Node {
layout::Node::new(Size::new(
@@ -53,7 +56,7 @@ mod circle {
fn draw(
&self,
- _renderer: &mut Renderer,
+ _renderer: &mut Renderer<B>,
_defaults: &Defaults,
layout: Layout<'_>,
_cursor_position: Point,
@@ -71,8 +74,11 @@ mod circle {
}
}
- impl<'a, Message> Into<Element<'a, Message, Renderer>> for Circle {
- fn into(self) -> Element<'a, Message, Renderer> {
+ impl<'a, Message, B> Into<Element<'a, Message, Renderer<B>>> for Circle
+ where
+ B: Backend,
+ {
+ fn into(self) -> Element<'a, Message, Renderer<B>> {
Element::new(self)
}
}
diff --git a/examples/geometry/Cargo.toml b/examples/geometry/Cargo.toml
index 9df52454..34eec4fb 100644
--- a/examples/geometry/Cargo.toml
+++ b/examples/geometry/Cargo.toml
@@ -8,4 +8,4 @@ publish = false
[dependencies]
iced = { path = "../.." }
iced_native = { path = "../../native" }
-iced_wgpu = { path = "../../wgpu" }
+iced_graphics = { path = "../../graphics" }
diff --git a/examples/geometry/src/main.rs b/examples/geometry/src/main.rs
index aabe6b21..71ce0d8c 100644
--- a/examples/geometry/src/main.rs
+++ b/examples/geometry/src/main.rs
@@ -10,14 +10,14 @@ mod rainbow {
// Of course, you can choose to make the implementation renderer-agnostic,
// if you wish to, by creating your own `Renderer` trait, which could be
// implemented by `iced_wgpu` and other renderers.
+ use iced_graphics::{
+ triangle::{Mesh2D, Vertex2D},
+ Backend, Defaults, Primitive, Renderer,
+ };
use iced_native::{
layout, mouse, Element, Hasher, Layout, Length, Point, Size, Vector,
Widget,
};
- use iced_wgpu::{
- triangle::{Mesh2D, Vertex2D},
- Defaults, Primitive, Renderer,
- };
pub struct Rainbow;
@@ -27,7 +27,10 @@ mod rainbow {
}
}
- impl<Message> Widget<Message, Renderer> for Rainbow {
+ impl<Message, B> Widget<Message, Renderer<B>> for Rainbow
+ where
+ B: Backend,
+ {
fn width(&self) -> Length {
Length::Fill
}
@@ -38,7 +41,7 @@ mod rainbow {
fn layout(
&self,
- _renderer: &Renderer,
+ _renderer: &Renderer<B>,
limits: &layout::Limits,
) -> layout::Node {
let size = limits.width(Length::Fill).resolve(Size::ZERO);
@@ -50,7 +53,7 @@ mod rainbow {
fn draw(
&self,
- _renderer: &mut Renderer,
+ _renderer: &mut Renderer<B>,
_defaults: &Defaults,
layout: Layout<'_>,
cursor_position: Point,
@@ -146,8 +149,11 @@ mod rainbow {
}
}
- impl<'a, Message> Into<Element<'a, Message, Renderer>> for Rainbow {
- fn into(self) -> Element<'a, Message, Renderer> {
+ impl<'a, Message, B> Into<Element<'a, Message, Renderer<B>>> for Rainbow
+ where
+ B: Backend,
+ {
+ fn into(self) -> Element<'a, Message, Renderer<B>> {
Element::new(self)
}
}
diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml
index f945cde5..b236cc0d 100644
--- a/examples/todos/Cargo.toml
+++ b/examples/todos/Cargo.toml
@@ -6,7 +6,7 @@ edition = "2018"
publish = false
[dependencies]
-iced = { path = "../..", features = ["async-std"] }
+iced = { path = "../..", features = ["async-std", "debug"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
diff --git a/examples/tour/Cargo.toml b/examples/tour/Cargo.toml
index b34c5feb..96749e90 100644
--- a/examples/tour/Cargo.toml
+++ b/examples/tour/Cargo.toml
@@ -6,6 +6,5 @@ edition = "2018"
publish = false
[dependencies]
-iced_winit = { path = "../../winit", features = ["debug"] }
-iced_glow = { path = "../../glow" }
+iced = { path = "../..", features = ["image", "debug"] }
env_logger = "0.7"
diff --git a/examples/tour/src/main.rs b/examples/tour/src/main.rs
index 8c3b1d19..ca7a4f5d 100644
--- a/examples/tour/src/main.rs
+++ b/examples/tour/src/main.rs
@@ -1,20 +1,14 @@
-use iced_glow::{
- button, scrollable, slider, text_input, window, Button, Checkbox, Color,
- Column, Command, Container, Element, HorizontalAlignment, Image, Length,
- Radio, Row, Scrollable, Slider, Space, Text, TextInput,
+use iced::{
+ button, executor, scrollable, slider, text_input, Application, Button,
+ Checkbox, Color, Column, Command, Container, Element, HorizontalAlignment,
+ Image, Length, Radio, Row, Scrollable, Settings, Slider, Space, Text,
+ TextInput,
};
-use iced_winit::{executor, Application, Settings};
pub fn main() {
env_logger::init();
- Tour::run(
- Settings::default(),
- iced_glow::Settings {
- default_font: None,
- antialiasing: None,
- },
- )
+ Tour::run(Settings::default())
}
pub struct Tour {
@@ -26,7 +20,6 @@ pub struct Tour {
}
impl Application for Tour {
- type Compositor = window::Compositor;
type Executor = executor::Null;
type Message = Message;
type Flags = ();
@@ -693,18 +686,17 @@ impl<'a> Step {
fn ferris<'a>(width: u16) -> Container<'a, StepMessage> {
Container::new(
- Text::new("Not supported yet!")
// This should go away once we unify resource loading on native
// platforms
- //if cfg!(target_arch = "wasm32") {
- // Image::new("images/ferris.png")
- //} else {
- // Image::new(format!(
- // "{}/images/ferris.png",
- // env!("CARGO_MANIFEST_DIR")
- // ))
- //}
- //.width(Length::Units(width)),
+ if cfg!(target_arch = "wasm32") {
+ Image::new("images/ferris.png")
+ } else {
+ Image::new(format!(
+ "{}/images/ferris.png",
+ env!("CARGO_MANIFEST_DIR")
+ ))
+ }
+ .width(Length::Units(width)),
)
.width(Length::Fill)
.center_x()
@@ -765,7 +757,7 @@ pub enum Layout {
}
mod style {
- use iced_glow::{button, Background, Color, Vector};
+ use iced::{button, Background, Color, Vector};
pub enum Button {
Primary,