Exemple #1
0
    void DrawChildren(PaintInfo &pi)
    {
        const U32 DISPLAY_MASK = STATE_ACTIVE | STATE_VISIBLE;

        NList<IControl>::Iterator i(&children);

        // Draw children from lowest Z-pos to highest
        for (i.GoToTail(); *i; i--)
        {
            IControl *child = *i;

            if ((child->GetControlState() & DISPLAY_MASK) == DISPLAY_MASK)
            {
                PaintInfo p = child->GetPaintInfo();

                // Convert to screen coordinates before drawing
                Point<S32> origin = child->GetPos() + pi.client.p0;
                p.window += origin;
                p.client += origin;

                // Clamp rectangles to client area of listbox
                if (p.window.p1.x > pi.client.p1.x)
                {
                    p.window.p1.x = pi.client.p1.x;
                    p.client.p1.x = pi.client.p1.x;
                }

                // Apply global alpha scale
                p.alphaScale *= IFace::data.alphaScale;

                child->Draw(p);
            }
        }
    }
Exemple #2
0
// 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);
}
Exemple #3
0
// 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);

}