From c4393277fb7ea776fd28dc6dd7474b069f8a94b3 Mon Sep 17 00:00:00 2001 From: Shane Smiskol Date: Sat, 21 Feb 2026 20:56:51 -0800 Subject: [PATCH] ui: draw debug rects (#37313) * debug * new --- system/ui/lib/application.py | 4 ++++ system/ui/widgets/__init__.py | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/system/ui/lib/application.py b/system/ui/lib/application.py index 7c0bd2bf3..5d284bf45 100644 --- a/system/ui/lib/application.py +++ b/system/ui/lib/application.py @@ -248,6 +248,10 @@ class GuiApplication: def set_show_fps(self, show: bool): self._show_fps = show + @property + def show_touches(self) -> bool: + return self._show_touches + @property def target_fps(self): return self._target_fps diff --git a/system/ui/widgets/__init__.py b/system/ui/widgets/__init__.py index 37254c8b3..cc8d72959 100644 --- a/system/ui/widgets/__init__.py +++ b/system/ui/widgets/__init__.py @@ -104,6 +104,9 @@ class Widget(abc.ABC): self._layout() ret = self._render(self._rect) + if gui_app.show_touches: + self._draw_debug_rect() + # Keep track of whether mouse down started within the widget's rectangle if self.enabled and self.__was_awake: self._process_mouse_events() @@ -116,6 +119,10 @@ class Widget(abc.ABC): return ret + def _draw_debug_rect(self) -> None: + rl.draw_rectangle_lines(int(self._rect.x), int(self._rect.y), + max(int(self._rect.width), 1), max(int(self._rect.height), 1), rl.RED) + def _process_mouse_events(self) -> None: hit_rect = self._hit_rect touch_valid = self._touch_valid()