diff options
author | Emre Aydin <aeaydin1@gmail.com> | 2021-05-27 17:19:33 +0300 |
---|---|---|
committer | Emre Aydin <aeaydin1@gmail.com> | 2021-05-27 17:19:40 +0300 |
commit | 0f9913ce33484e22a49298a0c2f28e24b9d55e95 (patch) | |
tree | 96f3ce18256525d579bc199224a2ee4e970dae8e | |
parent | 364ea7f280a3f074795e542b16b1d0ec76cf6ce2 (diff) |
Fixed changing enabled classes resetting folding in manage editor features.
-rw-r--r-- | editor/editor_feature_profile.cpp | 36 | ||||
-rw-r--r-- | editor/editor_feature_profile.h | 6 |
2 files changed, 42 insertions, 0 deletions
diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index bd00d86ec8..529bbe97eb 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -118,6 +118,18 @@ bool EditorFeatureProfile::has_class_properties_disabled(const StringName &p_cla return disabled_properties.has(p_class); } +void EditorFeatureProfile::set_item_collapsed(const StringName &p_class, bool p_collapsed) { + if (p_collapsed) { + collapsed_classes.insert(p_class); + } else { + collapsed_classes.erase(p_class); + } +} + +bool EditorFeatureProfile::is_item_collapsed(const StringName &p_class) const { + return collapsed_classes.has(p_class); +} + void EditorFeatureProfile::set_disable_feature(Feature p_feature, bool p_disable) { ERR_FAIL_INDEX(p_feature, FEATURE_MAX); features_disabled[p_feature] = p_disable; @@ -484,6 +496,9 @@ void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const S class_item->set_selectable(0, true); class_item->set_metadata(0, p_class); + bool collapsed = edited->is_item_collapsed(p_class); + class_item->set_collapsed(collapsed); + if (p_class == p_selected) { class_item->select(0); } @@ -596,6 +611,26 @@ void EditorFeatureProfileManager::_class_list_item_edited() { } } +void EditorFeatureProfileManager::_class_list_item_collapsed(Object *p_item) { + if (updating_features) { + return; + } + + TreeItem *item = Object::cast_to<TreeItem>(p_item); + if (!item) { + return; + } + + Variant md = item->get_metadata(0); + if (md.get_type() != Variant::STRING && md.get_type() != Variant::STRING_NAME) { + return; + } + + String class_name = md; + bool collapsed = item->is_collapsed(); + edited->set_item_collapsed(class_name, collapsed); +} + void EditorFeatureProfileManager::_property_item_edited() { if (updating_features) { return; @@ -853,6 +888,7 @@ EditorFeatureProfileManager::EditorFeatureProfileManager() { class_list->set_edit_checkbox_cell_only_when_checkbox_is_pressed(true); class_list->connect("cell_selected", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_selected)); class_list->connect("item_edited", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_edited), varray(), CONNECT_DEFERRED); + class_list->connect("item_collapsed", callable_mp(this, &EditorFeatureProfileManager::_class_list_item_collapsed)); // It will be displayed once the user creates or chooses a profile. class_list_vbc->hide(); diff --git a/editor/editor_feature_profile.h b/editor/editor_feature_profile.h index 01e6a6a142..9561e11c81 100644 --- a/editor/editor_feature_profile.h +++ b/editor/editor_feature_profile.h @@ -60,6 +60,8 @@ private: Set<StringName> disabled_editors; Map<StringName, Set<StringName>> disabled_properties; + Set<StringName> collapsed_classes; + bool features_disabled[FEATURE_MAX]; static const char *feature_names[FEATURE_MAX]; static const char *feature_identifiers[FEATURE_MAX]; @@ -80,6 +82,9 @@ public: bool is_class_property_disabled(const StringName &p_class, const StringName &p_property) const; bool has_class_properties_disabled(const StringName &p_class) const; + void set_item_collapsed(const StringName &p_class, bool p_collapsed); + bool is_item_collapsed(const StringName &p_class) const; + void set_disable_feature(Feature p_feature, bool p_disable); bool is_feature_disabled(Feature p_feature) const; @@ -151,6 +156,7 @@ class EditorFeatureProfileManager : public AcceptDialog { void _class_list_item_selected(); void _class_list_item_edited(); + void _class_list_item_collapsed(Object *p_item); void _property_item_edited(); void _save_and_update(); |