From 48b5f159b7c3e4921d5363a0417778961ecb8a04 Mon Sep 17 00:00:00 2001 From: Nimetu Date: Mon, 16 Sep 2019 23:04:26 +0300 Subject: [PATCH 1/3] Fixed: Table cell padding applied twice --HG-- branch : html-improvements --- code/nel/src/gui/group_table.cpp | 34 ++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index fa6279ad7..7a4cca66a 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -573,13 +573,19 @@ namespace NLGUI // ---------------------------------------------------------------------------- sint32 CGroupCell::getMaxUsedW() const { - return Group->getMaxUsedW(); + sint32 result = getPaddingLeftRight() + Group->getMaxUsedW(); + if (Border) + result += Border->getLeftRightWidth(); + return result; } // ------------------------------------------------------------------------------------------------ sint32 CGroupCell::getMinUsedW() const { - return Group->getMinUsedW(); + sint32 result = getPaddingLeftRight() + Group->getMinUsedW(); + if (Border) + result += Border->getLeftRightWidth(); + return result; } @@ -823,24 +829,25 @@ namespace NLGUI additionnalWidth = (sint32) width; } - sint32 cellBorderPadding = cell->getPaddingLeftRight(); - if (cell->Border) - cellBorderPadding += cell->Border->getLeftRightWidth(); - // Get width min and max if( !cell->IgnoreMaxWidth) - cell->WidthMax = cell->getMaxUsedW() + cell->LeftMargin + cellBorderPadding; + cell->WidthMax = cell->getMaxUsedW() + cell->LeftMargin; else cell->WidthMax = cell->WidthWanted + additionnalWidth + cell->LeftMargin; sint32 cellWidth; if(!cell->IgnoreMinWidth) - cellWidth = cell->NoWrap ? cell->WidthMax : cell->getMinUsedW() + cell->LeftMargin + cellBorderPadding; + cellWidth = cell->NoWrap ? cell->WidthMax : cell->getMinUsedW() + cell->LeftMargin; else cellWidth = cell->NoWrap ? cell->WidthMax : cell->LeftMargin; - if (cellWidth < cellBorderPadding) - cellWidth = cellBorderPadding; + { + sint32 cellBorderPadding = cell->getPaddingLeftRight(); + if (cell->Border) + cellBorderPadding += cell->Border->getLeftRightWidth(); + if (cellWidth < cellBorderPadding) + cellWidth = cellBorderPadding; + } // New cell ? if (cell->NewLine) @@ -1122,7 +1129,6 @@ namespace NLGUI // *** Now we know each column width, resize cells and get the height for each row column = 0; - // FIXME: real cell padding sint32 row = 0; sint32 currentX = 0; @@ -1413,8 +1419,7 @@ namespace NLGUI for (i=0; igetLeftRightWidth(); @@ -1461,8 +1466,7 @@ namespace NLGUI for (i=0; igetLeftRightWidth(); From 07a83ba15a25de06466a777f1246cc47512444fc Mon Sep 17 00:00:00 2001 From: Nimetu Date: Mon, 16 Sep 2019 23:10:12 +0300 Subject: [PATCH 2/3] Fixed: Make sure border pointer is not null. --HG-- branch : html-improvements --- code/nel/src/gui/group_table.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/code/nel/src/gui/group_table.cpp b/code/nel/src/gui/group_table.cpp index 7a4cca66a..df599ce4d 100644 --- a/code/nel/src/gui/group_table.cpp +++ b/code/nel/src/gui/group_table.cpp @@ -554,7 +554,7 @@ namespace NLGUI rVR.flush(); } - // Get the parent table + if (Border) { // TODO: monitor these in checkCoords and update when changed uint8 contentAlpha = CWidgetManager::getInstance()->getGlobalColorForContent().A; @@ -916,7 +916,9 @@ namespace NLGUI } // Additional space contributing to table width - sint32 tableBorderSpacing = Border->getLeftWidth() + Border->getRightWidth(); + sint32 tableBorderSpacing = 0; + if (Border) + tableBorderSpacing += Border->getLeftRightWidth(); tableBorderSpacing += ((sint32)_Columns.size()+1) * CellSpacing;; sint32 innerForceWidthMin = ForceWidthMin; @@ -1284,7 +1286,7 @@ namespace NLGUI if (Border) { currentY -= Border->getBottomWidth(); - finalWidth += Border->getLeftWidth() + Border->getRightWidth(); + finalWidth += Border->getLeftRightWidth(); } // Resize the table @@ -1705,6 +1707,8 @@ namespace NLGUI { uint32 w; fromString((const char*)ptr, w); + if (!Border) + Border = new CSSBorderRenderer(); Border->setWidth(w, w, w, w); } // @@ -1712,6 +1716,8 @@ namespace NLGUI if (ptr) { CRGBA c = convertColor((const char*)ptr); + if (!Border) + Border = new CSSBorderRenderer(); Border->setColor(c, c, c, c); } // From 5dc8b4ef8686271d35850e02f20e9e3560d5a1ba Mon Sep 17 00:00:00 2001 From: Nimetu Date: Mon, 16 Sep 2019 23:23:58 +0300 Subject: [PATCH 3/3] Changed: remove old code --HG-- branch : html-improvements --- code/nel/include/nel/gui/css_style.h | 4 ---- 1 file changed, 4 deletions(-) diff --git a/code/nel/include/nel/gui/css_style.h b/code/nel/include/nel/gui/css_style.h index bbeac8d9a..d972940e1 100644 --- a/code/nel/include/nel/gui/css_style.h +++ b/code/nel/include/nel/gui/css_style.h @@ -204,11 +204,8 @@ namespace NLGUI return Current.FontSize-2; } - sint styleStackIndex = 0; - inline void pushStyle() { - styleStackIndex++; _StyleStack.push_back(Current); Current.GlobalColor = false; @@ -228,7 +225,6 @@ namespace NLGUI inline void popStyle() { - styleStackIndex--; if (_StyleStack.empty()) { Current = Root;