/** * Set the layout of the child elements here. Will be executed if the display or a parent window * was resized. */ public void layout() { // reset to the position and size to the original position position.set(positionOriginal); size.set(sizeOriginal); /* Position */ position.x = calcHorizontalAlign(horizontalAlign); position.y = calcVerticalAlign(verticalAlign); // recalculate position x relative to parent if unit is percentage if (unitPositionX == EUnitType.PERCENTAGE && positionType == EPositionType.RELATIVE && parent != null) { getPosition().x += parent.getSize().x * positionOriginal.x / 100f; } else if (unitPositionX == EUnitType.PERCENTAGE && positionType == EPositionType.ABSOLUTE) { // recalculate position x absolute to display if unit is percentage getPosition().x += Display.getWidth() * positionOriginal.x / 100f; } else { getPosition().x += positionOriginal.x; } // recalculate position x relative to parent if unit is percentage if (unitPositionY == EUnitType.PERCENTAGE && positionType == EPositionType.RELATIVE && parent != null) { getPosition().y += parent.getSize().y * positionOriginal.y / 100f; } else if (unitPositionY == EUnitType.PERCENTAGE && positionType == EPositionType.ABSOLUTE) { // recalculate position x absolute to display if unit is percentage getPosition().y += Display.getHeight() * positionOriginal.y / 100f; } else { getPosition().y += positionOriginal.y; } /* Size */ // recalculate width relative to parent if unit is percentage if (unitSizeX == EUnitType.PERCENTAGE && positionType == EPositionType.RELATIVE && parent != null) { getSize().x = parent.getSize().x * size.x / 100f; } else if (unitSizeX == EUnitType.PERCENTAGE && positionType == EPositionType.ABSOLUTE) { // recalculate width absolute to display if unit is percentage getSize().x = Display.getWidth() * size.x / 100f; } // recalculate height relative to parent if unit is percentage if (unitSizeY == EUnitType.PERCENTAGE && positionType == EPositionType.RELATIVE && parent != null) { getSize().y = parent.getSize().y * size.y / 100f; } else if (unitSizeY == EUnitType.PERCENTAGE && positionType == EPositionType.ABSOLUTE) { // recalculate height absolute to display if unit is percentage getSize().y = Display.getHeight() * size.y / 100f; } }