Procházet zdrojové kódy

removed flex experiment

Nicolas Cannasse před 4 roky
rodič
revize
8de8c30ea3
2 změnil soubory, kde provedl 2 přidání a 86 odebrání
  1. 2 68
      h2d/Flow.hx
  2. 0 18
      h2d/domkit/BaseComponents.hx

+ 2 - 68
h2d/Flow.hx

@@ -185,12 +185,6 @@ class FlowProperties {
 	**/
 	public var constraint = true;
 
-	/**
-		When set, if a size constraint exists on the parent, element will be constrainted by the remaining space from non-flexible elements.
-		If the parent flow contains multiple flexible elements, the remaining space will be shared according to their weights.
-	**/
-	public var flexWeight : Null<Float>;
-
 	@:dox(hide)
 	public function new(elt) {
 		this.elt = elt;
@@ -1198,36 +1192,6 @@ class Flow extends Object {
 				return size;
 			}
 
-			var flexibleWidth = maxInWidth;
-			var numFlexible = 0;
-			var totFlexWeight = 0.0;
-			for( i in 0...children.length ) {
-				var p = propAt(i);
-				var c = childAt(i);
-				if( p.isAbsolute || !c.visible ) continue;
-				if( p.isBreak ) {
-					flexibleWidth = maxInWidth;
-					continue;
-				}
-				flexibleWidth -= horizontalSpacing;
-				if( p.flexWeight > 0 ) {
-					numFlexible++;
-					totFlexWeight += p.flexWeight;
-				}
-				else {
-					var pw = p.paddingLeft + p.paddingRight;
-					var ph = p.paddingTop + p.paddingBottom;
-					c.constraintSize(
-						isConstraintWidth && p.constraint ? (maxInWidth - pw) / Math.abs(c.scaleX) : -1,
-						isConstraintHeight && p.constraint ? (maxInHeight - ph) / Math.abs(c.scaleX) : -1
-					);
-					flexibleWidth -= Math.ceil(getSize(c).xMax) + pw;
-				}
-			}
-
-			if( flexibleWidth < maxInWidth )
-				flexibleWidth += horizontalSpacing;
-
 			for( i in 0...children.length ) {
 				var p = propAt(i);
 				var isAbs = p.isAbsolute;
@@ -1239,7 +1203,7 @@ class Flow extends Object {
 				var ph = p.paddingTop + p.paddingBottom;
 				if( !isAbs )
 					c.constraintSize(
-						isConstraintWidth && p.constraint ? ((p.flexWeight > 0 ? Math.floor(flexibleWidth * p.flexWeight / totFlexWeight) : maxInWidth) - pw) / Math.abs(c.scaleX) : -1,
+						isConstraintWidth && p.constraint ? (maxInWidth - pw) / Math.abs(c.scaleX) : -1,
 						isConstraintHeight && p.constraint ? (maxInHeight - ph) / Math.abs(c.scaleX) : -1
 					);
 
@@ -1375,36 +1339,6 @@ class Flow extends Object {
 				return size;
 			}
 
-			var flexibleHeight = maxInHeight;
-			var numFlexible = 0;
-			var totFlexWeight = 0.0;
-			for( i in 0...children.length ) {
-				var p = propAt(i);
-				var c = childAt(i);
-				if( p.isAbsolute || !c.visible ) continue;
-				if( p.isBreak ) {
-					flexibleHeight = maxInHeight;
-					continue;
-				}
-				flexibleHeight -= verticalSpacing;
-				if( p.flexWeight > 0 ) {
-					numFlexible++;
-					totFlexWeight += p.flexWeight;
-				}
-				else {
-					var pw = p.paddingLeft + p.paddingRight;
-					var ph = p.paddingTop + p.paddingBottom;
-					c.constraintSize(
-						isConstraintWidth && p.constraint ? (maxInWidth - pw) / Math.abs(c.scaleX) : -1,
-						isConstraintHeight && p.constraint ? (maxInHeight - ph) / Math.abs(c.scaleX) : -1
-					);
-					flexibleHeight -= Math.ceil(getSize(c).yMax) + ph;
-				}
-			}
-
-			if( flexibleHeight < maxInHeight )
-				flexibleHeight += verticalSpacing;
-
 			for( i in 0...children.length ) {
 				var p = propAt(i);
 				var isAbs = p.isAbsolute;
@@ -1418,7 +1352,7 @@ class Flow extends Object {
 				if( !isAbs )
 					c.constraintSize(
 						isConstraintWidth && p.constraint ? (maxInWidth - pw) / Math.abs(c.scaleX) : -1,
-						isConstraintHeight && p.constraint ? ((p.flexWeight > 0 ? Math.floor(flexibleHeight * p.flexWeight / totFlexWeight) : maxInHeight) - ph) / Math.abs(c.scaleY) : -1
+						isConstraintHeight && p.constraint ? (maxInHeight - ph) / Math.abs(c.scaleY) : -1
 					);
 
 				var b = getSize(c);

+ 0 - 18
h2d/domkit/BaseComponents.hx

@@ -368,8 +368,6 @@ class ObjectComp implements h2d.domkit.Object implements domkit.Component.Compon
 	@:p(none) var minWidth : Null<Int>;
 	@:p(none) var minHeight : Null<Int>;
 	@:p var forceLineBreak : Bool;
-	@:p(none) var flexWeight : Null<Float>;
-	@:p var flex : Bool;
 
 	static function set_rotation(o:h2d.Object, v:Float) {
 		o.rotation = v * Math.PI / 180;
@@ -492,22 +490,6 @@ class ObjectComp implements h2d.domkit.Object implements domkit.Component.Compon
 		if( p != null ) p.lineBreak = v;
 	}
 
-	static function set_flex(o:h2d.Object,v:Bool) {
-		var p = getFlowProps(o);
-		if( p != null ) {
-			if(v && p.flexWeight == null)
-				p.flexWeight = 1.0;
-			else if(!v)
-				p.flexWeight = null;
-		}
-	}
-
-	static function set_flexWeight(o:h2d.Object,v) {
-		var p = getFlowProps(o);
-		if( p != null )
-			p.flexWeight = v;
-	}
-
 	static function updateComponentId(p:domkit.Properties<Dynamic>) {
 		cast(p.obj,h2d.Object).name = p.id;
 	}