Search in sources :

Example 1 with Expression

use of com.talosvfx.talos.runtime.Expression in project talos by rockbite.

the class MathModuleWrapper method configureSlots.

@Override
protected void configureSlots() {
    Array<String> mathsExpressions = new Array<>();
    MathExpressionMappings.getAvailableMathExpressions(mathsExpressions);
    selectBox = new VisSelectBox();
    selectBox.setItems(mathsExpressions);
    aField = addInputSlotWithTextField("A: ", MathModule.A);
    leftWrapper.add(selectBox).left().expandX().pad(5).padLeft(17).row();
    bField = addInputSlotWithTextField("B: ", MathModule.B);
    aField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            float a = floatFromText(aField);
            module.setA(a);
        }
    });
    bField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            float b = floatFromText(bField);
            module.setB(b);
        }
    });
    addOutputSlot("result", 0);
    selectBox.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            String selectedString = selectBox.getSelected();
            Expression expression = MathExpressionMappings.getMathExpressionForName(selectedString);
            module.setExpression(expression);
        }
    });
}
Also used : Array(com.badlogic.gdx.utils.Array) Expression(com.talosvfx.talos.runtime.Expression) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) VisSelectBox(com.kotcrab.vis.ui.widget.VisSelectBox)

Aggregations

Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)1 Array (com.badlogic.gdx.utils.Array)1 VisSelectBox (com.kotcrab.vis.ui.widget.VisSelectBox)1 Expression (com.talosvfx.talos.runtime.Expression)1