From: Thomas Geymayer Date: Sat, 6 Jul 2013 10:05:19 +0000 (+0200) Subject: CSSBorder fix: width/height swapped X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=757ba039181b1dc95b33ed2ec6c4044ca0b5906d;p=simgear.git CSSBorder fix: width/height swapped --- diff --git a/simgear/misc/CSSBorder.cxx b/simgear/misc/CSSBorder.cxx index cc3ffc9a..e15828d6 100644 --- a/simgear/misc/CSSBorder.cxx +++ b/simgear/misc/CSSBorder.cxx @@ -58,7 +58,7 @@ namespace simgear { ret.val[i] = offsets.val[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; @@ -75,7 +75,7 @@ namespace simgear { ret.val[i] = offsets.val[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; diff --git a/simgear/misc/CSSBorder_test.cxx b/simgear/misc/CSSBorder_test.cxx index 5f754504..bfb0cb79 100644 --- a/simgear/misc/CSSBorder_test.cxx +++ b/simgear/misc/CSSBorder_test.cxx @@ -55,14 +55,21 @@ int main (int ac, char ** av) COMPARE(o.b, 15); COMPARE(o.l, 20); + b = CSSBorder::parse("5 10 15 20"); + o = b.getRelOffsets(SGRect(0,0,100,200)); + COMPARE(o.t, 0.025); + COMPARE(o.r, 0.1); + COMPARE(o.b, 0.075); + COMPARE(o.l, 0.2); + b = CSSBorder::parse("5% 10% 15% 20%"); - o = b.getAbsOffsets(SGRect(0,0,200,200)); + o = b.getAbsOffsets(SGRect(0,0,100,200)); COMPARE(o.t, 10); - COMPARE(o.r, 20); + COMPARE(o.r, 10); COMPARE(o.b, 30); - COMPARE(o.l, 40); + COMPARE(o.l, 20); - o = b.getRelOffsets(SGRect(0,0,200,200)); + o = b.getRelOffsets(SGRect(0,0,100,200)); COMPARE(o.t, 0.05); COMPARE(o.r, 0.1); COMPARE(o.b, 0.15);