use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class TextField method next.
/** Focuses the next TextField. If none is found, the keyboard is hidden. Does nothing if the text field is not in a stage.
* @param up If true, the TextField with the same or next smallest y coordinate is found, else the next highest. */
public void next(boolean up) {
Stage stage = getStage();
if (stage == null)
return;
TextField current = this;
while (true) {
current.getParent().localToStageCoordinates(tmp1.set(getX(), getY()));
TextField textField = current.findNextTextField(stage.getActors(), null, tmp2, tmp1, up);
if (textField == null) {
// Try to wrap around.
if (up)
tmp1.set(Float.MIN_VALUE, Float.MIN_VALUE);
else
tmp1.set(Float.MAX_VALUE, Float.MAX_VALUE);
textField = current.findNextTextField(getStage().getActors(), null, tmp2, tmp1, up);
}
if (textField == null) {
Gdx.input.setOnscreenKeyboardVisible(false);
break;
}
if (stage.setKeyboardFocus(textField))
break;
current = textField;
}
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class Widget method validate.
public void validate() {
if (!layoutEnabled)
return;
Group parent = getParent();
if (fillParent && parent != null) {
float parentWidth, parentHeight;
Stage stage = getStage();
if (stage != null && parent == stage.getRoot()) {
parentWidth = stage.getWidth();
parentHeight = stage.getHeight();
} else {
parentWidth = parent.getWidth();
parentHeight = parent.getHeight();
}
setSize(parentWidth, parentHeight);
}
if (!needsLayout)
return;
needsLayout = false;
layout();
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class WidgetGroup method validate.
public void validate() {
if (!layoutEnabled)
return;
Group parent = getParent();
if (fillParent && parent != null) {
float parentWidth, parentHeight;
Stage stage = getStage();
if (stage != null && parent == stage.getRoot()) {
parentWidth = stage.getWidth();
parentHeight = stage.getHeight();
} else {
parentWidth = parent.getWidth();
parentHeight = parent.getHeight();
}
if (getWidth() != parentWidth || getHeight() != parentHeight) {
setWidth(parentWidth);
setHeight(parentHeight);
invalidate();
}
}
if (!needsLayout)
return;
needsLayout = false;
layout();
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class Window method keepWithinStage.
void keepWithinStage() {
if (!keepWithinStage)
return;
Stage stage = getStage();
Camera camera = stage.getCamera();
if (camera instanceof OrthographicCamera) {
OrthographicCamera orthographicCamera = (OrthographicCamera) camera;
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom, getY(Align.right), Align.right);
if (getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom)
setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom, getY(Align.left), Align.left);
if (getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.top), camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top);
if (getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom)
setPosition(getX(Align.bottom), camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom);
} else if (getParent() == stage.getRoot()) {
float parentWidth = stage.getWidth();
float parentHeight = stage.getHeight();
if (getX() < 0)
setX(0);
if (getRight() > parentWidth)
setX(parentWidth - getWidth());
if (getY() < 0)
setY(0);
if (getTop() > parentHeight)
setY(parentHeight - getHeight());
}
}
use of com.badlogic.gdx.scenes.scene2d.Stage in project libgdx by libgdx.
the class DragNDropTest method create.
@Override
public void create() {
BufferedImage image = new BufferedImage(10, 10, BufferedImage.TYPE_4BYTE_ABGR);
stage = new Stage();
skin = new Skin(Gdx.files.internal("data/uiskin.json"));
Gdx.input.setInputProcessor(stage);
root = new Table();
root.setFillParent(true);
root.align(Align.left | Align.top);
stage.addActor(root);
}
Aggregations