Переглянути джерело

Fix flow autosize spacing when the first child is absolute (#1123)

Leonardo 2 роки тому
батько
коміт
41b57cb52f
2 змінених файлів з 6 додано та 3 видалено
  1. 6 2
      h2d/Flow.hx
  2. 0 1
      h2d/Object.hx

+ 6 - 2
h2d/Flow.hx

@@ -1237,8 +1237,9 @@ class Flow extends Object {
 				if( p.minHeight != null && p.calculatedHeight < p.minHeight ) p.calculatedHeight = p.minHeight;
 			}
 
+			var count = 0;
 			forChildren(function(i, p, c) {
-				if(i > 0) autoWidth -= horizontalSpacing;
+				if(count > 0 && !p.isAbsolute) autoWidth -= horizontalSpacing;
 				if(p.autoSize == null) {
 					calcSize(p, c);
 					if(!p.isAbsolute) {
@@ -1248,6 +1249,7 @@ class Flow extends Object {
 				}
 				else
 					autoSum += p.autoSize;
+				count++;
 			});
 
 			forChildren(function(i, p, c) {
@@ -1400,8 +1402,9 @@ class Flow extends Object {
 				if( p.minHeight != null && p.calculatedHeight < p.minHeight ) p.calculatedHeight = p.minHeight;
 			}
 
+			var count = 0;
 			forChildren(function(i, p, c) {
-				if(i > 0) autoHeight -= verticalSpacing;
+				if(count > 0 && !p.isAbsolute) autoHeight -= verticalSpacing;
 				if(p.autoSize == null) {
 					calcSize(p, c);
 					if(!p.isAbsolute) {
@@ -1411,6 +1414,7 @@ class Flow extends Object {
 				}
 				else
 					autoSum += p.autoSize;
+				count++;
 			});
 
 			forChildren(function(i, p, c) {

+ 0 - 1
h2d/Object.hx

@@ -294,7 +294,6 @@ class Object #if (domkit && !domkit_heaps) implements domkit.Model<h2d.Object> #
 		if( width <= 0 || height <= 0 ) return;
 
 		if( relativeTo == null  ) {
-			var x, y;
 			out.addPos(dx * matA + dy * matC + absX, dx * matB + dy * matD + absY);
 			out.addPos((dx + width) * matA + dy * matC + absX, (dx + width) * matB + dy * matD + absY);
 			out.addPos(dx * matA + (dy + height) * matC + absX, dx * matB + (dy + height) * matD + absY);