diff options
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r-- | editor/editor_properties.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 111d2666c3..6bfc16ccd7 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -2859,6 +2859,41 @@ void EditorPropertyResource::_fold_other_editors(Object *p_self) { } } +void EditorPropertyResource::_update_property_bg() { + if (!is_inside_tree()) { + return; + } + + updating_theme = true; + if (sub_inspector != nullptr) { + int count_subinspectors = 0; + Node *n = get_parent(); + while (n) { + EditorInspector *ei = Object::cast_to<EditorInspector>(n); + if (ei && ei->is_sub_inspector()) { + count_subinspectors++; + } + n = n->get_parent(); + } + count_subinspectors = MIN(15, count_subinspectors); + + add_theme_color_override("property_color", get_theme_color("sub_inspector_property_color", "Editor")); + add_theme_style_override("bg_selected", get_theme_stylebox("sub_inspector_property_bg_selected" + itos(count_subinspectors), "Editor")); + add_theme_style_override("bg", get_theme_stylebox("sub_inspector_property_bg" + itos(count_subinspectors), "Editor")); + + add_theme_constant_override("font_offset", get_theme_constant("sub_inspector_font_offset", "Editor")); + add_theme_constant_override("vseparation", 0); + } else { + add_theme_color_override("property_color", get_theme_color("property_color", "EditorProperty")); + add_theme_style_override("bg_selected", get_theme_stylebox("bg_selected", "EditorProperty")); + add_theme_style_override("bg", get_theme_stylebox("bg", "EditorProperty")); + add_theme_constant_override("vseparation", get_theme_constant("vseparation", "EditorProperty")); + add_theme_constant_override("font_offset", get_theme_constant("font_offset", "EditorProperty")); + } + + updating_theme = false; + update(); +} void EditorPropertyResource::update_property() { RES res = get_edited_object()->get(get_edited_property()); @@ -2907,13 +2942,14 @@ void EditorPropertyResource::update_property() { } opened_editor = true; } + + _update_property_bg(); } if (res.ptr() != sub_inspector->get_edited_object()) { sub_inspector->edit(res.ptr()); } - sub_inspector->refresh(); } else { if (sub_inspector) { set_bottom_editor(nullptr); @@ -2924,6 +2960,7 @@ void EditorPropertyResource::update_property() { EditorNode::get_singleton()->hide_top_editors(); opened_editor = false; } + _update_property_bg(); } } } @@ -2977,8 +3014,12 @@ void EditorPropertyResource::setup(const String &p_base_type) { void EditorPropertyResource::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { + if (updating_theme) { + return; + } Ref<Texture2D> t = get_theme_icon("select_arrow", "Tree"); edit->set_icon(t); + _update_property_bg(); } if (p_what == NOTIFICATION_DRAG_BEGIN) { |