List of usage examples for com.badlogic.gdx.scenes.scene2d.utils Layout getMaxHeight
public float getMaxHeight();
From source file:com.crashinvaders.common.scene2d.HorizontalGroupExtended.java
License:Apache License
@Override public void layout() { float spacing = this.spacing, padBottom = this.padBottom; int align = this.align; boolean reverse = this.reverse, round = this.round; float groupHeight = getHeight() - padTop - padBottom; float x = !reverse ? padLeft : getWidth() - padRight + spacing; Array<Actor> children = getVisibleChildren(); for (int i = 0, n = children.size; i < n; i++) { Actor child = children.get(i);/* www .ja va 2s .c o m*/ float width, height; if (child instanceof Layout) { Layout layout = (Layout) child; if (fill > 0) height = groupHeight * fill; else height = Math.min(layout.getPrefHeight(), groupHeight); height = Math.max(height, layout.getMinHeight()); float maxHeight = layout.getMaxHeight(); if (maxHeight > 0 && height > maxHeight) height = maxHeight; width = layout.getPrefWidth(); } else { width = child.getWidth(); height = child.getHeight(); if (fill > 0) height *= fill; } float y = padBottom; if ((align & Align.top) != 0) y += groupHeight - height; else if ((align & Align.bottom) == 0) // center y += (groupHeight - height) / 2; if (reverse) x -= (width + spacing); if (round) child.setBounds(Math.round(x), Math.round(y), Math.round(width), Math.round(height)); else child.setBounds(x, y, width, height); if (!reverse) x += (width + spacing); } }
From source file:com.meizu.taskmanager.ui.HorizontalGroup.java
License:Apache License
public void layout() { float spacing = this.spacing, padBottom = this.padBottom; int align = this.align; boolean reverse = this.reverse, round = this.round; float groupHeight = getHeight() - padTop - padBottom; float x = !reverse ? padLeft : getWidth() - padRight + spacing; SnapshotArray<Actor> children = getChildren(); for (int i = 0, n = children.size; i < n; i++) { Actor child = children.get(i);/*from ww w. j a va 2 s .c o m*/ float width, height; if (child instanceof Layout) { Layout layout = (Layout) child; if (fill > 0) height = groupHeight * fill; else height = Math.min(layout.getPrefHeight(), groupHeight); height = Math.max(height, layout.getMinHeight()); float maxHeight = layout.getMaxHeight(); if (maxHeight > 0 && height > maxHeight) height = maxHeight; width = layout.getPrefWidth(); } else { width = child.getWidth(); height = child.getHeight(); if (fill > 0) height *= fill; } float y = padBottom; if ((align & Align.top) != 0) y += groupHeight - height; else if ((align & Align.bottom) == 0) // center y += (groupHeight - height) / 2; if (reverse) x -= (width + spacing); if (round) child.setBounds(Math.round(x), Math.round(y), Math.round(width), Math.round(height)); else child.setBounds(x, y, width, height); if (!reverse) x += (width + spacing); } }
From source file:net.dermetfan.gdx.scenes.scene2d.ui.CircularGroup.java
License:Apache License
@Override public void layout() { float prefWidthUnderflow = shrinkChildren ? Math.max(0, getPrefWidth() - getWidth()) / 2 : 0, prefHeightUnderflow = shrinkChildren ? Math.max(0, getPrefHeight() - getHeight()) / 2 : 0; SnapshotArray<Actor> children = getChildren(); for (int index = 0; index < children.size; index++) { Actor child = children.get(index); // get dimensions and resize float width, height; if (child instanceof Layout) { Layout childLayout = (Layout) child; width = childLayout.getPrefWidth() - prefWidthUnderflow; width = Math.max(width, childLayout.getMinWidth()); if (childLayout.getMaxWidth() != 0) width = Math.min(width, childLayout.getMaxWidth()); height = childLayout.getPrefHeight() - prefHeightUnderflow; height = Math.max(height, childLayout.getMinHeight()); if (childLayout.getMaxHeight() != 0) height = Math.min(height, childLayout.getMaxHeight()); child.setSize(width, height); childLayout.validate();/*from w w w .ja v a2 s .c o m*/ } else { width = child.getWidth(); height = child.getHeight(); } float angle = fullAngle / (children.size - (virtualChildEnabled ? 0 : 1)) * index; angle += angleOffset; angle = modifier.angle(angle, child, index, children.size, this); float rotation = modifier.rotation(angle, child, index, children.size, this); tmp.set(modifier.anchorOffset(tmp.setZero(), child, index, children.size, this)); tmp.rotate(angle); float offsetX = tmp.x, offsetY = tmp.y; tmp.set(modifier.localAnchor(tmp.set(width, height / 2), child, index, children.size, this)); float localAnchorX = tmp.x, localAnchorY = tmp.y; child.setOrigin(localAnchorX, localAnchorY); child.setRotation(rotation); child.setPosition(getWidth() / 2 + offsetX - localAnchorX, getHeight() / 2 + offsetY - localAnchorY); } }