public Target (Actor actor) { if (actor == null) throw new IllegalArgumentException("actor cannot be null."); this.actor = actor; Stage stage = actor.getStage(); if (stage != null && actor == stage.getRoot()) throw new IllegalArgumentException("The stage root cannot be a drag and drop target."); }
public Target (Actor actor) { if (actor == null) throw new IllegalArgumentException("actor cannot be null."); this.actor = actor; Stage stage = actor.getStage(); if (stage != null && actor == stage.getRoot()) throw new IllegalArgumentException("The stage root cannot be a drag and drop target."); }
private void focusChanged (FocusEvent event) { Stage stage = getStage(); if (isModal && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this) && !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus))) event.cancel(); } } };
private void focusChanged (FocusEvent event) { Stage stage = getStage(); if (isModal && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this) && !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus))) event.cancel(); } } };
@Override public void create () { texture = new Texture(Gdx.files.internal("data/badlogicsmall.jpg")); stage = new Stage(); for (int i = 0; i < 100; i++) { Image img = new Image(new TextureRegion(texture)); img.setX((float)Math.random() * 480); img.setY((float)Math.random() * 320); img.getColor().a = (float)Math.random() * 0.5f + 0.5f; stage.addActor(img); } stage.getRoot().addAction(forever(sequence(fadeOut(3), fadeIn(3)))); }
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(); }
float minHeight = getMinHeight(), maxHeight = getMaxHeight(); Stage stage = getStage(); boolean clampPosition = keepWithinStage && getParent() == stage.getRoot();
float minHeight = getMinHeight(), maxHeight = getMaxHeight(); Stage stage = getStage(); boolean clampPosition = keepWithinStage && getParent() == stage.getRoot();
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(); }
float parentWidth, parentHeight; Stage stage = getStage(); if (stage != null && parent == stage.getRoot()) { parentWidth = stage.getWidth(); parentHeight = stage.getHeight();
float parentWidth, parentHeight; Stage stage = getStage(); if (stage != null && parent == stage.getRoot()) { parentWidth = stage.getWidth(); parentHeight = stage.getHeight();
public void keepWithinStage () { if (!keepWithinStage) return; Stage stage = getStage(); if (stage == null) return; 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()); } }
public void keepWithinStage () { if (!keepWithinStage) return; Stage stage = getStage(); if (stage == null) return; 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()); } }
stage.act(Gdx.graphics.getDeltaTime()); stage.getBatch().disableBlending(); Group root = stage.getRoot(); Array<Actor> actors = root.getChildren();
public Target (Actor actor) { if (actor == null) throw new IllegalArgumentException("actor cannot be null."); this.actor = actor; Stage stage = actor.getStage(); if (stage != null && actor == stage.getRoot()) throw new IllegalArgumentException("The stage root cannot be a drag and drop target."); }
public void setStage(Stage stage) { this.stage = stage; screenHeight = (int) stage.getHeight(); ignoreFocusChangeActorsList = new HashSet<String>(); addFocusChangedListenerToStage(); initialYCoordinateMap.clear(); for(Actor actor : stage.getRoot().getChildren()) { initialYCoordinateMap.put(actor, actor.getY()); } }
private void focusChanged (FocusEvent event) { Stage stage = getStage(); if (isModal && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this) && !(newFocusedActor.equals(previousKeyboardFocus) || newFocusedActor.equals(previousScrollFocus))) event.cancel(); } } };
private void focusChanged (FocusEvent event) { Stage stage = getStage(); if (isModal && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == Dialog.this) { // Dialog is top most actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(Dialog.this)) event.cancel(); } } });
private void focusChanged (FocusEvent event) { Stage stage = getStage(); if (isModal() && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == VisDialog.this) { // Dialog is top most actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(VisDialog.this)) event.cancel(); } } };
@Override public void expandGuiComponent(String name) { IGui gui = GaiaSky.instance.mainGui; ControlsWindow controls = (ControlsWindow) gui.getGuiStage().getRoot() .findActor(I18n.bundle.get("gui.controlpanel")); controls.getCollapsiblePane(name).expandPane(); }