Browse Source

added clientWidth/clientHeight

ncannasse 9 years ago
parent
commit
6294d02da4
1 changed files with 17 additions and 0 deletions
  1. 17 0
      h2d/Flow.hx

+ 17 - 0
h2d/Flow.hx

@@ -93,6 +93,15 @@ class Flow extends Sprite {
 	public var borderWidth(default, set) : Int = 0;
 	public var borderHeight(default, set) : Int = 0;
 
+	/**
+		Calculate the client width, which is the innner size of the flow without the borders and padding.
+	**/
+	public var clientWidth(get, never) : Int;
+	/**
+		Calculate the client height, which is the innner size of the flow without the borders and padding.
+	**/
+	public var clientHeight(get, never) : Int;
+
 	/**
 		By default, elements will be flowed horizontaly, then in several lines if maxWidth is reached.
 		You can instead flow them vertically, then to next column is maxHeight is reached by setting the isVertical flag to true.
@@ -159,6 +168,14 @@ class Flow extends Sprite {
 		return v;
 	}
 
+	function get_clientWidth() {
+		return Std.int(getBounds(this,tmpBounds).xMax) - (paddingLeft + paddingRight + borderWidth * 2);
+	}
+
+	function get_clientHeight() {
+		return Std.int(getBounds(this,tmpBounds).yMax) - (paddingTop + paddingBottom + borderHeight * 2);
+	}
+
 	function get_calculatedWidth() {
 		if( needReflow ) reflow();
 		return calculatedWidth;