diff --git a/extensions/CCBReader/CCScrollViewLoader.cpp b/extensions/CCBReader/CCScrollViewLoader.cpp index b61622dd1c..387b01ada8 100644 --- a/extensions/CCBReader/CCScrollViewLoader.cpp +++ b/extensions/CCBReader/CCScrollViewLoader.cpp @@ -31,6 +31,7 @@ void CCScrollViewLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, void CCScrollViewLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_CONTAINER) == 0) { ((CCScrollView *)pNode)->setContainer(pCCBFileNode); + ((CCScrollView *)pNode)->updateInset(); } else { CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); } diff --git a/extensions/GUI/CCScrollView/CCScrollView.cpp b/extensions/GUI/CCScrollView/CCScrollView.cpp index 45f1c0bef4..587cae2d5b 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.cpp +++ b/extensions/GUI/CCScrollView/CCScrollView.cpp @@ -447,19 +447,26 @@ const CCSize & CCScrollView::getContentSize() void CCScrollView::setContentSize(const CCSize & size) { - // this->setViewSize(size); if (this->getContainer() != NULL) { this->getContainer()->setContentSize(size); + this->updateInset(); + } +} +void CCScrollView::updateInset() +{ + if (this->getContainer() != NULL) + { m_fMaxInset = this->maxContainerOffset(); m_fMaxInset = ccp(m_fMaxInset.x + m_tViewSize.width * INSET_RATIO, m_fMaxInset.y + m_tViewSize.height * INSET_RATIO); m_fMinInset = this->minContainerOffset(); m_fMinInset = ccp(m_fMinInset.x - m_tViewSize.width * INSET_RATIO, m_fMinInset.y - m_tViewSize.height * INSET_RATIO); - } + } } + /** * make sure all children go to the container */ diff --git a/extensions/GUI/CCScrollView/CCScrollView.h b/extensions/GUI/CCScrollView/CCScrollView.h index f5e98d5ac7..a156d580cd 100644 --- a/extensions/GUI/CCScrollView/CCScrollView.h +++ b/extensions/GUI/CCScrollView/CCScrollView.h @@ -211,6 +211,7 @@ public: virtual void setContentSize(const CCSize & size); virtual const CCSize & getContentSize(); + void updateInset(); /** * Determines whether it clips its children or not. */