bool IGraphics::IsDirty(IRECT* pR) { bool dirty = false; int i, n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (pControl->IsDirty()) { *pR = pR->Union(pControl->GetRECT()); dirty = true; } } #ifdef USE_IDLE_CALLS if (dirty) { mIdleTicks = 0; } else if (++mIdleTicks > IDLE_TICKS) { OnGUIIdle(); mIdleTicks = 0; } #endif return dirty; }
// The OS is announcing what needs to be redrawn, // which may be a larger area than what is strictly dirty. bool IGraphics::Draw(IRECT* pR) { // #pragma REMINDER("Mutex set while drawing") // WDL_MutexLock lock(&mMutex); int i, j, n = mControls.GetSize(); if (!n) { return true; } if (mStrict) { mDrawRECT = *pR; int n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (int i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (!(pControl->IsHidden()) && pR->Intersects(pControl->GetRECT())) { pControl->Draw(this); } pControl->SetClean(); } } else { IControl* pBG = mControls.Get(0); if (pBG->IsDirty()) // Special case when everything needs to be drawn. { mDrawRECT = *(pBG->GetRECT()); for (int j = 0; j < n; ++j) { IControl* pControl2 = mControls.Get(j); if (!j || !(pControl2->IsHidden())) { pControl2->Draw(this); pControl2->SetClean(); } } } else { for (i = 1; i < n; ++i) // loop through all controls starting from one (not bg) { IControl* pControl = mControls.Get(i); // assign control i to pControl if (pControl->IsDirty()) // if pControl is dirty { // printf("control %i is Dirty\n", i); mDrawRECT = *(pControl->GetRECT()); // put the rect in the mDrawRect member variable for (j = 0; j < n; ++j) // loop through all controls { IControl* pControl2 = mControls.Get(j); // assign control j to pControl2 // if control1 == control2 OR control2 is not hidden AND control2's rect intersects mDrawRect if (!pControl2->IsHidden() && (i == j || pControl2->GetRECT()->Intersects(&mDrawRECT))) { //if ((i == j) && (!pControl2->IsHidden())|| (!(pControl2->IsHidden()) && pControl2->GetRECT()->Intersects(&mDrawRECT))) { //printf("control %i and %i \n", i, j); pControl2->Draw(this); } } pControl->SetClean(); } } } } #ifndef NDEBUG if (mShowControlBounds) { for (int j = 1; j < mControls.GetSize(); j++) { IControl* pControl = mControls.Get(j); DrawRect(&CONTROL_BOUNDS_COLOR, pControl->GetRECT()); } WDL_String str; str.SetFormatted(32, "x: %i, y: %i", mMouseX, mMouseY); IText txt(20, &CONTROL_BOUNDS_COLOR); IRECT rect(Width() - 150, Height() - 20, Width(), Height()); DrawIText(&txt, str.Get(), &rect); } #endif return DrawScreen(pR); }
// The OS is announcing what needs to be redrawn, // which may be a larger area than what is strictly dirty. bool IGraphics::Draw(IRECT* pR) { // #pragma REMINDER("Mutex set while drawing") // WDL_MutexLock lock(&mMutex); int i, j, n = mControls.GetSize(); if (!n) { return true; } if (mStrict) { mDrawRECT = *pR; int n = mControls.GetSize(); IControl** ppControl = mControls.GetList(); for (int i = 0; i < n; ++i, ++ppControl) { IControl* pControl = *ppControl; if (!(pControl->IsHidden()) && pR->Intersects(pControl->GetRECT())) { pControl->Draw(this); } pControl->SetClean(); } } else { IControl* pBG = mControls.Get(0); if (pBG->IsDirty()) { // Special case when everything needs to be drawn. mDrawRECT = *(pBG->GetRECT()); for (int j = 0; j < n; ++j) { IControl* pControl2 = mControls.Get(j); if (!j || !(pControl2->IsHidden())) { pControl2->Draw(this); pControl2->SetClean(); } } } else { for (i = 1; i < n; ++i) { // loop through all controls starting from one (not bg) IControl* pControl = mControls.Get(i); // assign control i to pControl if (pControl->IsDirty()) { // if pControl is dirty // printf("control %i is Dirty\n", i); mDrawRECT = *(pControl->GetRECT()); // put the rect in the mDrawRect member variable for (j = 0; j < n; ++j) { // loop through all controls IControl* pControl2 = mControls.Get(j); // assign control j to pControl2 // if control1 == control2 OR control2 is not hidden AND control2's rect intersects mDrawRect if (!pControl2->IsHidden() && (i == j || pControl2->GetRECT()->Intersects(&mDrawRECT))) { //if ((i == j) && (!pControl2->IsHidden())|| (!(pControl2->IsHidden()) && pControl2->GetRECT()->Intersects(&mDrawRECT))) { //printf("control %i and %i \n", i, j); pControl2->Draw(this); } } pControl->SetClean(); } } } } return DrawScreen(pR); }