CSSBorder fix: width/height swapped

This commit is contained in:
Thomas Geymayer 2013-07-06 12:05:19 +02:00
parent 948db69cc9
commit 757ba03918
2 changed files with 16 additions and 9 deletions

View File

@ -58,7 +58,7 @@ namespace simgear
{ {
ret.val[i] = offsets.val[i]; ret.val[i] = offsets.val[i];
if( !types.rel[i] ) if( !types.rel[i] )
ret.val[i] /= (i & 1) ? dim.height() : dim.width(); ret.val[i] /= (i & 1) ? dim.width() : dim.height();
} }
return ret; return ret;
@ -75,7 +75,7 @@ namespace simgear
{ {
ret.val[i] = offsets.val[i]; ret.val[i] = offsets.val[i];
if( types.rel[i] ) if( types.rel[i] )
ret.val[i] *= (i & 1) ? dim.height() : dim.width(); ret.val[i] *= (i & 1) ? dim.width() : dim.height();
} }
return ret; return ret;

View File

@ -55,14 +55,21 @@ int main (int ac, char ** av)
COMPARE(o.b, 15); COMPARE(o.b, 15);
COMPARE(o.l, 20); COMPARE(o.l, 20);
b = CSSBorder::parse("5% 10% 15% 20%"); b = CSSBorder::parse("5 10 15 20");
o = b.getAbsOffsets(SGRect<int>(0,0,200,200)); o = b.getRelOffsets(SGRect<int>(0,0,100,200));
COMPARE(o.t, 10); COMPARE(o.t, 0.025);
COMPARE(o.r, 20); COMPARE(o.r, 0.1);
COMPARE(o.b, 30); COMPARE(o.b, 0.075);
COMPARE(o.l, 40); COMPARE(o.l, 0.2);
o = b.getRelOffsets(SGRect<int>(0,0,200,200)); b = CSSBorder::parse("5% 10% 15% 20%");
o = b.getAbsOffsets(SGRect<int>(0,0,100,200));
COMPARE(o.t, 10);
COMPARE(o.r, 10);
COMPARE(o.b, 30);
COMPARE(o.l, 20);
o = b.getRelOffsets(SGRect<int>(0,0,100,200));
COMPARE(o.t, 0.05); COMPARE(o.t, 0.05);
COMPARE(o.r, 0.1); COMPARE(o.r, 0.1);
COMPARE(o.b, 0.15); COMPARE(o.b, 0.15);