예제 #1
0
void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType)
{
    if (frontCrossDisabled.empty())
    {
        return;
    }
    _frontCrossDisabledFileName = frontCrossDisabled;
    _frontCrossDisabledTexType = texType;
    switch (_frontCrossDisabledTexType)
    {
        case TextureResType::LOCAL:
            _frontCrossDisabledRenderer->setTexture(frontCrossDisabled);
            break;
        case TextureResType::PLIST:
            _frontCrossDisabledRenderer->setSpriteFrame(frontCrossDisabled);
            break;
        default:
            break;
    }
    updateFlippedX();
    updateFlippedY();
    this->updateChildrenDisplayedRGBA();

    _frontCrossDisabledRendererAdaptDirty = true;
}
예제 #2
0
void CheckBox::loadTextureFrontCrossDisabled(const char *frontCrossDisabled,TextureResType texType)
{
    if (!frontCrossDisabled || strcmp(frontCrossDisabled, "") == 0)
    {
        return;
    }
    _frontCrossDisabledFileName = frontCrossDisabled;
    _frontCrossDisabledTexType = texType;
    switch (_frontCrossDisabledTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            _frontCrossDisabledRenderer->setTexture(frontCrossDisabled);
            break;
        case UI_TEX_TYPE_PLIST:
            _frontCrossDisabledRenderer->setSpriteFrame(frontCrossDisabled);
            break;
        default:
            break;
    }
    frontCrossDisabledTextureScaleChangedWithSize();
    updateAnchorPoint();
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_frontCrossDisabledRenderer);
}
예제 #3
0
void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType)
{
    if (backGroundSelected.empty())
    {
        return;
    }
    _backGroundSelectedFileName = backGroundSelected;
    _backGroundSelectedTexType = texType;
    switch (_backGroundSelectedTexType)
    {
        case TextureResType::LOCAL:
            _backGroundSelectedBoxRenderer->setTexture(backGroundSelected);
            break;
        case TextureResType::PLIST:
            _backGroundSelectedBoxRenderer->setSpriteFrame(backGroundSelected);
            break;
        default:
            break;
    }
    updateFlippedX();
    updateFlippedY();
    this->updateChildrenDisplayedRGBA();

    _backGroundSelectedBoxRendererAdaptDirty = true;
}
예제 #4
0
void CheckBox::loadTextureBackGround(const std::string& backGround,TextureResType texType)
{
    if (backGround.empty())
    {
        return;
    }
    _backGroundFileName = backGround;
    _backGroundTexType = texType;
    switch (_backGroundTexType)
    {
        case TextureResType::LOCAL:
            _backGroundBoxRenderer->setTexture(backGround);
            break;
        case TextureResType::PLIST:
            _backGroundBoxRenderer->setSpriteFrame(backGround);
            break;
        default:
            break;
    }
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_backGroundBoxRenderer);
    updateContentSizeWithTextureSize(_backGroundBoxRenderer->getContentSize());
    _backGroundBoxRendererAdaptDirty = true;
}
예제 #5
0
void ImageView::loadTexture(const std::string& fileName, TextureResType texType)
{
    if (fileName.empty())
    {
        return;
    }
    _textureFile = fileName;
    _imageTexType = texType;
    switch (_imageTexType)
    {
        case TextureResType::LOCAL:
            _imageRenderer->initWithFile(fileName);
            break;
        case TextureResType::PLIST:
            _imageRenderer->initWithSpriteFrameName(fileName);
            break;
        default:
            break;
    }
    
    _imageTextureSize = _imageRenderer->getContentSize();
    updateFlippedX();
    updateFlippedY();
    this->updateChildrenDisplayedRGBA();

    updateContentSizeWithTextureSize(_imageTextureSize);
    _imageRendererAdaptDirty = true;
}
예제 #6
0
void CheckBox::loadTextureBackGroundSelected(const char *backGroundSelected,TextureResType texType)
{
    if (!backGroundSelected || strcmp(backGroundSelected, "") == 0)
    {
        return;
    }
    _backGroundSelectedFileName = backGroundSelected;
    _backGroundSelectedTexType = texType;
    switch (_backGroundSelectedTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            _backGroundSelectedBoxRenderer->setTexture(backGroundSelected);
            break;
        case UI_TEX_TYPE_PLIST:
            _backGroundSelectedBoxRenderer->setSpriteFrame(backGroundSelected);
            break;
        default:
            break;
    }
    backGroundSelectedTextureScaleChangedWithSize();
    updateAnchorPoint();
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_backGroundSelectedBoxRenderer);
}
예제 #7
0
void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
{
    if (normal.empty())
    {
        return;
    }
    _normalFileName = normal;
    _normalTexType = texType;
    if (_scale9Enabled)
    {
        extension::Scale9Sprite* normalRendererScale9 = static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer);
        switch (_normalTexType)
        {
            case TextureResType::LOCAL:
                normalRendererScale9->initWithFile(normal);
                break;
            case TextureResType::PLIST:
                normalRendererScale9->initWithSpriteFrameName(normal);
                break;
            default:
                break;
        }
        normalRendererScale9->setCapInsets(_capInsetsNormal);
    }
    else
    {
        Sprite* normalRenderer = static_cast<Sprite*>(_buttonNormalRenderer);
        switch (_normalTexType)
        {
            case TextureResType::LOCAL:
                normalRenderer->setTexture(normal);
                break;
            case TextureResType::PLIST:
                normalRenderer->setSpriteFrame(normal);
                break;
            default:
                break;
        }
    }
    _normalTextureSize = _buttonNormalRenderer->getContentSize();
    updateFlippedX();
    updateFlippedY();
    
    _buttonNormalRenderer->setColor(this->getColor());
    _buttonNormalRenderer->setOpacity(this->getOpacity());
    
    updateContentSizeWithTextureSize(_normalTextureSize);
    _normalTextureLoaded = true;
    _normalTextureAdaptDirty = true;
}
예제 #8
0
void Button::loadTexturePressed(const std::string& selected,TextureResType texType)
{
    if (selected.empty())
    {
        return;
    }
    _clickedFileName = selected;
    _pressedTexType = texType;
    if (_scale9Enabled)
    {
        extension::Scale9Sprite* clickedRendererScale9 = static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer);
        switch (_pressedTexType)
        {
            case TextureResType::LOCAL:
                clickedRendererScale9->initWithFile(selected);
                break;
            case TextureResType::PLIST:
                clickedRendererScale9->initWithSpriteFrameName(selected);
                break;
            default:
                break;
        }
        clickedRendererScale9->setCapInsets(_capInsetsPressed);
    }
    else
    {
        Sprite* clickedRenderer = static_cast<Sprite*>(_buttonClickedRenderer);
        switch (_pressedTexType)
        {
            case TextureResType::LOCAL:
                clickedRenderer->setTexture(selected);
                break;
            case TextureResType::PLIST:
                clickedRenderer->setSpriteFrame(selected);
                break;
            default:
                break;
        }
    }
    _pressedTextureSize = _buttonClickedRenderer->getContentSize();
    updateFlippedX();
    updateFlippedY();
    
    _buttonDisableRenderer->setColor(this->getColor());
    _buttonDisableRenderer->setOpacity(this->getOpacity());
    
    _pressedTextureLoaded = true;
    _pressedTextureAdaptDirty = true;
}
예제 #9
0
void Button::loadTextureDisabled(const std::string& disabled,TextureResType texType)
{
    if (disabled.empty())
    {
        return;
    }
    _disabledFileName = disabled;
    _disabledTexType = texType;
    if (_scale9Enabled)
    {
        extension::Scale9Sprite* disabledScale9 = static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer);
        switch (_disabledTexType)
        {
            case UI_TEX_TYPE_LOCAL:
                disabledScale9->initWithFile(disabled);
                break;
            case UI_TEX_TYPE_PLIST:
                disabledScale9->initWithSpriteFrameName(disabled);
                break;
            default:
                break;
        }
        disabledScale9->setCapInsets(_capInsetsDisabled);
    }
    else
    {
        Sprite* disabledRenderer = static_cast<Sprite*>(_buttonDisableRenderer);
        switch (_disabledTexType)
        {
            case UI_TEX_TYPE_LOCAL:
                disabledRenderer->setTexture(disabled);
                break;
            case UI_TEX_TYPE_PLIST:
                disabledRenderer->setSpriteFrame(disabled);
                break;
            default:
                break;
        }
    }
    _disabledTextureSize = _buttonDisableRenderer->getContentSize();
    disabledTextureScaleChangedWithSize();
    updateAnchorPoint();
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_buttonDisableRenderer);
    _disabledTextureLoaded = true;
}
예제 #10
0
void Button::loadTextureNormal(const std::string& normal,TextureResType texType)
{
    if (normal.empty())
    {
        return;
    }
    _normalFileName = normal;
    _normalTexType = texType;
    if (_scale9Enabled)
    {
        extension::Scale9Sprite* normalRendererScale9 = static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer);
        switch (_normalTexType)
        {
            case UI_TEX_TYPE_LOCAL:
                normalRendererScale9->initWithFile(normal);
                break;
            case UI_TEX_TYPE_PLIST:
                normalRendererScale9->initWithSpriteFrameName(normal);
                break;
            default:
                break;
        }
        normalRendererScale9->setCapInsets(_capInsetsNormal);
    }
    else
    {
        Sprite* normalRenderer = static_cast<Sprite*>(_buttonNormalRenderer);
        switch (_normalTexType)
        {
            case UI_TEX_TYPE_LOCAL:
                normalRenderer->setTexture(normal);
                break;
            case UI_TEX_TYPE_PLIST:
                normalRenderer->setSpriteFrame(normal);
                break;
            default:
                break;
        }
    }
    _normalTextureSize = _buttonNormalRenderer->getContentSize();
    normalTextureScaleChangedWithSize();
    updateAnchorPoint();
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_buttonNormalRenderer);
    _normalTextureLoaded = true;
}
예제 #11
0
void Button::loadTexturePressed(const char* selected,TextureResType texType)
{
    if (!selected || strcmp(selected, "") == 0)
    {
        return;
    }
    _clickedFileName = selected;
    _pressedTexType = texType;
    if (_scale9Enabled)
    {
        extension::CCScale9Sprite* clickedRendererScale9 = static_cast<extension::CCScale9Sprite*>(_buttonClickedRenderer);
        switch (_pressedTexType)
        {
        case UI_TEX_TYPE_LOCAL:
            clickedRendererScale9->initWithFile(selected);
            break;
        case UI_TEX_TYPE_PLIST:
            clickedRendererScale9->initWithSpriteFrameName(selected);
            break;
        default:
            break;
        }
        clickedRendererScale9->setCapInsets(_capInsetsPressed);
    }
    else
    {
        CCSprite* clickedRenderer = static_cast<CCSprite*>(_buttonClickedRenderer);
        switch (_pressedTexType)
        {
        case UI_TEX_TYPE_LOCAL:
            clickedRenderer->initWithFile(selected);
            break;
        case UI_TEX_TYPE_PLIST:
            clickedRenderer->initWithSpriteFrameName(selected);
            break;
        default:
            break;
        }
    }
    _pressedTextureSize = _buttonClickedRenderer->getContentSize();
    updateAnchorPoint();
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_buttonClickedRenderer);
    pressedTextureScaleChangedWithSize();
    _pressedTextureLoaded = true;
}
예제 #12
0
void ImageView::loadTexture(const char *fileName, TextureResType texType)
{
    if (!fileName || strcmp(fileName, "") == 0)
    {
        return;
    }
    _textureFile = fileName;
    _imageTexType = texType;
    switch (_imageTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            if (_scale9Enabled)
            {
                extension::CCScale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
                imageRendererScale9->initWithFile(fileName);
                imageRendererScale9->setCapInsets(_capInsets);
            }
            else
            {
                CCSprite* imageRenderer = STATIC_CAST_CCSPRITE;
                imageRenderer->initWithFile(fileName);
            }
            break;
        case UI_TEX_TYPE_PLIST:
            if (_scale9Enabled)
            {
                extension::CCScale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
                imageRendererScale9->initWithSpriteFrameName(fileName);
                imageRendererScale9->setCapInsets(_capInsets);
            }
            else
            {
                CCSprite* imageRenderer = STATIC_CAST_CCSPRITE;
                imageRenderer->initWithSpriteFrameName(fileName);
            }
            break;
        default:
            break;
    }
    _imageTextureSize = _imageRenderer->getContentSize();
    imageTextureScaleChangedWithSize();
    updateAnchorPoint();
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_imageRenderer);
}
void ImageView::loadTexture(const std::string& fileName, TextureResType texType)
{
    if (fileName.empty())
    {
        return;
    }
    _textureFile = fileName;
    _imageTexType = texType;
    switch (_imageTexType)
    {
    case TextureResType::LOCAL:
        if (_scale9Enabled)
        {
            extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
            imageRendererScale9->initWithFile(fileName);
            imageRendererScale9->setCapInsets(_capInsets);
        }
        else
        {
            Sprite* imageRenderer = STATIC_CAST_CCSPRITE;
            imageRenderer->setTexture(fileName);
        }
        break;
    case TextureResType::PLIST:
        if (_scale9Enabled)
        {
            extension::Scale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
            imageRendererScale9->initWithSpriteFrameName(fileName);
            imageRendererScale9->setCapInsets(_capInsets);
        }
        else
        {
            Sprite* imageRenderer = STATIC_CAST_CCSPRITE;
            imageRenderer->setSpriteFrame(fileName);
        }
        break;
    default:
        break;
    }
    _imageTextureSize = _imageRenderer->getContentSize();
    updateFlippedX();
    updateFlippedY();

    updateContentSizeWithTextureSize(_imageTextureSize);
    _imageRendererAdaptDirty = true;
}
예제 #14
0
void ImageView::loadTex(cocos2d::CCTexture2D *tex) {
    switch (_imageTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            if (_scale9Enabled)
            {
                extension::CCScale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
                //imageRendererScale9->initWithFile(fileName);
                
                imageRendererScale9->setCapInsets(_capInsets);
            }
            else
            {
                CCSprite* imageRenderer = STATIC_CAST_CCSPRITE;
                //imageRenderer->initWithFile(fileName);
                imageRenderer->initWithTexture(tex);
                
            }
            break;
        case UI_TEX_TYPE_PLIST:
            if (_scale9Enabled)
            {
                extension::CCScale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE;
                //imageRendererScale9->initWithSpriteFrameName(fileName);
                
                imageRendererScale9->setCapInsets(_capInsets);
            }
            else
            {
                CCSprite* imageRenderer = STATIC_CAST_CCSPRITE;
                //imageRenderer->initWithSpriteFrameName(fileName);
                imageRenderer->initWithTexture(tex);
                
            }
            break;
        default:
            break;
    }
    _imageTextureSize = _imageRenderer->getContentSize();
    imageTextureScaleChangedWithSize();
    updateAnchorPoint();
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_imageRenderer);
}
예제 #15
0
void CheckBox::loadTextureFrontCrossDisabled(const std::string& frontCrossDisabled,TextureResType texType)
{
    if (frontCrossDisabled.empty())
    {
        return;
    }
    _frontCrossDisabledFileName = frontCrossDisabled;
    _frontCrossDisabledTexType = texType;
    switch (_frontCrossDisabledTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            _frontCrossDisabledRenderer->setTexture(frontCrossDisabled);
            break;
        case UI_TEX_TYPE_PLIST:
            _frontCrossDisabledRenderer->setSpriteFrame(frontCrossDisabled);
            break;
        default:
            break;
    }
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_frontCrossDisabledRenderer);
    _frontCrossDisabledRendererAdaptDirty = true;
}
예제 #16
0
void CheckBox::loadTextureFrontCross(const std::string& cross,TextureResType texType)
{
    if (cross.empty())
    {
        return;
    }
    _frontCrossFileName = cross;
    _frontCrossTexType = texType;
    switch (_frontCrossTexType)
    {
        case TextureResType::LOCAL:
            _frontCrossRenderer->setTexture(cross);
            break;
        case TextureResType::PLIST:
            _frontCrossRenderer->setSpriteFrame(cross);
            break;
        default:
            break;
    }
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_frontCrossRenderer);
    _frontCrossRendererAdaptDirty = true;
}
예제 #17
0
void CheckBox::loadTextureBackGroundSelected(const std::string& backGroundSelected,TextureResType texType)
{
    if (backGroundSelected.empty())
    {
        return;
    }
    _backGroundSelectedFileName = backGroundSelected;
    _backGroundSelectedTexType = texType;
    switch (_backGroundSelectedTexType)
    {
        case UI_TEX_TYPE_LOCAL:
            _backGroundSelectedBoxRenderer->setTexture(backGroundSelected);
            break;
        case UI_TEX_TYPE_PLIST:
            _backGroundSelectedBoxRenderer->setSpriteFrame(backGroundSelected);
            break;
        default:
            break;
    }
    updateFlippedX();
    updateFlippedY();
    updateRGBAToRenderer(_backGroundSelectedBoxRenderer);
    _backGroundSelectedBoxRendererAdaptDirty = true;
}
예제 #18
0
void Widget::setFlippedY(bool flippedY)
{
    _flippedY = flippedY;
    updateFlippedY();
}