From 7cea7371150e6de28032827519936008592f112d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Mon, 20 Jan 2020 06:27:01 +0100 Subject: [PATCH] Package examples and remove `dev-dependencies` --- Cargo.toml | 29 ++++------ examples/bezier_tool/Cargo.toml | 12 ++++ .../src/main.rs} | 0 examples/counter/Cargo.toml | 9 +++ examples/{counter.rs => counter/src/main.rs} | 0 examples/custom_widget/Cargo.toml | 11 ++++ .../src/main.rs} | 0 examples/events/Cargo.toml | 10 ++++ examples/{events.rs => events/src/main.rs} | 0 examples/geometry/Cargo.toml | 11 ++++ .../{geometry.rs => geometry/src/main.rs} | 0 examples/pokedex/Cargo.toml | 14 +++++ examples/{pokedex.rs => pokedex/src/main.rs} | 4 +- examples/progress_bar/Cargo.toml | 9 +++ .../src/main.rs} | 0 examples/stopwatch/Cargo.toml | 12 ++++ .../{stopwatch.rs => stopwatch/src/main.rs} | 2 + examples/styling/Cargo.toml | 9 +++ examples/{styling.rs => styling/src/main.rs} | 0 examples/svg.rs | 54 ------------------ examples/svg/Cargo.toml | 9 +++ examples/{ => svg}/resources/tiger.svg | 0 examples/svg/src/main.rs | 37 ++++++++++++ examples/todos/Cargo.toml | 16 ++++++ examples/{resources => todos/fonts}/icons.ttf | Bin examples/{todos.rs => todos/src/main.rs} | 2 +- examples/tour/Cargo.toml | 13 +++++ .../{resources => tour/images}/ferris.png | Bin examples/{tour.rs => tour/src/main.rs} | 4 +- src/lib.rs | 4 +- 30 files changed, 193 insertions(+), 78 deletions(-) create mode 100644 examples/bezier_tool/Cargo.toml rename examples/{bezier_tool.rs => bezier_tool/src/main.rs} (100%) create mode 100644 examples/counter/Cargo.toml rename examples/{counter.rs => counter/src/main.rs} (100%) create mode 100644 examples/custom_widget/Cargo.toml rename examples/{custom_widget.rs => custom_widget/src/main.rs} (100%) create mode 100644 examples/events/Cargo.toml rename examples/{events.rs => events/src/main.rs} (100%) create mode 100644 examples/geometry/Cargo.toml rename examples/{geometry.rs => geometry/src/main.rs} (100%) create mode 100644 examples/pokedex/Cargo.toml rename examples/{pokedex.rs => pokedex/src/main.rs} (98%) create mode 100644 examples/progress_bar/Cargo.toml rename examples/{progress_bar.rs => progress_bar/src/main.rs} (100%) create mode 100644 examples/stopwatch/Cargo.toml rename examples/{stopwatch.rs => stopwatch/src/main.rs} (99%) create mode 100644 examples/styling/Cargo.toml rename examples/{styling.rs => styling/src/main.rs} (100%) delete mode 100644 examples/svg.rs create mode 100644 examples/svg/Cargo.toml rename examples/{ => svg}/resources/tiger.svg (100%) create mode 100644 examples/svg/src/main.rs create mode 100644 examples/todos/Cargo.toml rename examples/{resources => todos/fonts}/icons.ttf (100%) rename examples/{todos.rs => todos/src/main.rs} (99%) create mode 100644 examples/tour/Cargo.toml rename examples/{resources => tour/images}/ferris.png (100%) rename examples/{tour.rs => tour/src/main.rs} (99%) diff --git a/Cargo.toml b/Cargo.toml index 87f3000e..28a97af9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,6 +29,18 @@ members = [ "web", "wgpu", "winit", + "examples/bezier_tool", + "examples/counter", + "examples/custom_widget", + "examples/events", + "examples/geometry", + "examples/pokedex", + "examples/progress_bar", + "examples/stopwatch", + "examples/styling", + "examples/svg", + "examples/todos", + "examples/tour", ] [target.'cfg(not(target_arch = "wasm32"))'.dependencies] @@ -37,20 +49,3 @@ iced_wgpu = { version = "0.1.0", path = "wgpu" } [target.'cfg(target_arch = "wasm32")'.dependencies] iced_web = { version = "0.1.0", path = "web" } - -[dev-dependencies] -iced_native = { version = "0.1", path = "./native" } -iced_wgpu = { version = "0.1", path = "./wgpu" } -iced_futures = { version = "0.1.0-alpha", path = "./futures", features = ["async-std"] } -env_logger = "0.7" -serde = { version = "1.0", features = ["derive"] } -serde_json = "1.0" -directories = "2.0" -futures = "0.3" -async-std = { version = "1.3", features = ["unstable"] } -surf = "1.0" -rand = "0.7" -lyon = "0.15" - -[target.'cfg(target_arch = "wasm32")'.dev-dependencies] -wasm-bindgen = "0.2.51" diff --git a/examples/bezier_tool/Cargo.toml b/examples/bezier_tool/Cargo.toml new file mode 100644 index 00000000..b13a0aa5 --- /dev/null +++ b/examples/bezier_tool/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "bezier_tool" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } +iced_native = { path = "../../native" } +iced_wgpu = { path = "../../wgpu" } +lyon = "0.15" diff --git a/examples/bezier_tool.rs b/examples/bezier_tool/src/main.rs similarity index 100% rename from examples/bezier_tool.rs rename to examples/bezier_tool/src/main.rs diff --git a/examples/counter/Cargo.toml b/examples/counter/Cargo.toml new file mode 100644 index 00000000..a763cd78 --- /dev/null +++ b/examples/counter/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "counter" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } diff --git a/examples/counter.rs b/examples/counter/src/main.rs similarity index 100% rename from examples/counter.rs rename to examples/counter/src/main.rs diff --git a/examples/custom_widget/Cargo.toml b/examples/custom_widget/Cargo.toml new file mode 100644 index 00000000..30747dc0 --- /dev/null +++ b/examples/custom_widget/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "custom_widget" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } +iced_native = { path = "../../native" } +iced_wgpu = { path = "../../wgpu" } diff --git a/examples/custom_widget.rs b/examples/custom_widget/src/main.rs similarity index 100% rename from examples/custom_widget.rs rename to examples/custom_widget/src/main.rs diff --git a/examples/events/Cargo.toml b/examples/events/Cargo.toml new file mode 100644 index 00000000..f883075f --- /dev/null +++ b/examples/events/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "events" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } +iced_native = { path = "../../native" } diff --git a/examples/events.rs b/examples/events/src/main.rs similarity index 100% rename from examples/events.rs rename to examples/events/src/main.rs diff --git a/examples/geometry/Cargo.toml b/examples/geometry/Cargo.toml new file mode 100644 index 00000000..9df52454 --- /dev/null +++ b/examples/geometry/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "geometry" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } +iced_native = { path = "../../native" } +iced_wgpu = { path = "../../wgpu" } diff --git a/examples/geometry.rs b/examples/geometry/src/main.rs similarity index 100% rename from examples/geometry.rs rename to examples/geometry/src/main.rs diff --git a/examples/pokedex/Cargo.toml b/examples/pokedex/Cargo.toml new file mode 100644 index 00000000..2972590f --- /dev/null +++ b/examples/pokedex/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "pokedex" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } +iced_futures = { path = "../../futures", features = ["async-std"] } +surf = "1.0" +rand = "0.7" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" diff --git a/examples/pokedex.rs b/examples/pokedex/src/main.rs similarity index 98% rename from examples/pokedex.rs rename to examples/pokedex/src/main.rs index 505dbf19..283437b2 100644 --- a/examples/pokedex.rs +++ b/examples/pokedex/src/main.rs @@ -1,6 +1,6 @@ use iced::{ - button, image, Align, Application, Button, Column, Command, Container, - Element, Image, Length, Row, Settings, Text, + button, futures, image, Align, Application, Button, Column, Command, + Container, Element, Image, Length, Row, Settings, Text, }; pub fn main() { diff --git a/examples/progress_bar/Cargo.toml b/examples/progress_bar/Cargo.toml new file mode 100644 index 00000000..4eccbf14 --- /dev/null +++ b/examples/progress_bar/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "progress_bar" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } diff --git a/examples/progress_bar.rs b/examples/progress_bar/src/main.rs similarity index 100% rename from examples/progress_bar.rs rename to examples/progress_bar/src/main.rs diff --git a/examples/stopwatch/Cargo.toml b/examples/stopwatch/Cargo.toml new file mode 100644 index 00000000..1dae3b83 --- /dev/null +++ b/examples/stopwatch/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "stopwatch" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } +iced_native = { path = "../../native" } +iced_futures = { path = "../../futures", features = ["async-std"] } +async-std = { version = "1.0", features = ["unstable"] } diff --git a/examples/stopwatch.rs b/examples/stopwatch/src/main.rs similarity index 99% rename from examples/stopwatch.rs rename to examples/stopwatch/src/main.rs index 6e357039..d84c4817 100644 --- a/examples/stopwatch.rs +++ b/examples/stopwatch/src/main.rs @@ -143,6 +143,8 @@ impl Application for Stopwatch { } mod time { + use iced::futures; + pub fn every( duration: std::time::Duration, ) -> iced::Subscription { diff --git a/examples/styling/Cargo.toml b/examples/styling/Cargo.toml new file mode 100644 index 00000000..eb729f93 --- /dev/null +++ b/examples/styling/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "styling" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } diff --git a/examples/styling.rs b/examples/styling/src/main.rs similarity index 100% rename from examples/styling.rs rename to examples/styling/src/main.rs diff --git a/examples/svg.rs b/examples/svg.rs deleted file mode 100644 index 1895039d..00000000 --- a/examples/svg.rs +++ /dev/null @@ -1,54 +0,0 @@ -use iced::{Container, Element, Length, Sandbox, Settings}; - -pub fn main() { - Tiger::run(Settings::default()) -} - -#[derive(Default)] -struct Tiger; - -impl Sandbox for Tiger { - type Message = (); - - fn new() -> Self { - Self::default() - } - - fn title(&self) -> String { - String::from("SVG - Iced") - } - - fn update(&mut self, _message: ()) {} - - fn view(&mut self) -> Element<()> { - #[cfg(feature = "svg")] - let content = { - use iced::{Column, Svg}; - - Column::new().padding(20).push( - Svg::new(format!( - "{}/examples/resources/tiger.svg", - env!("CARGO_MANIFEST_DIR") - )) - .width(Length::Fill) - .height(Length::Fill), - ) - }; - - #[cfg(not(feature = "svg"))] - let content = { - use iced::{HorizontalAlignment, Text}; - - Text::new("You need to enable the `svg` feature!") - .horizontal_alignment(HorizontalAlignment::Center) - .size(30) - }; - - Container::new(content) - .width(Length::Fill) - .height(Length::Fill) - .center_x() - .center_y() - .into() - } -} diff --git a/examples/svg/Cargo.toml b/examples/svg/Cargo.toml new file mode 100644 index 00000000..d8f83ac2 --- /dev/null +++ b/examples/svg/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "svg" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../..", features = ["svg"] } diff --git a/examples/resources/tiger.svg b/examples/svg/resources/tiger.svg similarity index 100% rename from examples/resources/tiger.svg rename to examples/svg/resources/tiger.svg diff --git a/examples/svg/src/main.rs b/examples/svg/src/main.rs new file mode 100644 index 00000000..57358e24 --- /dev/null +++ b/examples/svg/src/main.rs @@ -0,0 +1,37 @@ +use iced::{Column, Container, Element, Length, Sandbox, Settings, Svg}; + +pub fn main() { + Tiger::run(Settings::default()) +} + +#[derive(Default)] +struct Tiger; + +impl Sandbox for Tiger { + type Message = (); + + fn new() -> Self { + Self::default() + } + + fn title(&self) -> String { + String::from("SVG - Iced") + } + + fn update(&mut self, _message: ()) {} + + fn view(&mut self) -> Element<()> { + let content = Column::new().padding(20).push( + Svg::new(format!("{}/tiger.svg", env!("CARGO_MANIFEST_DIR"))) + .width(Length::Fill) + .height(Length::Fill), + ); + + Container::new(content) + .width(Length::Fill) + .height(Length::Fill) + .center_x() + .center_y() + .into() + } +} diff --git a/examples/todos/Cargo.toml b/examples/todos/Cargo.toml new file mode 100644 index 00000000..53a135e6 --- /dev/null +++ b/examples/todos/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "todos" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +iced = { path = "../.." } +iced_futures = { path = "../../futures", features = ["async-std"] } +async-std = "1.0" +serde = { version = "1.0", features = ["derive"] } +serde_json = "1.0" +directories = "2.0" diff --git a/examples/resources/icons.ttf b/examples/todos/fonts/icons.ttf similarity index 100% rename from examples/resources/icons.ttf rename to examples/todos/fonts/icons.ttf diff --git a/examples/todos.rs b/examples/todos/src/main.rs similarity index 99% rename from examples/todos.rs rename to examples/todos/src/main.rs index 06595a1e..c6ddf2ea 100644 --- a/examples/todos.rs +++ b/examples/todos/src/main.rs @@ -451,7 +451,7 @@ fn empty_message(message: &str) -> Element<'static, Message> { // Fonts const ICONS: Font = Font::External { name: "Icons", - bytes: include_bytes!("resources/icons.ttf"), + bytes: include_bytes!("../fonts/icons.ttf"), }; fn icon(unicode: char) -> Text { diff --git a/examples/tour/Cargo.toml b/examples/tour/Cargo.toml new file mode 100644 index 00000000..10c3f1da --- /dev/null +++ b/examples/tour/Cargo.toml @@ -0,0 +1,13 @@ +[package] +name = "tour" +version = "0.1.0" +authors = ["Héctor Ramón Jiménez "] +edition = "2018" +publish = false + +[dependencies] +iced = { path = "../.." } +env_logger = "0.7" + +[target.'cfg(target_arch = "wasm32")'.dependencies] +wasm-bindgen = "0.2.51" diff --git a/examples/resources/ferris.png b/examples/tour/images/ferris.png similarity index 100% rename from examples/resources/ferris.png rename to examples/tour/images/ferris.png diff --git a/examples/tour.rs b/examples/tour/src/main.rs similarity index 99% rename from examples/tour.rs rename to examples/tour/src/main.rs index b0ee4d96..43c7e50f 100644 --- a/examples/tour.rs +++ b/examples/tour/src/main.rs @@ -681,10 +681,10 @@ fn ferris<'a>(width: u16) -> Container<'a, StepMessage> { // This should go away once we unify resource loading on native // platforms if cfg!(target_arch = "wasm32") { - Image::new("resources/ferris.png") + Image::new("images/ferris.png") } else { Image::new(format!( - "{}/examples/resources/ferris.png", + "{}/images/ferris.png", env!("CARGO_MANIFEST_DIR") )) } diff --git a/src/lib.rs b/src/lib.rs index 9c9bcff5..1da3f549 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -204,6 +204,6 @@ use iced_winit as common; use iced_web as common; pub use common::{ - Align, Background, Color, Command, Font, HorizontalAlignment, Length, - Space, Subscription, Vector, VerticalAlignment, + futures, Align, Background, Color, Command, Font, HorizontalAlignment, + Length, Space, Subscription, Vector, VerticalAlignment, };