Fix theme updating of the inspector sections

This commit is contained in:
Yuri Rubinsky 2024-06-10 23:22:52 +03:00
parent b75f0485ba
commit 89dd7107d9
2 changed files with 9 additions and 5 deletions

View File

@ -413,7 +413,7 @@ void EditorProperty::_notification(int p_what) {
if (has_borders) { if (has_borders) {
get_parent()->disconnect(SceneStringName(theme_changed), callable_mp(this, &EditorProperty::_update_property_bg)); get_parent()->disconnect(SceneStringName(theme_changed), callable_mp(this, &EditorProperty::_update_property_bg));
} }
} } break;
} }
} }
@ -1364,6 +1364,8 @@ void EditorInspectorSection::_notification(int p_what) {
switch (p_what) { switch (p_what) {
case NOTIFICATION_THEME_CHANGED: { case NOTIFICATION_THEME_CHANGED: {
update_minimum_size(); update_minimum_size();
bg_color = get_theme_color(SNAME("prop_subsection"), EditorStringName(Editor));
bg_color.a /= level;
} break; } break;
case NOTIFICATION_SORT_CHILDREN: { case NOTIFICATION_SORT_CHILDREN: {
@ -1562,13 +1564,14 @@ Size2 EditorInspectorSection::get_minimum_size() const {
return ms; return ms;
} }
void EditorInspectorSection::setup(const String &p_section, const String &p_label, Object *p_object, const Color &p_bg_color, bool p_foldable, int p_indent_depth) { void EditorInspectorSection::setup(const String &p_section, const String &p_label, Object *p_object, const Color &p_bg_color, bool p_foldable, int p_indent_depth, int p_level) {
section = p_section; section = p_section;
label = p_label; label = p_label;
object = p_object; object = p_object;
bg_color = p_bg_color; bg_color = p_bg_color;
foldable = p_foldable; foldable = p_foldable;
indent_depth = p_indent_depth; indent_depth = p_indent_depth;
level = p_level;
if (!foldable && !vbox_added) { if (!foldable && !vbox_added) {
add_child(vbox); add_child(vbox);
@ -1668,7 +1671,7 @@ void EditorInspectorSection::property_can_revert_changed(const String &p_path, b
} }
void EditorInspectorSection::_bind_methods() { void EditorInspectorSection::_bind_methods() {
ClassDB::bind_method(D_METHOD("setup", "section", "label", "object", "bg_color", "foldable"), &EditorInspectorSection::setup); ClassDB::bind_method(D_METHOD("setup", "section", "label", "object", "bg_color", "foldable", "indent_depth", "level"), &EditorInspectorSection::setup, DEFVAL(0), DEFVAL(1));
ClassDB::bind_method(D_METHOD("get_vbox"), &EditorInspectorSection::get_vbox); ClassDB::bind_method(D_METHOD("get_vbox"), &EditorInspectorSection::get_vbox);
ClassDB::bind_method(D_METHOD("unfold"), &EditorInspectorSection::unfold); ClassDB::bind_method(D_METHOD("unfold"), &EditorInspectorSection::unfold);
ClassDB::bind_method(D_METHOD("fold"), &EditorInspectorSection::fold); ClassDB::bind_method(D_METHOD("fold"), &EditorInspectorSection::fold);
@ -3178,7 +3181,7 @@ void EditorInspector::update_tree() {
Color c = sscolor; Color c = sscolor;
c.a /= level; c.a /= level;
section->setup(acc_path, label, object, c, use_folding, section_depth); section->setup(acc_path, label, object, c, use_folding, section_depth, level);
section->set_tooltip_text(tooltip); section->set_tooltip_text(tooltip);
// Add editors at the start of a group. // Add editors at the start of a group.

View File

@ -307,6 +307,7 @@ class EditorInspectorSection : public Container {
Color bg_color; Color bg_color;
bool foldable = false; bool foldable = false;
int indent_depth = 0; int indent_depth = 0;
int level = 1;
Timer *dropping_unfold_timer = nullptr; Timer *dropping_unfold_timer = nullptr;
bool dropping = false; bool dropping = false;
@ -329,7 +330,7 @@ protected:
public: public:
virtual Size2 get_minimum_size() const override; virtual Size2 get_minimum_size() const override;
void setup(const String &p_section, const String &p_label, Object *p_object, const Color &p_bg_color, bool p_foldable, int p_indent_depth = 0); void setup(const String &p_section, const String &p_label, Object *p_object, const Color &p_bg_color, bool p_foldable, int p_indent_depth = 0, int p_level = 1);
VBoxContainer *get_vbox(); VBoxContainer *get_vbox();
void unfold(); void unfold();
void fold(); void fold();