private int processHeightConstraint( final int rootBoxHeight, final Box box, @Nonnull final BoxConstraints constraint, final int elementWidth) { if (hasHeightConstraint(constraint)) { if (constraint.getHeight().hasWidthSuffix()) { return constraint.getHeight().getValueAsInt(elementWidth); } return constraint.getHeight().getValueAsInt(rootBoxHeight); } else { return rootBoxHeight; } }
private int calcElementHeight( @Nonnull final List<LayoutPart> children, final int rootBoxHeight, @Nonnull final BoxConstraints boxConstraints, final int boxWidth) { if (hasHeightConstraint(boxConstraints)) { int h; if (boxConstraints.getHeight().hasWidthSuffix()) { h = boxConstraints.getHeight().getValueAsInt(boxWidth); } else { h = boxConstraints.getHeight().getValueAsInt(rootBoxHeight); } if (h != -1) { return h; } } return getMaxNonFixedHeight(children, rootBoxHeight); }
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 handleHeightConstraint( @Nonnull final Box rootBox, @Nonnull final BoxConstraints rootBoxConstraints, @Nonnull final Box box, @Nonnull final BoxConstraints constraint) { int rootBoxY = rootBox.getY() + rootBoxConstraints.getPaddingTop().getValueAsInt(rootBox.getHeight()); int rootBoxHeight = rootBox.getHeight() - rootBoxConstraints.getPaddingTop().getValueAsInt(rootBox.getHeight()) - rootBoxConstraints.getPaddingBottom().getValueAsInt(rootBox.getHeight()); int boxHeight = constraint.getHeight().getValueAsInt(rootBoxHeight); if (constraint.getHeight().hasWidthSuffix()) { boxHeight = constraint.getHeight().getValueAsInt(box.getWidth()); } box.setHeight(boxHeight); if (constraint.getVerticalAlign() == VerticalAlign.top) { box.setY(rootBoxY); } else if (constraint.getVerticalAlign() == VerticalAlign.bottom) { box.setY(rootBoxY + rootBox.getHeight() - rootBoxConstraints.getPaddingBottom().getValueAsInt(rootBox.getHeight ()) - boxHeight); } else { // center is default in here box.setY(rootBoxY + (rootBoxHeight - boxHeight) / 2); } }
if (hasHeightConstraint(currentBoxConstraints) && currentBoxConstraints.getHeight().hasWidthSuffix()) { int elementWidth = processWidthConstraints(rootBoxWidth, currentBoxConstraints, 0); currentBox.setWidth(elementWidth);
} else if (hasHeightConstraint(boxConstraints) && boxConstraints.getHeight().hasWidthSuffix()) { elementWidth = calcElementWidth(children, rootBoxWidth, boxConstraints, 0); box.setWidth(elementWidth);
} else if (cons.getHeight().hasWidthSuffix()) { if (cons.getWidth().hasValue()) { box.setWidth(cons.getWidth().getValueAsInt(rootBoxWidth));