Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
#46773 implemented some of the requested item management methods, but one thing was amiss — a way to add an unparented
TreeItem
back to theTree
(or move it to anotherTree
). The issue was made worse by the fact that we have aTreeItem::remove_child
method, but noTreeItem::add_child
method. Documentation forremove_child
states that the unparented item can be reused, but how?At the same time, aforementioned PR added
move_before
/move_after
, which actually support moving items between different trees. So the implementation of theadd_child
method was on the surface. And it was explicitly asked for in godotengine/godot-proposals#3607.Personally, I thought about using it for some sort of cache in the editor. For example, in the editor help search dialog we could create every
TreeItem
that we need and then reuse them, instead of recreating them on the fly, constantly. I was working on that, but decided to splitTree
improvements for now.Additional changes in this PR include:
create_child
method variables;_change_tree(nullptr)
to theremove_child
method;Closes godotengine/godot-proposals#3607.
godot.windows.editor.dev.x86_64_2023-05-24_19-40-37.mp4