瀏覽代碼

added clientWidth/clientHeight

ncannasse 9 年之前
父節點
當前提交
6294d02da4
共有 1 個文件被更改,包括 17 次插入0 次删除
  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;