Game Development Community

GuiButtonCtrl::onRender()

by Bullitt Sesariza · in Torque Game Engine · 05/27/2008 (9:14 pm) · 1 replies

I've looked at the source code of GuiButtonCtrl and found these peculiar lines:

bool highlight = mMouseOver;
   bool depressed = mDepressed;

   ColorI fontColor   = mActive ? (highlight ? mProfile->mFontColorHL : mProfile->mFontColor) : mProfile->mFontColorNA;
   [b]ColorI backColor   = mActive ? mProfile->mFillColor : mProfile->mFillColorNA;[/b]
   [b]ColorI borderColor = mActive ? mProfile->mBorderColor : mProfile->mBorderColorNA;[/b]

When I searched the entire method, I couldn't find a single line where those locals are being used. And then I looked further down and found this:

RectI boundsRect(offset, mBounds.extent);

   if( mProfile->mBorder != 0 && !mHasTheme )
   {
      if (mDepressed || mStateOn)
         renderFilledBorder( boundsRect, mProfile->mBorderColorHL, mProfile->mFillColorHL );
      else
         [b]renderFilledBorder( boundsRect, mProfile->mBorderColor, mProfile->mFillColor );[/b]
   }

I assume they were used in that line (CMIIW). So it should've look like this:

RectI boundsRect(offset, mBounds.extent);

   if( mProfile->mBorder != 0 && !mHasTheme )
   {
      if (mDepressed || mStateOn)
         renderFilledBorder( boundsRect, mProfile->mBorderColorHL, mProfile->mFillColorHL );
      else
         [b]renderFilledBorder( boundsRect, borderColor, backColor );[/b]
   }

I don't know if it is what the developer intended but they should've change that method nevertheless. Either by deleting those lines or changing the "renderFilledBorder()" like my assumption. Dunno which one is the correct one. Hope this helps.

#1
05/27/2008 (11:34 pm)
Okay, found one more error. Now it's in GuiPopUpMenuCtrl::onRender():

if(mInAction)
      {
         renderFilledBorder(r, mProfile->mBorderColorHL, mProfile->mFillColor);
         renderFilledBorder( buttonRect, mProfile->mBorderColorHL, mProfile->mFillColorNA);
      }
      else
      {
         renderFilledBorder(r, mProfile->mBorderColorHL, mProfile->mFillColor);
         renderFilledBorder( buttonRect, mProfile->mBorderColorHL, mProfile->mFillColorNA);
      }

Now, what's with the same lines of codes inside both the if and else statement?