Example usage for com.badlogic.gdx.scenes.scene2d Actor getTop

List of usage examples for com.badlogic.gdx.scenes.scene2d Actor getTop

Introduction

In this page you can find the example usage for com.badlogic.gdx.scenes.scene2d Actor getTop.

Prototype

public float getTop() 

Source Link

Document

Returns y plus height.

Usage

From source file:com.kotcrab.vis.ui.util.ActorUtils.java

License:Apache License

/**
 * Makes sures that actor will be fully visible in stage. If it's necessary actor position will be changed to fit it
 * on screen.//from   w w  w.  j a  v  a2 s .  c o m
 */
public static void keepWithinStage(Stage stage, Actor actor) {
    //taken from scene2d.ui Window
    Camera camera = stage.getCamera();
    if (camera instanceof OrthographicCamera) {
        OrthographicCamera orthographicCamera = (OrthographicCamera) camera;
        float parentWidth = stage.getWidth();
        float parentHeight = stage.getHeight();
        if (actor.getX(Align.right) - camera.position.x > parentWidth / 2 / orthographicCamera.zoom)
            actor.setPosition(camera.position.x + parentWidth / 2 / orthographicCamera.zoom,
                    actor.getY(Align.right), Align.right);
        if (actor.getX(Align.left) - camera.position.x < -parentWidth / 2 / orthographicCamera.zoom)
            actor.setPosition(camera.position.x - parentWidth / 2 / orthographicCamera.zoom,
                    actor.getY(Align.left), Align.left);
        if (actor.getY(Align.top) - camera.position.y > parentHeight / 2 / orthographicCamera.zoom)
            actor.setPosition(actor.getX(Align.top),
                    camera.position.y + parentHeight / 2 / orthographicCamera.zoom, Align.top);
        if (actor.getY(Align.bottom) - camera.position.y < -parentHeight / 2 / orthographicCamera.zoom)
            actor.setPosition(actor.getX(Align.bottom),
                    camera.position.y - parentHeight / 2 / orthographicCamera.zoom, Align.bottom);
    } else if (actor.getParent() == stage.getRoot()) {
        float parentWidth = stage.getWidth();
        float parentHeight = stage.getHeight();
        if (actor.getX() < 0)
            actor.setX(0);
        if (actor.getRight() > parentWidth)
            actor.setX(parentWidth - actor.getWidth());
        if (actor.getY() < 0)
            actor.setY(0);
        if (actor.getTop() > parentHeight)
            actor.setY(parentHeight - actor.getHeight());
    }
}

From source file:es.eucm.ead.editor.view.widgets.layouts.LinearGallery.java

License:Open Source License

private boolean isVisible(Actor actor, float cx, float cy) {
    return (cx > actor.getX() && cx <= actor.getRight() && cy > actor.getY() && cy <= actor.getTop());
}

From source file:net.mwplay.cocostudio.ui.parser.group.CCScrollView.java

License:Apache License

@Override
public Group groupChildrenParse(CocoStudioUIEditor editor, ObjectData widget, Group parent, Actor actor) {
    ScrollPane scrollPane = (ScrollPane) actor;
    Table table = new Table();
    for (ObjectData childrenWidget : widget.getChildren()) {
        Actor childrenActor = editor.parseWidget(table, childrenWidget);
        if (childrenActor == null) {
            continue;
        }/*from  w ww .  j  a  va  2  s . c o m*/

        table.setSize(Math.max(table.getWidth(), childrenActor.getRight()),
                Math.max(table.getHeight(), childrenActor.getTop()));
        table.addActor(childrenActor);
    }
    sort(widget, table);
    //

    scrollPane.setWidget(table);

    return scrollPane;
}

From source file:net.mwplay.cocostudio.ui.widget.TImage.java

License:Apache License

public TImage toTopOf(Actor actor) {
    setPosition(actor.getX(), actor.getTop());
    return this;
}

From source file:net.mwplay.cocostudio.ui.widget.TImage.java

License:Apache License

public TImage toLeftTopOf(Actor actor) {
    setPosition(actor.getX() - getWidth(), actor.getTop());
    return this;
}