issue #5161, replace all _size to _contentSize

This commit is contained in:
andyque 2014-06-20 10:40:16 +08:00
parent f1ea2e9332
commit 585ccf2c71
15 changed files with 150 additions and 143 deletions

View File

@ -56,9 +56,9 @@ _capInsetsDisabled(Rect::ZERO),
_normalTexType(TextureResType::LOCAL), _normalTexType(TextureResType::LOCAL),
_pressedTexType(TextureResType::LOCAL), _pressedTexType(TextureResType::LOCAL),
_disabledTexType(TextureResType::LOCAL), _disabledTexType(TextureResType::LOCAL),
_normalTextureSize(_size), _normalTextureSize(_contentSize),
_pressedTextureSize(_size), _pressedTextureSize(_contentSize),
_disabledTextureSize(_size), _disabledTextureSize(_contentSize),
_pressedActionEnabled(false), _pressedActionEnabled(false),
_titleColor(Color3B::WHITE), _titleColor(Color3B::WHITE),
_normalTextureScaleXInSize(1.0f), _normalTextureScaleXInSize(1.0f),
@ -615,7 +615,7 @@ void Button::normalTextureScaleChangedWithSize()
{ {
if (_scale9Enabled) if (_scale9Enabled)
{ {
static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer)->setPreferredSize(_size); static_cast<extension::Scale9Sprite*>(_buttonNormalRenderer)->setPreferredSize(_contentSize);
_normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f; _normalTextureScaleXInSize = _normalTextureScaleYInSize = 1.0f;
} }
else else
@ -626,8 +626,8 @@ void Button::normalTextureScaleChangedWithSize()
_buttonNormalRenderer->setScale(1.0f); _buttonNormalRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_buttonNormalRenderer->setScaleX(scaleX); _buttonNormalRenderer->setScaleX(scaleX);
_buttonNormalRenderer->setScaleY(scaleY); _buttonNormalRenderer->setScaleY(scaleY);
_normalTextureScaleXInSize = scaleX; _normalTextureScaleXInSize = scaleX;
@ -651,7 +651,7 @@ void Button::pressedTextureScaleChangedWithSize()
{ {
if (_scale9Enabled) if (_scale9Enabled)
{ {
static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer)->setPreferredSize(_size); static_cast<extension::Scale9Sprite*>(_buttonClickedRenderer)->setPreferredSize(_contentSize);
_pressedTextureScaleXInSize = _pressedTextureScaleYInSize = 1.0f; _pressedTextureScaleXInSize = _pressedTextureScaleYInSize = 1.0f;
} }
else else
@ -662,8 +662,8 @@ void Button::pressedTextureScaleChangedWithSize()
_buttonClickedRenderer->setScale(1.0f); _buttonClickedRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / _pressedTextureSize.width; float scaleX = _contentSize.width / _pressedTextureSize.width;
float scaleY = _size.height / _pressedTextureSize.height; float scaleY = _contentSize.height / _pressedTextureSize.height;
_buttonClickedRenderer->setScaleX(scaleX); _buttonClickedRenderer->setScaleX(scaleX);
_buttonClickedRenderer->setScaleY(scaleY); _buttonClickedRenderer->setScaleY(scaleY);
_pressedTextureScaleXInSize = scaleX; _pressedTextureScaleXInSize = scaleX;
@ -686,7 +686,7 @@ void Button::disabledTextureScaleChangedWithSize()
{ {
if (_scale9Enabled) if (_scale9Enabled)
{ {
static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer)->setPreferredSize(_size); static_cast<extension::Scale9Sprite*>(_buttonDisableRenderer)->setPreferredSize(_contentSize);
} }
else else
{ {
@ -696,8 +696,8 @@ void Button::disabledTextureScaleChangedWithSize()
_buttonDisableRenderer->setScale(1.0f); _buttonDisableRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / _disabledTextureSize.width; float scaleX = _contentSize.width / _disabledTextureSize.width;
float scaleY = _size.height / _disabledTextureSize.height; float scaleY = _contentSize.height / _disabledTextureSize.height;
_buttonDisableRenderer->setScaleX(scaleX); _buttonDisableRenderer->setScaleX(scaleX);
_buttonDisableRenderer->setScaleY(scaleY); _buttonDisableRenderer->setScaleY(scaleY);
} }

View File

@ -473,8 +473,8 @@ void CheckBox::backGroundTextureScaleChangedWithSize()
_backGroundBoxRenderer->setScale(1.0f); _backGroundBoxRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_backGroundBoxRenderer->setScaleX(scaleX); _backGroundBoxRenderer->setScaleX(scaleX);
_backGroundBoxRenderer->setScaleY(scaleY); _backGroundBoxRenderer->setScaleY(scaleY);
} }
@ -495,8 +495,8 @@ void CheckBox::backGroundSelectedTextureScaleChangedWithSize()
_backGroundSelectedBoxRenderer->setScale(1.0f); _backGroundSelectedBoxRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_backGroundSelectedBoxRenderer->setScaleX(scaleX); _backGroundSelectedBoxRenderer->setScaleX(scaleX);
_backGroundSelectedBoxRenderer->setScaleY(scaleY); _backGroundSelectedBoxRenderer->setScaleY(scaleY);
} }
@ -517,8 +517,8 @@ void CheckBox::frontCrossTextureScaleChangedWithSize()
_frontCrossRenderer->setScale(1.0f); _frontCrossRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_frontCrossRenderer->setScaleX(scaleX); _frontCrossRenderer->setScaleX(scaleX);
_frontCrossRenderer->setScaleY(scaleY); _frontCrossRenderer->setScaleY(scaleY);
} }
@ -539,8 +539,8 @@ void CheckBox::backGroundDisabledTextureScaleChangedWithSize()
_backGroundBoxDisabledRenderer->setScale(1.0f); _backGroundBoxDisabledRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_backGroundBoxDisabledRenderer->setScaleX(scaleX); _backGroundBoxDisabledRenderer->setScaleX(scaleX);
_backGroundBoxDisabledRenderer->setScaleY(scaleY); _backGroundBoxDisabledRenderer->setScaleY(scaleY);
} }
@ -561,8 +561,8 @@ void CheckBox::frontCrossDisabledTextureScaleChangedWithSize()
_frontCrossDisabledRenderer->setScale(1.0f); _frontCrossDisabledRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_frontCrossDisabledRenderer->setScaleX(scaleX); _frontCrossDisabledRenderer->setScaleX(scaleX);
_frontCrossDisabledRenderer->setScaleY(scaleY); _frontCrossDisabledRenderer->setScaleY(scaleY);
} }

View File

@ -45,7 +45,7 @@ _capInsets(Rect::ZERO),
_imageRenderer(nullptr), _imageRenderer(nullptr),
_textureFile(""), _textureFile(""),
_imageTexType(TextureResType::LOCAL), _imageTexType(TextureResType::LOCAL),
_imageTextureSize(_size), _imageTextureSize(_contentSize),
_imageRendererAdaptDirty(true) _imageRendererAdaptDirty(true)
{ {
@ -300,7 +300,7 @@ void ImageView::imageTextureScaleChangedWithSize()
{ {
if (_scale9Enabled) if (_scale9Enabled)
{ {
static_cast<extension::Scale9Sprite*>(_imageRenderer)->setPreferredSize(_size); static_cast<extension::Scale9Sprite*>(_imageRenderer)->setPreferredSize(_contentSize);
} }
else else
{ {
@ -310,8 +310,8 @@ void ImageView::imageTextureScaleChangedWithSize()
_imageRenderer->setScale(1.0f); _imageRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_imageRenderer->setScaleX(scaleX); _imageRenderer->setScaleX(scaleX);
_imageRenderer->setScaleY(scaleY); _imageRenderer->setScaleY(scaleY);
} }

View File

@ -429,7 +429,7 @@ void Layout::setClippingEnabled(bool able)
_clippingStencil->onEnter(); _clippingStencil->onEnter();
} }
_clippingStencil->retain(); _clippingStencil->retain();
setStencilClippingSize(_size); setStencilClippingSize(_contentSize);
} }
else else
{ {
@ -469,9 +469,9 @@ void Layout::setStencilClippingSize(const Size &size)
{ {
Vec2 rect[4]; Vec2 rect[4];
rect[0] = Vec2::ZERO; rect[0] = Vec2::ZERO;
rect[1] = Vec2(_size.width, 0); rect[1] = Vec2(_contentSize.width, 0);
rect[2] = Vec2(_size.width, _size.height); rect[2] = Vec2(_contentSize.width, _contentSize.height);
rect[3] = Vec2(0, _size.height); rect[3] = Vec2(0, _contentSize.height);
Color4F green(0, 1, 0, 1); Color4F green(0, 1, 0, 1);
_clippingStencil->clear(); _clippingStencil->clear();
_clippingStencil->drawPolygon(rect, 4, green, 0, green); _clippingStencil->drawPolygon(rect, 4, green, 0, green);
@ -484,8 +484,8 @@ const Rect& Layout::getClippingRect()
{ {
Vec2 worldPos = convertToWorldSpace(Vec2::ZERO); Vec2 worldPos = convertToWorldSpace(Vec2::ZERO);
AffineTransform t = getNodeToWorldAffineTransform(); AffineTransform t = getNodeToWorldAffineTransform();
float scissorWidth = _size.width*t.a; float scissorWidth = _contentSize.width*t.a;
float scissorHeight = _size.height*t.d; float scissorHeight = _contentSize.height*t.d;
Rect parentClippingRect; Rect parentClippingRect;
Layout* parent = this; Layout* parent = this;
@ -560,24 +560,24 @@ const Rect& Layout::getClippingRect()
void Layout::onSizeChanged() void Layout::onSizeChanged()
{ {
Widget::onSizeChanged(); Widget::onSizeChanged();
setStencilClippingSize(_size); setStencilClippingSize(_contentSize);
_doLayoutDirty = true; _doLayoutDirty = true;
_clippingRectDirty = true; _clippingRectDirty = true;
if (_backGroundImage) if (_backGroundImage)
{ {
_backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f)); _backGroundImage->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
if (_backGroundScale9Enabled && _backGroundImage) if (_backGroundScale9Enabled && _backGroundImage)
{ {
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_size); static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_contentSize);
} }
} }
if (_colorRender) if (_colorRender)
{ {
_colorRender->setContentSize(_size); _colorRender->setContentSize(_contentSize);
} }
if (_gradientRender) if (_gradientRender)
{ {
_gradientRender->setContentSize(_size); _gradientRender->setContentSize(_contentSize);
} }
} }
@ -626,7 +626,7 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy
default: default:
break; break;
} }
bgiScale9->setPreferredSize(_size); bgiScale9->setPreferredSize(_contentSize);
} }
else else
{ {
@ -643,7 +643,7 @@ void Layout::setBackGroundImage(const std::string& fileName,TextureResType texTy
} }
} }
_backGroundImageTextureSize = _backGroundImage->getContentSize(); _backGroundImageTextureSize = _backGroundImage->getContentSize();
_backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f)); _backGroundImage->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
updateBackGroundImageRGBA(); updateBackGroundImageRGBA();
} }
@ -701,14 +701,14 @@ void Layout::addBackGroundImage()
{ {
_backGroundImage = extension::Scale9Sprite::create(); _backGroundImage = extension::Scale9Sprite::create();
addProtectedChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); addProtectedChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_size); static_cast<extension::Scale9Sprite*>(_backGroundImage)->setPreferredSize(_contentSize);
} }
else else
{ {
_backGroundImage = Sprite::create(); _backGroundImage = Sprite::create();
addProtectedChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1); addProtectedChild(_backGroundImage, BACKGROUNDIMAGE_Z, -1);
} }
_backGroundImage->setPosition(Vec2(_size.width/2.0f, _size.height/2.0f)); _backGroundImage->setPosition(Vec2(_contentSize.width/2.0f, _contentSize.height/2.0f));
} }
void Layout::removeBackGroundImage() void Layout::removeBackGroundImage()
@ -767,14 +767,14 @@ void Layout::setBackGroundColorType(BackGroundColorType type)
break; break;
case BackGroundColorType::SOLID: case BackGroundColorType::SOLID:
_colorRender = LayerColor::create(); _colorRender = LayerColor::create();
_colorRender->setContentSize(_size); _colorRender->setContentSize(_contentSize);
_colorRender->setOpacity(_cOpacity); _colorRender->setOpacity(_cOpacity);
_colorRender->setColor(_cColor); _colorRender->setColor(_cColor);
addProtectedChild(_colorRender, BCAKGROUNDCOLORRENDERER_Z, -1); addProtectedChild(_colorRender, BCAKGROUNDCOLORRENDERER_Z, -1);
break; break;
case BackGroundColorType::GRADIENT: case BackGroundColorType::GRADIENT:
_gradientRender = LayerGradient::create(); _gradientRender = LayerGradient::create();
_gradientRender->setContentSize(_size); _gradientRender->setContentSize(_contentSize);
_gradientRender->setOpacity(_cOpacity); _gradientRender->setOpacity(_cOpacity);
_gradientRender->setStartColor(_gStartColor); _gradientRender->setStartColor(_gStartColor);
_gradientRender->setEndColor(_gEndColor); _gradientRender->setEndColor(_gEndColor);

View File

@ -98,7 +98,7 @@ void ListView::updateInnerContainerSize()
{ {
totalHeight += item->getSize().height; totalHeight += item->getSize().height;
} }
float finalWidth = _size.width; float finalWidth = _contentSize.width;
float finalHeight = totalHeight; float finalHeight = totalHeight;
setInnerContainerSize(Size(finalWidth, finalHeight)); setInnerContainerSize(Size(finalWidth, finalHeight));
break; break;
@ -112,7 +112,7 @@ void ListView::updateInnerContainerSize()
totalWidth += item->getSize().width; totalWidth += item->getSize().width;
} }
float finalWidth = totalWidth; float finalWidth = totalWidth;
float finalHeight = _size.height; float finalHeight = _contentSize.height;
setInnerContainerSize(Size(finalWidth, finalHeight)); setInnerContainerSize(Size(finalWidth, finalHeight));
break; break;
} }

View File

@ -317,7 +317,7 @@ void LoadingBar::barRendererScaleChangedWithSize()
} }
else else
{ {
_totalLength = _size.width; _totalLength = _contentSize.width;
if (_scale9Enabled) if (_scale9Enabled)
{ {
setScale9Scale(); setScale9Scale();
@ -331,8 +331,8 @@ void LoadingBar::barRendererScaleChangedWithSize()
_barRenderer->setScale(1.0f); _barRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_barRenderer->setScaleX(scaleX); _barRenderer->setScaleX(scaleX);
_barRenderer->setScaleY(scaleY); _barRenderer->setScaleY(scaleY);
} }
@ -353,7 +353,7 @@ void LoadingBar::barRendererScaleChangedWithSize()
void LoadingBar::setScale9Scale() void LoadingBar::setScale9Scale()
{ {
float width = (float)(_percent) / 100.0f * _totalLength; float width = (float)(_percent) / 100.0f * _totalLength;
static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(Size(width, _size.height)); static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(Size(width, _contentSize.height));
} }
std::string LoadingBar::getDescription() const std::string LoadingBar::getDescription() const

View File

@ -414,7 +414,7 @@ void RichText::formarRenderers()
nextPosX += l->getContentSize().width; nextPosX += l->getContentSize().width;
} }
} }
_elementRenderersContainer->setContentSize(_size); _elementRenderersContainer->setContentSize(_contentSize);
delete [] maxHeights; delete [] maxHeights;
} }
@ -430,13 +430,13 @@ void RichText::formarRenderers()
if (_ignoreSize) if (_ignoreSize)
{ {
Size s = getVirtualRendererSize(); Size s = getVirtualRendererSize();
_size = s; _contentSize = s;
} }
else else
{ {
_size = _customSize; _contentSize = _customSize;
} }
updateContentSizeWithTextureSize(_size); updateContentSizeWithTextureSize(_contentSize);
_elementRenderersContainer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f); _elementRenderersContainer->setPosition(_contentSize.width / 2.0f, _contentSize.height / 2.0f);
} }

View File

@ -128,29 +128,29 @@ void ScrollView::initRenderer()
void ScrollView::onSizeChanged() void ScrollView::onSizeChanged()
{ {
Layout::onSizeChanged(); Layout::onSizeChanged();
_topBoundary = _size.height; _topBoundary = _contentSize.height;
_rightBoundary = _size.width; _rightBoundary = _contentSize.width;
float bounceBoundaryParameterX = _size.width / 3.0f; float bounceBoundaryParameterX = _contentSize.width / 3.0f;
float bounceBoundaryParameterY = _size.height / 3.0f; float bounceBoundaryParameterY = _contentSize.height / 3.0f;
_bounceTopBoundary = _size.height - bounceBoundaryParameterY; _bounceTopBoundary = _contentSize.height - bounceBoundaryParameterY;
_bounceBottomBoundary = bounceBoundaryParameterY; _bounceBottomBoundary = bounceBoundaryParameterY;
_bounceLeftBoundary = bounceBoundaryParameterX; _bounceLeftBoundary = bounceBoundaryParameterX;
_bounceRightBoundary = _size.width - bounceBoundaryParameterX; _bounceRightBoundary = _contentSize.width - bounceBoundaryParameterX;
Size innerSize = _innerContainer->getSize(); Size innerSize = _innerContainer->getSize();
float orginInnerSizeWidth = innerSize.width; float orginInnerSizeWidth = innerSize.width;
float orginInnerSizeHeight = innerSize.height; float orginInnerSizeHeight = innerSize.height;
float innerSizeWidth = MAX(orginInnerSizeWidth, _size.width); float innerSizeWidth = MAX(orginInnerSizeWidth, _contentSize.width);
float innerSizeHeight = MAX(orginInnerSizeHeight, _size.height); float innerSizeHeight = MAX(orginInnerSizeHeight, _contentSize.height);
_innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight)); _innerContainer->setSize(Size(innerSizeWidth, innerSizeHeight));
_innerContainer->setPosition(Vec2(0, _size.height - _innerContainer->getSize().height)); _innerContainer->setPosition(Vec2(0, _contentSize.height - _innerContainer->getSize().height));
} }
void ScrollView::setInnerContainerSize(const Size &size) void ScrollView::setInnerContainerSize(const Size &size)
{ {
float innerSizeWidth = _size.width; float innerSizeWidth = _contentSize.width;
float innerSizeHeight = _size.height; float innerSizeHeight = _contentSize.height;
Size originalInnerSize = _innerContainer->getSize(); Size originalInnerSize = _innerContainer->getSize();
if (size.width < _size.width) if (size.width < _contentSize.width)
{ {
CCLOG("Inner width <= scrollview width, it will be force sized!"); CCLOG("Inner width <= scrollview width, it will be force sized!");
} }
@ -158,7 +158,7 @@ void ScrollView::setInnerContainerSize(const Size &size)
{ {
innerSizeWidth = size.width; innerSizeWidth = size.width;
} }
if (size.height < _size.height) if (size.height < _contentSize.height)
{ {
CCLOG("Inner height <= scrollview height, it will be force sized!"); CCLOG("Inner height <= scrollview height, it will be force sized!");
} }
@ -179,7 +179,7 @@ void ScrollView::setInnerContainerSize(const Size &size)
} }
case Direction::HORIZONTAL: case Direction::HORIZONTAL:
{ {
if (_innerContainer->getRightBoundary() <= _size.width) if (_innerContainer->getRightBoundary() <= _contentSize.width)
{ {
Size newInnerSize = _innerContainer->getSize(); Size newInnerSize = _innerContainer->getSize();
float offset = originalInnerSize.width - newInnerSize.width; float offset = originalInnerSize.width - newInnerSize.width;
@ -192,7 +192,7 @@ void ScrollView::setInnerContainerSize(const Size &size)
Size newInnerSize = _innerContainer->getSize(); Size newInnerSize = _innerContainer->getSize();
float offsetY = originalInnerSize.height - newInnerSize.height; float offsetY = originalInnerSize.height - newInnerSize.height;
float offsetX = 0.0f; float offsetX = 0.0f;
if (_innerContainer->getRightBoundary() <= _size.width) if (_innerContainer->getRightBoundary() <= _contentSize.width)
{ {
offsetX = originalInnerSize.width - newInnerSize.width; offsetX = originalInnerSize.width - newInnerSize.width;
} }
@ -204,19 +204,23 @@ void ScrollView::setInnerContainerSize(const Size &size)
} }
if (_innerContainer->getLeftBoundary() > 0.0f) if (_innerContainer->getLeftBoundary() > 0.0f)
{ {
_innerContainer->setPosition(Vec2(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width, _innerContainer->getPosition().y)); _innerContainer->setPosition(Vec2(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width,
_innerContainer->getPosition().y));
} }
if (_innerContainer->getRightBoundary() < _size.width) if (_innerContainer->getRightBoundary() < _contentSize.width)
{ {
_innerContainer->setPosition(Vec2(_size.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width), _innerContainer->getPosition().y)); _innerContainer->setPosition(Vec2(_contentSize.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width),
_innerContainer->getPosition().y));
} }
if (_innerContainer->getPosition().y > 0.0f) if (_innerContainer->getPosition().y > 0.0f)
{ {
_innerContainer->setPosition(Vec2(_innerContainer->getPosition().x, _innerContainer->getAnchorPoint().y * _innerContainer->getSize().height)); _innerContainer->setPosition(Vec2(_innerContainer->getPosition().x,
_innerContainer->getAnchorPoint().y * _innerContainer->getSize().height));
} }
if (_innerContainer->getTopBoundary() < _size.height) if (_innerContainer->getTopBoundary() < _contentSize.height)
{ {
_innerContainer->setPosition(Vec2(_innerContainer->getPosition().x, _size.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height)); _innerContainer->setPosition(Vec2(_innerContainer->getPosition().x,
_contentSize.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height));
} }
} }
@ -359,14 +363,14 @@ bool ScrollView::checkNeedBounce()
{ {
if (_topBounceNeeded && _leftBounceNeeded) if (_topBounceNeeded && _leftBounceNeeded)
{ {
Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(_innerContainer->getLeftBoundary(), _innerContainer->getTopBoundary()); Vec2 scrollVector = Vec2(0.0f, _contentSize.height) - Vec2(_innerContainer->getLeftBoundary(), _innerContainer->getTopBoundary());
float orSpeed = scrollVector.getLength()/(0.2f); float orSpeed = scrollVector.getLength()/(0.2f);
_bounceDir = scrollVector.getNormalized(); _bounceDir = scrollVector.getNormalized();
startBounceChildren(orSpeed); startBounceChildren(orSpeed);
} }
else if (_topBounceNeeded && _rightBounceNeeded) else if (_topBounceNeeded && _rightBounceNeeded)
{ {
Vec2 scrollVector = Vec2(_size.width, _size.height) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getTopBoundary()); Vec2 scrollVector = Vec2(_contentSize.width, _contentSize.height) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getTopBoundary());
float orSpeed = scrollVector.getLength()/(0.2f); float orSpeed = scrollVector.getLength()/(0.2f);
_bounceDir = scrollVector.getNormalized(); _bounceDir = scrollVector.getNormalized();
startBounceChildren(orSpeed); startBounceChildren(orSpeed);
@ -380,14 +384,14 @@ bool ScrollView::checkNeedBounce()
} }
else if (_bottomBounceNeeded && _rightBounceNeeded) else if (_bottomBounceNeeded && _rightBounceNeeded)
{ {
Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getBottomBoundary()); Vec2 scrollVector = Vec2(_contentSize.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getBottomBoundary());
float orSpeed = scrollVector.getLength()/(0.2f); float orSpeed = scrollVector.getLength()/(0.2f);
_bounceDir = scrollVector.getNormalized(); _bounceDir = scrollVector.getNormalized();
startBounceChildren(orSpeed); startBounceChildren(orSpeed);
} }
else if (_topBounceNeeded) else if (_topBounceNeeded)
{ {
Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(0.0f, _innerContainer->getTopBoundary()); Vec2 scrollVector = Vec2(0.0f, _contentSize.height) - Vec2(0.0f, _innerContainer->getTopBoundary());
float orSpeed = scrollVector.getLength()/(0.2f); float orSpeed = scrollVector.getLength()/(0.2f);
_bounceDir = scrollVector.getNormalized(); _bounceDir = scrollVector.getNormalized();
startBounceChildren(orSpeed); startBounceChildren(orSpeed);
@ -408,7 +412,7 @@ bool ScrollView::checkNeedBounce()
} }
else if (_rightBounceNeeded) else if (_rightBounceNeeded)
{ {
Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), 0.0f); Vec2 scrollVector = Vec2(_contentSize.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), 0.0f);
float orSpeed = scrollVector.getLength()/(0.2f); float orSpeed = scrollVector.getLength()/(0.2f);
_bounceDir = scrollVector.getNormalized(); _bounceDir = scrollVector.getNormalized();
startBounceChildren(orSpeed); startBounceChildren(orSpeed);
@ -518,23 +522,23 @@ void ScrollView::jumpToDestination(const Vec2 &des)
case Direction::VERTICAL: case Direction::VERTICAL:
if (des.y <= 0) if (des.y <= 0)
{ {
finalOffsetY = MAX(des.y, _size.height - _innerContainer->getSize().height); finalOffsetY = MAX(des.y, _contentSize.height - _innerContainer->getSize().height);
} }
break; break;
case Direction::HORIZONTAL: case Direction::HORIZONTAL:
if (des.x <= 0) if (des.x <= 0)
{ {
finalOffsetX = MAX(des.x, _size.width - _innerContainer->getSize().width); finalOffsetX = MAX(des.x, _contentSize.width - _innerContainer->getSize().width);
} }
break; break;
case Direction::BOTH: case Direction::BOTH:
if (des.y <= 0) if (des.y <= 0)
{ {
finalOffsetY = MAX(des.y, _size.height - _innerContainer->getSize().height); finalOffsetY = MAX(des.y, _contentSize.height - _innerContainer->getSize().height);
} }
if (des.x <= 0) if (des.x <= 0)
{ {
finalOffsetX = MAX(des.x, _size.width - _innerContainer->getSize().width); finalOffsetX = MAX(des.x, _contentSize.width - _innerContainer->getSize().width);
} }
break; break;
default: default:
@ -1217,7 +1221,8 @@ void ScrollView::scrollToBottom(float time, bool attenuated)
void ScrollView::scrollToTop(float time, bool attenuated) void ScrollView::scrollToTop(float time, bool attenuated)
{ {
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height), time, attenuated); startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x,
_contentSize.height - _innerContainer->getSize().height), time, attenuated);
} }
void ScrollView::scrollToLeft(float time, bool attenuated) void ScrollView::scrollToLeft(float time, bool attenuated)
@ -1227,7 +1232,8 @@ void ScrollView::scrollToLeft(float time, bool attenuated)
void ScrollView::scrollToRight(float time, bool attenuated) void ScrollView::scrollToRight(float time, bool attenuated)
{ {
startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y), time, attenuated); startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getSize().width,
_innerContainer->getPosition().y), time, attenuated);
} }
void ScrollView::scrollToTopLeft(float time, bool attenuated) void ScrollView::scrollToTopLeft(float time, bool attenuated)
@ -1237,7 +1243,7 @@ void ScrollView::scrollToTopLeft(float time, bool attenuated)
CCLOG("Scroll diretion is not both!"); CCLOG("Scroll diretion is not both!");
return; return;
} }
startAutoScrollChildrenWithDestination(Vec2(0.0f, _size.height - _innerContainer->getSize().height), time, attenuated); startAutoScrollChildrenWithDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getSize().height), time, attenuated);
} }
void ScrollView::scrollToTopRight(float time, bool attenuated) void ScrollView::scrollToTopRight(float time, bool attenuated)
@ -1247,7 +1253,8 @@ void ScrollView::scrollToTopRight(float time, bool attenuated)
CCLOG("Scroll diretion is not both!"); CCLOG("Scroll diretion is not both!");
return; return;
} }
startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height), time, attenuated); startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getSize().width,
_contentSize.height - _innerContainer->getSize().height), time, attenuated);
} }
void ScrollView::scrollToBottomLeft(float time, bool attenuated) void ScrollView::scrollToBottomLeft(float time, bool attenuated)
@ -1267,19 +1274,19 @@ void ScrollView::scrollToBottomRight(float time, bool attenuated)
CCLOG("Scroll diretion is not both!"); CCLOG("Scroll diretion is not both!");
return; return;
} }
startAutoScrollChildrenWithDestination(Vec2(_size.width - _innerContainer->getSize().width, 0.0f), time, attenuated); startAutoScrollChildrenWithDestination(Vec2(_contentSize.width - _innerContainer->getSize().width, 0.0f), time, attenuated);
} }
void ScrollView::scrollToPercentVertical(float percent, float time, bool attenuated) void ScrollView::scrollToPercentVertical(float percent, float time, bool attenuated)
{ {
float minY = _size.height - _innerContainer->getSize().height; float minY = _contentSize.height - _innerContainer->getSize().height;
float h = - minY; float h = - minY;
startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f), time, attenuated); startAutoScrollChildrenWithDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f), time, attenuated);
} }
void ScrollView::scrollToPercentHorizontal(float percent, float time, bool attenuated) void ScrollView::scrollToPercentHorizontal(float percent, float time, bool attenuated)
{ {
float w = _innerContainer->getSize().width - _size.width; float w = _innerContainer->getSize().width - _contentSize.width;
startAutoScrollChildrenWithDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated); startAutoScrollChildrenWithDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y), time, attenuated);
} }
@ -1289,9 +1296,9 @@ void ScrollView::scrollToPercentBothDirection(const Vec2& percent, float time, b
{ {
return; return;
} }
float minY = _size.height - _innerContainer->getSize().height; float minY = _contentSize.height - _innerContainer->getSize().height;
float h = - minY; float h = - minY;
float w = _innerContainer->getSize().width - _size.width; float w = _innerContainer->getSize().width - _contentSize.width;
startAutoScrollChildrenWithDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated); startAutoScrollChildrenWithDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f), time, attenuated);
} }
@ -1302,7 +1309,8 @@ void ScrollView::jumpToBottom()
void ScrollView::jumpToTop() void ScrollView::jumpToTop()
{ {
jumpToDestination(Vec2(_innerContainer->getPosition().x, _size.height - _innerContainer->getSize().height)); jumpToDestination(Vec2(_innerContainer->getPosition().x,
_contentSize.height - _innerContainer->getSize().height));
} }
void ScrollView::jumpToLeft() void ScrollView::jumpToLeft()
@ -1312,7 +1320,7 @@ void ScrollView::jumpToLeft()
void ScrollView::jumpToRight() void ScrollView::jumpToRight()
{ {
jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, _innerContainer->getPosition().y)); jumpToDestination(Vec2(_contentSize.width - _innerContainer->getSize().width, _innerContainer->getPosition().y));
} }
void ScrollView::jumpToTopLeft() void ScrollView::jumpToTopLeft()
@ -1322,7 +1330,7 @@ void ScrollView::jumpToTopLeft()
CCLOG("Scroll diretion is not both!"); CCLOG("Scroll diretion is not both!");
return; return;
} }
jumpToDestination(Vec2(0.0f, _size.height - _innerContainer->getSize().height)); jumpToDestination(Vec2(0.0f, _contentSize.height - _innerContainer->getSize().height));
} }
void ScrollView::jumpToTopRight() void ScrollView::jumpToTopRight()
@ -1332,7 +1340,8 @@ void ScrollView::jumpToTopRight()
CCLOG("Scroll diretion is not both!"); CCLOG("Scroll diretion is not both!");
return; return;
} }
jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, _size.height - _innerContainer->getSize().height)); jumpToDestination(Vec2(_contentSize.width - _innerContainer->getSize().width,
_contentSize.height - _innerContainer->getSize().height));
} }
void ScrollView::jumpToBottomLeft() void ScrollView::jumpToBottomLeft()
@ -1352,19 +1361,19 @@ void ScrollView::jumpToBottomRight()
CCLOG("Scroll diretion is not both!"); CCLOG("Scroll diretion is not both!");
return; return;
} }
jumpToDestination(Vec2(_size.width - _innerContainer->getSize().width, 0.0f)); jumpToDestination(Vec2(_contentSize.width - _innerContainer->getSize().width, 0.0f));
} }
void ScrollView::jumpToPercentVertical(float percent) void ScrollView::jumpToPercentVertical(float percent)
{ {
float minY = _size.height - _innerContainer->getSize().height; float minY = _contentSize.height - _innerContainer->getSize().height;
float h = - minY; float h = - minY;
jumpToDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f)); jumpToDestination(Vec2(_innerContainer->getPosition().x, minY + percent * h / 100.0f));
} }
void ScrollView::jumpToPercentHorizontal(float percent) void ScrollView::jumpToPercentHorizontal(float percent)
{ {
float w = _innerContainer->getSize().width - _size.width; float w = _innerContainer->getSize().width - _contentSize.width;
jumpToDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y)); jumpToDestination(Vec2(-(percent * w / 100.0f), _innerContainer->getPosition().y));
} }
@ -1374,9 +1383,9 @@ void ScrollView::jumpToPercentBothDirection(const Vec2& percent)
{ {
return; return;
} }
float minY = _size.height - _innerContainer->getSize().height; float minY = _contentSize.height - _innerContainer->getSize().height;
float h = - minY; float h = - minY;
float w = _innerContainer->getSize().width - _size.width; float w = _innerContainer->getSize().width - _contentSize.width;
jumpToDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f)); jumpToDestination(Vec2(-(percent.x * w / 100.0f), minY + percent.y * h / 100.0f));
} }

View File

@ -500,14 +500,14 @@ void Slider::barRendererScaleChangedWithSize()
{ {
_barRenderer->setScale(1.0f); _barRenderer->setScale(1.0f);
_barLength = _size.width; _barLength = _contentSize.width;
} }
else else
{ {
_barLength = _size.width; _barLength = _contentSize.width;
if (_scale9Enabled) if (_scale9Enabled)
{ {
static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(_size); static_cast<extension::Scale9Sprite*>(_barRenderer)->setPreferredSize(_contentSize);
} }
else else
{ {
@ -517,8 +517,8 @@ void Slider::barRendererScaleChangedWithSize()
_barRenderer->setScale(1.0f); _barRenderer->setScale(1.0f);
return; return;
} }
float bscaleX = _size.width / btextureSize.width; float bscaleX = _contentSize.width / btextureSize.width;
float bscaleY = _size.height / btextureSize.height; float bscaleY = _contentSize.height / btextureSize.height;
_barRenderer->setScaleX(bscaleX); _barRenderer->setScaleX(bscaleX);
_barRenderer->setScaleY(bscaleY); _barRenderer->setScaleY(bscaleY);
} }
@ -534,8 +534,8 @@ void Slider::progressBarRendererScaleChangedWithSize()
if (!_scale9Enabled) if (!_scale9Enabled)
{ {
Size ptextureSize = _progressBarTextureSize; Size ptextureSize = _progressBarTextureSize;
float pscaleX = _size.width / ptextureSize.width; float pscaleX = _contentSize.width / ptextureSize.width;
float pscaleY = _size.height / ptextureSize.height; float pscaleY = _contentSize.height / ptextureSize.height;
_progressBarRenderer->setScaleX(pscaleX); _progressBarRenderer->setScaleX(pscaleX);
_progressBarRenderer->setScaleY(pscaleY); _progressBarRenderer->setScaleY(pscaleY);
} }
@ -544,7 +544,7 @@ void Slider::progressBarRendererScaleChangedWithSize()
{ {
if (_scale9Enabled) if (_scale9Enabled)
{ {
static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->setPreferredSize(_size); static_cast<extension::Scale9Sprite*>(_progressBarRenderer)->setPreferredSize(_contentSize);
_progressBarTextureSize = _progressBarRenderer->getContentSize(); _progressBarTextureSize = _progressBarRenderer->getContentSize();
} }
else else
@ -555,8 +555,8 @@ void Slider::progressBarRendererScaleChangedWithSize()
_progressBarRenderer->setScale(1.0f); _progressBarRenderer->setScale(1.0f);
return; return;
} }
float pscaleX = _size.width / ptextureSize.width; float pscaleX = _contentSize.width / ptextureSize.width;
float pscaleY = _size.height / ptextureSize.height; float pscaleY = _contentSize.height / ptextureSize.height;
_progressBarRenderer->setScaleX(pscaleX); _progressBarRenderer->setScaleX(pscaleX);
_progressBarRenderer->setScaleY(pscaleY); _progressBarRenderer->setScaleY(pscaleY);
} }

View File

@ -302,15 +302,15 @@ void Text::labelScaleChangedWithSize()
} }
else else
{ {
_labelRenderer->setDimensions(_size.width,_size.height); _labelRenderer->setDimensions(_contentSize.width,_contentSize.height);
Size textureSize = _labelRenderer->getContentSize(); Size textureSize = _labelRenderer->getContentSize();
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
{ {
_labelRenderer->setScale(1.0f); _labelRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_labelRenderer->setScaleX(scaleX); _labelRenderer->setScaleX(scaleX);
_labelRenderer->setScaleY(scaleY); _labelRenderer->setScaleY(scaleY);
_normalScaleValueX = scaleX; _normalScaleValueX = scaleX;

View File

@ -159,8 +159,8 @@ void TextAtlas::labelAtlasScaleChangedWithSize()
_labelAtlasRenderer->setScale(1.0f); _labelAtlasRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_labelAtlasRenderer->setScaleX(scaleX); _labelAtlasRenderer->setScaleX(scaleX);
_labelAtlasRenderer->setScaleY(scaleY); _labelAtlasRenderer->setScaleY(scaleY);
} }

View File

@ -155,8 +155,8 @@ void TextBMFont::labelBMFontScaleChangedWithSize()
_labelBMFontRenderer->setScale(1.0f); _labelBMFontRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_labelBMFontRenderer->setScaleX(scaleX); _labelBMFontRenderer->setScaleX(scaleX);
_labelBMFontRenderer->setScaleY(scaleY); _labelBMFontRenderer->setScaleY(scaleY);
} }

View File

@ -783,15 +783,15 @@ void TextField::textfieldRendererScaleChangedWithSize()
} }
else else
{ {
_textFieldRenderer->setDimensions(_size.width,_size.height); _textFieldRenderer->setDimensions(_contentSize.width, _contentSize.height);
Size textureSize = getContentSize(); Size textureSize = getContentSize();
if (textureSize.width <= 0.0f || textureSize.height <= 0.0f) if (textureSize.width <= 0.0f || textureSize.height <= 0.0f)
{ {
_textFieldRenderer->setScale(1.0f); _textFieldRenderer->setScale(1.0f);
return; return;
} }
float scaleX = _size.width / textureSize.width; float scaleX = _contentSize.width / textureSize.width;
float scaleY = _size.height / textureSize.height; float scaleY = _contentSize.height / textureSize.height;
_textFieldRenderer->setScaleX(scaleX); _textFieldRenderer->setScaleX(scaleX);
_textFieldRenderer->setScaleY(scaleY); _textFieldRenderer->setScaleY(scaleY);
} }

View File

@ -145,7 +145,6 @@ _touchEndPosition(Vec2::ZERO),
_touchEventListener(nullptr), _touchEventListener(nullptr),
_touchEventSelector(nullptr), _touchEventSelector(nullptr),
_actionTag(0), _actionTag(0),
_size(Size::ZERO),
_customSize(Size::ZERO), _customSize(Size::ZERO),
_ignoreSize(false), _ignoreSize(false),
_affectByClipping(false), _affectByClipping(false),
@ -258,11 +257,11 @@ void Widget::setSize(const Size &size)
_customSize = size; _customSize = size;
if (_ignoreSize) if (_ignoreSize)
{ {
_size = getVirtualRendererSize(); _contentSize = getVirtualRendererSize();
} }
else else
{ {
_size = size; _contentSize = size;
} }
if (_running) if (_running)
{ {
@ -309,11 +308,11 @@ void Widget::setSizePercent(const Vec2 &percent)
} }
if (_ignoreSize) if (_ignoreSize)
{ {
_size = getVirtualRendererSize(); _contentSize = getVirtualRendererSize();
} }
else else
{ {
_size = cSize; _contentSize = cSize;
} }
_customSize = cSize; _customSize = cSize;
onSizeChanged(); onSizeChanged();
@ -342,11 +341,11 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
{ {
if (_ignoreSize) if (_ignoreSize)
{ {
_size = getVirtualRendererSize(); _contentSize = getVirtualRendererSize();
} }
else else
{ {
_size = _customSize; _contentSize = _customSize;
} }
float spx = 0.0f; float spx = 0.0f;
float spy = 0.0f; float spy = 0.0f;
@ -366,11 +365,11 @@ void Widget::updateSizeAndPosition(const cocos2d::Size &parentSize)
Size cSize = Size(parentSize.width * _sizePercent.x , parentSize.height * _sizePercent.y); Size cSize = Size(parentSize.width * _sizePercent.x , parentSize.height * _sizePercent.y);
if (_ignoreSize) if (_ignoreSize)
{ {
_size = getVirtualRendererSize(); _contentSize = getVirtualRendererSize();
} }
else else
{ {
_size = cSize; _contentSize = cSize;
} }
_customSize = cSize; _customSize = cSize;
break; break;
@ -425,11 +424,11 @@ void Widget::ignoreContentAdaptWithSize(bool ignore)
if (_ignoreSize) if (_ignoreSize)
{ {
Size s = getVirtualRendererSize(); Size s = getVirtualRendererSize();
_size = s; _contentSize = s;
} }
else else
{ {
_size = _customSize; _contentSize = _customSize;
} }
onSizeChanged(); onSizeChanged();
} }
@ -441,7 +440,7 @@ bool Widget::isIgnoreContentAdaptWithSize() const
const Size& Widget::getSize() const const Size& Widget::getSize() const
{ {
return _size; return _contentSize;
} }
const Size& Widget::getCustomSize() const const Size& Widget::getCustomSize() const
@ -466,7 +465,7 @@ Node* Widget::getVirtualRenderer()
void Widget::onSizeChanged() void Widget::onSizeChanged()
{ {
setContentSize(_size); setContentSize(_contentSize);
for (auto& child : getChildren()) for (auto& child : getChildren())
{ {
Widget* widgetChild = dynamic_cast<Widget*>(child); Widget* widgetChild = dynamic_cast<Widget*>(child);
@ -486,11 +485,11 @@ void Widget::updateContentSizeWithTextureSize(const cocos2d::Size &size)
{ {
if (_ignoreSize) if (_ignoreSize)
{ {
_size = size; _contentSize = size;
} }
else else
{ {
_size = _customSize; _contentSize = _customSize;
} }
onSizeChanged(); onSizeChanged();
} }
@ -911,22 +910,22 @@ bool Widget::isEnabled() const
float Widget::getLeftBoundary() const float Widget::getLeftBoundary() const
{ {
return getPosition().x - getAnchorPoint().x * _size.width; return getPosition().x - getAnchorPoint().x * _contentSize.width;
} }
float Widget::getBottomBoundary() const float Widget::getBottomBoundary() const
{ {
return getPosition().y - getAnchorPoint().y * _size.height; return getPosition().y - getAnchorPoint().y * _contentSize.height;
} }
float Widget::getRightBoundary() const float Widget::getRightBoundary() const
{ {
return getLeftBoundary() + _size.width; return getLeftBoundary() + _contentSize.width;
} }
float Widget::getTopBoundary() const float Widget::getTopBoundary() const
{ {
return getBottomBoundary() + _size.height; return getBottomBoundary() + _contentSize.height;
} }
const Vec2& Widget::getTouchBeganPosition()const const Vec2& Widget::getTouchBeganPosition()const
@ -1012,7 +1011,7 @@ void Widget::copyProperties(Widget *widget)
setName(widget->getName()); setName(widget->getName());
setActionTag(widget->getActionTag()); setActionTag(widget->getActionTag());
_ignoreSize = widget->_ignoreSize; _ignoreSize = widget->_ignoreSize;
_size = widget->_size; _contentSize = widget->_contentSize;
_customSize = widget->_customSize; _customSize = widget->_customSize;
_sizeType = widget->getSizeType(); _sizeType = widget->getSizeType();
_sizePercent = widget->_sizePercent; _sizePercent = widget->_sizePercent;

View File

@ -407,7 +407,7 @@ public:
const Size& getCustomSize() const; const Size& getCustomSize() const;
virtual const Size& getLayoutSize() {return _size;}; virtual const Size& getLayoutSize() {return _contentSize;};
/** /**
* Returns size percent of widget * Returns size percent of widget
@ -659,7 +659,6 @@ protected:
//use //use
int _actionTag; int _actionTag;
Size _size;
Size _customSize; Size _customSize;
Vec2 _sizePercent; Vec2 _sizePercent;