summaryrefslogtreecommitdiff
path: root/editor/editor_inspector.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <juan@godotengine.org>2018-10-29 17:38:51 -0300
committerJuan Linietsky <juan@godotengine.org>2018-10-29 17:39:17 -0300
commit4761c6bb7bbaacd20583be502901a8ab834a8718 (patch)
treeb0b78ec2a115f09fa6a424cfeba6bbf61d52c48c /editor/editor_inspector.cpp
parent4d9b8a98ba1bdd2bc7d80f4ab61061c07298fd15 (diff)
Automatically unfold sections of properties that someone else edited (no local info exists).
Diffstat (limited to 'editor/editor_inspector.cpp')
-rw-r--r--editor/editor_inspector.cpp40
1 files changed, 39 insertions, 1 deletions
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index 892e6daae2..1324ad0e65 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1431,6 +1431,28 @@ void EditorInspector::update_tree() {
// TreeItem *current_category = NULL;
+ bool unfold_if_edited = false;
+
+ if (use_folding && auto_unfold_edited && get_tree()->get_edited_scene_root()) {
+ String path;
+ Node *node = Object::cast_to<Node>(object);
+ if (node) {
+ path = get_tree()->get_edited_scene_root()->get_filename();
+ }
+ Resource *res = Object::cast_to<Resource>(object);
+ if (res) {
+ if (res->get_path().is_resource_file()) {
+ path = res->get_path();
+ } else if (res->get_path().begins_with("res://")) { //internal resource
+ path = get_tree()->get_edited_scene_root()->get_filename();
+ }
+ }
+
+ if (!EditorNode::get_singleton()->get_editor_folding().has_folding_data(path)) {
+ unfold_if_edited = true;
+ }
+ }
+
String filter = search_box ? search_box->get_text() : "";
String group;
String group_base;
@@ -1441,6 +1463,8 @@ void EditorInspector::update_tree() {
object->get_property_list(&plist, true);
HashMap<String, VBoxContainer *> item_path;
+ Map<VBoxContainer *, EditorInspectorSection *> section_map;
+
item_path[""] = main_vbox;
Color sscolor = get_color("prop_subsection", "Editor");
@@ -1603,7 +1627,9 @@ void EditorInspector::update_tree() {
c.a /= level;
section->setup(acc_path, path_name, object, c, use_folding);
- item_path[acc_path] = section->get_vbox();
+ VBoxContainer *vb = section->get_vbox();
+ item_path[acc_path] = vb;
+ section_map[vb] = section;
}
current_vbox = item_path[acc_path];
level = (MIN(level + 1, 4));
@@ -1746,6 +1772,13 @@ void EditorInspector::update_tree() {
if (current_selected && ep->property == current_selected) {
ep->select(current_focusable);
}
+
+ if (unfold_if_edited && ep->can_revert_to_default()) {
+ //if edited and there is a parent section, unfold it.
+ if (current_vbox && section_map.has(current_vbox)) {
+ section_map[current_vbox]->unfold();
+ }
+ }
}
}
@@ -2242,6 +2275,10 @@ String EditorInspector::get_object_class() const {
return object_class;
}
+void EditorInspector::set_auto_unfold_edited(bool p_enable) {
+ auto_unfold_edited = p_enable;
+}
+
void EditorInspector::_bind_methods() {
ClassDB::bind_method("_property_changed", &EditorInspector::_property_changed, DEFVAL(false));
@@ -2297,6 +2334,7 @@ EditorInspector::EditorInspector() {
set_process(true);
property_focusable = -1;
use_sub_inspector_bg = false;
+ auto_unfold_edited = false;
get_v_scrollbar()->connect("value_changed", this, "_vscroll_changed");
update_scroll_request = -1;