use of com.badlogic.gdx.scenes.scene2d.utils.Layout in project libgdx by libgdx.
the class SplitPane method layout.
@Override
public void layout() {
if (!vertical)
calculateHorizBoundsAndPositions();
else
calculateVertBoundsAndPositions();
Actor firstWidget = this.firstWidget;
if (firstWidget != null) {
Rectangle firstWidgetBounds = this.firstWidgetBounds;
firstWidget.setBounds(firstWidgetBounds.x, firstWidgetBounds.y, firstWidgetBounds.width, firstWidgetBounds.height);
if (firstWidget instanceof Layout)
((Layout) firstWidget).validate();
}
Actor secondWidget = this.secondWidget;
if (secondWidget != null) {
Rectangle secondWidgetBounds = this.secondWidgetBounds;
secondWidget.setBounds(secondWidgetBounds.x, secondWidgetBounds.y, secondWidgetBounds.width, secondWidgetBounds.height);
if (secondWidget instanceof Layout)
((Layout) secondWidget).validate();
}
}
use of com.badlogic.gdx.scenes.scene2d.utils.Layout in project libgdx by libgdx.
the class Stack method computeSize.
private void computeSize() {
sizeInvalid = false;
prefWidth = 0;
prefHeight = 0;
minWidth = 0;
minHeight = 0;
maxWidth = 0;
maxHeight = 0;
SnapshotArray<Actor> children = getChildren();
for (int i = 0, n = children.size; i < n; i++) {
Actor child = children.get(i);
float childMaxWidth, childMaxHeight;
if (child instanceof Layout) {
Layout layout = (Layout) child;
prefWidth = Math.max(prefWidth, layout.getPrefWidth());
prefHeight = Math.max(prefHeight, layout.getPrefHeight());
minWidth = Math.max(minWidth, layout.getMinWidth());
minHeight = Math.max(minHeight, layout.getMinHeight());
childMaxWidth = layout.getMaxWidth();
childMaxHeight = layout.getMaxHeight();
} else {
prefWidth = Math.max(prefWidth, child.getWidth());
prefHeight = Math.max(prefHeight, child.getHeight());
minWidth = Math.max(minWidth, child.getWidth());
minHeight = Math.max(minHeight, child.getHeight());
childMaxWidth = 0;
childMaxHeight = 0;
}
if (childMaxWidth > 0)
maxWidth = maxWidth == 0 ? childMaxWidth : Math.min(maxWidth, childMaxWidth);
if (childMaxHeight > 0)
maxHeight = maxHeight == 0 ? childMaxHeight : Math.min(maxHeight, childMaxHeight);
}
}
use of com.badlogic.gdx.scenes.scene2d.utils.Layout in project libgdx by libgdx.
the class Table method layout.
public void layout() {
float width = getWidth();
float height = getHeight();
layout(0, 0, width, height);
Array<Cell> cells = this.cells;
if (round) {
for (int i = 0, n = cells.size; i < n; i++) {
Cell c = cells.get(i);
float actorWidth = Math.round(c.actorWidth);
float actorHeight = Math.round(c.actorHeight);
float actorX = Math.round(c.actorX);
float actorY = height - Math.round(c.actorY) - actorHeight;
c.setActorBounds(actorX, actorY, actorWidth, actorHeight);
Actor actor = c.actor;
if (actor != null)
actor.setBounds(actorX, actorY, actorWidth, actorHeight);
}
} else {
for (int i = 0, n = cells.size; i < n; i++) {
Cell c = cells.get(i);
float actorHeight = c.actorHeight;
float actorY = height - c.actorY - actorHeight;
c.setActorY(actorY);
Actor actor = c.actor;
if (actor != null)
actor.setBounds(c.actorX, actorY, c.actorWidth, actorHeight);
}
}
// Validate children separately from sizing actors to ensure actors without a cell are validated.
Array<Actor> children = getChildren();
for (int i = 0, n = children.size; i < n; i++) {
Actor child = children.get(i);
if (child instanceof Layout)
((Layout) child).validate();
}
}
use of com.badlogic.gdx.scenes.scene2d.utils.Layout in project libgdx by libgdx.
the class HorizontalGroup method layout.
public void layout() {
if (sizeInvalid)
computeSize();
if (wrap) {
layoutWrapped();
return;
}
boolean round = this.round;
int align = this.align;
float space = this.space, padBottom = this.padBottom, fill = this.fill;
float rowHeight = (expand ? getHeight() : prefHeight) - padTop - padBottom, x = padLeft;
if ((align & Align.right) != 0)
x += getWidth() - prefWidth;
else if (// center
(align & Align.left) == 0)
x += (getWidth() - prefWidth) / 2;
float startY;
if ((align & Align.bottom) != 0)
startY = padBottom;
else if ((align & Align.top) != 0)
startY = getHeight() - padTop - rowHeight;
else
startY = padBottom + (getHeight() - padBottom - padTop - rowHeight) / 2;
align = rowAlign;
SnapshotArray<Actor> children = getChildren();
int i = 0, n = children.size, incr = 1;
if (reverse) {
i = n - 1;
n = -1;
incr = -1;
}
for (int r = 0; i != n; i += incr) {
Actor child = children.get(i);
float width, height;
Layout layout = null;
if (child instanceof Layout) {
layout = (Layout) child;
width = layout.getPrefWidth();
height = layout.getPrefHeight();
} else {
width = child.getWidth();
height = child.getHeight();
}
if (fill > 0)
height = rowHeight * fill;
if (layout != null) {
height = Math.max(height, layout.getMinHeight());
float maxHeight = layout.getMaxHeight();
if (maxHeight > 0 && height > maxHeight)
height = maxHeight;
}
float y = startY;
if ((align & Align.top) != 0)
y += rowHeight - height;
else if (// center
(align & Align.bottom) == 0)
y += (rowHeight - height) / 2;
if (round)
child.setBounds(Math.round(x), Math.round(y), Math.round(width), Math.round(height));
else
child.setBounds(x, y, width, height);
x += width + space;
if (layout != null)
layout.validate();
}
}
Aggregations