Exemplo n.º 1
0
void UIListViewEx::interceptTouchEvent(int handleState, UIWidget *sender, const cocos2d::CCPoint &touchPoint)
{
    UIScrollView::interceptTouchEvent(handleState, sender, touchPoint);
    if (handleState != 1)
    {
        UIWidget* parent = sender;
        while (parent)
        {
            if (parent && parent->getParent() == m_pInnerContainer)
            {
                _curSelectedIndex = getIndex(parent);
                break;
            }
            parent = parent->getParent();
        }
        selectedItemEvent();
    }
}
Exemplo n.º 2
0
void UIParent::removeChild(UIWidget& widget)
{
	Expects(widget.getParent() == this);
	widget.setParent(nullptr);

	children.erase(std::remove_if(children.begin(), children.end(), [&] (auto& c)
	{
		return c.get() == &widget;
	}), children.end());

	markAsNeedingLayout();
}
Exemplo n.º 3
0
bool UIWidget::clippingParentAreaContainPoint(const CCPoint &pt)
{
    m_bAffectByClipping = false;
    UIWidget* parent = getParent();
    UIWidget* clippingParent = NULL;
    while (parent)
    {
        Layout* layoutParent = dynamic_cast<Layout*>(parent);
        if (layoutParent)
        {
            if (layoutParent->isClippingEnabled())
            {
                m_bAffectByClipping = true;
                clippingParent = layoutParent;
                break;
            }
        }
        parent = parent->getParent();
    }
    
    if (!m_bAffectByClipping)
    {
        return true;
    }
    
    
    if (clippingParent)
    {
        bool bRet = false;
        if (clippingParent->hitTest(pt))
        {
            bRet = true;
        }
        if (bRet)
        {
            return clippingParent->clippingParentAreaContainPoint(pt);
        }
        return false;
    }
    return true;
}