preProcessConstraintWidthThisLevel();
}
private void preProcessConstraintWidthThisLevel() {
// try the original width value first
SizeValue myWidth = getConstraintWidth();
// is it empty and we have an layoutManager there's still hope for a width constraint
if (layoutManager != null && (myWidth == null || isCalcWidthConstraint)) {
// collect all child layoutPart that have a fixed pixel size in a list
List < LayoutPart > layoutPartChild = new ArrayList < LayoutPart >();
for (int i=0; i<elements.size(); i++) {
Element e = elements.get(i);
SizeValue childWidth = e.getConstraintWidth();
if (childWidth != null && childWidth.isPixel()) {
layoutPartChild.add(e.layoutPart);
}
}
// if all (!) child elements have a pixel fixed width we can calculate a new width constraint for this element!
if (elements.size() == layoutPartChild.size()) {
SizeValue newWidth = layoutManager.calculateConstraintWidth(this.layoutPart, layoutPartChild);
if (newWidth != null) {
setConstraintWidth(newWidth);
isCalcWidthConstraint = true;
}
}