예제 #1
0
  public void layout() {
    Table table = getTable();
    float width = table.getWidth();
    float height = table.getHeight();

    super.layout(0, 0, width, height);

    java.util.List<Cell> cells = getCells();
    if (round) {
      for (int i = 0, n = cells.size(); i < n; i++) {
        Cell c = cells.get(i);
        if (c.getIgnore()) continue;
        float widgetWidth = Math.round(c.getWidgetWidth());
        float widgetHeight = Math.round(c.getWidgetHeight());
        float widgetX = Math.round(c.getWidgetX());
        float widgetY = height - Math.round(c.getWidgetY()) - widgetHeight;
        c.setWidgetX(widgetX);
        c.setWidgetY(widgetY);
        c.setWidgetWidth(widgetWidth);
        c.setWidgetHeight(widgetHeight);
        Actor actor = (Actor) c.getWidget();
        if (actor != null) {
          actor.setX(widgetX);
          actor.setY(widgetY);
          if (actor.getWidth() != widgetWidth || actor.getHeight() != widgetHeight) {
            actor.setWidth(widgetWidth);
            actor.setHeight(widgetHeight);
            if (actor instanceof Layout) ((Layout) actor).invalidate();
          }
        }
      }
    } else {
      for (int i = 0, n = cells.size(); i < n; i++) {
        Cell c = cells.get(i);
        if (c.getIgnore()) continue;
        float widgetWidth = c.getWidgetWidth();
        float widgetHeight = c.getWidgetHeight();
        float widgetX = c.getWidgetX();
        float widgetY = height - c.getWidgetY() - widgetHeight;
        c.setWidgetX(widgetX);
        c.setWidgetY(widgetY);
        c.setWidgetWidth(widgetWidth);
        c.setWidgetHeight(widgetHeight);
        Actor actor = (Actor) c.getWidget();
        if (actor != null) {
          actor.setX(widgetX);
          actor.setY(widgetY);
          if (actor.getWidth() != widgetWidth || actor.getHeight() != widgetHeight) {
            actor.setWidth(widgetWidth);
            actor.setHeight(widgetHeight);
            if (actor instanceof Layout) ((Layout) actor).invalidate();
          }
        }
      }
    }
    // Validate children separately from sizing actors to ensure actors without a cell are
    // validated.
    Array<Actor> children = table.getChildren();
    for (int i = 0, n = children.size; i < n; i++) {
      Actor child = children.get(i);
      if (child instanceof Layout) ((Layout) child).validate();
    }
  }
예제 #2
0
 /** Invalides the layout of this widget and every parent widget to the root of the hierarchy. */
 public void invalidateHierarchy() {
   super.invalidate();
   getTable().invalidateHierarchy();
 }