Clarify API for top selected nodes in EditorSelection and make public

This commit is contained in:
Aaron Franke 2024-12-01 06:40:29 -08:00
parent 594d64ec24
commit 17db92b8b8
No known key found for this signature in database
GPG key ID: 40A1750B977E56BF
12 changed files with 119 additions and 102 deletions

View file

@ -1252,7 +1252,10 @@ void EditorSelection::_bind_methods() {
ClassDB::bind_method(D_METHOD("add_node", "node"), &EditorSelection::add_node);
ClassDB::bind_method(D_METHOD("remove_node", "node"), &EditorSelection::remove_node);
ClassDB::bind_method(D_METHOD("get_selected_nodes"), &EditorSelection::get_selected_nodes);
ClassDB::bind_method(D_METHOD("get_transformable_selected_nodes"), &EditorSelection::_get_transformable_selected_nodes);
ClassDB::bind_method(D_METHOD("get_top_selected_nodes"), &EditorSelection::get_top_selected_nodes);
#ifndef DISABLE_DEPRECATED
ClassDB::bind_method(D_METHOD("get_transformable_selected_nodes"), &EditorSelection::get_top_selected_nodes);
#endif // DISABLE_DEPRECATED
ADD_SIGNAL(MethodInfo("selection_changed"));
}
@ -1265,7 +1268,7 @@ void EditorSelection::_update_node_list() {
return;
}
selected_node_list.clear();
top_selected_node_list.clear();
// If the selection does not have the parent of the selected node, then add the node to the node list.
// However, if the parent is already selected, then adding this node is redundant as
@ -1285,7 +1288,7 @@ void EditorSelection::_update_node_list() {
if (skip) {
continue;
}
selected_node_list.push_back(E.key);
top_selected_node_list.push_back(E.key);
}
node_list_changed = true;
@ -1309,10 +1312,10 @@ void EditorSelection::_emit_change() {
emitted = false;
}
TypedArray<Node> EditorSelection::_get_transformable_selected_nodes() {
TypedArray<Node> EditorSelection::get_top_selected_nodes() {
TypedArray<Node> ret;
for (const Node *E : selected_node_list) {
for (const Node *E : top_selected_node_list) {
ret.push_back(E);
}
@ -1329,13 +1332,13 @@ TypedArray<Node> EditorSelection::get_selected_nodes() {
return ret;
}
const List<Node *> &EditorSelection::get_selected_node_list() {
const List<Node *> &EditorSelection::get_top_selected_node_list() {
if (changed) {
update();
} else {
_update_node_list();
}
return selected_node_list;
return top_selected_node_list;
}
List<Node *> EditorSelection::get_full_selected_node_list() {