diff options
Diffstat (limited to 'scene/main')
| -rw-r--r-- | scene/main/multiplayer_peer.h | 1 | ||||
| -rw-r--r-- | scene/main/node.cpp | 1 | ||||
| -rw-r--r-- | scene/main/window.cpp | 13 | ||||
| -rw-r--r-- | scene/main/window.h | 3 |
4 files changed, 15 insertions, 3 deletions
diff --git a/scene/main/multiplayer_peer.h b/scene/main/multiplayer_peer.h index 99be9137f8..ed1d56839f 100644 --- a/scene/main/multiplayer_peer.h +++ b/scene/main/multiplayer_peer.h @@ -35,7 +35,6 @@ #include "core/extension/ext_wrappers.gen.inc" #include "core/object/gdvirtual.gen.inc" -#include "core/object/script_language.h" #include "core/variant/native_ptr.h" class MultiplayerPeer : public PacketPeer { diff --git a/scene/main/node.cpp b/scene/main/node.cpp index d8f38c9148..d8a50c4313 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -34,6 +34,7 @@ #include "core/core_string_names.h" #include "core/io/resource_loader.h" #include "core/object/message_queue.h" +#include "core/object/script_language.h" #include "core/string/print_string.h" #include "instance_placeholder.h" #include "scene/animation/tween.h" diff --git a/scene/main/window.cpp b/scene/main/window.cpp index c79ac1f40b..ba53a5e3c3 100644 --- a/scene/main/window.cpp +++ b/scene/main/window.cpp @@ -1269,7 +1269,9 @@ void Window::_notification(int p_what) { notification(NOTIFICATION_TRANSLATION_CHANGED); } #endif - notification(NOTIFICATION_THEME_CHANGED); + + // Emits NOTIFICATION_THEME_CHANGED internally. + set_theme_context(ThemeDB::get_singleton()->get_nearest_theme_context(this)); } break; case NOTIFICATION_READY: { @@ -1313,6 +1315,8 @@ void Window::_notification(int p_what) { } break; case NOTIFICATION_EXIT_TREE: { + set_theme_context(nullptr, false); + if (transient) { _clear_transient(); } @@ -1889,6 +1893,11 @@ bool Window::has_theme_owner_node() const { return theme_owner->has_owner_node(); } +void Window::set_theme_context(ThemeContext *p_context, bool p_propagate) { + ERR_MAIN_THREAD_GUARD; + theme_owner->set_owner_context(p_context, p_propagate); +} + void Window::set_theme(const Ref<Theme> &p_theme) { ERR_MAIN_THREAD_GUARD; if (theme == p_theme) { @@ -2887,7 +2896,7 @@ Window::Window() { max_size_used = max_size; // Update max_size_used. } - theme_owner = memnew(ThemeOwner); + theme_owner = memnew(ThemeOwner(this)); RS::get_singleton()->viewport_set_update_mode(get_viewport_rid(), RS::VIEWPORT_UPDATE_DISABLED); } diff --git a/scene/main/window.h b/scene/main/window.h index 545b782995..689fa754cb 100644 --- a/scene/main/window.h +++ b/scene/main/window.h @@ -39,6 +39,7 @@ class Font; class Shortcut; class StyleBox; class ThemeOwner; +class ThemeContext; class Window : public Viewport { GDCLASS(Window, Viewport) @@ -365,6 +366,8 @@ public: Node *get_theme_owner_node() const; bool has_theme_owner_node() const; + void set_theme_context(ThemeContext *p_context, bool p_propagate = true); + void set_theme(const Ref<Theme> &p_theme); Ref<Theme> get_theme() const; |
