List of usage examples for com.badlogic.gdx.scenes.scene2d Actor setBounds
public void setBounds(float x, float y, float width, float height)
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); float width, height; if (child instanceof Layout) { Layout layout = (Layout) child; if (fill > 0) height = groupHeight * fill; else//from w w w. j a v a2 s . c o m 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.kotcrab.vis.editor.ui.HorizontalFlowGroup.java
License:Apache License
public void layout() { if (sizeInvalid) { computeSize();/*from w w w . j a v a 2 s . c om*/ if (lastPrefHeight != prefHeight) { lastPrefHeight = prefHeight; invalidateHierarchy(); } } SnapshotArray<Actor> children = getChildren(); float groupWidth = getWidth(); float x = 0; float y = getHeight(); float maxHeight = 0; for (int i = 0, n = children.size; i < n; i++) { Actor child = children.get(i); float width = child.getWidth(); float height = child.getHeight(); if (child instanceof Layout) { Layout layout = (Layout) child; width = layout.getPrefWidth(); height = layout.getPrefHeight(); } if (x + width <= groupWidth) { maxHeight = Math.max(height, maxHeight); } else { y -= maxHeight + spacing; maxHeight = height; x = 0; } child.setBounds(x, y - height, width, height); x += width + spacing; } }
From source file:com.kotcrab.vis.ui.layout.ColumnGroup.java
License:Apache License
@Override public void layout() { if (sizeInvalid) { computeSize();//from ww w . jav a2 s.co m if (lastPrefHeight != prefHeight) { lastPrefHeight = prefHeight; invalidateHierarchy(); } } float y = getHeight(); SnapshotArray<Actor> children = getChildren(); for (int i = 0, n = children.size; i < n; i++) { Actor child = children.get(i); float width = child.getWidth(); float height = child.getHeight(); if (child instanceof Layout) { Layout layout = (Layout) child; width = layout.getPrefWidth(); height = layout.getPrefHeight(); } child.setBounds(0, y - height, width, height); y -= height; } }
From source file:com.kotcrab.vis.ui.layout.FloatingGroup.java
License:Apache License
@Override public void layout() { if (useChildrenPreferredSize == false) return;/* w ww. j a v a 2 s .c o m*/ SnapshotArray<Actor> children = getChildren(); for (int i = 0; i < children.size; i++) { Actor child = children.get(i); float width = child.getWidth(); float height = child.getHeight(); if (child instanceof Layout) { Layout layout = (Layout) child; width = layout.getPrefWidth(); height = layout.getPrefHeight(); } child.setBounds(child.getX(), child.getY(), width, height); } }
From source file:com.kotcrab.vis.ui.layout.GridGroup.java
License:Apache License
@Override public void layout() { if (sizeInvalid) { computeSize();// ww w. j ava 2 s.c o m if (lastPrefHeight != prefHeight) { lastPrefHeight = prefHeight; invalidateHierarchy(); } } SnapshotArray<Actor> children = getChildren(); float width = getWidth(); boolean notEnoughSpace = itemWidth + spacing * 2 > width; float x = spacing; float y = notEnoughSpace ? (getHeight()) : (getHeight() - itemHeight - spacing); for (int i = 0; i < children.size; i++) { Actor child = children.get(i); if (x + itemWidth + spacing > width) { x = spacing; y -= itemHeight + spacing; } child.setBounds(x, y, itemWidth, itemHeight); x += itemWidth + spacing; } }
From source file:com.kotcrab.vis.ui.layout.HorizontalFlowGroup.java
License:Apache License
@Override public void layout() { if (sizeInvalid) { computeSize();/*from ww w . jav a2 s.c om*/ if (lastPrefHeight != prefHeight) { lastPrefHeight = prefHeight; invalidateHierarchy(); } } SnapshotArray<Actor> children = getChildren(); float x = 0; float y = getHeight(); float rowHeight = 0; for (int i = 0; i < children.size; i++) { Actor child = children.get(i); float width = child.getWidth(); float height = child.getHeight(); if (child instanceof Layout) { Layout layout = (Layout) child; width = layout.getPrefWidth(); height = layout.getPrefHeight(); } if (x + width > getWidth()) { x = 0; y -= rowHeight + spacing; rowHeight = height; } else { rowHeight = Math.max(height, rowHeight); } child.setBounds(x, y - height, width, height); x += width + spacing; } }
From source file:com.kotcrab.vis.ui.layout.VerticalFlowGroup.java
License:Apache License
@Override public void layout() { if (sizeInvalid) { computeSize();//from ww w .j av a 2 s. co m if (lastPrefHeight != prefHeight) { lastPrefHeight = prefHeight; invalidateHierarchy(); } } SnapshotArray<Actor> children = getChildren(); float x = 0; float y = getHeight(); float columnWidth = 0; for (int i = 0; i < children.size; i++) { Actor child = children.get(i); float width = child.getWidth(); float height = child.getHeight(); if (child instanceof Layout) { Layout layout = (Layout) child; width = layout.getPrefWidth(); height = layout.getPrefHeight(); } if (y - height < 0) { y = getHeight(); x += columnWidth + spacing; columnWidth = width; } else { columnWidth = Math.max(width, columnWidth); } child.setBounds(x, y - height, width, height); y -= height + spacing; } }
From source file:com.kotcrab.vis.ui.widget.MultiSplitPane.java
License:Apache License
@Override public void layout() { if (!vertical) calculateHorizBoundsAndPositions(); else/*ww w. j a v a 2 s. com*/ calculateVertBoundsAndPositions(); SnapshotArray<Actor> actors = getChildren(); for (int i = 0; i < actors.size; i++) { Actor actor = actors.get(i); Rectangle bounds = widgetBounds.get(i); actor.setBounds(bounds.x, bounds.y, bounds.width, bounds.height); if (actor instanceof Layout) ((Layout) actor).validate(); } }
From source file:com.kotcrab.vis.ui.widget.VisSplitPane.java
License:Apache License
@Override public void layout() { if (!vertical) calculateHorizBoundsAndPositions(); else//from ww w . j av a2s. co m 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(); } }
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); float width, height; if (child instanceof Layout) { Layout layout = (Layout) child; if (fill > 0) height = groupHeight * fill; else/* w w w . ja v a 2 s . c om*/ 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); } }