Browse Source

added clientWidth/clientHeight

ncannasse 9 năm trước cách đây
mục cha
commit
6294d02da4
1 tập tin đã thay đổi với 17 bổ sung0 xóa
  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 borderWidth(default, set) : Int = 0;
 	public var borderHeight(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.
 		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.
 		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;
 		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() {
 	function get_calculatedWidth() {
 		if( needReflow ) reflow();
 		if( needReflow ) reflow();
 		return calculatedWidth;
 		return calculatedWidth;