iced-yoda/examples/tour/src/iced_ggez/renderer/debugger.rs

33 lines
810 B
Rust
Raw Normal View History

use super::{into_color, Renderer};
use ggez::graphics::{DrawMode, MeshBuilder, Rect};
2019-09-04 11:09:57 +02:00
2019-09-20 19:15:31 +02:00
impl iced_native::renderer::Debugger for Renderer<'_> {
fn explain(
&mut self,
layout: &iced_native::Layout<'_>,
color: iced_native::Color,
) {
2019-09-04 11:09:57 +02:00
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,
},
into_color(color),
2019-09-04 11:09:57 +02:00
);
self.debug_mesh = Some(debug_mesh);
for child in layout.children() {
self.explain(&child, color);
}
}
}