private int processWidthConstraints( final int rootBoxWidth, @Nonnull final BoxConstraints constraints, final int elementHeight) { if (hasWidthConstraint(constraints)) { if (constraints.getWidth().hasHeightSuffix()) { return constraints.getWidth().getValueAsInt(elementHeight); } return constraints.getWidth().getValueAsInt(rootBoxWidth); } else { return rootBoxWidth; } }
private int calcElementWidth( @Nonnull final List<LayoutPart> children, final int rootBoxWidth, @Nonnull final BoxConstraints boxConstraints, final int elementHeight) { if (boxConstraints.getWidth().hasValue()) { int h = boxConstraints.getWidth().getValueAsInt(rootBoxWidth); if (boxConstraints.getWidth().hasHeightSuffix()) { h = boxConstraints.getWidth().getValueAsInt(elementHeight); } if (h != -1) { return h; } } return getMaxNonFixedWidth(children, rootBoxWidth); }
private void layoutElement( @Nonnull final LayoutPart element, @Nonnull Box rootBox, @Nonnull BoxConstraints rootBoxConstraints) { Box box = element.getBox(); BoxConstraints constraint = element.getBoxConstraints(); if (constraint.getWidth().hasHeightSuffix()) { handleVerticalAlignment(rootBox, rootBoxConstraints, box, constraint); handleHorizontalAlignment(rootBox, rootBoxConstraints, box, constraint); } else if (constraint.getHeight().hasWidthSuffix()) { handleHorizontalAlignment(rootBox, rootBoxConstraints, box, constraint); handleVerticalAlignment(rootBox, rootBoxConstraints, box, constraint); } else { handleVerticalAlignment(rootBox, rootBoxConstraints, box, constraint); handleHorizontalAlignment(rootBox, rootBoxConstraints, box, constraint); } box.setX(box.getX() + leftMargin(constraint, rootBox.getWidth()) - rightMargin(constraint, rootBox.getWidth())); box.setY(box.getY() + topMargin(constraint, rootBox.getHeight()) - bottomMargin(constraint, rootBox.getHeight())); }
private void handleWidthConstraint( @Nonnull final Box rootBox, @Nonnull final BoxConstraints rootBoxConstraints, @Nonnull final Box box, @Nonnull final BoxConstraints constraint) { int rootBoxX = rootBox.getX() + rootBoxConstraints.getPaddingLeft().getValueAsInt(rootBox.getWidth()); int rootBoxWidth = rootBox.getWidth() - rootBoxConstraints.getPaddingLeft().getValueAsInt(rootBox.getWidth()) - rootBoxConstraints.getPaddingRight().getValueAsInt(rootBox.getWidth()); int boxWidth = constraint.getWidth().getValueAsInt(rootBoxWidth); if (constraint.getWidth().hasHeightSuffix()) { boxWidth = constraint.getWidth().getValueAsInt(box.getHeight()); } box.setWidth(boxWidth); if (constraint.getHorizontalAlign() == HorizontalAlign.left) { box.setX(rootBoxX); } else if (constraint.getHorizontalAlign() == HorizontalAlign.right) { box.setX(rootBoxX + rootBox.getWidth() - rootBoxConstraints.getPaddingRight().getValueAsInt(rootBox.getWidth()) - boxWidth); } else { // default and center is the same in here box.setX(rootBoxX + (rootBoxWidth - boxWidth) / 2); } }
} else if (hasWidthConstraint(currentBoxConstraints) && currentBoxConstraints.getWidth().hasHeightSuffix()) { elementHeight = calcElementHeight(children, rootBoxHeight, currentBoxConstraints, 0); currentBox.setHeight(elementHeight);
if (boxConstraints.getWidth().hasHeightSuffix()) { int elementHeight = processHeightConstraint(rootBoxHeight, box, boxConstraints, 0); box.setHeight(elementHeight);
if (cons.getWidth().hasHeightSuffix()) { if (cons.getHeight().hasValue()) { box.setHeight(cons.getHeight().getValueAsInt(rootBoxHeight));