コード例 #1
0
void CACollectionView::mouseMoved(CATouch* pTouch, CAEvent* pEvent)
{
    if (m_bAllowsSelection)
    {
        DPoint point = m_pContainer->convertTouchToNodeSpace(pTouch);
        
        std::map<CAIndexPath3E, CACollectionViewCell*>::iterator itr;
        for (itr = m_mpUsedCollectionCells.begin(); itr != m_mpUsedCollectionCells.end(); ++itr)
        {
            CACollectionViewCell* cell = itr->second;
            CC_CONTINUE_IF(cell == NULL);
            if (cell->getFrame().containsPoint(point) && cell->isVisible())
            {
                CC_BREAK_IF(cell->getControlState() == CAControlStateDisabled);
                
                if (m_pHighlightedCollectionCells)
                {
                    CAIndexPath3E index = CAIndexPath3E(m_pHighlightedCollectionCells->getSection(),
                                                        m_pHighlightedCollectionCells->getRow(),
                                                        m_pHighlightedCollectionCells->getItem());
                    if (m_pSelectedCollectionCells.count(index))
                    {
                        m_pHighlightedCollectionCells->setControlStateHighlighted();
                    }
                    else
                    {
                        m_pHighlightedCollectionCells->setControlStateNormal();
                    }
                    
                }
                
                m_pHighlightedCollectionCells = cell;
                cell->setControlStateHighlighted();
                
                break;
            }
        }
    }
}