Ejemplo n.º 1
0
unsigned int CABatchView::atlasIndexForSubview(CAView *view, int nZ)
{
    const CAVector<CAView*>& pBrothers = view->getSuperview()->getSubviews();
    
    unsigned int uSubviewIndex = (unsigned int)pBrothers.getIndex(view);

    bool bIgnoreParent = (CABatchView*)(view->getSuperview()) == this;
    CAView *pPrevious = NULL;
    if (uSubviewIndex > 0 && uSubviewIndex < UINT_MAX)
    {
        pPrevious = (CAView*)(pBrothers.at(uSubviewIndex - 1));
    }

    if (bIgnoreParent)
    {
        if (uSubviewIndex == 0)
        {
            return 0;
        }

        return highestAtlasIndexInSubview(pPrevious) + 1;
    }

    if (uSubviewIndex == 0)
    {
        CAView *p = (CAView*)(view->getSuperview());

        if (nZ < 0)
        {
            return p->getAtlasIndex();
        }
        else
        {
            return p->getAtlasIndex() + 1;
        }
    }
    else
    {
        if ((pPrevious->getZOrder() < 0 && nZ < 0) || (pPrevious->getZOrder() >= 0 && nZ >= 0))
        {
            return highestAtlasIndexInSubview(pPrevious) + 1;
        }

        CAView *p = (CAView*)(view->getSuperview());
        return p->getAtlasIndex() + 1;
    }

    CCAssert(0, "should not run here");
    return 0;
}
Ejemplo n.º 2
0
void CABatchView::removeViewFromAtlas(CAView *view)
{
    m_pobImageAtlas->removeQuadAtIndex(view->getAtlasIndex());

    view->setBatch(NULL);

    
    
    unsigned int uIndex = (unsigned int)m_obDescendants.getIndex(view);
    if (uIndex != UINT_MAX)
    {
        m_obDescendants.erase(uIndex);
        unsigned int count = (unsigned int)m_obDescendants.size();
        
        for(; uIndex < count; ++uIndex)
        {
            CAView* s = m_obDescendants.at(uIndex);
            s->setAtlasIndex(s->getAtlasIndex() - 1);
        }
    }

    CAVector<CAView*>::const_iterator itr;
    for (itr=view->getSubviews().begin(); itr!=view->getSubviews().end(); itr++)
    {
        removeViewFromAtlas(*itr);
    }
}