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) {
if(pPropertyName->compare(PROPERTY_CONTAINER) == 0) {
((CCScrollView *)pNode)->setContainer(pCCBFileNode);
((CCScrollView *)pNode)->updateInset();
} else {
CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader);
}

View File

@ -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
*/

View File

@ -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.
*/