mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:15:09 +00:00
LibGUI: Add a way to highlight the focused widget for debugging
You can now pass --gui-focus-debug to any GUI::Application and it will draw a cyan rectangle around the currently focused widget.
This commit is contained in:
parent
e064999e0d
commit
39d55d1d76
3 changed files with 18 additions and 2 deletions
|
@ -56,8 +56,14 @@ Application::Application(int argc, char** argv)
|
||||||
WindowServerConnection::the();
|
WindowServerConnection::the();
|
||||||
if (argc > 0)
|
if (argc > 0)
|
||||||
m_invoked_as = argv[0];
|
m_invoked_as = argv[0];
|
||||||
for (int i = 1; i < argc; i++)
|
for (int i = 1; i < argc; i++) {
|
||||||
m_args.append(argv[i]);
|
String arg(argv[i]);
|
||||||
|
|
||||||
|
if (arg == "--gui-focus-debug")
|
||||||
|
m_focus_debugging_enabled = true;
|
||||||
|
|
||||||
|
m_args.append(move(arg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Application::~Application()
|
Application::~Application()
|
||||||
|
|
|
@ -68,6 +68,8 @@ public:
|
||||||
|
|
||||||
void set_system_palette(SharedBuffer&);
|
void set_system_palette(SharedBuffer&);
|
||||||
|
|
||||||
|
bool focus_debugging_enabled() const { return m_focus_debugging_enabled; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OwnPtr<Core::EventLoop> m_event_loop;
|
OwnPtr<Core::EventLoop> m_event_loop;
|
||||||
RefPtr<MenuBar> m_menubar;
|
RefPtr<MenuBar> m_menubar;
|
||||||
|
@ -77,6 +79,7 @@ private:
|
||||||
class TooltipWindow;
|
class TooltipWindow;
|
||||||
RefPtr<TooltipWindow> m_tooltip_window;
|
RefPtr<TooltipWindow> m_tooltip_window;
|
||||||
bool m_quit_when_last_window_deleted { true };
|
bool m_quit_when_last_window_deleted { true };
|
||||||
|
bool m_focus_debugging_enabled { false };
|
||||||
String m_invoked_as;
|
String m_invoked_as;
|
||||||
Vector<String> m_args;
|
Vector<String> m_args;
|
||||||
};
|
};
|
||||||
|
|
|
@ -242,6 +242,13 @@ void Widget::handle_paint_event(PaintEvent& event)
|
||||||
Painter painter(*this);
|
Painter painter(*this);
|
||||||
painter.draw_rect(rect(), Color::Magenta);
|
painter.draw_rect(rect(), Color::Magenta);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Application::the().focus_debugging_enabled()) {
|
||||||
|
if (is_focused()) {
|
||||||
|
Painter painter(*this);
|
||||||
|
painter.draw_rect(rect(), Color::Cyan);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Widget::set_layout(NonnullRefPtr<Layout> layout)
|
void Widget::set_layout(NonnullRefPtr<Layout> layout)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue