mirror of https://github.com/axmolengine/axmol.git
issue #1458: Adding CCScrollView::updateInset.
This commit is contained in:
parent
bf45edeed5
commit
554b1709c3
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue