浏览代码

handle v/h align of absolutes in layout:stack

Nicolas Cannasse 5 年之前
父节点
当前提交
21042eb975
共有 1 个文件被更改,包括 14 次插入8 次删除
  1. 14 8
      h2d/Flow.hx

+ 14 - 8
h2d/Flow.hx

@@ -942,18 +942,21 @@ class Flow extends Object {
 				var c = childAt(i);
 				if( !c.visible ) continue;
 				var p = propAt(i);
-				if( p.isAbsolute ) continue;
+				var isAbs = p.isAbsolute;
+				if( isAbs && p.verticalAlign == null && p.horizontalAlign == null ) continue;
 
-				c.constraintSize(
-					isConstraintWidth && p.constraint ? maxInWidth / Math.abs(c.scaleX) : -1,
-					isConstraintHeight && p.constraint ? maxInHeight / Math.abs(c.scaleY) : -1
-				);
+				if( !isAbs )
+					c.constraintSize(
+						isConstraintWidth && p.constraint ? maxInWidth / Math.abs(c.scaleX) : -1,
+						isConstraintHeight && p.constraint ? maxInHeight / Math.abs(c.scaleY) : -1
+					);
 
 				var b = c.getSize(tmpBounds);
 				p.calculatedWidth = Math.ceil(b.xMax) + p.paddingLeft + p.paddingRight;
 				p.calculatedHeight = Math.ceil(b.yMax) + p.paddingTop + p.paddingBottom;
 				if( p.minWidth != null && p.calculatedWidth < p.minWidth ) p.calculatedWidth = p.minWidth;
 				if( p.minHeight != null && p.calculatedHeight < p.minHeight ) p.calculatedHeight = p.minHeight;
+				if( isAbs ) continue;
 				if( p.calculatedWidth > maxChildW ) maxChildW = p.calculatedWidth;
 				if( p.calculatedHeight > maxChildH ) maxChildH = p.calculatedHeight;
 			}
@@ -971,7 +974,8 @@ class Flow extends Object {
 				var c = childAt(i);
 				if( !c.visible ) continue;
 				var p = propAt(i);
-				if( p.isAbsolute ) continue;
+				var isAbs = p.isAbsolute;
+				if( isAbs && p.verticalAlign == null && p.horizontalAlign == null ) continue;
 
 				var valign = p.verticalAlign == null ? valign : p.verticalAlign;
 				var halign = p.horizontalAlign == null ? halign : p.horizontalAlign;
@@ -994,8 +998,10 @@ class Flow extends Object {
 					ymin;
 				}
 
-				c.x = px + p.offsetX + p.paddingLeft;
-				c.y = py + p.offsetY + p.paddingTop;
+				if( !isAbs || p.horizontalAlign != null )
+					c.x = px + p.offsetX + p.paddingLeft;
+				if( !isAbs || p.verticalAlign != null )
+					c.y = py + p.offsetY + p.paddingTop;
 			}
 		}