فهرست منبع

allow Flow fillWidth/fillHeight to take whole scene when no parent constraint

Nicolas Cannasse 6 سال پیش
والد
کامیت
9830b1e64e
1فایلهای تغییر یافته به همراه10 افزوده شده و 0 حذف شده
  1. 10 0
      h2d/Flow.hx

+ 10 - 0
h2d/Flow.hx

@@ -209,6 +209,7 @@ class Flow extends Object {
 	var realMaxHeight : Float = -1;
 	var realMinWidth : Int = -1;
 	var realMinHeight : Int = -1;
+	var isConstraint : Bool;
 
 	public function new(?parent) {
 		super(parent);
@@ -390,6 +391,7 @@ class Flow extends Object {
 	override function constraintSize( width, height ) {
 		constraintWidth = width;
 		constraintHeight = height;
+		isConstraint = true;
 		updateConstraint();
 	}
 
@@ -628,6 +630,14 @@ class Flow extends Object {
 
 		onBeforeReflow();
 
+		if( !isConstraint && (fillWidth || fillHeight) ) {
+			var scene = getScene();
+			if( scene.width != constraintWidth || scene.height != constraintHeight ) {
+				constraintSize(fillWidth ? scene.width : -1, fillHeight ? scene.height : -1);
+				isConstraint = false;
+			}
+		}
+
 		var isConstraintWidth = realMaxWidth >= 0;
 		var isConstraintHeight = realMaxHeight >= 0;
 		// outter size