Skip to content

Commit bc225d4

Browse files
authored
Merge branch 'master' into ios_fixes
2 parents cf036c6 + 2f10a1f commit bc225d4

46 files changed

Lines changed: 759 additions & 421 deletions

Some content is hidden

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

CHANGELOG.md

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,55 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88
### Added
9-
- `"system_font"` feature gates reading system fonts. [#370]
9+
- Support for the [`smol`] async runtime. [#699]
10+
11+
[#699]: https://github.com/hecrj/iced/pull/699
12+
[`smol`]: https://github.com/smol-rs/smol
13+
14+
## [0.2.0] - 2020-11-26
15+
### Added
16+
- __[`Canvas` interactivity][canvas]__ (#325)
17+
A trait-based approach to react to mouse and keyboard interactions in [the `Canvas` widget][#193].
18+
19+
- __[`iced_graphics` subcrate][opengl]__ (#354)
20+
A backend-agnostic graphics subcrate that can be leveraged to build new renderers.
21+
22+
- __[OpenGL renderer][opengl]__ (#354)
23+
An OpenGL renderer powered by [`iced_graphics`], [`glow`], and [`glutin`]. It is an alternative to the default [`wgpu`] renderer.
24+
25+
- __[Overlay support][pick_list]__ (#444)
26+
Basic support for superpositioning interactive widgets on top of other widgets.
27+
28+
- __[Faster event loop][view]__ (#597)
29+
The event loop now takes advantage of the data dependencies in [The Elm Architecture] and leverages the borrow checker to keep the widget tree alive between iterations, avoiding unnecessary rebuilds.
30+
31+
- __[Event capturing][event]__ (#614)
32+
The runtime now can tell whether a widget has handled an event or not, easing [integration with existing applications].
33+
34+
- __[`PickList` widget][pick_list]__ (#444)
35+
A drop-down selector widget built on top of the new overlay support.
36+
37+
- __[`QRCode` widget][qr_code]__ (#622)
38+
A widget that displays a QR code, powered by [the `qrcode` crate].
39+
40+
[canvas]: https://github.com/hecrj/iced/pull/325
41+
[opengl]: https://github.com/hecrj/iced/pull/354
42+
[`iced_graphics`]: https://github.com/hecrj/iced/pull/354
43+
[pane_grid]: https://github.com/hecrj/iced/pull/397
44+
[pick_list]: https://github.com/hecrj/iced/pull/444
45+
[error]: https://github.com/hecrj/iced/pull/514
46+
[view]: https://github.com/hecrj/iced/pull/597
47+
[event]: https://github.com/hecrj/iced/pull/614
48+
[color]: https://github.com/hecrj/iced/pull/200
49+
[qr_code]: https://github.com/hecrj/iced/pull/622
50+
[#193]: https://github.com/hecrj/iced/pull/193
51+
[`glutin`]: https://github.com/rust-windowing/glutin
52+
[`wgpu`]: https://github.com/gfx-rs/wgpu-rs
53+
[`glow`]: https://github.com/grovesNL/glow
54+
[the `qrcode` crate]: https://docs.rs/qrcode/0.12.0/qrcode/
55+
[integration with existing applications]: https://github.com/hecrj/iced/pull/183
56+
[The Elm Architecture]: https://guide.elm-lang.org/architecture/
1057

11-
[#370]: https://github.com/hecrj/iced/pull/370
1258

1359
## [0.1.1] - 2020-04-15
1460
### Added
@@ -114,7 +160,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
114160
### Added
115161
- First release! :tada:
116162

117-
[Unreleased]: https://github.com/hecrj/iced/compare/0.1.1...HEAD
163+
[Unreleased]: https://github.com/hecrj/iced/compare/0.2.0...HEAD
164+
[0.2.0]: https://github.com/hecrj/iced/compare/0.1.1...0.2.0
118165
[0.1.1]: https://github.com/hecrj/iced/compare/0.1.0...0.1.1
119166
[0.1.0]: https://github.com/hecrj/iced/compare/0.1.0-beta...0.1.0
120167
[0.1.0-beta]: https://github.com/hecrj/iced/compare/0.1.0-alpha...0.1.0-beta

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ tokio = ["iced_futures/tokio"]
4141
tokio_old = ["iced_futures/tokio_old"]
4242
# Enables `async-std` as the `executor::Default` on native platforms
4343
async-std = ["iced_futures/async-std"]
44+
# Enables `smol` as the `executor::Default` on native platforms
45+
smol = ["iced_futures/smol"]
4446
# Enables advanced color conversion via `palette`
4547
palette = ["iced_core/palette"]
4648

examples/game_of_life/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ publish = false
77

88
[dependencies]
99
iced = { path = "../..", features = ["canvas", "tokio", "debug"] }
10-
tokio = { version = "0.3", features = ["sync"] }
10+
tokio = { version = "1.0", features = ["sync"] }
1111
itertools = "0.9"
1212
rustc-hash = "1.1"

examples/integration/src/main.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub fn main() {
3636
let (mut device, queue) = futures::executor::block_on(async {
3737
let adapter = instance
3838
.request_adapter(&wgpu::RequestAdapterOptions {
39-
power_preference: wgpu::PowerPreference::Default,
39+
power_preference: wgpu::PowerPreference::HighPerformance,
4040
compatible_surface: Some(&surface),
4141
})
4242
.await
@@ -45,9 +45,9 @@ pub fn main() {
4545
adapter
4646
.request_device(
4747
&wgpu::DeviceDescriptor {
48+
label: None,
4849
features: wgpu::Features::empty(),
4950
limits: wgpu::Limits::default(),
50-
shader_validation: false,
5151
},
5252
None,
5353
)
@@ -63,7 +63,7 @@ pub fn main() {
6363
device.create_swap_chain(
6464
&surface,
6565
&wgpu::SwapChainDescriptor {
66-
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
66+
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
6767
format: format,
6868
width: size.width,
6969
height: size.height,
@@ -157,7 +157,7 @@ pub fn main() {
157157
swap_chain = device.create_swap_chain(
158158
&surface,
159159
&wgpu::SwapChainDescriptor {
160-
usage: wgpu::TextureUsage::OUTPUT_ATTACHMENT,
160+
usage: wgpu::TextureUsage::RENDER_ATTACHMENT,
161161
format: format,
162162
width: size.width,
163163
height: size.height,

examples/integration/src/scene.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ impl Scene {
1919
background_color: Color,
2020
) -> wgpu::RenderPass<'a> {
2121
encoder.begin_render_pass(&wgpu::RenderPassDescriptor {
22+
label: None,
2223
color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor {
2324
attachment: target,
2425
resolve_target: None,
@@ -48,10 +49,10 @@ impl Scene {
4849

4950
fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline {
5051
let vs_module =
51-
device.create_shader_module(wgpu::include_spirv!("shader/vert.spv"));
52+
device.create_shader_module(&wgpu::include_spirv!("shader/vert.spv"));
5253

5354
let fs_module =
54-
device.create_shader_module(wgpu::include_spirv!("shader/frag.spv"));
55+
device.create_shader_module(&wgpu::include_spirv!("shader/frag.spv"));
5556

5657
let pipeline_layout =
5758
device.create_pipeline_layout(&wgpu::PipelineLayoutDescriptor {
@@ -64,34 +65,33 @@ fn build_pipeline(device: &wgpu::Device) -> wgpu::RenderPipeline {
6465
device.create_render_pipeline(&wgpu::RenderPipelineDescriptor {
6566
label: None,
6667
layout: Some(&pipeline_layout),
67-
vertex_stage: wgpu::ProgrammableStageDescriptor {
68+
vertex: wgpu::VertexState {
6869
module: &vs_module,
6970
entry_point: "main",
71+
buffers: &[],
7072
},
71-
fragment_stage: Some(wgpu::ProgrammableStageDescriptor {
73+
fragment: Some(wgpu::FragmentState {
7274
module: &fs_module,
7375
entry_point: "main",
76+
targets: &[wgpu::ColorTargetState {
77+
format: wgpu::TextureFormat::Bgra8UnormSrgb,
78+
color_blend: wgpu::BlendState::REPLACE,
79+
alpha_blend: wgpu::BlendState::REPLACE,
80+
write_mask: wgpu::ColorWrite::ALL,
81+
}],
7482
}),
75-
rasterization_state: Some(wgpu::RasterizationStateDescriptor {
83+
primitive: wgpu::PrimitiveState {
84+
topology: wgpu::PrimitiveTopology::TriangleList,
7685
front_face: wgpu::FrontFace::Ccw,
7786
cull_mode: wgpu::CullMode::None,
7887
..Default::default()
79-
}),
80-
primitive_topology: wgpu::PrimitiveTopology::TriangleList,
81-
color_states: &[wgpu::ColorStateDescriptor {
82-
format: wgpu::TextureFormat::Bgra8UnormSrgb,
83-
color_blend: wgpu::BlendDescriptor::REPLACE,
84-
alpha_blend: wgpu::BlendDescriptor::REPLACE,
85-
write_mask: wgpu::ColorWrite::ALL,
86-
}],
87-
depth_stencil_state: None,
88-
vertex_state: wgpu::VertexStateDescriptor {
89-
index_format: wgpu::IndexFormat::Uint16,
90-
vertex_buffers: &[],
9188
},
92-
sample_count: 1,
93-
sample_mask: !0,
94-
alpha_to_coverage_enabled: false,
89+
depth_stencil: None,
90+
multisample: wgpu::MultisampleState {
91+
count: 1,
92+
mask: !0,
93+
alpha_to_coverage_enabled: false,
94+
},
9595
});
9696

9797
pipeline

examples/pane_grid/src/main.rs

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use iced::{
22
button, executor, keyboard, pane_grid, scrollable, Align, Application,
3-
Button, Column, Command, Container, Element, HorizontalAlignment, Length,
4-
PaneGrid, Scrollable, Settings, Subscription, Text,
3+
Button, Color, Column, Command, Container, Element, HorizontalAlignment,
4+
Length, PaneGrid, Row, Scrollable, Settings, Subscription, Text,
55
};
66
use iced_native::{event, subscription, Event};
77

@@ -141,10 +141,21 @@ impl Application for Example {
141141
let pane_grid = PaneGrid::new(&mut self.panes, |pane, content| {
142142
let is_focused = focus == Some(pane);
143143

144-
let title_bar =
145-
pane_grid::TitleBar::new(format!("Pane {}", content.id))
146-
.padding(10)
147-
.style(style::TitleBar { is_focused });
144+
let title = Row::with_children(vec![
145+
Text::new("Pane").into(),
146+
Text::new(content.id.to_string())
147+
.color(if is_focused {
148+
PANE_ID_COLOR_FOCUSED
149+
} else {
150+
PANE_ID_COLOR_UNFOCUSED
151+
})
152+
.into(),
153+
])
154+
.spacing(5);
155+
156+
let title_bar = pane_grid::TitleBar::new(title)
157+
.padding(10)
158+
.style(style::TitleBar { is_focused });
148159

149160
pane_grid::Content::new(content.view(pane, total_panes))
150161
.title_bar(title_bar)
@@ -165,6 +176,17 @@ impl Application for Example {
165176
}
166177
}
167178

179+
const PANE_ID_COLOR_UNFOCUSED: Color = Color::from_rgb(
180+
0xFF as f32 / 255.0,
181+
0xC7 as f32 / 255.0,
182+
0xC7 as f32 / 255.0,
183+
);
184+
const PANE_ID_COLOR_FOCUSED: Color = Color::from_rgb(
185+
0xFF as f32 / 255.0,
186+
0x47 as f32 / 255.0,
187+
0x47 as f32 / 255.0,
188+
);
189+
168190
fn handle_hotkey(key_code: keyboard::KeyCode) -> Option<Message> {
169191
use keyboard::KeyCode;
170192
use pane_grid::{Axis, Direction};

examples/stopwatch/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ edition = "2018"
66
publish = false
77

88
[dependencies]
9-
iced = { path = "../..", features = ["tokio"] }
9+
iced = { path = "../..", features = ["smol"] }

examples/todos/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,6 @@ enum LoadError {
489489

490490
#[derive(Debug, Clone)]
491491
enum SaveError {
492-
DirectoryError,
493492
FileError,
494493
WriteError,
495494
FormatError,
@@ -538,7 +537,7 @@ impl SavedState {
538537
if let Some(dir) = path.parent() {
539538
async_std::fs::create_dir_all(dir)
540539
.await
541-
.map_err(|_| SaveError::DirectoryError)?;
540+
.map_err(|_| SaveError::FileError)?;
542541
}
543542

544543
{

futures/Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,20 @@ optional = true
2626
features = ["rt-core", "rt-threaded", "time", "stream"]
2727

2828
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
29-
version = "0.3"
29+
package = "tokio"
30+
version = "1.0"
3031
optional = true
31-
features = ["rt-multi-thread", "time", "stream"]
32+
features = ["rt", "rt-multi-thread", "time"]
3233

3334
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-std]
3435
version = "1.0"
3536
optional = true
3637
features = ["unstable"]
3738

39+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.smol]
40+
version = "1.2"
41+
optional = true
42+
3843
[target.'cfg(target_arch = "wasm32")'.dependencies]
3944
wasm-bindgen-futures = "0.4"
4045

futures/src/executor.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ mod tokio_old;
1313
#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))]
1414
mod async_std;
1515

16+
#[cfg(all(not(target_arch = "wasm32"), feature = "smol"))]
17+
mod smol;
18+
1619
#[cfg(target_arch = "wasm32")]
1720
mod wasm_bindgen;
1821

@@ -30,6 +33,9 @@ pub use self::tokio_old::TokioOld;
3033
#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))]
3134
pub use self::async_std::AsyncStd;
3235

36+
#[cfg(all(not(target_arch = "wasm32"), feature = "smol"))]
37+
pub use self::smol::Smol;
38+
3339
#[cfg(target_arch = "wasm32")]
3440
pub use wasm_bindgen::WasmBindgen;
3541

0 commit comments

Comments
 (0)