mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 11:20:03 +00:00
LibGUI: Add a ThemeChange event
This commit is contained in:
@@ -334,6 +334,22 @@ void Window::event(Core::Event& event)
|
||||
return result.widget->dispatch_event(*local_event, this);
|
||||
}
|
||||
|
||||
if (event.type() == Event::ThemeChange) {
|
||||
if (!m_main_widget)
|
||||
return;
|
||||
auto theme_event = static_cast<ThemeChangeEvent&>(event);
|
||||
auto dispatch_theme_change = [&](auto& widget, auto recursive) {
|
||||
widget.dispatch_event(theme_event, this);
|
||||
widget.for_each_child_widget([&](auto& widget) -> IterationDecision {
|
||||
widget.dispatch_event(theme_event, this);
|
||||
recursive(widget, recursive);
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
};
|
||||
dispatch_theme_change(*m_main_widget.ptr(), dispatch_theme_change);
|
||||
return;
|
||||
}
|
||||
|
||||
Core::Object::event(event);
|
||||
}
|
||||
|
||||
@@ -635,6 +651,14 @@ void Window::schedule_relayout()
|
||||
});
|
||||
}
|
||||
|
||||
void Window::for_each_window(Badge<WindowServerConnection>, Function<void(Window&)> callback)
|
||||
{
|
||||
for (auto& e : *reified_windows) {
|
||||
ASSERT(e.value);
|
||||
callback(*e.value);
|
||||
}
|
||||
}
|
||||
|
||||
void Window::update_all_windows(Badge<WindowServerConnection>)
|
||||
{
|
||||
for (auto& e : *reified_windows) {
|
||||
|
||||
Reference in New Issue
Block a user