From 899e5f8685dc10df5b24a1b765803e19224be61c Mon Sep 17 00:00:00 2001 From: Lightning_A Date: Fri, 18 Jun 2021 16:02:50 -0600 Subject: [PATCH] Rename `is_a_parent_of()` to `is_ancestor_of()` --- doc/classes/Node.xml | 2 +- editor/code_editor.cpp | 2 +- editor/editor_help.cpp | 2 +- editor/plugins/canvas_item_editor_plugin.cpp | 2 +- editor/plugins/node_3d_editor_plugin.cpp | 6 +++--- scene/2d/gpu_particles_2d.cpp | 2 +- scene/2d/remote_transform_2d.cpp | 2 +- scene/3d/remote_transform_3d.cpp | 2 +- scene/debugger/scene_debugger.cpp | 18 +++++++++--------- scene/gui/base_button.cpp | 2 +- scene/gui/control.cpp | 2 +- scene/gui/scroll_container.cpp | 4 ++-- scene/main/node.cpp | 16 ++++++++-------- scene/main/node.h | 2 +- scene/main/scene_tree.cpp | 2 +- scene/main/timer.cpp | 2 +- scene/main/viewport.cpp | 6 +++--- 17 files changed, 37 insertions(+), 37 deletions(-) diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 1300351e475..653fc1b0596 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -416,7 +416,7 @@ Returns [code]true[/code] if the [NodePath] points to a valid node and its subname points to a valid resource, e.g. [code]Area2D/CollisionShape2D:shape[/code]. Properties with a non-[Resource] type (e.g. nodes or primitive math types) are not considered resources. - + diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 807a45eb329..7f91ae28a44 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -117,7 +117,7 @@ void FindReplaceBar::_unhandled_input(const Ref &p_event) { } Control *focus_owner = get_focus_owner(); - if (text_editor->has_focus() || (focus_owner && vbc_lineedit->is_a_parent_of(focus_owner))) { + if (text_editor->has_focus() || (focus_owner && vbc_lineedit->is_ancestor_of(focus_owner))) { bool accepted = true; switch (k->get_keycode()) { diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 7365e8fd7d5..16db465a4a8 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -1909,7 +1909,7 @@ void FindBar::_unhandled_input(const Ref &p_event) { Ref k = p_event; if (k.is_valid()) { - if (k->is_pressed() && (rich_text_label->has_focus() || is_a_parent_of(get_focus_owner()))) { + if (k->is_pressed() && (rich_text_label->has_focus() || is_ancestor_of(get_focus_owner()))) { bool accepted = true; switch (k->get_keycode()) { diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 5d248176c1b..e648ffff29c 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1241,7 +1241,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref &p_event, bo Ref pan_gesture = p_event; if (pan_gesture.is_valid() && !p_already_accepted) { - // If control key pressed, then zoom instead of pan + // If ctrl key pressed, then zoom instead of pan. if (pan_gesture->is_ctrl_pressed()) { const float factor = pan_gesture->get_delta().y; diff --git a/editor/plugins/node_3d_editor_plugin.cpp b/editor/plugins/node_3d_editor_plugin.cpp index 726f74e67fe..911c5147bf3 100644 --- a/editor/plugins/node_3d_editor_plugin.cpp +++ b/editor/plugins/node_3d_editor_plugin.cpp @@ -6370,7 +6370,7 @@ void Node3DEditor::_request_gizmo(Object *p_obj) { if (!sp) { return; } - if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_a_parent_of(sp)))) { + if (editor->get_edited_scene() && (sp == editor->get_edited_scene() || (sp->get_owner() && editor->get_edited_scene()->is_ancestor_of(sp)))) { Ref seg; for (int i = 0; i < gizmo_plugins_by_priority.size(); ++i) { @@ -6444,7 +6444,7 @@ void Node3DEditor::_toggle_maximize_view(Object *p_viewport) { } void Node3DEditor::_node_added(Node *p_node) { - if (EditorNode::get_singleton()->get_scene_root()->is_a_parent_of(p_node)) { + if (EditorNode::get_singleton()->get_scene_root()->is_ancestor_of(p_node)) { if (Object::cast_to(p_node)) { world_env_count++; if (world_env_count == 1) { @@ -6460,7 +6460,7 @@ void Node3DEditor::_node_added(Node *p_node) { } void Node3DEditor::_node_removed(Node *p_node) { - if (EditorNode::get_singleton()->get_scene_root()->is_a_parent_of(p_node)) { + if (EditorNode::get_singleton()->get_scene_root()->is_ancestor_of(p_node)) { if (Object::cast_to(p_node)) { world_env_count--; if (world_env_count == 0) { diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index d7404ff4799..bf7bb12dbe9 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -451,7 +451,7 @@ void GPUParticles2D::_notification(int p_what) { RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid); #ifdef TOOLS_ENABLED - if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) { + if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { draw_rect(visibility_rect, Color(0, 0.7, 0.9, 0.4), false); } #endif diff --git a/scene/2d/remote_transform_2d.cpp b/scene/2d/remote_transform_2d.cpp index a7613dc009f..e7cef965fe5 100644 --- a/scene/2d/remote_transform_2d.cpp +++ b/scene/2d/remote_transform_2d.cpp @@ -35,7 +35,7 @@ void RemoteTransform2D::_update_cache() { cache = ObjectID(); if (has_node(remote_node)) { Node *node = get_node(remote_node); - if (!node || this == node || node->is_a_parent_of(this) || this->is_a_parent_of(node)) { + if (!node || this == node || node->is_ancestor_of(this) || this->is_ancestor_of(node)) { return; } diff --git a/scene/3d/remote_transform_3d.cpp b/scene/3d/remote_transform_3d.cpp index a7b3a6f1ec7..d5fb1fa6abd 100644 --- a/scene/3d/remote_transform_3d.cpp +++ b/scene/3d/remote_transform_3d.cpp @@ -34,7 +34,7 @@ void RemoteTransform3D::_update_cache() { cache = ObjectID(); if (has_node(remote_node)) { Node *node = get_node(remote_node); - if (!node || this == node || node->is_a_parent_of(this) || this->is_a_parent_of(node)) { + if (!node || this == node || node->is_ancestor_of(this) || this->is_ancestor_of(node)) { return; } diff --git a/scene/debugger/scene_debugger.cpp b/scene/debugger/scene_debugger.cpp index 11ce9b2ddc7..5cf44c9afdb 100644 --- a/scene/debugger/scene_debugger.cpp +++ b/scene/debugger/scene_debugger.cpp @@ -525,7 +525,7 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian for (Set::Element *F = E->get().front(); F; F = F->next()) { Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } @@ -569,7 +569,7 @@ void LiveEditor::_node_call_func(int p_id, const StringName &p_method, VARIANT_A for (Set::Element *F = E->get().front(); F; F = F->next()) { Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } @@ -652,7 +652,7 @@ void LiveEditor::_create_node_func(const NodePath &p_parent, const String &p_typ for (Set::Element *F = E->get().front(); F; F = F->next()) { Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } @@ -696,7 +696,7 @@ void LiveEditor::_instance_node_func(const NodePath &p_parent, const String &p_p for (Set::Element *F = E->get().front(); F; F = F->next()) { Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } @@ -736,7 +736,7 @@ void LiveEditor::_remove_node_func(const NodePath &p_at) { Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } @@ -772,7 +772,7 @@ void LiveEditor::_remove_and_keep_node_func(const NodePath &p_at, ObjectID p_kee Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } @@ -811,7 +811,7 @@ void LiveEditor::_restore_node_func(ObjectID p_id, const NodePath &p_at, int p_a Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } @@ -862,7 +862,7 @@ void LiveEditor::_duplicate_node_func(const NodePath &p_at, const String &p_new_ for (Set::Element *F = E->get().front(); F; F = F->next()) { Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } @@ -901,7 +901,7 @@ void LiveEditor::_reparent_node_func(const NodePath &p_at, const NodePath &p_new for (Set::Element *F = E->get().front(); F; F = F->next()) { Node *n = F->get(); - if (base && !base->is_a_parent_of(n)) { + if (base && !base->is_ancestor_of(n)) { continue; } diff --git a/scene/gui/base_button.cpp b/scene/gui/base_button.cpp index 66155958cfb..c1ae0479f54 100644 --- a/scene/gui/base_button.cpp +++ b/scene/gui/base_button.cpp @@ -391,7 +391,7 @@ bool BaseButton::_is_focus_owner_in_shorcut_context() const { Control *vp_focus = get_focus_owner(); // If the context is valid and the viewport focus is valid, check if the context is the focus or is a parent of it. - return ctx_node && vp_focus && (ctx_node == vp_focus || ctx_node->is_a_parent_of(vp_focus)); + return ctx_node && vp_focus && (ctx_node == vp_focus || ctx_node->is_ancestor_of(vp_focus)); } void BaseButton::_bind_methods() { diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index c84627c21e5..bb2a8302c47 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -1084,7 +1084,7 @@ Rect2 Control::get_parent_anchorable_rect() const { } else { #ifdef TOOLS_ENABLED Node *edited_root = get_tree()->get_edited_scene_root(); - if (edited_root && (this == edited_root || edited_root->is_a_parent_of(this))) { + if (edited_root && (this == edited_root || edited_root->is_ancestor_of(this))) { parent_rect.size = Size2(ProjectSettings::get_singleton()->get("display/window/size/width"), ProjectSettings::get_singleton()->get("display/window/size/height")); } else { parent_rect = get_viewport()->get_visible_rect(); diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 5f872644abd..28d12604583 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -239,13 +239,13 @@ void ScrollContainer::_update_scrollbar_position() { } void ScrollContainer::_gui_focus_changed(Control *p_control) { - if (follow_focus && is_a_parent_of(p_control)) { + if (follow_focus && is_ancestor_of(p_control)) { ensure_control_visible(p_control); } } void ScrollContainer::ensure_control_visible(Control *p_control) { - ERR_FAIL_COND_MSG(!is_a_parent_of(p_control), "Must be a parent of the control."); + ERR_FAIL_COND_MSG(!is_ancestor_of(p_control), "Must be an ancestor of the control."); Rect2 global_rect = get_global_rect(); Rect2 other_rect = p_control->get_global_rect(); diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 622c271935d..8cf2aa24fbb 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1040,7 +1040,7 @@ void Node::add_child(Node *p_child, bool p_legible_unique_name) { ERR_FAIL_COND_MSG(p_child == this, vformat("Can't add child '%s' to itself.", p_child->get_name())); // adding to itself! ERR_FAIL_COND_MSG(p_child->data.parent, vformat("Can't add child '%s' to '%s', already has a parent '%s'.", p_child->get_name(), get_name(), p_child->data.parent->get_name())); //Fail if node has a parent #ifdef DEBUG_ENABLED - ERR_FAIL_COND_MSG(p_child->is_a_parent_of(this), vformat("Can't add child '%s' to '%s' as it would result in a cyclic dependency since '%s' is already a parent of '%s'.", p_child->get_name(), get_name(), p_child->get_name(), get_name())); + ERR_FAIL_COND_MSG(p_child->is_ancestor_of(this), vformat("Can't add child '%s' to '%s' as it would result in a cyclic dependency since '%s' is already a parent of '%s'.", p_child->get_name(), get_name(), p_child->get_name(), get_name())); #endif ERR_FAIL_COND_MSG(data.blocked > 0, "Parent node is busy setting up children, add_node() failed. Consider using call_deferred(\"add_child\", child) instead."); @@ -1283,7 +1283,7 @@ Node *Node::find_parent(const String &p_mask) const { return nullptr; } -bool Node::is_a_parent_of(const Node *p_node) const { +bool Node::is_ancestor_of(const Node *p_node) const { ERR_FAIL_NULL_V(p_node, false); Node *p = p_node->data.parent; while (p) { @@ -1741,7 +1741,7 @@ String Node::get_editor_description() const { void Node::set_editable_instance(Node *p_node, bool p_editable) { ERR_FAIL_NULL(p_node); - ERR_FAIL_COND(!is_a_parent_of(p_node)); + ERR_FAIL_COND(!is_ancestor_of(p_node)); if (!p_editable) { p_node->data.editable_instance = false; // Avoid this flag being needlessly saved; @@ -1756,13 +1756,13 @@ bool Node::is_editable_instance(const Node *p_node) const { if (!p_node) { return false; // Easier, null is never editable. :) } - ERR_FAIL_COND_V(!is_a_parent_of(p_node), false); + ERR_FAIL_COND_V(!is_ancestor_of(p_node), false); return p_node->data.editable_instance; } Node *Node::get_deepest_editable_node(Node *p_start_node) const { ERR_FAIL_NULL_V(p_start_node, nullptr); - ERR_FAIL_COND_V(!is_a_parent_of(p_start_node), p_start_node); + ERR_FAIL_COND_V(!is_ancestor_of(p_start_node), p_start_node); Node const *iterated_item = p_start_node; Node *node = p_start_node; @@ -2066,7 +2066,7 @@ void Node::remap_nested_resources(RES p_resource, const Map &p_resourc // because re-targeting of connections from some descendant to another is not possible // if the emitter node comes later in tree order than the receiver void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { - if ((this != p_original) && !(p_original->is_a_parent_of(this))) { + if ((this != p_original) && !(p_original->is_ancestor_of(this))) { return; } @@ -2459,7 +2459,7 @@ void Node::update_configuration_warnings() { if (!is_inside_tree()) { return; } - if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) { + if (get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { get_tree()->emit_signal(SceneStringNames::get_singleton()->node_configuration_warning_changed, this); } #endif @@ -2506,7 +2506,7 @@ void Node::_bind_methods() { ClassDB::bind_method(D_METHOD("get_node_and_resource", "path"), &Node::_get_node_and_resource); ClassDB::bind_method(D_METHOD("is_inside_tree"), &Node::is_inside_tree); - ClassDB::bind_method(D_METHOD("is_a_parent_of", "node"), &Node::is_a_parent_of); + ClassDB::bind_method(D_METHOD("is_ancestor_of", "node"), &Node::is_ancestor_of); ClassDB::bind_method(D_METHOD("is_greater_than", "node"), &Node::is_greater_than); ClassDB::bind_method(D_METHOD("get_path"), &Node::get_path); ClassDB::bind_method(D_METHOD("get_path_to", "node"), &Node::get_path_to); diff --git a/scene/main/node.h b/scene/main/node.h index e7b36f351bf..d088508f9ed 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -279,7 +279,7 @@ public: _FORCE_INLINE_ bool is_inside_tree() const { return data.inside_tree; } - bool is_a_parent_of(const Node *p_node) const; + bool is_ancestor_of(const Node *p_node) const; bool is_greater_than(const Node *p_node) const; NodePath get_path() const; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index f588e000f9d..7f6163ab0cc 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -591,7 +591,7 @@ void SceneTree::set_quit_on_go_back(bool p_enable) { #ifdef TOOLS_ENABLED bool SceneTree::is_node_being_edited(const Node *p_node) const { - return Engine::get_singleton()->is_editor_hint() && edited_scene_root && (edited_scene_root->is_a_parent_of(p_node) || edited_scene_root == p_node); + return Engine::get_singleton()->is_editor_hint() && edited_scene_root && (edited_scene_root->is_ancestor_of(p_node) || edited_scene_root == p_node); } #endif diff --git a/scene/main/timer.cpp b/scene/main/timer.cpp index 4bc159f6aa6..d88956e56d9 100644 --- a/scene/main/timer.cpp +++ b/scene/main/timer.cpp @@ -37,7 +37,7 @@ void Timer::_notification(int p_what) { case NOTIFICATION_READY: { if (autostart) { #ifdef TOOLS_ENABLED - if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) { + if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && (get_tree()->get_edited_scene_root() == this || get_tree()->get_edited_scene_root()->is_ancestor_of(this))) { break; } #endif diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 59ec0e63458..9dd2172bfc7 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -1770,7 +1770,7 @@ Control *Viewport::_gui_find_control_at_pos(CanvasItem *p_node, const Point2 &p_ } Control *drag_preview = _gui_get_drag_preview(); - if (!drag_preview || (c != drag_preview && !drag_preview->is_a_parent_of(c))) { + if (!drag_preview || (c != drag_preview && !drag_preview->is_ancestor_of(c))) { r_inv_xform = matrix; return c; } @@ -3023,7 +3023,7 @@ void Viewport::input(const Ref &p_event, bool p_local_coords) { return; } - if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { + if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this)) { return; } @@ -3065,7 +3065,7 @@ void Viewport::unhandled_input(const Ref &p_event, bool p_local_coor return; } - if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_a_parent_of(this)) { + if (Engine::get_singleton()->is_editor_hint() && get_tree()->get_edited_scene_root() && get_tree()->get_edited_scene_root()->is_ancestor_of(this)) { return; }