1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-20 14:55:08 +00:00

LibGUI: Add a ThemeChange event

This commit is contained in:
Oriko 2020-03-16 13:36:21 +02:00 committed by Andreas Kling
parent 2b162ef794
commit 2a32330257
8 changed files with 53 additions and 1 deletions

View file

@ -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) {