summaryrefslogtreecommitdiffstats
path: root/editor/editor_properties.cpp
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2021-02-11 18:01:56 -0300
committerreduz <reduzio@gmail.com>2021-02-12 09:31:47 -0300
commitb9b68b755c32dc296eddd5b95116c21d63ac62c8 (patch)
treedbb8c38c30ff45c0d9c006d96f6c9f0b75cdafbf /editor/editor_properties.cpp
parentd3867b2dab4e37b29c4033cac71378e56334317f (diff)
downloadredot-engine-b9b68b755c32dc296eddd5b95116c21d63ac62c8.tar.gz
Improved Inspector Sub-Resource Editing
-Better margins -Colors to delimit subresources better.
Diffstat (limited to 'editor/editor_properties.cpp')
-rw-r--r--editor/editor_properties.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp
index 669f381979..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,6 +2942,8 @@ void EditorPropertyResource::update_property() {
}
opened_editor = true;
}
+
+ _update_property_bg();
}
if (res.ptr() != sub_inspector->get_edited_object()) {
@@ -2923,6 +2960,7 @@ void EditorPropertyResource::update_property() {
EditorNode::get_singleton()->hide_top_editors();
opened_editor = false;
}
+ _update_property_bg();
}
}
}
@@ -2976,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) {