void Button::onSizeChanged() { Widget::onSizeChanged(); normalTextureScaleChangedWithSize(); pressedTextureScaleChangedWithSize(); disabledTextureScaleChangedWithSize(); }
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; }
void Button::loadTextureNormal(const char* normal,TextureResType texType) { if (!normal || strcmp(normal, "") == 0) { 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(); updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); normalTextureScaleChangedWithSize(); _normalTextureLoaded = true; }
void UIButton::loadTextureNormal(const char* normal,TextureResType texType) { if (!normal || strcmp(normal, "") == 0) { return; } m_strNormalFileName = normal; // setUseMergedTexture(useSpriteFrame); m_eNormalTexType = texType; if (m_bScale9Enabled) { switch (m_eNormalTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCScale9Sprite*>(m_pButtonNormalRenderer)->initWithFile(normal); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCScale9Sprite*>(m_pButtonNormalRenderer)->initWithSpriteFrameName(normal); break; default: break; } dynamic_cast<CCScale9Sprite*>(m_pButtonNormalRenderer)->setColor(getColor()); dynamic_cast<CCScale9Sprite*>(m_pButtonNormalRenderer)->setOpacity(getOpacity()); } else { switch (m_eNormalTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCSprite*>(m_pButtonNormalRenderer)->initWithFile(normal); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCSprite*>(m_pButtonNormalRenderer)->initWithSpriteFrameName(normal); break; default: break; } dynamic_cast<CCSprite*>(m_pButtonNormalRenderer)->setColor(getColor()); dynamic_cast<CCSprite*>(m_pButtonNormalRenderer)->setOpacity(getOpacity()); } m_normalTextureSize = m_pButtonNormalRenderer->getContentSize(); updateAnchorPoint(); normalTextureScaleChangedWithSize(); }
void UIButton::loadTextureNormal(const char* normal,TextureResType texType) { if (!normal || strcmp(normal, "") == 0) { return; } _normalFileName = normal; _normalTexType = texType; if (_scale9Enabled) { switch (_normalTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonNormalRenderer)->initWithFile(normal); break; case UI_TEX_TYPE_PLIST: dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonNormalRenderer)->initWithSpriteFrameName(normal); break; default: break; } dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonNormalRenderer)->setColor(getColor()); dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonNormalRenderer)->setOpacity(getOpacity()); dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonNormalRenderer)->setCapInsets(_capInsetsNormal); } else { switch (_normalTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<cocos2d::Sprite*>(_buttonNormalRenderer)->initWithFile(normal); break; case UI_TEX_TYPE_PLIST: dynamic_cast<cocos2d::Sprite*>(_buttonNormalRenderer)->initWithSpriteFrameName(normal); break; default: break; } dynamic_cast<cocos2d::Sprite*>(_buttonNormalRenderer)->setColor(getColor()); dynamic_cast<cocos2d::Sprite*>(_buttonNormalRenderer)->setOpacity(getOpacity()); } _normalTextureSize = _buttonNormalRenderer->getContentSize(); updateAnchorPoint(); normalTextureScaleChangedWithSize(); }
void Button::adaptRenderers() { if (_normalTextureAdaptDirty) { normalTextureScaleChangedWithSize(); _normalTextureAdaptDirty = false; } if (_pressedTextureAdaptDirty) { pressedTextureScaleChangedWithSize(); _pressedTextureAdaptDirty = false; } if (_disabledTextureAdaptDirty) { disabledTextureScaleChangedWithSize(); _disabledTextureAdaptDirty = false; } }
void UIButton::onSizeChanged() { normalTextureScaleChangedWithSize(); pressedTextureScaleChangedWithSize(); disabledTextureScaleChangedWithSize(); }