mirror of https://github.com/axmolengine/axmol.git
change imageview non-s9 to simple rendering type
This commit is contained in:
parent
df2ebfbc9c
commit
4c99bdf04f
|
@ -112,7 +112,7 @@ bool ImageView::init(const std::string &imageFileName, TextureResType texType)
|
||||||
void ImageView::initRenderer()
|
void ImageView::initRenderer()
|
||||||
{
|
{
|
||||||
_imageRenderer = Scale9Sprite::create();
|
_imageRenderer = Scale9Sprite::create();
|
||||||
_imageRenderer->setScale9Enabled(false);
|
_imageRenderer->setRenderingType(Scale9Sprite::RenderingType::SIMPLE);
|
||||||
|
|
||||||
addProtectedChild(_imageRenderer, IMAGE_RENDERER_Z, -1);
|
addProtectedChild(_imageRenderer, IMAGE_RENDERER_Z, -1);
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,11 @@ void ImageView::setScale9Enabled(bool able)
|
||||||
|
|
||||||
|
|
||||||
_scale9Enabled = able;
|
_scale9Enabled = able;
|
||||||
_imageRenderer->setScale9Enabled(_scale9Enabled);
|
if (_scale9Enabled) {
|
||||||
|
_imageRenderer->setRenderingType(Scale9Sprite::RenderingType::SLICE);
|
||||||
|
}else{
|
||||||
|
_imageRenderer->setRenderingType(Scale9Sprite::RenderingType::SIMPLE);
|
||||||
|
}
|
||||||
|
|
||||||
if (_scale9Enabled)
|
if (_scale9Enabled)
|
||||||
{
|
{
|
||||||
|
@ -256,35 +260,9 @@ Node* ImageView::getVirtualRenderer()
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageView::imageTextureScaleChangedWithSize()
|
void ImageView::imageTextureScaleChangedWithSize()
|
||||||
{
|
|
||||||
if (_ignoreSize)
|
|
||||||
{
|
|
||||||
if (!_scale9Enabled)
|
|
||||||
{
|
|
||||||
_imageRenderer->setScale(1.0f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_scale9Enabled)
|
|
||||||
{
|
{
|
||||||
_imageRenderer->setPreferredSize(_contentSize);
|
_imageRenderer->setPreferredSize(_contentSize);
|
||||||
_imageRenderer->setScale(1.0f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Size textureSize = _imageTextureSize;
|
|
||||||
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
|
|
||||||
{
|
|
||||||
_imageRenderer->setScale(1.0f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
float scaleX = _contentSize.width / textureSize.width;
|
|
||||||
float scaleY = _contentSize.height / textureSize.height;
|
|
||||||
_imageRenderer->setScaleX(scaleX);
|
|
||||||
_imageRenderer->setScaleY(scaleY);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_imageRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
_imageRenderer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue