Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor Feature Profile: Only rebuild selected TreeItem and all children when a property is edited #92136

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions editor/editor_feature_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,8 @@ void EditorFeatureProfileManager::_hide_requested() {
_cancel_pressed(); // From AcceptDialog.
}

void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected) {
TreeItem *class_item = class_list->create_item(p_parent);
void EditorFeatureProfileManager::_fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected, int p_class_insert_index) {
TreeItem *class_item = class_list->create_item(p_parent, p_class_insert_index);
class_item->set_cell_mode(0, TreeItem::CELL_MODE_CHECK);
class_item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_class));
String text = p_class;
Expand Down Expand Up @@ -647,7 +647,7 @@ void EditorFeatureProfileManager::_class_list_item_edited() {
String class_selected = md;
edited->set_disable_class(class_selected, !checked);
_save_and_update();
_update_selected_profile();
_update_profile_tree_from(item);
} else if (md.get_type() == Variant::INT) {
int feature_selected = md;
edited->set_disable_feature(EditorFeatureProfile::Feature(feature_selected), !checked);
Expand Down Expand Up @@ -703,19 +703,29 @@ void EditorFeatureProfileManager::_property_item_edited() {
String property_selected = md;
edited->set_disable_class_property(class_name, property_selected, !checked);
_save_and_update();
_update_selected_profile();
_update_profile_tree_from(class_list->get_selected());
} else if (md.get_type() == Variant::INT) {
int feature_selected = md;
switch (feature_selected) {
case CLASS_OPTION_DISABLE_EDITOR: {
edited->set_disable_class_editor(class_name, !checked);
_save_and_update();
_update_selected_profile();
_update_profile_tree_from(class_list->get_selected());
} break;
}
}
}

void EditorFeatureProfileManager::_update_profile_tree_from(TreeItem *p_edited) {
String edited_class = p_edited->get_metadata(0);

TreeItem *edited_parent = p_edited->get_parent();
int class_insert_index = p_edited->get_index();
p_edited->get_parent()->remove_child(p_edited);

_fill_classes_from(edited_parent, edited_class, edited_class, class_insert_index);
}

void EditorFeatureProfileManager::_update_selected_profile() {
String class_selected;
int feature_selected = -1;
Expand Down
3 changes: 2 additions & 1 deletion editor/editor_feature_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ class EditorFeatureProfileManager : public AcceptDialog {
String current_profile;
void _update_profile_list(const String &p_select_profile = String());
void _update_selected_profile();
void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected);
void _update_profile_tree_from(TreeItem *p_edited);
void _fill_classes_from(TreeItem *p_parent, const String &p_class, const String &p_selected, int p_class_insert_index = -1);

Ref<EditorFeatureProfile> current;
Ref<EditorFeatureProfile> edited;
Expand Down
Loading