From 93093fa0236f3b9bdb048eee32e8d6f347c44794 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Nov 2019 06:18:22 +0100 Subject: Disable debug view by default in `tour` example --- examples/tour.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/tour.rs b/examples/tour.rs index 6d7a080f..f5bb84d1 100644 --- a/examples/tour.rs +++ b/examples/tour.rs @@ -29,7 +29,7 @@ impl Application for Tour { scroll: scrollable::State::new(), back_button: button::State::new(), next_button: button::State::new(), - debug: true, + debug: false, }, Command::none(), ) -- cgit From 08aa862a42b8bd710b3add7408b090d1fc918cab Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Nov 2019 10:54:40 +0100 Subject: Update examples `README` --- examples/README.md | 73 +++++++++++++++++++++++++----------------------------- 1 file changed, 34 insertions(+), 39 deletions(-) (limited to 'examples') diff --git a/examples/README.md b/examples/README.md index 0a06a012..95ec6c5c 100644 --- a/examples/README.md +++ b/examples/README.md @@ -4,29 +4,17 @@ you want to learn about a specific release, check out [the release list]. [the release list]: https://github.com/hecrj/iced/releases - ## [Tour](tour.rs) -A simple UI tour showcasing different widgets that can be built using Iced. - -The example can run both on native and web platforms, using the same GUI code! - -[![Tour - Iced][gui_gif]][gui_gfycat] - -[gui_gif]: https://thumbs.gfycat.com/VeneratedSourAurochs-small.gif -[gui_gfycat]: https://gfycat.com/veneratedsouraurochs -On native, the example uses: - - [`iced_winit`], as a bridge between [`iced_native`] and [`winit`]. - - [`iced_wgpu`], a WIP Iced renderer built on top of [`wgpu`] and supporting - Vulkan, Metal, D3D11, and D3D12 (OpenGL and WebGL soon!). +A simple UI tour that can run both on native platforms and the web! It showcases different widgets that can be built using Iced. -The web version uses [`iced_web`], which is still a work in progress. In -particular, the styling of elements is not finished yet (text color, alignment, -sizing, etc). +The __[`tour`]__ file contains all the code of the example! All the cross-platform GUI is defined in terms of __state__, __messages__, __update logic__ and __view logic__. -The __[`tour`]__ file contains all the code of the example! All the -cross-platform GUI is defined in terms of __state__, __messages__, -__update logic__ and __view logic__. +
+ + + +
[`tour`]: tour.rs [`iced_winit`]: ../winit @@ -36,42 +24,49 @@ __update logic__ and __view logic__. [`winit`]: https://github.com/rust-windowing/winit [`wgpu`]: https://github.com/gfx-rs/wgpu-rs -#### Running the native version -Use [Cargo](https://doc.rust-lang.org/cargo/reference/manifest.html#examples) -to run the example: - +You can run the native version with `cargo run`: ``` cargo run --example tour ``` -#### Running the web version -Build using the `wasm32-unknown-unknown` target and use the [`wasm-bindgen`] CLI -to generate appropriate bindings in a `tour` directory. +The web version can be run by following [the usage instructions of `iced_web`] or by accessing [iced.rs](https://iced.rs/)! -``` -cd examples -cargo build --example tour --target wasm32-unknown-unknown -wasm-bindgen ../target/wasm32-unknown-unknown/debug/examples/tour.wasm --out-dir tour --web -``` +[the usage instructions of `iced_web`]: ../web#usage -Finally, serve the `examples` directory using an HTTP server and access the -`tour.html` file. -[`wasm-bindgen`]: https://github.com/rustwasm/wasm-bindgen +## [Todos](todos.rs) + +A simple todos tracker inspired by [TodoMVC]. It showcases dynamic layout, text input, checkboxes, scrollables, icons, and async actions! It automatically saves your tasks in the background, even if you did not finish typing them. + +All the example code is located in the __[`todos`]__ file. + +
+ + + +
+ +You can run the native version with `cargo run`: +``` +cargo run --example todos +``` +We have not yet implemented a `LocalStorage` version of the auto-save feature. Therefore, it does not work on web _yet_! +[`todos`]: todos.rs +[TodoMVC]: http://todomvc.com/ ## [Coffee] Since [Iced was born in May], it has been powering the user interfaces in [Coffee], an experimental 2D game engine. -If you want to give Iced a try without having to write your own renderer, -the __[`ui` module]__ in [Coffee] is probably your best choice as of now. -[![Tour - Coffee][coffee_gui_gif]][coffee_gui_gfycat] +
+ + + +
[Iced was born in May]: https://github.com/hecrj/coffee/pull/35 [`ui` module]: https://docs.rs/coffee/0.3.2/coffee/ui/index.html [Coffee]: https://github.com/hecrj/coffee -[coffee_gui_gif]: https://thumbs.gfycat.com/GloomyWeakHammerheadshark-small.gif -[coffee_gui_gfycat]: https://gfycat.com/gloomyweakhammerheadshark -- cgit From 7f1c6fc14cddbf7055a4d00a4c188311592e679e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 20 Nov 2019 11:02:40 +0100 Subject: Remove `scroll` example and `tour.html` --- examples/scroll.rs | 84 ------------------------------------------------------ examples/tour.html | 14 --------- 2 files changed, 98 deletions(-) delete mode 100644 examples/scroll.rs delete mode 100644 examples/tour.html (limited to 'examples') diff --git a/examples/scroll.rs b/examples/scroll.rs deleted file mode 100644 index 61ad2a53..00000000 --- a/examples/scroll.rs +++ /dev/null @@ -1,84 +0,0 @@ -use iced::{ - button, scrollable, Align, Application, Button, Command, Container, - Element, Image, Length, Scrollable, Text, -}; - -pub fn main() { - env_logger::init(); - - Example::run() -} - -#[derive(Default)] -struct Example { - item_count: u16, - - scroll: scrollable::State, - add_button: button::State, -} - -#[derive(Debug, Clone, Copy)] -pub enum Message { - AddItem, -} - -impl Application for Example { - type Message = Message; - - fn new() -> (Example, Command) { - (Example::default(), Command::none()) - } - - fn title(&self) -> String { - String::from("Scroll - Iced") - } - - fn update(&mut self, message: Message) -> Command { - match message { - Message::AddItem => { - self.item_count += 1; - } - } - - Command::none() - } - - fn view(&mut self) -> Element { - let content = (0..self.item_count) - .fold( - Scrollable::new(&mut self.scroll) - .spacing(20) - .padding(20) - .align_items(Align::Center), - |scrollable, i| { - if i % 2 == 0 { - scrollable.push(lorem_ipsum().width(Length::Units(600))) - } else { - scrollable.push( - Image::new(format!( - "{}/examples/resources/ferris.png", - env!("CARGO_MANIFEST_DIR") - )) - .width(Length::Units(400)), - ) - } - }, - ) - .push( - Button::new(&mut self.add_button, Text::new("Add item")) - .on_press(Message::AddItem) - .padding(20) - .border_radius(5), - ); - - Container::new(content) - .width(Length::Fill) - .height(Length::Fill) - .center_y() - .into() - } -} - -fn lorem_ipsum() -> Text { - Text::new("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi in dui vel massa blandit interdum. Quisque placerat, odio ut vulputate sagittis, augue est facilisis ex, eget euismod felis magna in sapien. Nullam luctus consequat massa, ac interdum mauris blandit pellentesque. Nullam in est urna. Aliquam tristique lectus ac luctus feugiat. Aenean libero diam, euismod facilisis consequat quis, pellentesque luctus erat. Praesent vel tincidunt elit.") -} diff --git a/examples/tour.html b/examples/tour.html deleted file mode 100644 index 35360e59..00000000 --- a/examples/tour.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - Tour - Iced - - - - - -- cgit