mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-20 19:45:12 +00:00
LibGUI: Add GUI_HOVER_DEBUG runtime debugging flag (environment)
You can now see the outline of GUI widgets when hovering them. For example: $ export GUI_HOVER_DEBUG=1 $ FileManager Then move the mouse around in the file manager. :^)
This commit is contained in:
parent
3d4f93cf8d
commit
b3d27c2340
Notes:
sideshowbarker
2024-07-18 08:00:14 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b3d27c2340a
5 changed files with 16 additions and 0 deletions
|
@ -200,6 +200,8 @@ set(WSSCREEN_DEBUG ON)
|
|||
# set(DT_DEBUG ON)
|
||||
# False positive: GUI_DND_DEBUG is a flag, but passed as an envvar.
|
||||
# set(GUI_DND_DEBUG ON)
|
||||
# False positive: GUI_HOVER_DEBUG is a flag, but passed as an envvar.
|
||||
# set(GUI_HOVER_DEBUG ON)
|
||||
# False positive: GUI_FOCUS_DEBUG is a flag, but passed as an envvar.
|
||||
# set(GUI_FOCUS_DEBUG ON)
|
||||
# False positive: LOG_DEBUG is a flag, but for a bitset, not a feature.
|
||||
|
|
|
@ -81,6 +81,9 @@ Application::Application(int argc, char** argv, Core::EventLoop::MakeInspectable
|
|||
if (getenv("GUI_FOCUS_DEBUG"))
|
||||
m_focus_debugging_enabled = true;
|
||||
|
||||
if (getenv("GUI_HOVER_DEBUG"))
|
||||
m_hover_debugging_enabled = true;
|
||||
|
||||
if (getenv("GUI_DND_DEBUG"))
|
||||
m_dnd_debugging_enabled = true;
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
void set_system_palette(Core::AnonymousBuffer&);
|
||||
|
||||
bool focus_debugging_enabled() const { return m_focus_debugging_enabled; }
|
||||
bool hover_debugging_enabled() const { return m_hover_debugging_enabled; }
|
||||
bool dnd_debugging_enabled() const { return m_dnd_debugging_enabled; }
|
||||
|
||||
Core::EventLoop& event_loop() { return *m_event_loop; }
|
||||
|
@ -102,6 +103,7 @@ private:
|
|||
WeakPtr<Window> m_active_window;
|
||||
bool m_quit_when_last_window_deleted { true };
|
||||
bool m_focus_debugging_enabled { false };
|
||||
bool m_hover_debugging_enabled { false };
|
||||
bool m_dnd_debugging_enabled { false };
|
||||
String m_invoked_as;
|
||||
Vector<String> m_args;
|
||||
|
|
|
@ -356,6 +356,11 @@ void Widget::handle_paint_event(PaintEvent& event)
|
|||
painter.draw_rect(rect(), Color::Cyan);
|
||||
}
|
||||
|
||||
if (app && app->hover_debugging_enabled() && this == window()->hovered_widget()) {
|
||||
Painter painter(*this);
|
||||
painter.draw_rect(rect(), Color::Red);
|
||||
}
|
||||
|
||||
if (is_being_inspected()) {
|
||||
Painter painter(*this);
|
||||
painter.draw_rect(rect(), Color::Magenta);
|
||||
|
|
|
@ -809,6 +809,10 @@ void Window::set_hovered_widget(Widget* widget)
|
|||
|
||||
if (m_hovered_widget)
|
||||
Core::EventLoop::current().post_event(*m_hovered_widget, make<Event>(Event::Enter));
|
||||
|
||||
auto* app = Application::the();
|
||||
if (app && app->hover_debugging_enabled())
|
||||
update();
|
||||
}
|
||||
|
||||
void Window::set_current_backing_store(WindowBackingStore& backing_store, bool flush_immediately)
|
||||
|
|
Loading…
Add table
Reference in a new issue