issue #1458: Adding CCScrollView::updateInset.

This commit is contained in:
James Chen 2012-09-09 22:46:31 +08:00
parent bf45edeed5
commit 554b1709c3
3 changed files with 11 additions and 2 deletions

View File

@ -31,6 +31,7 @@ void CCScrollViewLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent,
void CCScrollViewLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { void CCScrollViewLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) {
if(pPropertyName->compare(PROPERTY_CONTAINER) == 0) { if(pPropertyName->compare(PROPERTY_CONTAINER) == 0) {
((CCScrollView *)pNode)->setContainer(pCCBFileNode); ((CCScrollView *)pNode)->setContainer(pCCBFileNode);
((CCScrollView *)pNode)->updateInset();
} else { } else {
CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader);
} }

View File

@ -447,11 +447,17 @@ const CCSize & CCScrollView::getContentSize()
void CCScrollView::setContentSize(const CCSize & size) void CCScrollView::setContentSize(const CCSize & size)
{ {
// this->setViewSize(size);
if (this->getContainer() != NULL) if (this->getContainer() != NULL)
{ {
this->getContainer()->setContentSize(size); this->getContainer()->setContentSize(size);
this->updateInset();
}
}
void CCScrollView::updateInset()
{
if (this->getContainer() != NULL)
{
m_fMaxInset = this->maxContainerOffset(); m_fMaxInset = this->maxContainerOffset();
m_fMaxInset = ccp(m_fMaxInset.x + m_tViewSize.width * INSET_RATIO, m_fMaxInset = ccp(m_fMaxInset.x + m_tViewSize.width * INSET_RATIO,
m_fMaxInset.y + m_tViewSize.height * INSET_RATIO); m_fMaxInset.y + m_tViewSize.height * INSET_RATIO);
@ -460,6 +466,7 @@ void CCScrollView::setContentSize(const CCSize & size)
m_fMinInset.y - m_tViewSize.height * INSET_RATIO); m_fMinInset.y - m_tViewSize.height * INSET_RATIO);
} }
} }
/** /**
* make sure all children go to the container * make sure all children go to the container
*/ */

View File

@ -211,6 +211,7 @@ public:
virtual void setContentSize(const CCSize & size); virtual void setContentSize(const CCSize & size);
virtual const CCSize & getContentSize(); virtual const CCSize & getContentSize();
void updateInset();
/** /**
* Determines whether it clips its children or not. * Determines whether it clips its children or not.
*/ */