From d768c9d0bb2557b2979c7146188a537603dcd48a Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Wed, 13 Mar 2024 09:12:50 -0700 Subject: [PATCH] HDividedBoxLayout, VDividedBoxLayout: support includeInLayout --- src/feathers/layout/HDividedBoxLayout.hx | 19 ++++++++++++++++++- src/feathers/layout/VDividedBoxLayout.hx | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/feathers/layout/HDividedBoxLayout.hx b/src/feathers/layout/HDividedBoxLayout.hx index cb66500a..6797b0f2 100644 --- a/src/feathers/layout/HDividedBoxLayout.hx +++ b/src/feathers/layout/HDividedBoxLayout.hx @@ -275,6 +275,9 @@ class HDividedBoxLayout extends EventDispatcher implements ILayout { var contentWidth = this._paddingLeft; var contentHeight = 0.0; for (item in items) { + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } if ((item is IValidating)) { // the width might have changed after the initial validation (cast item : IValidating).validateNow(); @@ -334,6 +337,9 @@ class HDividedBoxLayout extends EventDispatcher implements ILayout { private inline function validateItems(items:Array) { for (i in 0...items.length) { var item = items[i]; + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } var isDivider = i % 2 == 1; if (!isDivider) { if (this._customItemWidths != null && i < this._customItemWidths.length) { @@ -356,6 +362,9 @@ class HDividedBoxLayout extends EventDispatcher implements ILayout { continue; } var item = items[i]; + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } switch (this._verticalAlign) { case BOTTOM: item.y = Math.max(this._paddingTop, this._paddingTop + (viewPortHeight - this._paddingTop - this._paddingBottom) - item.height); @@ -378,10 +387,15 @@ class HDividedBoxLayout extends EventDispatcher implements ILayout { var totalMeasuredWidth = 0.0; var totalMinWidth = 0.0; var totalPercentWidth = 0.0; + var fallbackItemIndex = -1; for (i in 0...items.length) { var item = items[i]; + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } var isDivider = i % 2 == 1; if (!isDivider) { + fallbackItemIndex = i; var nonDividerIndex = Math.floor(i / 2); var needsPercentWidth = true; if (this._customItemWidths != null && nonDividerIndex < this._customItemWidths.length) { @@ -493,7 +507,7 @@ class HDividedBoxLayout extends EventDispatcher implements ILayout { var index = this._fallbackFluidIndex; if (index == -1) { - index = items.length - 1; + index = fallbackItemIndex; } if (index != -1) { var fallbackItem = items[index]; @@ -527,6 +541,9 @@ class HDividedBoxLayout extends EventDispatcher implements ILayout { continue; } var item = items[i]; + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } var itemHeight = availableHeight; if ((item is IMeasureObject)) { var measureItem:IMeasureObject = cast item; diff --git a/src/feathers/layout/VDividedBoxLayout.hx b/src/feathers/layout/VDividedBoxLayout.hx index d2ef5bd0..0df33f11 100644 --- a/src/feathers/layout/VDividedBoxLayout.hx +++ b/src/feathers/layout/VDividedBoxLayout.hx @@ -275,6 +275,9 @@ class VDividedBoxLayout extends EventDispatcher implements ILayout { var contentWidth = 0.0; var contentHeight = this._paddingTop; for (item in items) { + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } if ((item is IValidating)) { // the height might have changed after the initial validation (cast item : IValidating).validateNow(); @@ -334,6 +337,9 @@ class VDividedBoxLayout extends EventDispatcher implements ILayout { private inline function validateItems(items:Array) { for (i in 0...items.length) { var item = items[i]; + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } var isDivider = i % 2 == 1; if (!isDivider) { if (this._customItemHeights != null && i < this._customItemHeights.length) { @@ -356,6 +362,9 @@ class VDividedBoxLayout extends EventDispatcher implements ILayout { continue; } var item = items[i]; + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } switch (this._horizontalAlign) { case RIGHT: item.x = Math.max(this._paddingLeft, this._paddingLeft + (viewPortWidth - this._paddingLeft - this._paddingRight) - item.width); @@ -379,10 +388,15 @@ class VDividedBoxLayout extends EventDispatcher implements ILayout { var totalMeasuredHeight = 0.0; var totalMinHeight = 0.0; var totalPercentHeight = 0.0; + var fallbackItemIndex = -1; for (i in 0...items.length) { var item = items[i]; + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } var isDivider = i % 2 == 1; if (!isDivider) { + fallbackItemIndex = i; var nonDividerIndex = Math.floor(i / 2); var needsPercentHeight = true; if (this._customItemHeights != null && nonDividerIndex < this._customItemHeights.length) { @@ -494,7 +508,7 @@ class VDividedBoxLayout extends EventDispatcher implements ILayout { var index = this._fallbackFluidIndex; if (index == -1) { - index = items.length - 1; + index = fallbackItemIndex; } if (index != -1) { var fallbackItem = items[index]; @@ -528,6 +542,9 @@ class VDividedBoxLayout extends EventDispatcher implements ILayout { continue; } var item = items[i]; + if ((item is ILayoutObject) && !(cast item : ILayoutObject).includeInLayout) { + continue; + } var itemWidth = availableWidth; if ((item is IMeasureObject)) { var measureItem:IMeasureObject = cast item;