void GraphicsLayerChromium::updateLayerPreserves3D() { if (m_preserves3D && m_transformLayer.isNull()) { // Create the transform layer. m_transformLayer = WebLayer::create(); m_transformLayer.setPreserves3D(true); m_transformLayer.setAnimationDelegate(this); m_layer.transferAnimationsTo(&m_transformLayer); // Copy the position from this layer. updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); m_layer.setPosition(FloatPoint::zero()); m_layer.setAnchorPoint(FloatPoint(0.5f, 0.5f)); m_layer.setTransform(SkMatrix44()); // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer. m_layer.setOpacity(1); m_layer.setContentsScale(contentsScale()); // Move this layer to be a child of the transform layer. if (!m_layer.parent().isNull()) m_layer.parent().replaceChild(m_layer, m_transformLayer); m_transformLayer.addChild(m_layer); updateChildList(); } else if (!m_preserves3D && !m_transformLayer.isNull()) { // Relace the transformLayer in the parent with this layer. m_layer.removeFromParent(); if (!m_transformLayer.parent().isNull()) m_transformLayer.parent().replaceChild(m_transformLayer, m_layer); m_layer.setAnimationDelegate(this); m_transformLayer.transferAnimationsTo(&m_layer); // Release the transform layer. m_transformLayer.setAnimationDelegate(0); m_transformLayer.reset(); updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); updateChildList(); } m_layer.setPreserves3D(m_preserves3D); primaryLayer().setOpacity(m_opacity); updateNames(); }
void GraphicsLayerChromium::updateLayerPreserves3D() { if (m_preserves3D && !m_transformLayer) { m_transformLayer = adoptPtr(Platform::current()->compositorSupport()->createLayer()); m_transformLayer->setPreserves3D(true); m_transformLayer->setAnimationDelegate(this); m_layer->layer()->transferAnimationsTo(m_transformLayer.get()); // Copy the position from this layer. updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); m_layer->layer()->setPosition(FloatPoint::zero()); m_layer->layer()->setAnchorPoint(FloatPoint(0.5f, 0.5f)); m_layer->layer()->setTransform(SkMatrix44()); // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer. m_layer->layer()->setOpacity(1); // Move this layer to be a child of the transform layer. if (parent()) parent()->platformLayer()->replaceChild(m_layer->layer(), m_transformLayer.get()); m_transformLayer->addChild(m_layer->layer()); updateChildList(); } else if (!m_preserves3D && m_transformLayer) { // Replace the transformLayer in the parent with this layer. m_layer->layer()->removeFromParent(); if (parent()) parent()->platformLayer()->replaceChild(m_transformLayer.get(), m_layer->layer()); m_layer->layer()->setAnimationDelegate(this); m_transformLayer->transferAnimationsTo(m_layer->layer()); // Release the transform layer. m_transformLayer->setAnimationDelegate(0); m_transformLayer.clear(); updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); updateChildList(); } m_layer->layer()->setPreserves3D(m_preserves3D); platformLayer()->setOpacity(m_opacity); updateNames(); }
void GraphicsLayerBlackBerry::updateLayerPreserves3D() { if (m_preserves3D && !m_transformLayer) { // Create the transform layer. m_transformLayer = LayerWebKitThread::create(LayerData::TransformLayer, this); // Copy the position from this layer. updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); updateAnimations(); m_layer->setPosition(FloatPoint(m_size.width() / 2.0f, m_size.height() / 2.0f)); m_layer->setAnchorPoint(FloatPoint(0.5f, 0.5f)); TransformationMatrix identity; m_layer->setTransform(identity); // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer. m_layer->setOpacity(1); // Move this layer to be a child of the transform layer. if (m_layer->superlayer()) m_layer->superlayer()->replaceSublayer(m_layer.get(), m_transformLayer.get()); m_transformLayer->addSublayer(m_layer.get()); m_transformLayer->setPreserves3D(true); m_layer->setPreserves3D(true); updateSublayerList(); } else if (!m_preserves3D && m_transformLayer) { // Relace the transformLayer in the parent with this layer. m_layer->removeFromSuperlayer(); if (m_transformLayer->superlayer()) m_transformLayer->superlayer()->replaceSublayer(m_transformLayer.get(), m_layer.get()); // Release the transform layer. m_transformLayer = 0; updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); updateAnimations(); m_layer->setPreserves3D(false); updateSublayerList(); } updateOpacityOnLayer(); }
void GraphicsLayerChromium::updateLayerPreserves3D() { if (m_preserves3D && !m_transformLayer) { // Create the transform layer. m_transformLayer = LayerChromium::create(); m_transformLayer->setPreserves3D(true); m_transformLayer->setLayerAnimationDelegate(this); // Copy the position from this layer. updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); m_layer->setPosition(FloatPoint(m_size.width() / 2.0f, m_size.height() / 2.0f)); m_layer->setAnchorPoint(FloatPoint(0.5f, 0.5f)); TransformationMatrix identity; m_layer->setTransform(identity); // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer. m_layer->setOpacity(1); m_layer->setContentsScale(contentsScale()); // Move this layer to be a child of the transform layer. if (m_layer->parent()) m_layer->parent()->replaceChild(m_layer.get(), m_transformLayer.get()); m_transformLayer->addChild(m_layer.get()); updateChildList(); } else if (!m_preserves3D && m_transformLayer) { // Relace the transformLayer in the parent with this layer. m_layer->removeFromParent(); if (m_transformLayer->parent()) m_transformLayer->parent()->replaceChild(m_transformLayer.get(), m_layer.get()); // Release the transform layer. m_transformLayer->setLayerAnimationDelegate(0); m_transformLayer = 0; updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); updateChildList(); } m_layer->setPreserves3D(m_preserves3D); primaryLayer()->setOpacity(m_opacity); updateNames(); }
void GraphicsLayerCACF::updateLayerPreserves3D() { if (m_preserves3D && !m_transformLayer) { // Create the transform layer. m_transformLayer = WebLayer::create(WKCACFLayer::TransformLayer, this); #ifndef NDEBUG m_transformLayer->setName(String().format("Transform Layer CATransformLayer(%p) GraphicsLayer(%p)", m_transformLayer.get(), this)); #endif // Copy the position from this layer. updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); CGPoint point = CGPointMake(m_size.width() / 2.0f, m_size.height() / 2.0f); m_layer->setPosition(point); m_layer->setAnchorPoint(CGPointMake(0.5f, 0.5f)); m_layer->setTransform(wkqcCATransform3DIdentity()); // Set the old layer to opacity of 1. Further down we will set the opacity on the transform layer. m_layer->setOpacity(1); // Move this layer to be a child of the transform layer. if (m_layer->superlayer()) m_layer->superlayer()->replaceSublayer(m_layer.get(), m_transformLayer.get()); m_transformLayer->addSublayer(m_layer.get()); updateSublayerList(); } else if (!m_preserves3D && m_transformLayer) { // Relace the transformLayer in the parent with this layer. m_layer->removeFromSuperlayer(); m_transformLayer->superlayer()->replaceSublayer(m_transformLayer.get(), m_layer.get()); // Release the transform layer. m_transformLayer = 0; updateLayerPosition(); updateLayerSize(); updateAnchorPoint(); updateTransform(); updateChildrenTransform(); updateSublayerList(); } updateOpacityOnLayer(); }
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; } backGroundSelectedTextureScaleChangedWithSize(); updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_backGroundSelectedBoxRenderer); }
void CheckBox::loadTextureBackGroundDisabled(const char *backGroundDisabled,TextureResType texType) { if (!backGroundDisabled || strcmp(backGroundDisabled, "") == 0) { return; } _backGroundDisabledFileName = backGroundDisabled; _backGroundDisabledTexType = texType; switch (_backGroundDisabledTexType) { case UI_TEX_TYPE_LOCAL: _backGroundBoxDisabledRenderer->setTexture(backGroundDisabled); break; case UI_TEX_TYPE_PLIST: _backGroundBoxDisabledRenderer->setSpriteFrame(backGroundDisabled); break; default: break; } backGroundDisabledTextureScaleChangedWithSize(); updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_backGroundBoxDisabledRenderer); }
void CheckBox::loadTextureFrontCross(const char *cross,TextureResType texType) { if (!cross || strcmp(cross, "") == 0) { return; } _frontCrossFileName = cross; _frontCrossTexType = texType; switch (_frontCrossTexType) { case UI_TEX_TYPE_LOCAL: _frontCrossRenderer->setTexture(cross); break; case UI_TEX_TYPE_PLIST: _frontCrossRenderer->setSpriteFrame(cross); break; default: break; } frontCrossTextureScaleChangedWithSize(); updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_frontCrossRenderer); }
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; } frontCrossDisabledTextureScaleChangedWithSize(); updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_frontCrossDisabledRenderer); }
void GraphicsLayerBlackBerry::setAnchorPoint(const FloatPoint3D& point) { if (point == m_anchorPoint) return; GraphicsLayer::setAnchorPoint(point); updateAnchorPoint(); }
void GraphicsLayerChromium::setAnchorPoint(const FloatPoint3D& point) { if (point == m_anchorPoint) return; GraphicsLayer::setAnchorPoint(point); updateAnchorPoint(); }
void TextAtlas::setProperty(const std::string& stringValue, const std::string& charMapFile, int itemWidth, int itemHeight, const std::string& startCharMap) { _stringValue = stringValue; _charMapFileName = charMapFile; _itemWidth = itemWidth; _itemHeight = itemHeight; _startCharMap = startCharMap; _labelAtlasRenderer->initWithString(stringValue, charMapFile, itemWidth, itemHeight, (int)(startCharMap[0])); updateAnchorPoint(); labelAtlasScaleChangedWithSize(); }
void UILabelBMFont::setFntFile(const char *fileName) { if (!fileName || std::strcmp(fileName, "") == 0) { return; } m_pLabelBMFontRenderer->initWithString("", fileName); updateAnchorPoint(); labelBMFontScaleChangedWithSize(); m_bFntFileHasInit = true; }
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->setColor(getColor()); imageRendererScale9->setOpacity(getOpacity()); imageRendererScale9->setCapInsets(_capInsets); } else { CCSprite* imageRenderer = STATIC_CAST_CCSPRITE; imageRenderer->initWithFile(fileName); imageRenderer->setColor(getColor()); imageRenderer->setOpacity(getOpacity()); } break; case UI_TEX_TYPE_PLIST: if (_scale9Enabled) { extension::CCScale9Sprite* imageRendererScale9 = STATIC_CAST_SCALE9SPRITE; imageRendererScale9->initWithSpriteFrameName(fileName); imageRendererScale9->setColor(getColor()); imageRendererScale9->setOpacity(getOpacity()); imageRendererScale9->setCapInsets(_capInsets); } else { CCSprite* imageRenderer = STATIC_CAST_CCSPRITE; imageRenderer->initWithSpriteFrameName(fileName); imageRenderer->setColor(getColor()); imageRenderer->setOpacity(getOpacity()); } break; default: break; } _imageTextureSize = _imageRenderer->getContentSize(); updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); imageTextureScaleChangedWithSize(); }
void TextBMFont::setFntFile(const char *fileName) { if (!fileName || strcmp(fileName, "") == 0) { return; } _fntFileName = fileName; _labelBMFontRenderer->initWithString("", fileName); updateAnchorPoint(); labelBMFontScaleChangedWithSize(); _fntFileHasInit = true; setText(_stringValue.c_str()); }
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; }
void UIImageView::loadTexture(const char *fileName, TextureResType texType) { if (!fileName || strcmp(fileName, "") == 0) { return; } m_strTextureFile = fileName; m_eImageTexType = texType; switch (m_eImageTexType) { case UI_TEX_TYPE_LOCAL: if (m_bScale9Enabled) { DYNAMIC_CAST_SCALE9SPRITE->initWithFile(fileName); DYNAMIC_CAST_SCALE9SPRITE->setColor(getColor()); DYNAMIC_CAST_SCALE9SPRITE->setOpacity(getOpacity()); DYNAMIC_CAST_SCALE9SPRITE->setCapInsets(m_capInsets); } else { DYNAMIC_CAST_CCSPRITE->initWithFile(fileName); DYNAMIC_CAST_CCSPRITE->setColor(getColor()); DYNAMIC_CAST_CCSPRITE->setOpacity(getOpacity()); } break; case UI_TEX_TYPE_PLIST: if (m_bScale9Enabled) { DYNAMIC_CAST_SCALE9SPRITE->initWithSpriteFrameName(fileName); DYNAMIC_CAST_SCALE9SPRITE->setColor(getColor()); DYNAMIC_CAST_SCALE9SPRITE->setOpacity(getOpacity()); DYNAMIC_CAST_SCALE9SPRITE->setCapInsets(m_capInsets); } else { DYNAMIC_CAST_CCSPRITE->initWithSpriteFrameName(fileName); DYNAMIC_CAST_CCSPRITE->setColor(getColor()); DYNAMIC_CAST_CCSPRITE->setOpacity(getOpacity()); } break; default: break; } m_imageTextureSize = m_pImageRenderer->getContentSize(); updateAnchorPoint(); imageTextureScaleChangedWithSize(); }
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::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; }
void Button::loadTextureDisabled(const char* disabled,TextureResType texType) { if (!disabled || strcmp(disabled, "") == 0) { 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(); updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); disabledTextureScaleChangedWithSize(); _disabledTextureLoaded = true; }
void ImageView::loadTexture(const std::string& fileName, TextureResType texType) { if (fileName.empty()) { return; } _textureFile = fileName; _imageTexType = texType; switch (_imageTexType) { case UI_TEX_TYPE_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 UI_TEX_TYPE_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(); imageTextureScaleChangedWithSize(); updateAnchorPoint(); updateFlippedX(); updateFlippedY(); updateRGBAToRenderer(_imageRenderer); }
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; 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)->updateDisplayedColor(getColor()); dynamic_cast<CCScale9Sprite*>(m_pButtonNormalRenderer)->updateDisplayedOpacity(getOpacity()); dynamic_cast<CCScale9Sprite*>(m_pButtonNormalRenderer)->setCapInsets(m_capInsetsNormal); } 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)->updateDisplayedColor(getColor()); dynamic_cast<CCSprite*>(m_pButtonNormalRenderer)->updateDisplayedOpacity(getOpacity()); } m_normalTextureSize = m_pButtonNormalRenderer->getContentSize(); updateAnchorPoint(); normalTextureScaleChangedWithSize(); }
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); }
void UIButton::loadTextureDisabled(const char* disabled,TextureResType texType) { if (!disabled || strcmp(disabled, "") == 0) { return; } m_strDisabledFileName = disabled; // setUseMergedTexture(useSpriteFrame); m_eDisabledTexType = texType; if (m_bScale9Enabled) { switch (m_eDisabledTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCScale9Sprite*>(m_pButtonDisableRenderer)->initWithFile(disabled); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCScale9Sprite*>(m_pButtonDisableRenderer)->initWithSpriteFrameName(disabled); break; default: break; } dynamic_cast<CCScale9Sprite*>(m_pButtonDisableRenderer)->setColor(getColor()); dynamic_cast<CCScale9Sprite*>(m_pButtonDisableRenderer)->setOpacity(getOpacity()); } else { switch (m_eDisabledTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCSprite*>(m_pButtonDisableRenderer)->initWithFile(disabled); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCSprite*>(m_pButtonDisableRenderer)->initWithSpriteFrameName(disabled); break; default: break; } dynamic_cast<CCSprite*>(m_pButtonDisableRenderer)->setColor(getColor()); dynamic_cast<CCSprite*>(m_pButtonDisableRenderer)->setOpacity(getOpacity()); } m_disabledTextureSize = m_pButtonDisableRenderer->getContentSize(); updateAnchorPoint(); disabledTextureScaleChangedWithSize(); }
void UIButton::loadTextureDisabled(const char* disabled,TextureResType texType) { if (!disabled || strcmp(disabled, "") == 0) { return; } _disabledFileName = disabled; _disabledTexType = texType; if (_scale9Enabled) { switch (_disabledTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonDisableRenderer)->initWithFile(disabled); break; case UI_TEX_TYPE_PLIST: dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonDisableRenderer)->initWithSpriteFrameName(disabled); break; default: break; } dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonDisableRenderer)->setColor(getColor()); dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonDisableRenderer)->setOpacity(getOpacity()); dynamic_cast<cocos2d::extension::Scale9Sprite*>(_buttonDisableRenderer)->setCapInsets(_capInsetsDisabled); } else { switch (_disabledTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<cocos2d::Sprite*>(_buttonDisableRenderer)->initWithFile(disabled); break; case UI_TEX_TYPE_PLIST: dynamic_cast<cocos2d::Sprite*>(_buttonDisableRenderer)->initWithSpriteFrameName(disabled); break; default: break; } dynamic_cast<cocos2d::Sprite*>(_buttonDisableRenderer)->setColor(getColor()); dynamic_cast<cocos2d::Sprite*>(_buttonDisableRenderer)->setOpacity(getOpacity()); } _disabledTextureSize = _buttonDisableRenderer->getContentSize(); updateAnchorPoint(); disabledTextureScaleChangedWithSize(); }
void UIButton::loadTexturePressed(const char* selected,TextureResType texType) { if (!selected || strcmp(selected, "") == 0) { return; } m_strClickedFileName = selected; m_ePressedTexType = texType; if (m_bScale9Enabled) { switch (m_ePressedTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCScale9Sprite*>(m_pButtonClickedRenderer)->initWithFile(selected); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCScale9Sprite*>(m_pButtonClickedRenderer)->initWithSpriteFrameName(selected); break; default: break; } dynamic_cast<CCScale9Sprite*>(m_pButtonClickedRenderer)->updateDisplayedColor(getColor()); dynamic_cast<CCScale9Sprite*>(m_pButtonClickedRenderer)->updateDisplayedOpacity(getOpacity()); dynamic_cast<CCScale9Sprite*>(m_pButtonClickedRenderer)->setCapInsets(m_capInsetsPressed); } else { switch (m_ePressedTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCSprite*>(m_pButtonClickedRenderer)->initWithFile(selected); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCSprite*>(m_pButtonClickedRenderer)->initWithSpriteFrameName(selected); break; default: break; } dynamic_cast<CCSprite*>(m_pButtonClickedRenderer)->updateDisplayedColor(getColor()); dynamic_cast<CCSprite*>(m_pButtonClickedRenderer)->updateDisplayedOpacity(getOpacity()); } m_pressedTextureSize = m_pButtonClickedRenderer->getContentSize(); updateAnchorPoint(); pressedTextureScaleChangedWithSize(); }
void UIButton::setPressedTexture(const char* selected,TextureResType texType) { if (!selected || strcmp(selected, "") == 0) { return; } m_strClickedFileName = selected; // setUseMergedTexture(useSpriteFrame); m_ePressedTexType = texType; if (m_bScale9Enable) { switch (m_ePressedTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCScale9Sprite*>(m_pButtonClicked)->initWithFile(selected); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCScale9Sprite*>(m_pButtonClicked)->initWithSpriteFrameName(selected); break; default: break; } dynamic_cast<CCScale9Sprite*>(m_pButtonClicked)->setColor(getColor()); dynamic_cast<CCScale9Sprite*>(m_pButtonClicked)->setOpacity(getOpacity()); } else { switch (m_ePressedTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCSprite*>(m_pButtonClicked)->initWithFile(selected); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCSprite*>(m_pButtonClicked)->initWithSpriteFrameName(selected); break; default: break; } dynamic_cast<CCSprite*>(m_pButtonClicked)->setColor(getColor()); dynamic_cast<CCSprite*>(m_pButtonClicked)->setOpacity(getOpacity()); } updateAnchorPoint(); }
void UIButton::setNormalTexture(const char* normal,TextureResType texType) { if (!normal || strcmp(normal, "") == 0) { return; } m_strNormalFileName = normal; // setUseMergedTexture(useSpriteFrame); m_eNormalTexType = texType; if (m_bScale9Enable) { switch (m_eNormalTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCScale9Sprite*>(m_pButtonNormal)->initWithFile(normal); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCScale9Sprite*>(m_pButtonNormal)->initWithSpriteFrameName(normal); break; default: break; } dynamic_cast<CCScale9Sprite*>(m_pButtonNormal)->setColor(getColor()); dynamic_cast<CCScale9Sprite*>(m_pButtonNormal)->setOpacity(getOpacity()); } else { switch (m_eNormalTexType) { case UI_TEX_TYPE_LOCAL: dynamic_cast<CCSprite*>(m_pButtonNormal)->initWithFile(normal); break; case UI_TEX_TYPE_PLIST: dynamic_cast<CCSprite*>(m_pButtonNormal)->initWithSpriteFrameName(normal); break; default: break; } dynamic_cast<CCSprite*>(m_pButtonNormal)->setColor(getColor()); dynamic_cast<CCSprite*>(m_pButtonNormal)->setOpacity(getOpacity()); } updateAnchorPoint(); }
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; } updateDisplayedColor(getColor()); updateDisplayedOpacity(getOpacity()); updateAnchorPoint(); frontCrossDisabledTextureScaleChangedWithSize(); }