Exemplo n.º 1
0
void Layout::setClippingEnabled(bool able)
{
    if (able == _clippingEnabled)
    {
        return;
    }
    _clippingEnabled = able;
    switch (_clippingType)
    {
        case ClippingType::STENCIL:
            if (able)
            {
                _clippingStencil = DrawNode::create();
                if (_running)
                {
                    _clippingStencil->onEnter();
                }
                _clippingStencil->retain();
                setStencilClippingSize(_contentSize);
            }
            else
            {
                if (_running)
                {
                    _clippingStencil->onExit();
                }
                _clippingStencil->release();
                _clippingStencil = nullptr;
            }
            break;
        default:
            break;
    }
}
Exemplo n.º 2
0
void Layout::setClippingEnabled(bool able)
{
    if (able == _clippingEnabled)
    {
        return;
    }
    _clippingEnabled = able;
    switch (_clippingType)
    {
        case LAYOUT_CLIPPING_STENCIL:
            if (able)
            {
                glGetIntegerv(GL_STENCIL_BITS, &g_sStencilBits);
                _clippingStencil = CCDrawNode::create();
                if (m_bRunning)
                {
                    _clippingStencil->onEnter();
                }
                CC_SAFE_RETAIN(_clippingStencil);
                setStencilClippingSize(_size);
            }
            else
            {
                if (m_bRunning)
                {
                    _clippingStencil->onExit();
                }
                CC_SAFE_RELEASE(_clippingStencil);
                _clippingStencil = NULL;
            }
            break;
        default:
            break;
    }
}
Exemplo n.º 3
0
void Layout::onSizeChanged()
{
    Widget::onSizeChanged();
    setStencilClippingSize(_contentSize);
    _doLayoutDirty = true;
    _clippingRectDirty = true;
    if (_backGroundImage)
    {
        _backGroundImage->setPosition(_contentSize.width/2.0f, _contentSize.height/2.0f);
        if (_backGroundScale9Enabled)
        {
            _backGroundImage->setPreferredSize(_contentSize);
        }
        else
        {
            _backGroundImage->setPreferredSize(_backGroundImageTextureSize);
        }
    }
    if (_colorRender)
    {
        _colorRender->setContentSize(_contentSize);
    }
    if (_gradientRender)
    {
        _gradientRender->setContentSize(_contentSize);
    }
}
Exemplo n.º 4
0
void Layout::onSizeChanged()
{
    Widget::onSizeChanged();
    setContentSize(_size);
    setStencilClippingSize(_size);
    _doLayoutDirty = true;
    _clippingRectDirty = true;
    if (_backGroundImage)
    {
        _backGroundImage->setPosition(CCPoint(_size.width/2.0f, _size.height/2.0f));
        if (_backGroundScale9Enabled && _backGroundImage)
        {
            static_cast<extension::CCScale9Sprite*>(_backGroundImage)->setPreferredSize(_size);
        }
    }
    if (_colorRender)
    {
        _colorRender->setContentSize(_size);
    }
    if (_gradientRender)
    {
        _gradientRender->setContentSize(_size);
    }
}