Rename `is_a_parent_of()` to `is_ancestor_of()`

This commit is contained in:
Lightning_A 2021-06-18 16:02:50 -06:00
parent 8ffb631cdb
commit 899e5f8685
17 changed files with 37 additions and 37 deletions

View File

@ -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.
</description>
</method>
<method name="is_a_parent_of" qualifiers="const">
<method name="is_ancestor_of" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="node" type="Node">

View File

@ -117,7 +117,7 @@ void FindReplaceBar::_unhandled_input(const Ref<InputEvent> &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()) {

View File

@ -1909,7 +1909,7 @@ void FindBar::_unhandled_input(const Ref<InputEvent> &p_event) {
Ref<InputEventKey> 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()) {

View File

@ -1241,7 +1241,7 @@ bool CanvasItemEditor::_gui_input_zoom_or_pan(const Ref<InputEvent> &p_event, bo
Ref<InputEventPanGesture> 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;

View File

@ -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<EditorNode3DGizmo> 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<WorldEnvironment>(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<WorldEnvironment>(p_node)) {
world_env_count--;
if (world_env_count == 0) {

View File

@ -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

View File

@ -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;
}

View File

@ -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;
}

View File

@ -525,7 +525,7 @@ void LiveEditor::_node_set_func(int p_id, const StringName &p_prop, const Varian
for (Set<Node *>::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<Node *>::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<Node *>::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<Node *>::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<Node *>::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<Node *>::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;
}

View File

@ -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() {

View File

@ -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();

View File

@ -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();

View File

@ -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<RES, RES> &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);

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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<InputEvent> &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<InputEvent> &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;
}