BorderThickness not implemented?
by gamer · in Torque Game Engine · 04/06/2006 (5:59 pm) · 7 replies
I don't think borderThickness is implemented. I tried define a profile with some borderThickness but it doesn't work. The border thickness seems to be 1 px. any idea?
new GuiControlProfile(GuiBorderedControlProfile)
{
opaque=false;
border=2; //3 is in, 4 is out, 1 is regular solid, 2 is encaved, 5 is filled
borderThickness = 10;
fontColor = "40 231 240";
fontColorHL = "40 231 240";
fontColorNA = "128 128 128";
borderColor = "0 0 0";
}
in onRender taken from guiDefaultControlRender.cc:
switch(profile->mBorder)
{
case 1:
dglDrawRect(bounds, profile->mBorderColor);
break;
case 2:
dglDrawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorHL);
dglDrawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorHL);
dglDrawLine(r, t, r, b, profile->mBevelColorHL);
dglDrawLine(l, b, r - 1, b, profile->mBevelColorHL);
dglDrawLine(l, t, r - 1, t, profile->mBorderColorNA);
dglDrawLine(l, t + 1, l, b - 1, profile->mBorderColorNA);
dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColorNA);
dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColorNA);
break;
case 3:
dglDrawLine(l, b, r, b, profile->mBevelColorHL);
dglDrawLine(r, t, r, b - 1, profile->mBevelColorHL);
dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mFillColor);
dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mFillColor);
dglDrawLine(l, t, l, b - 1, profile->mBorderColorNA);
dglDrawLine(l + 1, t, r - 1, t, profile->mBorderColorNA);
dglDrawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorLL);
dglDrawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorLL);
break;
case 4:
dglDrawLine(l, t, l, b - 1, profile->mBevelColorHL);
dglDrawLine(l + 1, t, r, t, profile->mBevelColorHL);
dglDrawLine(l, b, r, b, profile->mBevelColorLL);
dglDrawLine(r, t + 1, r, b - 1, profile->mBevelColorLL);
dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColor);
break;
case 5:
renderFilledBorder( bounds, profile );
break;
}
}
new GuiControlProfile(GuiBorderedControlProfile)
{
opaque=false;
border=2; //3 is in, 4 is out, 1 is regular solid, 2 is encaved, 5 is filled
borderThickness = 10;
fontColor = "40 231 240";
fontColorHL = "40 231 240";
fontColorNA = "128 128 128";
borderColor = "0 0 0";
}
in onRender taken from guiDefaultControlRender.cc:
switch(profile->mBorder)
{
case 1:
dglDrawRect(bounds, profile->mBorderColor);
break;
case 2:
dglDrawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorHL);
dglDrawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorHL);
dglDrawLine(r, t, r, b, profile->mBevelColorHL);
dglDrawLine(l, b, r - 1, b, profile->mBevelColorHL);
dglDrawLine(l, t, r - 1, t, profile->mBorderColorNA);
dglDrawLine(l, t + 1, l, b - 1, profile->mBorderColorNA);
dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColorNA);
dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColorNA);
break;
case 3:
dglDrawLine(l, b, r, b, profile->mBevelColorHL);
dglDrawLine(r, t, r, b - 1, profile->mBevelColorHL);
dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mFillColor);
dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mFillColor);
dglDrawLine(l, t, l, b - 1, profile->mBorderColorNA);
dglDrawLine(l + 1, t, r - 1, t, profile->mBorderColorNA);
dglDrawLine(l + 1, t + 1, l + 1, b - 2, profile->mBevelColorLL);
dglDrawLine(l + 2, t + 1, r - 2, t + 1, profile->mBevelColorLL);
break;
case 4:
dglDrawLine(l, t, l, b - 1, profile->mBevelColorHL);
dglDrawLine(l + 1, t, r, t, profile->mBevelColorHL);
dglDrawLine(l, b, r, b, profile->mBevelColorLL);
dglDrawLine(r, t + 1, r, b - 1, profile->mBevelColorLL);
dglDrawLine(l + 1, b - 1, r - 1, b - 1, profile->mBorderColor);
dglDrawLine(r - 1, t + 1, r - 1, b - 2, profile->mBorderColor);
break;
case 5:
renderFilledBorder( bounds, profile );
break;
}
}
About the author
#2
also it seems GuiTSCtrl doesn't support border at all, it inherits from GuiControl and GuiControl does support border, so I am thinking about calling its parent onRender in GuiTSCtrl's on Render, but my c++ is lousy I don't remember how to call the parent method,any idea? would this introduce unwanted side effects?
void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
{
}
04/06/2006 (6:45 pm)
Case 5 is in tge 1.4. also it seems GuiTSCtrl doesn't support border at all, it inherits from GuiControl and GuiControl does support border, so I am thinking about calling its parent onRender in GuiTSCtrl's on Render, but my c++ is lousy I don't remember how to call the parent method,any idea? would this introduce unwanted side effects?
void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
{
}
#3
will renderChildControls twice if mApplyFilterToChildren is true, and will render child anyway if it's false because of the following line:
if(mApplyFilterToChildren)
renderChildControls(offset, updateRect);
but anyway i'll leave that for now.
04/06/2006 (6:54 pm)
Ok I add a line to GuiTSCtrl:onRender, now it can draw border. The only problem this will cause is that it will renderChildControls twice if mApplyFilterToChildren is true, and will render child anyway if it's false because of the following line:
if(mApplyFilterToChildren)
renderChildControls(offset, updateRect);
but anyway i'll leave that for now.
void GuiTSCtrl::onRender(Point2I offset, const RectI &updateRect)
{
if(SceneLighting::isLighting())
return;
__super::onRender(offset,updateRect); //hacked in here to support border, parent class guiControl draws border
CameraQuery newCam = mLastCameraQuery;
if(processCameraQuery(&newCam))
mLastCameraQuery = newCam;
if(mForceFOV != 0)
newCam.fov = mDegToRad(mForceFOV);
if(mCameraZRot)
{
MatrixF rotMat(EulerF(0, 0, mDegToRad(mCameraZRot)));
newCam.cameraMatrix.mul(rotMat);
}
// set up the camera and viewport stuff:
F32 left, right, top, bottom;
if (newCam.ortho)
{
left = -newCam.leftRight;
right = newCam.leftRight;
top = newCam.topBottom;
bottom = -newCam.topBottom;
}
else
{
F32 wwidth = newCam.nearPlane * mTan(newCam.fov / 2);
F32 wheight = F32(mBounds.extent.y) / F32(mBounds.extent.x) * wwidth;
F32 hscale = wwidth * 2 / F32(mBounds.extent.x);
F32 vscale = wheight * 2 / F32(mBounds.extent.y);
left = (updateRect.point.x - offset.x) * hscale - wwidth;
right = (updateRect.point.x + updateRect.extent.x - offset.x) * hscale - wwidth;
top = wheight - vscale * (updateRect.point.y - offset.y);
bottom = wheight - vscale * (updateRect.point.y + updateRect.extent.y - offset.y);
}
dglSetViewport(updateRect);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
dglSetFrustum(left, right, bottom, top, newCam.nearPlane, (gClientSceneGraph ? (F64)gClientSceneGraph->getVisibleDistanceMod() : newCam.farPlane), newCam.ortho);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
newCam.cameraMatrix.inverse();
dglMultMatrix(&newCam.cameraMatrix);
glGetDoublev(GL_PROJECTION_MATRIX, mSaveProjection);
glGetDoublev(GL_MODELVIEW_MATRIX, mSaveModelview);
mSaveViewport[0] = updateRect.point.x;
mSaveViewport[1] = updateRect.point.y + updateRect.extent.y;
mSaveViewport[2] = updateRect.extent.x;
mSaveViewport[3] = -updateRect.extent.y;
renderWorld(updateRect);
if(mApplyFilterToChildren)
renderChildControls(offset, updateRect);
smFrameCount++;
}
#4
since i believe pretty much everything in playGui is going to be children of GuiTSControl.
i'd look into calling the border-rendering stuff directly.
you might have to separate it out from the parent.
__super:: is interesting, i didn't know that.
another way to do it is to find out what the parent class of GuiTSControl is by hand (it's GuiControl)
and using "GuiControl::whateverFunction()".
04/06/2006 (7:01 pm)
Rendering the child controls twice seems pretty painful to me,since i believe pretty much everything in playGui is going to be children of GuiTSControl.
i'd look into calling the border-rendering stuff directly.
you might have to separate it out from the parent.
__super:: is interesting, i didn't know that.
another way to do it is to find out what the parent class of GuiTSControl is by hand (it's GuiControl)
and using "GuiControl::whateverFunction()".
#6

I'd take a look at how guiScrollCtrl implements this for more hints.
Hall Of Worlds - For Gamers
EdM|GPGT
04/06/2006 (7:36 pm)
@gamer - Actually the only control that pays any attention to the borderThickness field is the guiScrollCtrl. In the following image, the same control is shown with a borderThickness of 2 (left control), and a borderThickness of 10 (right control).
I'd take a look at how guiScrollCtrl implements this for more hints.
Hall Of Worlds - For GamersEdM|GPGT
Associate Orion Elenzil
Real Life Plus
looks like all those +/- 1 or 2's need to refer to borderThickness.
edit: is case 5 a tge1.4 thing, or did you add it ? (I'm in 1.3)