Remove Node.get_position_in_parent()

This commit is contained in:
Tomasz Chabora 2020-04-06 01:06:10 +02:00
parent 4a0e99f197
commit c1023157eb
11 changed files with 18 additions and 32 deletions

View File

@ -238,7 +238,7 @@
<return type="int">
</return>
<description>
Returns the node's index, i.e. its position among the siblings of its parent.
Returns the node's order in the scene tree branch. For example, if called on the first child node the position is [code]0[/code].
</description>
</method>
<method name="get_network_master" qualifiers="const">
@ -331,13 +331,6 @@
Returns the time elapsed since the last physics-bound frame (see [method _physics_process]). This is always a constant value in physics processing unless the frames per second is changed via [member Engine.iterations_per_second].
</description>
</method>
<method name="get_position_in_parent" qualifiers="const">
<return type="int">
</return>
<description>
Returns the node's order in the scene tree branch. For example, if called on the first child node the position is [code]0[/code].
</description>
</method>
<method name="get_process_delta_time" qualifiers="const">
<return type="float">
</return>

View File

@ -2196,7 +2196,7 @@ void EditorPropertyResource::_menu_option(int p_which) {
file_system_dock->navigate_to_path(res->get_path());
// Ensure that the FileSystem dock is visible.
TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
tab_container->set_current_tab(file_system_dock->get_position_in_parent());
tab_container->set_current_tab(file_system_dock->get_index());
} break;
default: {

View File

@ -1243,7 +1243,7 @@ void ScriptEditor::_menu_option(int p_option) {
file_system_dock->navigate_to_path(path);
// Ensure that the FileSystem dock is visible.
TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
tab_container->set_current_tab(file_system_dock->get_position_in_parent());
tab_container->set_current_tab(file_system_dock->get_index());
}
} break;
case CLOSE_DOCS: {

View File

@ -257,7 +257,7 @@ void CustomPropertyEditor::_menu_option(int p_which) {
file_system_dock->navigate_to_path(r->get_path());
// Ensure that the FileSystem dock is visible.
TabContainer *tab_container = (TabContainer *)file_system_dock->get_parent_control();
tab_container->set_current_tab(file_system_dock->get_position_in_parent());
tab_container->set_current_tab(file_system_dock->get_index());
} break;
default: {

View File

@ -1535,7 +1535,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
if (p_nodes[ni] == p_new_parent)
return; // Attempt to reparent to itself.
if (p_nodes[ni]->get_parent() != p_new_parent || p_position_in_parent + ni != p_nodes[ni]->get_position_in_parent())
if (p_nodes[ni]->get_parent() != p_new_parent || p_position_in_parent + ni != p_nodes[ni]->get_index())
no_change = false;
}
@ -1644,7 +1644,7 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V
owners.push_back(E->get());
}
int child_pos = node->get_position_in_parent();
int child_pos = node->get_index();
editor_data->get_undo_redo().add_undo_method(node->get_parent(), "add_child", node);
editor_data->get_undo_redo().add_undo_method(node->get_parent(), "move_child", node, child_pos);
@ -1918,7 +1918,7 @@ Node *SceneTreeDock::_get_selection_group_tail(Node *p_node, List<Node *> p_list
Node *tail = p_node;
Node *parent = tail->get_parent();
for (int i = p_node->get_position_in_parent(); i < parent->get_child_count(); i++) {
for (int i = p_node->get_index(); i < parent->get_child_count(); i++) {
Node *sibling = parent->get_child(i);
if (p_list.find(sibling))

View File

@ -1262,7 +1262,7 @@ void VisualScriptEditor::_add_func_input() {
}
func_input_vbox->add_child(hbox);
hbox->set_meta("id", hbox->get_position_in_parent());
hbox->set_meta("id", hbox->get_index());
delete_button->connect("pressed", callable_mp(this, &VisualScriptEditor::_remove_func_input), varray(hbox));

View File

@ -1893,7 +1893,7 @@ static Control *_next_control(Control *p_from) {
return nullptr;
}
int next = p_from->get_position_in_parent();
int next = p_from->get_index();
ERR_FAIL_INDEX_V(next, parent->get_child_count(), nullptr);
for (int i = (next + 1); i < parent->get_child_count(); i++) {
@ -2032,7 +2032,7 @@ Control *Control::find_prev_valid_focus() const {
} else {
for (int i = (from->get_position_in_parent() - 1); i >= 0; i--) {
for (int i = (from->get_index() - 1); i >= 0; i--) {
Control *c = Object::cast_to<Control>(from->get_parent()->get_child(i));

View File

@ -35,7 +35,7 @@ void CanvasLayer::set_layer(int p_xform) {
layer = p_xform;
if (viewport.is_valid())
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
}
int CanvasLayer::get_layer() const {
@ -151,7 +151,7 @@ void CanvasLayer::_notification(int p_what) {
viewport = vp->get_viewport_rid();
RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas);
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
_update_follow_viewport();
@ -167,7 +167,7 @@ void CanvasLayer::_notification(int p_what) {
case NOTIFICATION_MOVED_IN_PARENT: {
if (is_inside_tree())
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
} break;
}
@ -214,7 +214,7 @@ void CanvasLayer::set_custom_viewport(Node *p_viewport) {
viewport = vp->get_viewport_rid();
RenderingServer::get_singleton()->viewport_attach_canvas(viewport, canvas);
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_position_in_parent());
RenderingServer::get_singleton()->viewport_set_canvas_stacking(viewport, canvas, layer, get_index());
RenderingServer::get_singleton()->viewport_set_canvas_transform(viewport, canvas, transform);
}
}

View File

@ -95,7 +95,7 @@ Node *InstancePlaceholder::create_instance(bool p_replace, const Ref<PackedScene
if (!scene)
return nullptr;
scene->set_name(get_name());
int pos = get_position_in_parent();
int pos = get_index();
for (List<PropSet>::Element *E = stored_values.front(); E; E = E->next()) {
scene->set(E->get().name, E->get().value);

View File

@ -1268,7 +1268,7 @@ void Node::add_child_below_node(Node *p_node, Node *p_child, bool p_legible_uniq
add_child(p_child, p_legible_unique_name);
if (is_a_parent_of(p_node)) {
move_child(p_child, p_node->get_position_in_parent() + 1);
move_child(p_child, p_node->get_index() + 1);
} else {
WARN_PRINT("Cannot move under node " + p_node->get_name() + " as " + p_child->get_name() + " does not share a parent.");
}
@ -1918,6 +1918,7 @@ int Node::get_index() const {
return data.pos;
}
void Node::remove_and_skip() {
ERR_FAIL_COND(!data.parent);
@ -2042,11 +2043,6 @@ bool Node::get_scene_instance_load_placeholder() const {
return data.use_placeholder;
}
int Node::get_position_in_parent() const {
return data.pos;
}
Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const {
Node *node = nullptr;
@ -2215,7 +2211,7 @@ Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const
}
parent->add_child(dup);
int pos = E->get()->get_position_in_parent();
int pos = E->get()->get_index();
if (pos < parent->get_child_count() - 1) {
@ -2860,7 +2856,6 @@ void Node::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_pause_mode"), &Node::get_pause_mode);
ClassDB::bind_method(D_METHOD("can_process"), &Node::can_process);
ClassDB::bind_method(D_METHOD("print_stray_nodes"), &Node::_print_stray_nodes);
ClassDB::bind_method(D_METHOD("get_position_in_parent"), &Node::get_position_in_parent);
ClassDB::bind_method(D_METHOD("set_display_folded", "fold"), &Node::set_display_folded);
ClassDB::bind_method(D_METHOD("is_displayed_folded"), &Node::is_displayed_folded);

View File

@ -369,8 +369,6 @@ public:
void set_process_unhandled_key_input(bool p_enable);
bool is_processing_unhandled_key_input() const;
int get_position_in_parent() const;
Node *duplicate(int p_flags = DUPLICATE_GROUPS | DUPLICATE_SIGNALS | DUPLICATE_SCRIPTS) const;
Node *duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const;
#ifdef TOOLS_ENABLED