diff options
author | Oriko <oriko1010@protonmail.com> | 2020-03-16 13:36:21 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-03-16 13:39:34 +0100 |
commit | 2a32330257b96922d9ed274baf6fc96abca957f0 (patch) | |
tree | 4eba5f05e4729305d56c4ca383c24127cf6c038b /Libraries/LibGUI/Window.cpp | |
parent | 2b162ef79459d4b4961c25809ef98da4ca5cefd5 (diff) | |
download | serenity-2a32330257b96922d9ed274baf6fc96abca957f0.zip |
LibGUI: Add a ThemeChange event
Diffstat (limited to 'Libraries/LibGUI/Window.cpp')
-rw-r--r-- | Libraries/LibGUI/Window.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/Libraries/LibGUI/Window.cpp b/Libraries/LibGUI/Window.cpp index 60c583802b..9cb37b02c5 100644 --- a/Libraries/LibGUI/Window.cpp +++ b/Libraries/LibGUI/Window.cpp @@ -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) { |