Search in sources :

Example 1 with IGui

use of gaiasky.interafce.IGui in project gaiasky by langurmonkey.

the class EventScriptingInterface method getPositionAndSizeGui.

@Override
public float[] getPositionAndSizeGui(String name) {
    IGui gui = GaiaSky.instance.mainGui;
    Actor actor = gui.getGuiStage().getRoot().findActor(name);
    if (actor != null) {
        float x = actor.getX();
        float y = actor.getY();
        // x and y relative to parent, so we need to add coordinates of
        // parents up to top
        Group parent = actor.getParent();
        while (parent != null) {
            x += parent.getX();
            y += parent.getY();
            parent = parent.getParent();
        }
        return new float[] { x, y, actor.getWidth(), actor.getHeight() };
    } else {
        return null;
    }
}
Also used : IGui(gaiasky.interafce.IGui) Group(com.badlogic.gdx.scenes.scene2d.Group) Actor(com.badlogic.gdx.scenes.scene2d.Actor)

Aggregations

Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 Group (com.badlogic.gdx.scenes.scene2d.Group)1 IGui (gaiasky.interafce.IGui)1