void wyNode::removeChild(wyNode* child, bool cleanup) { // if child list is locked, means something is happening if(m_children->locked || m_childrenChanging) return; m_childrenChanging = true; // try to find this child int index = wyArrayIndexOf(m_children, child, NULL, NULL); // if found, remove it if(index != -1) { child->onDetachFromParent(this); if(m_running) child->onExit(); if(cleanup) child->cleanup(); child->m_parent = NULL; wyArrayDeleteIndex(m_children, index); wyObjectRelease(child); } // restore flag m_childrenChanging = false; }
void wyPageControl::removePageAt(int index) { wyNode* page = (wyNode*)wyArrayDeleteIndex(m_pages, index); if(page != NULL) { // remove from container m_container->removeChildLocked(page, true); // notify indicator before page is released if(m_indicator) m_indicator->onPageRemoved(page, index); // release page and update positions page->release(); updatePagePositions(); } }
void wyBladeRibbon::update(float delta) { for(int i = m_dyingBlades->num - 1; i >= 0; i--) { // delete point in dying blade wyBlade* blade = (wyBlade*)wyArrayGet(m_dyingBlades, i); blade->deletePoint(delta); // if no point, add it to reuse queue if(blade->m_pointCount <= 0) { blade->reset(); wyArrayPush(m_reusableBlades, blade); wyArrayDeleteIndex(m_dyingBlades, i); } } if(m_blade) m_blade->deletePoint(delta); }
int wyNode::reorderChild(wyNode* child, int z) { // if child list is locked, means something is happening if(m_children->locked || m_childrenChanging) return -1; m_childrenChanging = true; // remove it first int index = wyArrayIndexOf(m_children, child, NULL, NULL); if(index != -1) { child->m_parent = NULL; wyArrayDeleteIndex(m_children, index); } else { LOGW("wyNode::reorderChild: you want to reorder a child whose parent is not this?"); return -1; } // insert it back with new z-order int ret = insertChild(child, z); // reset flag m_childrenChanging = false; return ret; }