Skip to content

Commit 7016221

Browse files
authored
Merge pull request #164 from hecrj/feature/custom-runtime
Custom futures executor with `iced_futures`
2 parents 6ca5e61 + 91d9d65 commit 7016221

70 files changed

Lines changed: 1097 additions & 329 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,24 @@ maintenance = { status = "actively-developed" }
2323
[workspace]
2424
members = [
2525
"core",
26+
"futures",
2627
"native",
2728
"style",
2829
"web",
2930
"wgpu",
3031
"winit",
32+
"examples/bezier_tool",
33+
"examples/counter",
34+
"examples/custom_widget",
35+
"examples/events",
36+
"examples/geometry",
37+
"examples/pokedex",
38+
"examples/progress_bar",
39+
"examples/stopwatch",
40+
"examples/styling",
41+
"examples/svg",
42+
"examples/todos",
43+
"examples/tour",
3144
]
3245

3346
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
@@ -36,19 +49,3 @@ iced_wgpu = { version = "0.1.0", path = "wgpu" }
3649

3750
[target.'cfg(target_arch = "wasm32")'.dependencies]
3851
iced_web = { version = "0.1.0", path = "web" }
39-
40-
[dev-dependencies]
41-
iced_native = { version = "0.1", path = "./native" }
42-
iced_wgpu = { version = "0.1", path = "./wgpu" }
43-
env_logger = "0.7"
44-
serde = { version = "1.0", features = ["derive"] }
45-
serde_json = "1.0"
46-
directories = "2.0"
47-
futures = "0.3"
48-
async-std = { version = "1.3", features = ["unstable"] }
49-
surf = "1.0"
50-
rand = "0.7"
51-
lyon = "0.15"
52-
53-
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
54-
wasm-bindgen = "0.2.51"

core/Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,4 @@ description = "The essential concepts of Iced"
77
license = "MIT"
88
repository = "https://github.com/hecrj/iced"
99

10-
[features]
11-
# Exposes a future-based `Command` type
12-
command = ["futures"]
13-
# Exposes a future-based `Subscription` type
14-
subscription = ["futures"]
15-
1610
[dependencies]
17-
futures = { version = "0.3", optional = true }

core/src/lib.rs

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,3 @@ pub use length::Length;
3232
pub use point::Point;
3333
pub use rectangle::Rectangle;
3434
pub use vector::Vector;
35-
36-
#[cfg(feature = "command")]
37-
mod command;
38-
39-
#[cfg(feature = "command")]
40-
pub use command::Command;
41-
42-
#[cfg(feature = "subscription")]
43-
pub mod subscription;
44-
45-
#[cfg(feature = "subscription")]
46-
pub use subscription::Subscription;

examples/README.md

Lines changed: 61 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ you want to learn about a specific release, check out [the release list].
44

55
[the release list]: https://github.com/hecrj/iced/releases
66

7-
## [Tour](tour.rs)
8-
7+
## [Tour](tour)
98
A simple UI tour that can run both on native platforms and the web! It showcases different widgets that can be built using Iced.
109

11-
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__.
10+
The __[`main`](tour/src/main.rs)__ 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__.
1211

1312
<div align="center">
1413
<a href="https://gfycat.com/politeadorableiberianmole">
1514
<img src="https://thumbs.gfycat.com/PoliteAdorableIberianmole-small.gif">
1615
</a>
1716
</div>
1817

19-
[`tour`]: tour.rs
2018
[`iced_winit`]: ../winit
2119
[`iced_native`]: ../native
2220
[`iced_wgpu`]: ../wgpu
@@ -26,19 +24,17 @@ The __[`tour`]__ file contains all the code of the example! All the cross-platfo
2624

2725
You can run the native version with `cargo run`:
2826
```
29-
cargo run --example tour
27+
cargo run --package tour
3028
```
3129

3230
The web version can be run by following [the usage instructions of `iced_web`] or by accessing [iced.rs](https://iced.rs/)!
3331

3432
[the usage instructions of `iced_web`]: ../web#usage
3533

34+
## [Todos](todos)
35+
A 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.
3636

37-
## [Todos](todos.rs)
38-
39-
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.
40-
41-
All the example code is located in the __[`todos`]__ file.
37+
The example code is located in the __[`main`](todos/src/main.rs)__ file.
4238

4339
<div align="center">
4440
<a href="https://gfycat.com/littlesanehalicore">
@@ -48,15 +44,67 @@ All the example code is located in the __[`todos`]__ file.
4844

4945
You can run the native version with `cargo run`:
5046
```
51-
cargo run --example todos
47+
cargo run --package todos
5248
```
5349
We have not yet implemented a `LocalStorage` version of the auto-save feature. Therefore, it does not work on web _yet_!
5450

55-
[`todos`]: todos.rs
5651
[TodoMVC]: http://todomvc.com/
5752

58-
## [Coffee]
53+
## [Pokédex](pokedex)
54+
An application that helps you learn about Pokémon! It performs an asynchronous HTTP request to the [PokéAPI] in order to load and display a random Pokédex entry (sprite included!).
55+
56+
The example code can be found in the __[`main`](pokedex/src/main.rs)__ file.
57+
58+
<div align="center">
59+
<a href="https://gfycat.com/aggressivedarkelephantseal-rust-gui">
60+
<img src="https://thumbs.gfycat.com/AggressiveDarkElephantseal-small.gif" height="400px">
61+
</a>
62+
</div>
63+
64+
You can run it on native platforms with `cargo run`:
65+
```
66+
cargo run --package pokedex
67+
```
68+
69+
[PokéAPI]: https://pokeapi.co/
70+
71+
## [Styling](styling)
72+
An example showcasing custom styling with a light and dark theme.
73+
74+
The example code is located in the __[`main`](styling/src/main.rs)__ file.
5975

76+
<div align="center">
77+
<a href="https://user-images.githubusercontent.com/518289/71867993-acff4300-310c-11ea-85a3-d01d8f884346.gif">
78+
<img src="https://user-images.githubusercontent.com/518289/71867993-acff4300-310c-11ea-85a3-d01d8f884346.gif" height="400px">
79+
</a>
80+
</div>
81+
82+
You can run it with `cargo run`:
83+
```
84+
cargo run --package styling
85+
```
86+
87+
## Extras
88+
A bunch of simpler examples exist:
89+
90+
- [`bezier_tool`](bezier_tool), a Paint-like tool for drawing Bezier curves using [`lyon`].
91+
- [`counter`](counter), the classic counter example explained in the [`README`](../README.md).
92+
- [`custom_widget`](custom_widget), a demonstration of how to build a custom widget that draws a circle.
93+
- [`events`](events), a log of native events displayed using a conditional `Subscription`.
94+
- [`geometry`](geometry), a custom widget showcasing how to draw geometry with the `Mesh2D` primitive in [`iced_wgpu`](../wgpu).
95+
- [`progress_bar`](progress_bar), a simple progress bar that can be filled by using a slider.
96+
- [`stopwatch`](stopwatch), a watch with start/stop and reset buttons showcasing how to listen to time.
97+
- [`svg`](svg), an application that renders the [Ghostscript Tiger] by leveraging the `Svg` widget.
98+
99+
All of them are packaged in their own crate and, therefore, can be run using `cargo`:
100+
```
101+
cargo run --package <example>
102+
```
103+
104+
[`lyon`]: https://github.com/nical/lyon
105+
[Ghostscript Tiger]: https://commons.wikimedia.org/wiki/File:Ghostscript_Tiger.svg
106+
107+
## [Coffee]
60108
Since [Iced was born in May], it has been powering the user interfaces in
61109
[Coffee], an experimental 2D game engine.
62110

examples/bezier_tool/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "bezier_tool"
3+
version = "0.1.0"
4+
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
5+
edition = "2018"
6+
publish = false
7+
8+
[dependencies]
9+
iced = { path = "../.." }
10+
iced_native = { path = "../../native" }
11+
iced_wgpu = { path = "../../wgpu" }
12+
lyon = "0.15"

examples/counter/Cargo.toml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[package]
2+
name = "counter"
3+
version = "0.1.0"
4+
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
5+
edition = "2018"
6+
publish = false
7+
8+
[dependencies]
9+
iced = { path = "../.." }

examples/custom_widget/Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[package]
2+
name = "custom_widget"
3+
version = "0.1.0"
4+
authors = ["Héctor Ramón Jiménez <hector0193@gmail.com>"]
5+
edition = "2018"
6+
publish = false
7+
8+
[dependencies]
9+
iced = { path = "../.." }
10+
iced_native = { path = "../../native" }
11+
iced_wgpu = { path = "../../wgpu" }

0 commit comments

Comments
 (0)