Java Code Examples for com.badlogic.gdx.scenes.scene2d.Actor#setBounds()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.Actor#setBounds() . 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: BoundsLmlAttribute.java    From gdx-vfx with Apache License 2.0 6 votes vote down vote up
@Override
public void process(final LmlParser parser, final LmlTag tag, final Actor actor, final String rawAttributeData) {
    String[] values = parser.parseArray(rawAttributeData, actor);
    if (values.length != 4) {
        parser.throwError("There must be exactly 4 values in the array");
    }
    try {
        actor.setBounds(
                Float.parseFloat(values[0]),
                Float.parseFloat(values[1]),
                Float.parseFloat(values[2]),
                Float.parseFloat(values[3]));
    } catch (NumberFormatException e) {
        parser.throwError("Can't read bounds values from the array.", e);
    }
}
 
Example 2
Source File: MundusSplitPane.java    From Mundus with Apache License 2.0 6 votes vote down vote up
@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();
    }
}
 
Example 3
Source File: VisSplitPane.java    From vis-ui with Apache License 2.0 6 votes vote down vote up
@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();
	}
}
 
Example 4
Source File: MundusMultiSplitPane.java    From Mundus with Apache License 2.0 5 votes vote down vote up
@Override
public void layout() {
    if (!vertical)
        calculateHorizBoundsAndPositions();
    else
        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();
    }
}
 
Example 5
Source File: MultiSplitPane.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void layout () {
	if (!vertical)
		calculateHorizBoundsAndPositions();
	else
		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();
	}
}
 
Example 6
Source File: GridGroup.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void layout () {
	if (sizeInvalid) {
		computeSize();
		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;
	}
}