Fixed: Wrong border size when border hidden/none

--HG--
branch : html-improvements
hg/feature/html-improvements
Nimetu 5 years ago
parent c6dc92e0ec
commit 0ef7419fd6

@ -1134,7 +1134,9 @@ namespace NLGUI
if (cell->NewLine) if (cell->NewLine)
{ {
column = 0; column = 0;
currentX = Border->LeftWidth + CellSpacing; currentX = CellSpacing;
if (Border)
currentX += Border->getLeftWidth();
_Rows.push_back(CRow()); _Rows.push_back(CRow());
} }
@ -1412,7 +1414,9 @@ namespace NLGUI
maxWidth += columns[i]; maxWidth += columns[i];
// TODO: CellPadding is probably already in columns width // TODO: CellPadding is probably already in columns width
maxWidth += Border->LeftWidth + Border->RightWidth + ((sint32)columns.size()+1) * CellSpacing + ((sint32)columns.size()*2) * CellPadding; maxWidth += ((sint32)columns.size()+1) * CellSpacing + ((sint32)columns.size()*2) * CellPadding;
if (Border)
maxWidth += Border->getLeftRightWidth();
return maxWidth; return maxWidth;
} }
@ -1458,7 +1462,9 @@ namespace NLGUI
maxWidth += columns[i]; maxWidth += columns[i];
// TODO: CellPadding is probably already in columns width // TODO: CellPadding is probably already in columns width
maxWidth += Border->LeftWidth + Border->RightWidth + ((sint32)columns.size()+1) * CellSpacing + ((sint32)columns.size()*2) * CellPadding; maxWidth += ((sint32)columns.size()+1) * CellSpacing + ((sint32)columns.size()*2) * CellPadding;
if (Border)
maxWidth += Border->getLeftRightWidth();
return maxWidth; return maxWidth;
} }
@ -1556,12 +1562,16 @@ namespace NLGUI
{ {
if( name == "border" ) if( name == "border" )
{ {
if (Border)
return toString( Border->TopWidth ); return toString( Border->TopWidth );
return "0";
} }
else else
if( name == "bordercolor" ) if( name == "bordercolor" )
{ {
if (Border)
return toString( Border->TopColor ); return toString( Border->TopColor );
return toString(CRGBA::Transparent);
} }
else else
if( name == "cellpadding" ) if( name == "cellpadding" )
@ -1597,6 +1607,8 @@ namespace NLGUI
sint32 i; sint32 i;
if( fromString( value, i ) ) if( fromString( value, i ) )
{ {
if (!Border)
Border = new CSSBorderRenderer();
Border->TopWidth = i; Border->TopWidth = i;
Border->RightWidth = i; Border->RightWidth = i;
Border->BottomWidth = i; Border->BottomWidth = i;
@ -1610,6 +1622,8 @@ namespace NLGUI
CRGBA c; CRGBA c;
if( fromString( value, c ) ) if( fromString( value, c ) )
{ {
if (!Border)
Border = new CSSBorderRenderer();
Border->TopColor = c; Border->TopColor = c;
Border->RightColor = c; Border->RightColor = c;
Border->BottomColor = c; Border->BottomColor = c;
@ -1659,8 +1673,11 @@ namespace NLGUI
return NULL; return NULL;
xmlSetProp( node, BAD_CAST "type", BAD_CAST "table" ); xmlSetProp( node, BAD_CAST "type", BAD_CAST "table" );
if (Border)
{
xmlSetProp( node, BAD_CAST "border", BAD_CAST toString( Border->TopWidth ).c_str() ); xmlSetProp( node, BAD_CAST "border", BAD_CAST toString( Border->TopWidth ).c_str() );
xmlSetProp( node, BAD_CAST "bordercolor", BAD_CAST toString( Border->TopColor ).c_str() ); xmlSetProp( node, BAD_CAST "bordercolor", BAD_CAST toString( Border->TopColor ).c_str() );
}
xmlSetProp( node, BAD_CAST "cellpadding", BAD_CAST toString( CellPadding ).c_str() ); xmlSetProp( node, BAD_CAST "cellpadding", BAD_CAST toString( CellPadding ).c_str() );
xmlSetProp( node, BAD_CAST "cellspacing", BAD_CAST toString( CellSpacing ).c_str() ); xmlSetProp( node, BAD_CAST "cellspacing", BAD_CAST toString( CellSpacing ).c_str() );
xmlSetProp( node, BAD_CAST "bgcolor", BAD_CAST toString( BgColor ).c_str() ); xmlSetProp( node, BAD_CAST "bgcolor", BAD_CAST toString( BgColor ).c_str() );

Loading…
Cancel
Save