From 734e80dea6cd39923aaa0d2f27c7368c9cbc5d62 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 13 Oct 2019 18:22:26 +0200 Subject: Draft `Debugger` implementation in `iced_wgpu` --- wgpu/src/renderer.rs | 33 ++++++++++++++++++++++++++++++--- 1 file 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, 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, +) { + // 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); } } -- cgit