| 991 | } |
| 992 | |
| 993 | void Node::addChildHelper(Node* child, int localZOrder, int tag, std::string_view name, bool setTag) |
| 994 | { |
| 995 | auto assertNotSelfChild([this, child]() -> bool { |
| 996 | for (Node* parent(getParent()); parent != nullptr; parent = parent->getParent()) |
| 997 | if (parent == child) |
| 998 | return false; |
| 999 | |
| 1000 | return true; |
| 1001 | }); |
| 1002 | (void)assertNotSelfChild; |
| 1003 | |
| 1004 | AXASSERT(assertNotSelfChild(), "A node cannot be the child of his own children"); |
| 1005 | |
| 1006 | if (_children.empty()) |
| 1007 | { |
| 1008 | this->childrenAlloc(); |
| 1009 | } |
| 1010 | |
| 1011 | this->insertChild(child, localZOrder); |
| 1012 | |
| 1013 | child->setParent(this); |
| 1014 | |
| 1015 | if (_childFollowCameraMask) |
| 1016 | { |
| 1017 | child->setCameraMask(this->getCameraMask()); |
| 1018 | child->applyMaskOnEnter(true); |
| 1019 | } |
| 1020 | |
| 1021 | if (setTag) |
| 1022 | { |
| 1023 | child->setTag(tag); |
| 1024 | child->updateParentChildrenIndexer(child->getName()); |
| 1025 | } |
| 1026 | else |
| 1027 | { |
| 1028 | child->setName(name); |
| 1029 | child->updateParentChildrenIndexer(child->getTag()); |
| 1030 | } |
| 1031 | |
| 1032 | child->updateOrderOfArrival(); |
| 1033 | |
| 1034 | if (_running) |
| 1035 | { |
| 1036 | child->onEnter(); |
| 1037 | // prevent onEnterTransitionDidFinish to be called twice when a node is added in onEnter |
| 1038 | if (_isTransitionFinished) |
| 1039 | { |
| 1040 | child->onEnterTransitionDidFinish(); |
| 1041 | } |
| 1042 | } |
| 1043 | |
| 1044 | if (_cascadeColorEnabled) |
| 1045 | { |
| 1046 | updateCascadeColor(); |
| 1047 | } |
| 1048 | |
| 1049 | if (_cascadeOpacityEnabled) |
| 1050 | { |
nothing calls this directly
no test coverage detected