From 4441874c624f5f7b3932a63fddd5f5855c4fed29 Mon Sep 17 00:00:00 2001 From: Grublady Date: Tue, 18 Mar 2025 19:01:02 -0400 Subject: [PATCH] Update inspector theme when changed --- editor/editor_inspector.cpp | 19 +++++++++++++++++-- editor/editor_inspector.h | 4 ++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index 45a7080375..df76c39bd9 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -4753,6 +4753,12 @@ void EditorInspector::_clear_current_favorites() { update_tree(); } +void EditorInspector::_update_theme() { + updating_theme = true; + add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree"))); + updating_theme = false; +} + void EditorInspector::_notification(int p_what) { switch (p_what) { case NOTIFICATION_TRANSLATION_CHANGED: { @@ -4762,6 +4768,10 @@ void EditorInspector::_notification(int p_what) { } break; case NOTIFICATION_THEME_CHANGED: { + if (updating_theme) { + break; + } + favorites_category->icon = get_editor_theme_icon(SNAME("Favorites")); int separation = get_theme_constant(SNAME("v_separation"), SNAME("EditorInspector")); @@ -4776,12 +4786,17 @@ void EditorInspector::_notification(int p_what) { ERR_FAIL_NULL(EditorFeatureProfileManager::get_singleton()); EditorFeatureProfileManager::get_singleton()->connect("current_feature_profile_changed", callable_mp(this, &EditorInspector::_feature_profile_changed)); set_process(is_visible_in_tree()); - add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree"))); + get_parent()->connect(SceneStringName(theme_changed), callable_mp(this, &EditorInspector::_update_theme)); + _update_theme(); if (!is_sub_inspector()) { get_tree()->connect("node_removed", callable_mp(this, &EditorInspector::_node_removed)); } } break; + case NOTIFICATION_EXIT_TREE: { + get_parent()->disconnect(SceneStringName(theme_changed), callable_mp(this, &EditorInspector::_update_theme)); + } break; + case NOTIFICATION_PREDELETE: { if (!is_sub_inspector() && is_inside_tree()) { get_tree()->disconnect("node_removed", callable_mp(this, &EditorInspector::_node_removed)); @@ -4842,7 +4857,7 @@ void EditorInspector::_notification(int p_what) { case EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED: { if (!is_sub_inspector() && EditorThemeManager::is_generated_theme_outdated()) { - add_theme_style_override(SceneStringName(panel), get_theme_stylebox(SceneStringName(panel), SNAME("Tree"))); + _update_theme(); } if (use_settings_name_style && EditorSettings::get_singleton()->check_changed_settings_in_group("interface/editor/localize_settings")) { diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 866dad40cb..e943a7f8b4 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -569,6 +569,8 @@ class EditorInspector : public ScrollContainer { int property_focusable; int update_scroll_request; + bool updating_theme = false; + struct DocCacheInfo { String doc_path; String theme_item_name; @@ -606,6 +608,8 @@ class EditorInspector : public ScrollContainer { void _set_property_favorited(const String &p_path, bool p_favorited); void _clear_current_favorites(); + void _update_theme(); + void _node_removed(Node *p_node); HashMap per_array_page;