summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-10-28 04:28:21 +0100
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2019-10-28 04:28:21 +0100
commit2b23e0986c532dbacd89ccd73bb603db558cbdaf (patch)
tree4c1e154fcc8be04c9d45eb68d1fce0ef23267add
parent35e94f5a324f5c28de855b725039733efb21b26a (diff)
downloadiced-2b23e0986c532dbacd89ccd73bb603db558cbdaf.tar.gz
iced-2b23e0986c532dbacd89ccd73bb603db558cbdaf.tar.bz2
iced-2b23e0986c532dbacd89ccd73bb603db558cbdaf.zip
Implement text clipping (caching still broken)
-rw-r--r--examples/scroll.rs16
-rw-r--r--native/Cargo.toml2
-rw-r--r--wgpu/Cargo.toml6
-rw-r--r--wgpu/src/renderer.rs21
-rw-r--r--winit/Cargo.toml2
5 files changed, 18 insertions, 29 deletions
diff --git a/examples/scroll.rs b/examples/scroll.rs
index b1e427bf..608923fe 100644
--- a/examples/scroll.rs
+++ b/examples/scroll.rs
@@ -4,6 +4,8 @@ use iced::{
};
pub fn main() {
+ env_logger::init();
+
Example::default().run()
}
@@ -32,25 +34,17 @@ impl Application for Example {
}
fn view(&mut self) -> Element<Message> {
- //let content = (0..3).fold(
- // Scrollable::new(&mut self.scroll).spacing(20).padding(20),
- // |content, _| {
- // content.push(
- // )
- // },
- //);
-
let content = (0..self.item_count)
.fold(
Scrollable::new(&mut self.scroll)
.spacing(20)
.padding(20)
.align_items(Align::Center),
- |column, i| {
+ |scrollable, i| {
if i % 2 == 0 {
- column.push(lorem_ipsum().width(Length::Units(600)))
+ scrollable.push(lorem_ipsum().width(Length::Units(600)))
} else {
- column.push(
+ scrollable.push(
Image::new(format!(
"{}/examples/resources/ferris.png",
env!("CARGO_MANIFEST_DIR")
diff --git a/native/Cargo.toml b/native/Cargo.toml
index 8cabe94c..bb6139d6 100644
--- a/native/Cargo.toml
+++ b/native/Cargo.toml
@@ -11,4 +11,4 @@ repository = "https://github.com/hecrj/iced"
iced_core = { version = "0.1.0-alpha", path = "../core" }
stretch = "0.2"
twox-hash = "1.5"
-raw-window-handle = "0.1"
+raw-window-handle = "0.3"
diff --git a/wgpu/Cargo.toml b/wgpu/Cargo.toml
index ffb15ea2..30f9224f 100644
--- a/wgpu/Cargo.toml
+++ b/wgpu/Cargo.toml
@@ -9,9 +9,9 @@ repository = "https://github.com/hecrj/iced"
[dependencies]
iced_native = { version = "0.1.0-alpha", path = "../native" }
-wgpu = { version = "0.3", git = "https://github.com/gfx-rs/wgpu-rs", rev = "cb25914b95b58fee0dc139b400867e7a731d98f4" }
-wgpu_glyph = { version = "0.4", git = "https://github.com/hecrj/wgpu_glyph", rev = "48daa98f5f785963838b4345e86ac40eac095ba9" }
-raw-window-handle = "0.1"
+wgpu = { version = "0.3", git = "https://github.com/gfx-rs/wgpu-rs", rev = "ed2c67f762970d0099c1e6c6e078fb645afbf964" }
+wgpu_glyph = { version = "0.4", git = "https://github.com/hecrj/wgpu_glyph", rev = "954ac865ca1b7f6b97bf403f8c6174a7120e667c" }
+raw-window-handle = "0.3"
image = "0.22"
nalgebra = "0.18"
log = "0.4"
diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs
index cfdd7a45..0f91428e 100644
--- a/wgpu/src/renderer.rs
+++ b/wgpu/src/renderer.rs
@@ -75,7 +75,7 @@ impl Renderer {
extensions: Extensions {
anisotropic_filtering: false,
},
- limits: Limits { max_bind_groups: 1 },
+ limits: Limits { max_bind_groups: 2 },
});
let surface = Surface::create(window);
@@ -162,17 +162,6 @@ impl Renderer {
self.draw_primitive(primitive, &mut layer);
self.flush(target.transformation, &layer, &mut encoder, &frame.view);
- self.glyph_brush
- .borrow_mut()
- .draw_queued(
- &mut self.device,
- &mut encoder,
- &frame.view,
- u32::from(target.width),
- u32::from(target.height),
- )
- .expect("Draw text");
-
self.queue.submit(&[encoder.finish()]);
*mouse_cursor
@@ -331,11 +320,17 @@ impl Renderer {
}
glyph_brush
- .draw_queued_with_transform(
+ .draw_queued_with_transform_and_scissoring(
&mut self.device,
encoder,
target,
translated.into(),
+ wgpu_glyph::Region {
+ x: layer.bounds.x,
+ y: layer.bounds.y,
+ width: layer.bounds.width,
+ height: layer.bounds.height,
+ },
)
.expect("Draw text");
}
diff --git a/winit/Cargo.toml b/winit/Cargo.toml
index fa5d6adf..c8227ac4 100644
--- a/winit/Cargo.toml
+++ b/winit/Cargo.toml
@@ -9,5 +9,5 @@ repository = "https://github.com/hecrj/iced"
[dependencies]
iced_native = { version = "0.1.0-alpha", path = "../native" }
-winit = { version = "0.20.0-alpha3", git = "https://github.com/hecrj/winit", branch = "redraw-requested-2.0" }
+winit = { version = "0.20.0-alpha3", git = "https://github.com/rust-windowing/winit", rev = "709808eb4e69044705fcb214bcc30556db761405"}
log = "0.4"