Java Code Examples for com.badlogic.gdx.scenes.scene2d.utils.Layout#getPrefWidth()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.utils.Layout#getPrefWidth() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TransformScalableWrapper.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
@Override
public float getPrefWidth() {
    if (actor == null) return 0f;

    if (actor instanceof Layout) {
        Layout layout = (Layout) actor;
        return layout.getPrefWidth() * getScaleX();
    } else {
        return origWidth * getScaleX();
    }
}
 
Example 2
Source File: ScalarScalableWrapper.java    From gdx-vfx with Apache License 2.0 5 votes vote down vote up
@Override
public float getPrefWidth() {
    if (actor == null) return 0f;

    if (actor instanceof Layout) {
        Layout layout = (Layout) actor;
        return layout.getPrefWidth() * scaleX;
    } else {
        return origWidth * scaleX;
    }
}
 
Example 3
Source File: FilteredTree.java    From talos with Apache License 2.0 5 votes vote down vote up
private void computeSize (Array<Node<T>> nodes, float indent) {
    float ySpacing = this.ySpacing;
    float spacing = iconSpacingLeft + iconSpacingRight;
    for (int i = 0, n = nodes.size; i < n; i++) {
        Node node = nodes.get(i);

        if (node.filtered)
            continue;

        float rowWidth = indent + iconSpacingRight;
        Actor actor = node.actor;
        if (actor instanceof Layout) {
            Layout layout = (Layout)actor;
            rowWidth += layout.getPrefWidth();
            node.height = layout.getPrefHeight();
            layout.pack();
        } else {
            rowWidth += actor.getWidth();
            node.height = actor.getHeight();
        }
        if (node.icon != null) {
            rowWidth += spacing + node.icon.getMinWidth();
            node.height = Math.max(node.height, node.icon.getMinHeight());
        }
        prefWidth = Math.max(prefWidth, rowWidth);
        prefHeight -= node.height + ySpacing;
        if (node.expanded)
            computeSize(node.children, indent + indentSpacing);
    }
}
 
Example 4
Source File: TransformScalableWrapper.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public float getPrefWidth() {
    if (actor == null) return 0f;

    if (actor instanceof Layout) {
        Layout layout = (Layout) actor;
        return layout.getPrefWidth() * getScaleX();
    } else {
        return origWidth * getScaleX();
    }
}
 
Example 5
Source File: ScalarScalableWrapper.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public float getPrefWidth() {
    if (actor == null) return 0f;

    if (actor instanceof Layout) {
        Layout layout = (Layout) actor;
        return layout.getPrefWidth() * scaleX;
    } else {
        return origWidth * scaleX;
    }
}
 
Example 6
Source File: VerticalFlowGroup.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
private void computeSize () {
	prefWidth = 0;
	prefHeight = getHeight();
	sizeInvalid = false;

	SnapshotArray<Actor> children = getChildren();

	float y = 0;
	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 > getHeight()) {
			y = 0;
			prefWidth += columnWidth + spacing;
			columnWidth = width;
		} else {
			columnWidth = Math.max(width, columnWidth);
		}

		y += height + spacing;
	}

	//handle last column width
	prefWidth += columnWidth + spacing;
}
 
Example 7
Source File: HorizontalFlowGroup.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
private void computeSize () {
	prefWidth = getWidth();
	prefHeight = 0;
	sizeInvalid = false;

	SnapshotArray<Actor> children = getChildren();

	float x = 0;
	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;
			prefHeight += rowHeight + spacing;
			rowHeight = height;
		} else {
			rowHeight = Math.max(height, rowHeight);
		}

		x += width + spacing;
	}

	//handle last row height
	prefHeight += rowHeight + spacing;
}