Exemple #1
0
bool CAListView::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent)
{
	if (!m_vTouches.empty())
	{
        m_vTouches.replace(0, pTouch);
		return true;
	}
    bool isInertia = m_tInertia.getLength() < 1.0f;
	if (!CAScrollView::ccTouchBegan(pTouch, pEvent))
		return false;

	if (m_bAllowsSelection && this->isScrollWindowNotOutSide() == false && isInertia)
	{
		DPoint point = m_pContainer->convertTouchToNodeSpace(pTouch);

		std::map<unsigned int, CAListViewCell*>::iterator itr;
		for (itr = m_mpUsedListCells.begin(); itr != m_mpUsedListCells.end(); ++itr)
		{
			CAListViewCell* pCell = itr->second;
			CC_CONTINUE_IF(pCell == NULL);

			if (pCell->getFrame().containsPoint(point) && pCell->isVisible())
			{
				CC_BREAK_IF(pCell->getControlState() == CAControlStateDisabled);

                if (m_pHighlightedListCells != pCell)
                {
                    if (m_pHighlightedListCells)
                    {
                        m_pHighlightedListCells->setControlStateNormal();
                    }
                    m_pHighlightedListCells = pCell;
                }

				CC_BREAK_IF(pCell->getControlState() == CAControlStateSelected);

                CAViewAnimation::beginAnimations(m_s__StrID, NULL);
                CAViewAnimation::setAnimationDuration(0.05f);
                CAViewAnimation::setAnimationDidStopSelector(pCell, CAViewAnimation0_selector(CAListViewCell::setControlStateHighlighted));
                CAViewAnimation::commitAnimations();
				break;
			}
		}
	}
	return true;
}
Exemple #2
0
bool CAListView::ccTouchBegan(CATouch *pTouch, CAEvent *pEvent)
{
	if (m_pTouches->count() > 0)
	{
		m_pTouches->replaceObjectAtIndex(0, pTouch);
		return true;
	}
    bool isInertia = m_tInertia.getLength() < 1.0f;
	if (!CAScrollView::ccTouchBegan(pTouch, pEvent))
		return false;

	if (m_bAllowsSelection && this->isScrollWindowNotOutSide() == false && isInertia)
	{
		CCPoint point = m_pContainer->convertTouchToNodeSpace(pTouch);

		std::map<unsigned int, CAListViewCell*>::iterator itr;
		for (itr = m_pUsedListCells.begin(); itr != m_pUsedListCells.end(); ++itr)
		{
			CAListViewCell* pCell = itr->second;
			CC_CONTINUE_IF(pCell == NULL);

			if (pCell->getFrame().containsPoint(point) && pCell->isVisible())
			{
				CC_BREAK_IF(pCell->getControlState() == CAControlStateDisabled);

				if (m_pHighlightedListCells)
				{
					m_pHighlightedListCells->setControlStateNormal();
				}

				m_pHighlightedListCells = pCell;

				CC_BREAK_IF(pCell->getControlState() == CAControlStateSelected);

				CCDelayTime* delayTime = CCDelayTime::create(0.05f);
				CCCallFunc* func = CCCallFunc::create(pCell, callfunc_selector(CAListViewCell::setControlStateHighlighted));
				CCSequence* actions = CCSequence::create(delayTime, func, NULL);
				m_pContainer->runAction(actions);
				break;
			}
		}
	}
	return true;
}
Exemple #3
0
void CAListView::mouseMoved(CATouch* pTouch, CAEvent* pEvent)
{
    if (m_bAllowsSelection)
    {
        DPoint point = m_pContainer->convertTouchToNodeSpace(pTouch);
        
        std::map<unsigned int, CAListViewCell*>::iterator itr;
        for (itr = m_mpUsedListCells.begin(); itr != m_mpUsedListCells.end(); ++itr)
        {
            CAListViewCell* pCell = itr->second;
            CC_CONTINUE_IF(pCell == NULL);
            
            if (pCell->getFrame().containsPoint(point) && pCell->isVisible())
            {
                CC_BREAK_IF(pCell->getControlState() == CAControlStateDisabled);
                
                if (m_pHighlightedListCells)
                {
                    unsigned int index = m_pHighlightedListCells->getIndex();
                    if (m_pSelectedListCells.count(index))
                    {
                        m_pHighlightedListCells->setControlStateHighlighted();
                    }
                    else
                    {
                        m_pHighlightedListCells->setControlStateNormal();
                    }
                    
                }
                
                m_pHighlightedListCells = pCell;
                pCell->setControlStateHighlighted();

                break;
            }
        }
    }
}