diff --git a/src/kits/interface/layouter/ComplexLayouter.cpp b/src/kits/interface/layouter/ComplexLayouter.cpp index 36134deea4..af40a406b2 100644 --- a/src/kits/interface/layouter/ComplexLayouter.cpp +++ b/src/kits/interface/layouter/ComplexLayouter.cpp @@ -165,6 +165,7 @@ ComplexLayouter::ComplexLayouter(int32 elementCount, int32 spacing) fSums(new(nothrow) SumItem[elementCount + 1]), fSumBackups(new(nothrow) SumItemBackup[elementCount + 1]), fOptimizer(new(nothrow) LayoutOptimizer(elementCount)), + fUnlimited(B_SIZE_UNLIMITED / (elementCount == 0 ? 1 : elementCount)), fLayoutValid(false), fOptimizerConstraintsAdded(false) { @@ -226,8 +227,8 @@ ComplexLayouter::AddConstraints(int32 element, int32 length, if (min < 0) min = 0; - if (max > B_SIZE_UNLIMITED) - max = B_SIZE_UNLIMITED; + if (max > fUnlimited) + max = fUnlimited; int32 end = element + length - 1; Constraint** slot = fConstraints + end; @@ -582,10 +583,11 @@ ComplexLayouter::_ValidateLayout() fSums[0].min = 0; fSums[0].max = 0; + int32 maxSum = 0; for (int32 i = 0; i < fElementCount; i++) { SumItem& sum = fSums[i + 1]; sum.min = 0; - sum.max = B_SIZE_UNLIMITED; + sum.max = maxSum += fUnlimited; sum.minDirty = false; sum.maxDirty = false; } @@ -649,6 +651,8 @@ ComplexLayouter::_ValidateLayout() int32 spacing = (fElementCount - 1) * fSpacing; fMin = fSums[fElementCount].min + spacing - 1; fMax = fSums[fElementCount].max + spacing - 1; + if (fMax >= fUnlimited) + fMax = B_SIZE_UNLIMITED; } fOptimizerConstraintsAdded = false; diff --git a/src/kits/interface/layouter/ComplexLayouter.h b/src/kits/interface/layouter/ComplexLayouter.h index adfa1ee5a5..e548762d70 100644 --- a/src/kits/interface/layouter/ComplexLayouter.h +++ b/src/kits/interface/layouter/ComplexLayouter.h @@ -73,6 +73,7 @@ private: LayoutOptimizer* fOptimizer; float fMin; float fMax; + int32 fUnlimited; bool fLayoutValid; bool fOptimizerConstraintsAdded; };