List of usage examples for com.badlogic.gdx.scenes.scene2d.utils Layout getMinHeight
public float getMinHeight();
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);//from w w w. j a v a 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 w w w . ja va2 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
/** computes {@link #cachedMinWidth}, {@link #cachedMinHeight}, {@link #cachedPrefWidth} and {@link #cachedPrefHeight} */ protected void computeSize() { cachedMinWidth = cachedMinHeight = Float.POSITIVE_INFINITY; cachedPrefWidth = cachedPrefHeight = 0; SnapshotArray<Actor> children = getChildren(); for (int index = 0; index < children.size; index++) { Actor child = children.get(index); // find child size float minWidth, minHeight, prefWidth, prefHeight; if (child instanceof Layout) { Layout layout = (Layout) child; minWidth = layout.getMinWidth(); minHeight = layout.getMinHeight(); prefWidth = layout.getPrefWidth(); prefHeight = layout.getPrefHeight(); } else {/* ww w . jav a 2 s.c om*/ minWidth = prefWidth = child.getWidth(); minHeight = prefHeight = child.getHeight(); } // anchor offset and local anchor tmp.set(modifier.anchorOffset(tmp.setZero(), child, index, children.size, this)); float offsetX = tmp.x, offsetY = tmp.y; tmp.set(modifier.localAnchor(tmp.set(minWidth, minHeight / 2), child, index, children.size, this)) .sub(offsetX, offsetY); if (tmp.x < minWidth || tmp.x < 0) minWidth -= tmp.x; else minWidth += tmp.x - minWidth; if (tmp.y < minHeight || tmp.y < 0) minHeight -= tmp.y; else minHeight += tmp.y - minHeight; tmp.set(modifier.localAnchor(tmp.set(prefWidth, prefHeight / 2), child, index, children.size, this)) .sub(offsetX, offsetY); if (tmp.x < prefWidth || tmp.x < 0) prefWidth -= tmp.x; else prefWidth += tmp.x - prefWidth; if (tmp.y < prefHeight || tmp.y < 0) prefHeight -= tmp.y; else prefHeight += tmp.y - prefHeight; // update caches if (minWidth < cachedMinWidth) cachedMinWidth = minWidth; if (minHeight < cachedMinHeight) cachedMinHeight = minHeight; if (prefWidth > cachedPrefWidth) cachedPrefWidth = prefWidth; if (prefHeight > cachedPrefHeight) cachedPrefHeight = prefHeight; } cachedMinWidth *= 2; cachedMinHeight *= 2; cachedPrefWidth *= 2; cachedPrefHeight *= 2; // ensure circle cachedMinWidth = cachedMinHeight = Math.max(cachedMinWidth, cachedMinHeight); cachedPrefWidth = cachedPrefHeight = Math.max(cachedPrefWidth, cachedPrefHeight); sizeInvalid = false; }
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();// w ww .ja va 2s . c om } 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); } }