diff options
Diffstat (limited to 'editor')
-rw-r--r-- | editor/editor_folding.cpp | 8 | ||||
-rw-r--r-- | editor/editor_folding.h | 2 | ||||
-rw-r--r-- | editor/editor_inspector.cpp | 40 | ||||
-rw-r--r-- | editor/editor_inspector.h | 19 | ||||
-rw-r--r-- | editor/editor_node.cpp | 1 | ||||
-rw-r--r-- | editor/editor_node.h | 1 | ||||
-rw-r--r-- | editor/inspector_dock.cpp | 1 |
7 files changed, 63 insertions, 9 deletions
diff --git a/editor/editor_folding.cpp b/editor/editor_folding.cpp index 33d596e58e..41c2566273 100644 --- a/editor/editor_folding.cpp +++ b/editor/editor_folding.cpp @@ -1,5 +1,6 @@ #include "editor_folding.h" +#include "core/os/file_access.h" #include "editor_settings.h" PoolVector<String> EditorFolding::_get_unfolds(const Object *p_object) { @@ -164,5 +165,12 @@ void EditorFolding::load_scene_folding(Node *p_scene, const String &p_path) { } } +bool EditorFolding::has_folding_data(const String &p_path) { + String path = EditorSettings::get_singleton()->get_project_settings_dir(); + String file = p_path.get_file() + "-folding-" + p_path.md5_text() + ".cfg"; + file = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(file); + return FileAccess::exists(file); +} + EditorFolding::EditorFolding() { } diff --git a/editor/editor_folding.h b/editor/editor_folding.h index b1b423cffc..cfd4b5466d 100644 --- a/editor/editor_folding.h +++ b/editor/editor_folding.h @@ -17,6 +17,8 @@ public: void save_scene_folding(const Node *p_scene, const String &p_path); void load_scene_folding(Node *p_scene, const String &p_path); + bool has_folding_data(const String &p_path); + EditorFolding(); }; 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; diff --git a/editor/editor_inspector.h b/editor/editor_inspector.h index 58511a17fe..350debcb7b 100644 --- a/editor/editor_inspector.h +++ b/editor/editor_inspector.h @@ -38,20 +38,19 @@ class UndoRedo; class EditorDefaultClassValueCache : public Object { - GDCLASS(EditorDefaultClassValueCache,Object) + GDCLASS(EditorDefaultClassValueCache, Object) - Map<StringName,Map<StringName,Variant> > default_values; + Map<StringName, Map<StringName, Variant> > default_values; - static EditorDefaultClassValueCache *singleton; -public: + static EditorDefaultClassValueCache *singleton; - static EditorDefaultClassValueCache *get_singleton(); +public: + static EditorDefaultClassValueCache *get_singleton(); - Variant get_default_value(const StringName& p_class,const StringName& p_property); - EditorDefaultClassValueCache(); + Variant get_default_value(const StringName &p_class, const StringName &p_property); + EditorDefaultClassValueCache(); }; - class EditorProperty : public Container { GDCLASS(EditorProperty, Container) @@ -167,6 +166,8 @@ public: void set_draw_top_bg(bool p_draw) { draw_top_bg = p_draw; } + bool can_revert_to_default() const { return can_revert; } + EditorProperty(); }; @@ -286,6 +287,7 @@ class EditorInspector : public ScrollContainer { bool read_only; bool keying; bool use_sub_inspector_bg; + bool auto_unfold_edited; float refresh_countdown; bool update_tree_pending; @@ -380,6 +382,7 @@ public: String get_object_class() const; void set_use_sub_inspector_bg(bool p_enable); + void set_auto_unfold_edited(bool p_enable); EditorInspector(); }; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d3d1f7c49e..e9ce2cb8ae 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -4864,6 +4864,7 @@ EditorNode::EditorNode() { EDITOR_DEF_RST("interface/scene_tabs/show_thumbnail_on_hover", true); EDITOR_DEF_RST("interface/inspector/capitalize_properties", true); EDITOR_DEF_RST("interface/inspector/disable_folding", false); + EDITOR_DEF_RST("interface/inspector/auto_unfold_edited", true); EDITOR_DEF("interface/inspector/horizontal_vector2_editing", false); EDITOR_DEF("interface/inspector/horizontal_vector_types_editing", true); EDITOR_DEF("interface/inspector/open_resources_in_current_inspector", true); diff --git a/editor/editor_node.h b/editor/editor_node.h index eea488b888..33af473de3 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -696,6 +696,7 @@ public: void set_current_scene(int p_idx); static EditorData &get_editor_data() { return singleton->editor_data; } + static EditorFolding &get_editor_folding() { return singleton->editor_folding; } EditorHistory *get_editor_history() { return &editor_history; } static VSplitContainer *get_top_split() { return singleton->top_split; } diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 750fca2852..2a8885c0a4 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -593,6 +593,7 @@ InspectorDock::InspectorDock(EditorNode *p_editor, EditorData &p_editor_data) { inspector->set_undo_redo(&editor_data->get_undo_redo()); inspector->set_use_filter(true); // TODO: check me + inspector->set_auto_unfold_edited(bool(EDITOR_GET("interface/inspector/auto_unfold_edited"))); inspector->connect("resource_selected", this, "_resource_selected"); inspector->connect("property_keyed", this, "_property_keyed"); |