mirror of https://github.com/axmolengine/axmol.git
Fix the display bug when a scrollView nested in another scrollView
This commit is contained in:
parent
18c43e29b2
commit
f1f31deb98
|
@ -492,11 +492,24 @@ void CCScrollView::beforeDraw()
|
|||
{
|
||||
if (m_bClippingToBounds)
|
||||
{
|
||||
CCRect frame = getViewRect();
|
||||
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
|
||||
CCEGLView::sharedOpenGLView()->setScissorInPoints(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
|
||||
m_bScissorRestored = false;
|
||||
CCRect frame = getViewRect();
|
||||
if (CCEGLView::sharedOpenGLView()->isScissorEnable()) {
|
||||
m_bScissorRestored = true;
|
||||
m_tParentScissorRect = CCEGLView::sharedOpenGLView()->getScissorRect();
|
||||
//set the intersection of m_tParentScissorRect and frame as the new scissor rect
|
||||
if (frame.intersectsRect(m_tParentScissorRect)) {
|
||||
float x = MAX(frame.origin.x, m_tParentScissorRect.origin.x);
|
||||
float y = MAX(frame.origin.y, m_tParentScissorRect.origin.y);
|
||||
float xx = MIN(frame.origin.x+frame.size.width, m_tParentScissorRect.origin.x+m_tParentScissorRect.size.width);
|
||||
float yy = MIN(frame.origin.y+frame.size.height, m_tParentScissorRect.origin.y+m_tParentScissorRect.size.height);
|
||||
CCEGLView::sharedOpenGLView()->setScissorInPoints(x, y, xx-x, yy-y);
|
||||
}
|
||||
}
|
||||
else {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
CCEGLView::sharedOpenGLView()->setScissorInPoints(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -508,7 +521,12 @@ void CCScrollView::afterDraw()
|
|||
{
|
||||
if (m_bClippingToBounds)
|
||||
{
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
if (m_bScissorRestored) {//restore the parent's scissor rect
|
||||
CCEGLView::sharedOpenGLView()->setScissorInPoints(m_tParentScissorRect.origin.x, m_tParentScissorRect.origin.y, m_tParentScissorRect.size.width, m_tParentScissorRect.size.height);
|
||||
}
|
||||
else {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -317,6 +317,11 @@ protected:
|
|||
* max and min scale
|
||||
*/
|
||||
float m_fMinScale, m_fMaxScale;
|
||||
/**
|
||||
* scissor rect for parent, just for restoring GL_SCISSOR_BOX
|
||||
*/
|
||||
CCRect m_tParentScissorRect;
|
||||
bool m_bScissorRestored;
|
||||
};
|
||||
|
||||
// end of GUI group
|
||||
|
|
Loading…
Reference in New Issue