Update inspector theme when changed

This commit is contained in:
Grublady 2025-03-18 19:01:02 -04:00
parent af2c713971
commit 4441874c62
2 changed files with 21 additions and 2 deletions

View file

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

View file

@ -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<StringName, int> per_array_page;