From ced3ffc22570048711fefba638782a31d0e06035 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 5 Sep 2019 07:23:03 +0200 Subject: Move `ggez` example to `tour` --- examples/tour/renderer/debugger.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/tour/renderer/debugger.rs (limited to 'examples/tour/renderer/debugger.rs') diff --git a/examples/tour/renderer/debugger.rs b/examples/tour/renderer/debugger.rs new file mode 100644 index 00000000..98124795 --- /dev/null +++ b/examples/tour/renderer/debugger.rs @@ -0,0 +1,30 @@ +use super::Renderer; +use ggez::graphics::{Color, DrawMode, MeshBuilder, Rect}; + +impl iced::renderer::Debugger for Renderer<'_> { + type Color = Color; + + fn explain(&mut self, layout: &iced::Layout<'_>, color: Color) { + let bounds = layout.bounds(); + + let mut debug_mesh = + self.debug_mesh.take().unwrap_or(MeshBuilder::new()); + + debug_mesh.rectangle( + DrawMode::stroke(1.0), + Rect { + x: bounds.x, + y: bounds.y, + w: bounds.width, + h: bounds.height, + }, + color, + ); + + self.debug_mesh = Some(debug_mesh); + + for child in layout.children() { + self.explain(&child, color); + } + } +} -- cgit