Permalink
Browse files

Gui Border Changes

Updates to the way GuiControl renders its borders. Changed borderThickness to borderSize.
  • Loading branch information...
greenfire27 committed Jan 18, 2019
1 parent b863ff1 commit e8d027a70bcfb7b6e61eba18ea035601b2a910d1
@@ -67,9 +67,9 @@ void GuiButtonCtrl::onRender(Point2I offset,
if( mProfile->mBorder != 0 && !mHasTheme )
{
if (mDepressed || mStateOn)
renderFilledBorder( boundsRect, mProfile->mBorderColorHL, mProfile->mFillColorHL );
renderFilledBorder( boundsRect, mProfile->mBorderColorHL, mProfile->mFillColorHL, mProfile->mBorderSize);
else
renderFilledBorder( boundsRect, mProfile->mBorderColor, mProfile->mFillColor );
renderFilledBorder( boundsRect, mProfile->mBorderColor, mProfile->mFillColor, mProfile->mBorderSize);
}
else if( mHasTheme )
{
@@ -253,7 +253,7 @@ void GuiFormCtrl::onRender(Point2I offset, const RectI &updateRect)
{
dglClearBitmapModulation();

S32 barStart = (mHasMenu ? mThumbSize.x : 1 + mProfile->mBorderThickness) + offset.x + textWidth;
S32 barStart = (mHasMenu ? mThumbSize.x : 1 + mProfile->mBorderSize) + offset.x + textWidth;
S32 barTop = mThumbSize.y/2 + offset.y - mProfile->mBitmapArrayRects[3].extent.y /2;

Point2I barOffset(barStart, barTop);
@@ -226,17 +226,17 @@ void GuiScrollCtrl::addObject(SimObject *object)

GuiControl* GuiScrollCtrl::findHitControl(const Point2I &pt, S32 initialLayer)
{
if(pt.x < mProfile->mBorderThickness || pt.y < mProfile->mBorderThickness)
if(pt.x < mProfile->mBorderSize || pt.y < mProfile->mBorderSize)
return this;
if(pt.x >= mBounds.extent.x - mProfile->mBorderThickness - (mHasVScrollBar ? mScrollBarThickness : 0) ||
pt.y >= mBounds.extent.y - mProfile->mBorderThickness - (mHasHScrollBar ? mScrollBarThickness : 0))
if(pt.x >= mBounds.extent.x - mProfile->mBorderSize - (mHasVScrollBar ? mScrollBarThickness : 0) ||
pt.y >= mBounds.extent.y - mProfile->mBorderSize - (mHasHScrollBar ? mScrollBarThickness : 0))
return this;
return Parent::findHitControl(pt, initialLayer);
}

void GuiScrollCtrl::computeSizes()
{
S32 thickness = (mProfile ? mProfile->mBorderThickness : 1);
S32 thickness = (mProfile ? mProfile->mBorderSize : 1);
Point2I borderExtent(thickness, thickness);
mContentPos = borderExtent + mChildMargin;
mContentExt = mBounds.extent - (mChildMargin * 2)
@@ -324,7 +324,7 @@ void GuiScrollCtrl::computeSizes()

void GuiScrollCtrl::calcScrollRects(void)
{
S32 thickness = ( mProfile ? mProfile->mBorderThickness : 1 );
S32 thickness = ( mProfile ? mProfile->mBorderSize : 1 );
if (mHasHScrollBar)
{
mLeftArrowRect.set(thickness,
@@ -981,9 +981,9 @@ void GuiMenuBar::onRender(Point2I offset, const RectI &updateRect)
RectI highlightBounds = bounds;
highlightBounds.inset(1,1);
if(walk == mouseDownMenu)
renderFilledBorder(highlightBounds, mProfile->mBorderColorHL, mProfile->mFillColorHL );
renderFilledBorder(highlightBounds, mProfile->mBorderColorHL, mProfile->mFillColorHL, mProfile->mBorderSize);
else if(walk == mouseOverMenu && mouseDownMenu == NULL)
renderFilledBorder(highlightBounds, mProfile->mBorderColor, mProfile->mFillColor );
renderFilledBorder(highlightBounds, mProfile->mBorderColor, mProfile->mFillColor, mProfile->mBorderSize);
}

// Do we draw a bitmap?
@@ -447,8 +447,8 @@ void GuiControl::onRender(Point2I offset, const RectI &updateRect)
RectI ctrlRect(offset, mBounds.extent);

dglSetBitmapModulation( mProfile->mFontColor );
//if opaque, fill the update rect with the fill color
if (mProfile->mOpaque)
//if opaque, fill the update rect with the fill color and the border is not 5
if (mProfile->mOpaque && mProfile->mBorder != 5)
dglDrawRectFill( ctrlRect, mProfile->mFillColor );

//if there's a border, draw the border
@@ -117,46 +117,50 @@ void renderBorder(RectI &bounds, GuiControlProfile *profile)
S32 l = bounds.point.x, r = bounds.point.x + bounds.extent.x - 1;
S32 t = bounds.point.y, b = bounds.point.y + bounds.extent.y - 1;

RectI centerRect = bounds;
centerRect.inset(profile->mBorderSize, profile->mBorderSize);

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);
case 1://normal borders
renderFilledBorder(bounds, profile);
break;
case 2://pillow
dglDrawLine(l + 1, t + 1, l + 1, b - 1, profile->mBevelColorHL);
dglDrawLine(l + 2, t + 1, r - 1, t + 1, profile->mBevelColorHL);
dglDrawLine(r, t + 1, r, b + 1, profile->mBevelColorHL);
dglDrawLine(l + 1, b, r, b, profile->mBevelColorHL);
dglDrawLine(l, t, r, t, profile->mBevelColorLL);
dglDrawLine(l, t + 1, l, b, profile->mBevelColorLL);
dglDrawLine(l + 2, b - 1, r, b - 1, profile->mBevelColorLL);
dglDrawLine(r - 1, t + 2, r - 1, b - 1, profile->mBevelColorLL);
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);
case 3://inner bevel
dglDrawLine(l + 1, b, r + 1, b, profile->mBevelColorHL);
dglDrawLine(r, t + 1, r, b, profile->mBevelColorHL);
dglDrawLine(l + 2, b - 1, r, b - 1, profile->mBorderColor);
dglDrawLine(r - 1, t + 2, r - 1, b - 1, profile->mBorderColor);
dglDrawLine(l, t, l, b, profile->mBorderColorNA);
dglDrawLine(l + 1, t, r, t, profile->mBorderColorNA);
dglDrawLine(l + 1, t + 1, l + 1, b - 1, profile->mBevelColorLL);
dglDrawLine(l + 2, t + 1, r - 1, t + 1, profile->mBevelColorLL);
break;
case 4:
dglDrawLine(l, t, l, b - 1, profile->mBevelColorHL);
case 4://outer bevel
dglDrawLine(l, t, l, b, 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 );
dglDrawLine(l + 1, b, r + 1, b, profile->mBevelColorLL);
dglDrawLine(r, t + 1, r, b, profile->mBevelColorLL);
dglDrawLine(l + 2, b - 1, r, b - 1, profile->mBorderColor);
dglDrawLine(r - 1, t + 2, r - 1, b - 1, profile->mBorderColor);
break;
case 5: //normal borders, but the fill is not drawn under the borders
dglDrawRectFill(centerRect, profile->mFillColor);
renderFilledBorder( bounds, profile );
break;

case 6:// Draw boarder only on top and left
dglDrawLine(l, t, l, b, profile->mBorderColor);
dglDrawLine(l, t, r, t, profile->mBorderColor);
dglDrawLine(l, t, l, b + 1, profile->mBorderColor);
dglDrawLine(l + 1, t, r + 1, t, profile->mBorderColor);
break;
case 7:// Draw boarder only on bottom and right
dglDrawLine(r, t, r, b, profile->mBorderColor);
@@ -266,15 +270,26 @@ void renderBorder(RectI &bounds, GuiControlProfile *profile)

void renderFilledBorder( RectI &bounds, GuiControlProfile *profile )
{
renderFilledBorder( bounds, profile->mBorderColor, profile->mFillColor );
renderFilledBorder( bounds, profile->mBorderColor, profile->mFillColor, profile->mBorderSize );
}

void renderFilledBorder( RectI &bounds, ColorI &borderColor, ColorI &fillColor )
void renderFilledBorder( RectI &bounds, ColorI &borderColor, ColorI &fillColor, S32 borderSize )
{
RectI fillBounds = bounds;
fillBounds.inset( 1, 1 );
dglDrawRect( bounds, borderColor );
dglDrawRectFill( fillBounds, fillColor );
RectI centerRect = bounds;
centerRect.inset( borderSize, borderSize );
dglDrawRectFill(centerRect, fillColor);

RectI leftRect = RectI(bounds.point.x, bounds.point.y, borderSize, bounds.extent.y - borderSize);
dglDrawRectFill(leftRect, borderColor);

RectI topRect = RectI(bounds.point.x + borderSize, bounds.point.y, bounds.extent.x, borderSize);
dglDrawRectFill(topRect, borderColor);

RectI rightRect = RectI(bounds.point.x + bounds.extent.x - borderSize, bounds.point.y + borderSize, borderSize, bounds.extent.y - borderSize);
dglDrawRectFill(rightRect, borderColor);

RectI bottomRect = RectI(bounds.point.x, bounds.point.y + bounds.extent.y - borderSize, bounds.extent.x - borderSize, borderSize);
dglDrawRectFill(bottomRect, borderColor);
}

// DAW: Render out the sizable bitmap borders based on a multiplier into the bitmap array
@@ -31,7 +31,7 @@ void renderLoweredBox(RectI &bounds, GuiControlProfile *profile);
void renderSlightlyLoweredBox(RectI &bounds, GuiControlProfile *profile, bool active = true);
void renderBorder(RectI &bounds, GuiControlProfile *profile);
void renderFilledBorder( RectI &bounds, GuiControlProfile *profile );
void renderFilledBorder( RectI &bounds, ColorI &borderColor, ColorI &fillColor );
void renderFilledBorder( RectI &bounds, ColorI &borderColor, ColorI &fillColor, S32 borderSize);
void renderSizableBitmapBordersFilled(RectI &bounds, S32 baseMultiplier, GuiControlProfile *profile); // DAW: Added
void renderSizableBitmapBordersFilledIndex(RectI &bounds, S32 startIndex, GuiControlProfile *profile);
void renderFixedBitmapBordersFilled(RectI &bounds, S32 baseMultiplier, GuiControlProfile *profile); // DAW: Added
@@ -1228,7 +1228,7 @@ void GuiPopUpMenuCtrl::onAction()
textWidth = mFont->getStrWidth(mEntries[i].buf);

//if(textWidth > mBounds.extent.x)
S32 sbWidth = mSc->mProfile->mBorderThickness * 2 + mSc->scrollBarThickness(); // DAW: Calculate the scroll bar width
S32 sbWidth = mSc->mProfile->mBorderSize * 2 + mSc->scrollBarThickness(); // DAW: Calculate the scroll bar width
if(textWidth > (mBounds.extent.x - sbWidth-mProfile->mTextOffset.x - mSc->getChildMargin().x * 2)) // DAW: The text draw area to test against is the width of the drop-down minus the scroll bar width, the text margin and the scroll bar child margins.
{
//textWidth +=10;
@@ -1252,7 +1252,7 @@ void GuiPopUpMenuCtrl::onAction()

//Calc max Y distance, so Scroll Ctrl will fit on window
//S32 maxYdis = windowExt.y - pointInGC.y - mBounds.extent.y - menuSpace;
S32 sbBorder = mSc->mProfile->mBorderThickness * 2 + mSc->getChildMargin().y * 2; // DAW: Added to take into account the border thickness and the margin of the child controls of the scroll control when figuring out the size of the contained text list control
S32 sbBorder = mSc->mProfile->mBorderSize * 2 + mSc->getChildMargin().y * 2; // DAW: Added to take into account the border thickness and the margin of the child controls of the scroll control when figuring out the size of the contained text list control
S32 maxYdis = windowExt.y - pointInGC.y - mBounds.extent.y - sbBorder; // - menuSpace; // DAW: Need to remove the border thickness from the contained control maximum extent and got rid of the 'menuspace' variable

//If scroll bars need to be added
@@ -1213,7 +1213,7 @@ void GuiPopUpMenuCtrlEx::onAction()
textWidth = mFont->getStrWidth(mEntries[i].buf);

//if(textWidth > mBounds.extent.x)
S32 sbWidth = mSc->mProfile->mBorderThickness * 2 + mSc->scrollBarThickness(); // DAW: Calculate the scroll bar width
S32 sbWidth = mSc->mProfile->mBorderSize * 2 + mSc->scrollBarThickness(); // DAW: Calculate the scroll bar width
if(textWidth > (mBounds.extent.x - sbWidth-mProfile->mTextOffset.x - mSc->getChildMargin().x * 2)) // DAW: The text draw area to test against is the width of the drop-down minus the scroll bar width, the text margin and the scroll bar child margins.
{
//textWidth +=10;
@@ -1237,7 +1237,7 @@ void GuiPopUpMenuCtrlEx::onAction()

//Calc max Y distance, so Scroll Ctrl will fit on window
//S32 maxYdis = windowExt.y - pointInGC.y - mBounds.extent.y - menuSpace;
S32 sbBorder = mSc->mProfile->mBorderThickness * 2 + mSc->getChildMargin().y * 2; // DAW: Added to take into account the border thickness and the margin of the child controls of the scroll control when figuring out the size of the contained text list control
S32 sbBorder = mSc->mProfile->mBorderSize * 2 + mSc->getChildMargin().y * 2; // DAW: Added to take into account the border thickness and the margin of the child controls of the scroll control when figuring out the size of the contained text list control
S32 maxYdis = windowExt.y - pointInGC.y - mBounds.extent.y - sbBorder; // - menuSpace; // DAW: Need to remove the border thickness from the contained control maximum extent and got rid of the 'menuspace' variable

//If scroll bars need to be added
@@ -61,4 +61,4 @@ class GuiTabPageCtrl : public GuiTextCtrl
void onRender(Point2I offset, const RectI &updateRect); ///< Called when it's time to render this page to the scene
};

#endif //_GUI_WINDOW_CTRL_H
#endif //_GUITABPAGECTRL_H_
@@ -335,7 +335,7 @@ void GuiTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected,
{
RectI highlightRect = RectI(offset.x, offset.y, mCellSize.x, mCellSize.y);
highlightRect.inset( 0, -1 );
renderFilledBorder( highlightRect, mProfile->mBorderColorHL, mProfile->mFillColorHL);
renderFilledBorder( highlightRect, mProfile->mBorderColorHL, mProfile->mFillColorHL, mProfile->mBorderSize);
dglSetBitmapModulation(mProfile->mFontColorHL);
}
else
@@ -147,7 +147,7 @@ GuiControlProfile::GuiControlProfile(void) :
mOpaque = false;

mBorder = 0;
mBorderThickness = 1;
mBorderSize = 1;

// default font
mFontType = StringTable->EmptyString;
@@ -181,7 +181,7 @@ GuiControlProfile::GuiControlProfile(void) :
mFillColorNA = def->mFillColorNA;

mBorder = def->mBorder;
mBorderThickness = def->mBorderThickness;
mBorderSize = def->mBorderSize;
mBorderColor = def->mBorderColor;
mBorderColorHL = def->mBorderColorHL;
mBorderColorNA = def->mBorderColorNA;
@@ -232,7 +232,7 @@ void GuiControlProfile::initPersistFields()
addField("fillColorHL", TypeColorI, Offset(mFillColorHL, GuiControlProfile));
addField("fillColorNA", TypeColorI, Offset(mFillColorNA, GuiControlProfile));
addField("border", TypeS32, Offset(mBorder, GuiControlProfile));
addField("borderThickness",TypeS32, Offset(mBorderThickness, GuiControlProfile));
addField("borderSize", TypeS32, Offset(mBorderSize, GuiControlProfile));
addField("borderColor", TypeColorI, Offset(mBorderColor, GuiControlProfile));
addField("borderColorHL", TypeColorI, Offset(mBorderColorHL, GuiControlProfile));
addField("borderColorNA", TypeColorI, Offset(mBorderColorNA, GuiControlProfile));
@@ -118,7 +118,7 @@ class GuiControlProfile : public SimObject
ColorI mFillColorNA; ///< This is used to instead of mFillColor if the object is not active or disabled

S32 mBorder; ///< For most controls, if mBorder is > 0 a border will be drawn, some controls use this to draw different types of borders however @see guiDefaultControlRender.cc
S32 mBorderThickness; ///< Border thickness
S32 mBorderSize; ///< Border thickness
ColorI mBorderColor; ///< Border color, used to draw a border around the bounds if border is enabled
ColorI mBorderColorHL; ///< Used instead of mBorderColor when the object is highlited
ColorI mBorderColorNA; ///< Used instead of mBorderColor when the object is not active or disabled

0 comments on commit e8d027a

Please sign in to comment.