Skip to content

Commit

Permalink
Merge pull request #92136 from Maran23/editor-feature-profile-improve…
Browse files Browse the repository at this point in the history
…ments

Editor Feature Profile: Only rebuild selected TreeItem and all children when a property is edited
  • Loading branch information
akien-mga committed May 20, 2024
2 parents 15a8887 + 7008111 commit b44e9b0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
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

0 comments on commit b44e9b0

Please sign in to comment.