Skip to content

Commit

Permalink
HDividedBoxLayout, VDividedBoxLayout: support includeInLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Mar 13, 2024
1 parent cf53455 commit d768c9d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 2 deletions.
19 changes: 18 additions & 1 deletion src/feathers/layout/HDividedBoxLayout.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -334,6 +337,9 @@ class HDividedBoxLayout extends EventDispatcher implements ILayout {
private inline function validateItems(items:Array<DisplayObject>) {
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) {
Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down
19 changes: 18 additions & 1 deletion src/feathers/layout/VDividedBoxLayout.hx
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -334,6 +337,9 @@ class VDividedBoxLayout extends EventDispatcher implements ILayout {
private inline function validateItems(items:Array<DisplayObject>) {
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) {
Expand All @@ -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);
Expand All @@ -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) {
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d768c9d

Please sign in to comment.