Forráskód Böngészése

added lineBreak to flow properties and domkit

Nicolas Cannasse 5 éve
szülő
commit
ff089bf49c
2 módosított fájl, 9 hozzáadás és 2 törlés
  1. 3 2
      h2d/Flow.hx
  2. 6 0
      h2d/domkit/BaseComponents.hx

+ 3 - 2
h2d/Flow.hx

@@ -38,6 +38,7 @@ class FlowProperties {
 	public var calculatedHeight(default,null) : Int = 0;
 
 	public var isBreak(default,null) : Bool;
+	public var lineBreak = false;
 
 	/**
 		If our flow have a maximum size, it will constraint the children by using .constraintSize()
@@ -736,7 +737,7 @@ class Flow extends Object {
 
 				if( isAbs ) continue;
 
-				if( multiline && x - startX + p.calculatedWidth > maxInWidth && x - startX > 0 ) {
+				if( ((multiline && x - startX + p.calculatedWidth > maxInWidth) || p.lineBreak) && x - startX > 0 ) {
 					br = true;
 					alignLine(i);
 					y += maxLineHeight + verticalSpacing;
@@ -883,7 +884,7 @@ class Flow extends Object {
 
 				if( isAbs ) continue;
 
-				if( multiline && y - startY + p.calculatedHeight > maxInHeight && y - startY > 0 ) {
+				if( ((multiline && y - startY + p.calculatedHeight > maxInHeight) || p.lineBreak) && y - startY > 0 ) {
 					br = true;
 					alignLine(i);
 					x += maxColWidth + horizontalSpacing;

+ 6 - 0
h2d/domkit/BaseComponents.hx

@@ -279,6 +279,7 @@ class ObjectComp implements h2d.domkit.Object implements domkit.Component.Compon
 	@:p var offsetY : Int;
 	@:p(none) var minWidth : Null<Int>;
 	@:p(none) var minHeight : Null<Int>;
+	@:p var lineBreak : Bool;
 
 	static function set_rotation(o:h2d.Object, v:Float) {
 		o.rotation = v * Math.PI / 180;
@@ -396,6 +397,11 @@ class ObjectComp implements h2d.domkit.Object implements domkit.Component.Compon
 		if( p != null ) p.minHeight = v;
 	}
 
+	static function set_lineBreak(o:h2d.Object,v) {
+		var p = getFlowProps(o);
+		if( p != null ) p.lineBreak = v;
+	}
+
 	static function updateComponentId(p:domkit.Properties<Dynamic>) {
 		cast(p.obj,h2d.Object).name = p.id;
 	}