Exemple #1
0
 @Override
 public void layoutContents(final UIContainer container) {
   rebuildGrid(container);
   grid.updateMinimalSize();
   final int height = grid.minHeight;
   final int heightDiff =
       container.getContentHeight() > height ? container.getContentHeight() - height : 0;
   int rowHeightDiff = heightDiff;
   switch (verticalAlignment) {
     case TOP:
       rowHeightDiff = heightDiff;
       break;
     case MIDDLE:
       rowHeightDiff = heightDiff / 2;
       break;
     case BOTTOM:
       rowHeightDiff = 0;
       break;
     default:
       rowHeightDiff = heightDiff;
   }
   for (final LayoutComponent lc : grid.components) {
     if (fillVerticalSpace) {
       rowHeightDiff = Math.round(heightDiff * (1f - (float) lc.firstRow / grid.maxRow));
     }
     lc.component.setLocalXY(
         grid.columnOffsets[lc.firstColumn],
         rowHeightDiff + height - grid.rowOffsets[lc.firstRow] - lc.getComponentHeight());
     if (lc.grow) {
       lc.component.setLocalComponentWidth(grid.getCellsWidth(lc.firstColumn, lc.lastColumn));
     }
   }
 }
Exemple #2
0
 private void rebuildGrid(final UIContainer container) {
   final List<Spatial> content = container.getChildren();
   grid = new LayoutGrid();
   for (final Spatial spatial : content) {
     if (spatial instanceof UIComponent) {
       final UIComponent c = (UIComponent) spatial;
       grid.add(c);
     }
   }
 }
Exemple #3
0
 @Override
 public void updateMinimumSizeFromContents(final UIContainer container) {
   rebuildGrid(container);
   grid.updateMinimalSize();
   container.setMinimumContentSize(grid.minWidth, grid.minHeight);
 }