Fixed: Table cell padding applied twice

--HG--
branch : html-improvements
hg/feature/html-improvements
Nimetu 5 years ago
parent 5843ebede0
commit 48b5f159b7

@ -573,13 +573,19 @@ namespace NLGUI
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
sint32 CGroupCell::getMaxUsedW() const sint32 CGroupCell::getMaxUsedW() const
{ {
return Group->getMaxUsedW(); sint32 result = getPaddingLeftRight() + Group->getMaxUsedW();
if (Border)
result += Border->getLeftRightWidth();
return result;
} }
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
sint32 CGroupCell::getMinUsedW() const 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; additionnalWidth = (sint32) width;
} }
sint32 cellBorderPadding = cell->getPaddingLeftRight();
if (cell->Border)
cellBorderPadding += cell->Border->getLeftRightWidth();
// Get width min and max // Get width min and max
if( !cell->IgnoreMaxWidth) if( !cell->IgnoreMaxWidth)
cell->WidthMax = cell->getMaxUsedW() + cell->LeftMargin + cellBorderPadding; cell->WidthMax = cell->getMaxUsedW() + cell->LeftMargin;
else else
cell->WidthMax = cell->WidthWanted + additionnalWidth + cell->LeftMargin; cell->WidthMax = cell->WidthWanted + additionnalWidth + cell->LeftMargin;
sint32 cellWidth; sint32 cellWidth;
if(!cell->IgnoreMinWidth) if(!cell->IgnoreMinWidth)
cellWidth = cell->NoWrap ? cell->WidthMax : cell->getMinUsedW() + cell->LeftMargin + cellBorderPadding; cellWidth = cell->NoWrap ? cell->WidthMax : cell->getMinUsedW() + cell->LeftMargin;
else else
cellWidth = cell->NoWrap ? cell->WidthMax : cell->LeftMargin; 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 ? // New cell ?
if (cell->NewLine) if (cell->NewLine)
@ -1122,7 +1129,6 @@ namespace NLGUI
// *** Now we know each column width, resize cells and get the height for each row // *** Now we know each column width, resize cells and get the height for each row
column = 0; column = 0;
// FIXME: real cell padding
sint32 row = 0; sint32 row = 0;
sint32 currentX = 0; sint32 currentX = 0;
@ -1413,8 +1419,7 @@ namespace NLGUI
for (i=0; i<columns.size(); i++) for (i=0; i<columns.size(); i++)
maxWidth += columns[i]; maxWidth += columns[i];
// TODO: CellPadding is probably already in columns width maxWidth += ((sint32)columns.size()+1) * CellSpacing;
maxWidth += ((sint32)columns.size()+1) * CellSpacing + ((sint32)columns.size()*2) * CellPadding;
if (Border) if (Border)
maxWidth += Border->getLeftRightWidth(); maxWidth += Border->getLeftRightWidth();
@ -1461,8 +1466,7 @@ namespace NLGUI
for (i=0; i<columns.size(); i++) for (i=0; i<columns.size(); i++)
maxWidth += columns[i]; maxWidth += columns[i];
// TODO: CellPadding is probably already in columns width maxWidth += ((sint32)columns.size()+1) * CellSpacing;
maxWidth += ((sint32)columns.size()+1) * CellSpacing + ((sint32)columns.size()*2) * CellPadding;
if (Border) if (Border)
maxWidth += Border->getLeftRightWidth(); maxWidth += Border->getLeftRightWidth();

Loading…
Cancel
Save