diff options
author | 2019-10-13 18:22:26 +0200 | |
---|---|---|
committer | 2019-10-13 18:22:26 +0200 | |
commit | 734e80dea6cd39923aaa0d2f27c7368c9cbc5d62 (patch) | |
tree | a53f14d335246aba5e2dcc0f9718a679a3151355 /wgpu | |
parent | ccc463a7c051b1096bc8a9f17ec64c2912a11247 (diff) | |
download | iced-734e80dea6cd39923aaa0d2f27c7368c9cbc5d62.tar.gz iced-734e80dea6cd39923aaa0d2f27c7368c9cbc5d62.tar.bz2 iced-734e80dea6cd39923aaa0d2f27c7368c9cbc5d62.zip |
Draft `Debugger` implementation in `iced_wgpu`
Diffstat (limited to 'wgpu')
-rw-r--r-- | wgpu/src/renderer.rs | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/wgpu/src/renderer.rs b/wgpu/src/renderer.rs index 8d54b2c7..8930e9df 100644 --- a/wgpu/src/renderer.rs +++ b/wgpu/src/renderer.rs @@ -272,9 +272,36 @@ impl Debugger for Renderer { widget: &dyn Widget<Message, Self>, layout: Layout<'_>, cursor_position: Point, - _color: Color, + color: Color, ) -> Self::Output { - // TODO: Include a bordered box to display layout bounds - widget.draw(self, layout, cursor_position) + let mut primitives = Vec::new(); + let (primitive, cursor) = widget.draw(self, layout, cursor_position); + + explain_layout(layout, color, &mut primitives); + primitives.push(primitive); + + (Primitive::Group { primitives }, cursor) + } +} + +fn explain_layout( + layout: Layout, + color: Color, + primitives: &mut Vec<Primitive>, +) { + // TODO: Draw borders instead + primitives.push(Primitive::Quad { + bounds: layout.bounds(), + background: Background::Color(Color { + r: 0.0, + g: 0.0, + b: 0.0, + a: 0.05, + }), + border_radius: 0, + }); + + for child in layout.children() { + explain_layout(child, color, primitives); } } |