void ofxFlashDisplayObjectContainer :: swapChildren ( ofxFlashDisplayObject* child1, ofxFlashDisplayObject* child2 ) { int index1 = getChildIndex( child1 ); int index2 = getChildIndex( child2 ); if( index1 == -1 || index2 == -1 ) return; for( int i=0; i<children.size(); i++ ) { if( children[ i ] == child1 || children[ i ] == child2 ) { children.erase( children.begin() + i-- ); } } if( index1 < index2 ) { children.insert( children.begin() + index1, child2 ); children.insert( children.begin() + index2, child1 ); } else { children.insert( children.begin() + index2, child1 ); children.insert( children.begin() + index1, child2 ); } }
Test::TestGroup* Test::TestGroup::getNextChild(TestGroup& current) { int nextIndex = getChildIndex(current) + 1; if (nextIndex >= int(mChildren.size())) return NULL; return mChildren[nextIndex]; }
Test::TestGroup* Test::TestGroup::getPreviousChild(TestGroup& current) { int prevIndex = getChildIndex(current) - 1; if (prevIndex < 0) return NULL; return mChildren[prevIndex]; }
void ccHObject::removeChild(const ccHObject* anObject, bool preventAutoDelete/*=false*/) { assert(anObject); int pos = getChildIndex(anObject); if (pos >= 0) removeChild(pos,preventAutoDelete); }
void ccHObject::removeChild(const ccHObject* anObject) { assert(anObject); int pos = getChildIndex(anObject); if (pos>=0) removeChild(pos); }
void Stage::showScene(string name) { int index = getChildIndex(name); if(index < 0) return; nextScene = (Scene*)children[index]; sceneIndex = index; if(activeScene != NULL) hideCurrentScene(); else showNextScene(); }
void gkHUD::removeChild(gkHUDElement* hud) { GK_ASSERT(hud); UTsize i = getChildIndex(hud->getName()); if (i != UT_NPOS) { m_children.erase(i); } }
int32_t getDeviceIndexFullNode(char* userAgent, NODE_FULL* node) { BYTE childIndex = getChildIndex(*userAgent, node->lookupListOffset); // If the child index is invalid then return this device index. if (childIndex >= node->children.numberOfChildren) return node->deviceIndex; // Move to the next child. return getDeviceIndexChildren(userAgent, childIndex, &(node->children), node->deviceIndex); }
int32_t getDeviceIndexNoDeviceNode(char* userAgent, NODE_NO_DEVICE_INDEX* node, int32_t parentDeviceIndex) { BYTE childIndex = getChildIndex(*userAgent, abs(node->lookupListOffset)); // If the child index is invalid then return this device index. if (childIndex >= node->children.numberOfChildren) return parentDeviceIndex; // Move to the next child. return getDeviceIndexChildren(userAgent, childIndex, &(node->children), parentDeviceIndex); }
void QuadNode::visitItemsAt(const vec2 & pos, VisitFunctor<QuadItem> & visit){ if(!items.empty()){ for(std::list<QuadItem*>::const_iterator it = items.begin(); it != items.end(); it++) if(*it) visit(*it); }else if(!children.empty()){ int index = getChildIndex(pos); if(index != -1) children[index]->visitItemsAt(pos, visit); } }
void ccHObject::onDeletionOf(const ccHObject* obj) { //remove any dependency declared with this object //and remove it from the children list as well (in case of) //DGM: we can't call 'detachChild' as this method will try to //modify the child contents! removeDependencyWith(const_cast<ccHObject*>(obj)); //this method will only modify the dependency flags of obj int pos = getChildIndex(obj); if (pos >= 0) { //we can't swap children as we want to keep the order! m_children.erase(m_children.begin()+pos); } }
void ccGenericMesh::setTriNormsTable(NormsIndexesTableType* triNormsTable, bool autoReleaseOldTable/*=true*/) { if (m_triNormals == triNormsTable) return; if (m_triNormals && autoReleaseOldTable) { int childIndex = getChildIndex(m_triNormals); m_triNormals->release(); m_triNormals=0; if (childIndex>=0) removeChild(childIndex); } m_triNormals = triNormsTable; if (m_triNormals) m_triNormals->link(); }
int deleteNode(Tree* tree, void* dataToDelete){ TreeNode* parentNode; TreeNode* nodeToSearch; int index; if(tree->root == NULL) return 0; parentNode = tree->root; if(((List*)(parentNode->children))->head == NULL){ tree->root = NULL; return 1; } nodeToSearch = searchNode(tree,dataToDelete); parentNode = nodeToSearch->parent; if(nodeToSearch == NULL)return 0; if(nodeToSearch->children->head != NULL) return 0; index = getChildIndex(parentNode->children,dataToDelete,tree->compare); if(index == -1) return 0; return Remove(parentNode->children,index); };
void ccGenericMesh::setTexCoordinatesTable(TextureCoordsContainer* texCoordsTable, bool autoReleaseOldTable/*=true*/) { if (m_texCoords == texCoordsTable) return; if (m_texCoords && autoReleaseOldTable) { int childIndex = getChildIndex(m_texCoords); m_texCoords->release(); m_texCoords=0; if (childIndex>=0) removeChild(childIndex); } m_texCoords = texCoordsTable; if (m_texCoords) m_texCoords->link(); }
void ccGenericMesh::setMaterialSet(ccMaterialSet* materialSet, bool autoReleaseOldMaterialSet/*=true*/) { if (m_materials == materialSet) return; if (m_materials && autoReleaseOldMaterialSet) { int childIndex = getChildIndex(m_materials); m_materials->release(); m_materials=0; if (childIndex>=0) removeChild(childIndex); } m_materials = materialSet; if (m_materials) m_materials->link(); //update display (for textures!) setDisplay(m_currentDisplay); }
void ccHObject::detachChild(ccHObject* child) { if (!child) { assert(false); return; } //remove any dependency (bilateral) removeDependencyWith(child); child->removeDependencyWith(this); if (child->getParent() == this) child->setParent(0); int pos = getChildIndex(child); if (pos >= 0) { //we can't swap children as we want to keep the order! m_children.erase(m_children.begin()+pos); } }
int QuadNode::getItemsAt(std::set<QuadItem*>& itemset, vec2 pos) { if(!items.empty()) { int items_added = 0; for(std::list<QuadItem*>::iterator it = items.begin(); it != items.end(); it++) { QuadItem* oi = (*it); if(oi!=0) { itemset.insert(oi); items_added++; } } return items_added; } if(children.empty()) return 0; int index = getChildIndex(pos); if(index == -1) return 0; return children[index]->getItemsAt(itemset, pos); }
int QuadNode::getItemsAt(std::vector<QuadItem*>& itemvec, vec2f pos) { if(items.size()>0) { int items_added = 0; for(std::list<QuadItem*>::iterator it = items.begin(); it != items.end(); it++) { QuadItem* oi = (*it); if(oi!=0) { itemvec.push_back(oi); items_added++; } } return items_added; } if(children.size()==0) return 0; int index = getChildIndex(pos); if(index == -1) return 0; return children[index]->getItemsAt(itemvec, pos); }
//=================================================detachChild====================================================// void ccHObject::detachChild(ccHObject* child) { //子物体不存在 if (!child) { assert(false); return; } //remove any dependency (bilateral) // removeDependencyWith(child);// 移除与子物体的依赖关系 child->removeDependencyWith(this); //移除子物体与this的依赖关系 //父物体的父母设置成0 if (child->getParent() == this) child->setParent(0); //找到子物体,并删除 int pos = getChildIndex(child); if (pos >= 0){ //we can't swap children as we want to keep the order! m_children.erase(m_children.begin()+pos); } }
void ccHObject::removeChild(ccHObject* child) { int pos = getChildIndex(child); if (pos >= 0) removeChild(pos); }
void Stage::showChild(string name) { int index = getChildIndex(name); if(index < 0) return; children[index]->visible = true; }
void Stage::hideChild(string name) { int index = getChildIndex(name); if(index < 0) return; children[index]->visible = false; }
inline bool GroupNode::removeChild(SceneNode* child) { return removeChild(getChildIndex(child)); }
unsigned int Window::addChildAndGetIndex(osg::Node* node) { if(addChild(node)) return getChildIndex(node); return 0; }
gkHUDElement* gkHUD::getChild(const gkString& name) { UTsize i = getChildIndex(name); return i != UT_NPOS ? m_children[i] : 0; }
void Data::setChildSelected(DataPtr _child) { mIndexSelected = getChildIndex(_child); }
void gkHUD::addChild(gkHUDElement* hud) { GK_ASSERT(hud && getChildIndex(hud->getName()) == UT_NPOS); m_children.push_back(hud); }