Explorar o código

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

Nicolas Cannasse %!s(int64=6) %!d(string=hai) anos
pai
achega
9830b1e64e
Modificáronse 1 ficheiros con 10 adicións e 0 borrados
  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