From 408330f439102ed6a29da1ea23bc13d363ae0920 Mon Sep 17 00:00:00 2001 From: kokoISnoTarget <72217393+kokoISnoTarget@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:41:57 +0200 Subject: [PATCH 1/2] feat: Add debug boxes behind debug flag --- Cargo.toml | 1 + src/renderer.rs | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index 7b726fc4..9006ab6c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,6 +26,7 @@ keywords = ["markdown", "viewer", "gpu"] default = ["wayland", "x11"] x11 = ["copypasta/x11", "winit/x11"] wayland = ["copypasta/wayland", "winit/wayland"] +debug = [] [dependencies] winit = { version = "0.28.7", default-features = false } diff --git a/src/renderer.rs b/src/renderer.rs index f098c0a6..274da943 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -532,6 +532,18 @@ impl Renderer { } } } + #[cfg(feature = "debug")] + { + let mut rect = element + .bounds + .as_ref() + .context("Element not positioned")? + .clone(); + rect.pos.1 -= self.scroll_y; + let color = glyphon::Color::rgb(255, 0, 255).0; + let _ = + self.stroke_rectangle(rect, native_color(color, &self.surface_format), 1.0); + } } self.draw_scrollbar()?; From 4dc41f79eae8ae608099a8854847e6e0f6b94f84 Mon Sep 17 00:00:00 2001 From: kokoISnoTarget <72217393+kokoISnoTarget@users.noreply.github.com> Date: Fri, 12 Apr 2024 12:55:04 +0200 Subject: [PATCH 2/2] fmt --- src/renderer.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/renderer.rs b/src/renderer.rs index 274da943..093b218e 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -541,8 +541,7 @@ impl Renderer { .clone(); rect.pos.1 -= self.scroll_y; let color = glyphon::Color::rgb(255, 0, 255).0; - let _ = - self.stroke_rectangle(rect, native_color(color, &self.surface_format), 1.0); + let _ = self.stroke_rectangle(rect, native_color(color, &self.surface_format), 1.0); } }