Search in sources :

Example 1 with VisSelectBox

use of com.kotcrab.vis.ui.widget.VisSelectBox in project HyperLap2D by rednblackgames.

the class AlternativeAutoTileDialog method initView.

/**
 * Initiates the view of the dialog.
 */
public void initView() {
    clear();
    String[] allAutoTileVOArray = new String[tiledPlugin.dataToSave.getAutoTiles().size];
    int index = 0;
    // add a "none" to the drop down list
    allAutoTileVOArray[index++] = "";
    for (int i = 0; i < tiledPlugin.dataToSave.getAutoTiles().size; i++) {
        AutoTileVO next = tiledPlugin.dataToSave.getAutoTiles().get(i);
        if (!openingAutoTileVO.equals(next)) {
            allAutoTileVOArray[index++] = next.regionName;
        }
    }
    alternativeSelectBoxArray = new VisSelectBox[allAutoTileVOArray.length - 1];
    alternativePercentTextFieldArray = new VisValidatableTextField[allAutoTileVOArray.length + 0];
    VisTable table = new VisTable();
    table.row().padTop(20);
    table.add(getVisImageButton(openingAutoTileVO.regionName)).maxHeight(32);
    // .width(115);
    table.add(StandardWidgetsFactory.createLabel(openingAutoTileVO.regionName, Align.left)).padLeft(5).left();
    alternativePercentTextFieldArray[0] = StandardWidgetsFactory.createValidableTextField(new FloatValidator());
    alternativePercentTextFieldArray[0].setText(openingAutoTileVO.alternativeAutoTileList.get(0, new AlternativeAutoTileVO()).percent.toString());
    table.add(alternativePercentTextFieldArray[0]).padLeft(5).padRight(5).fillX().left();
    table.row();
    for (int i = 0; i < allAutoTileVOArray.length - 1; i++) {
        String region = openingAutoTileVO.alternativeAutoTileList.get(i + 1, new AlternativeAutoTileVO()).region;
        VisImageButton imgButton = getVisImageButton(region);
        table.add(imgButton).maxHeight(32);
        alternativeSelectBoxArray[i] = StandardWidgetsFactory.createSelectBox(String.class);
        alternativeSelectBoxArray[i].setItems(allAutoTileVOArray);
        alternativeSelectBoxArray[i].setSelected(openingAutoTileVO.alternativeAutoTileList.get(i + 1, new AlternativeAutoTileVO()).region);
        alternativeSelectBoxArray[i].addListener(new ChangeListener() {

            @Override
            public void changed(ChangeEvent event, Actor actor) {
                updateVisImageButton(imgButton, ((SelectBox<String>) actor).getSelected());
                pack();
            }
        });
        table.add(alternativeSelectBoxArray[i]).padLeft(5).left();
        alternativePercentTextFieldArray[i + 1] = StandardWidgetsFactory.createValidableTextField(new FloatValidator());
        alternativePercentTextFieldArray[i + 1].setText(openingAutoTileVO.alternativeAutoTileList.get(i + 1, new AlternativeAutoTileVO()).percent.toString());
        table.add(alternativePercentTextFieldArray[i + 1]).padLeft(5).padRight(5).fillX().left();
        table.row().padTop(5).padBottom(5);
    }
    VisTextButton saveButton = StandardWidgetsFactory.createTextButton("Save");
    saveButton.addListener(new ClickListener() {

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);
            tiledPlugin.facade.sendNotification(TiledPlugin.ACTION_SAVE_ALTERNATIVES_AUTO_TILE);
            hide();
        }
    });
    VisTextButton cancelButton = StandardWidgetsFactory.createTextButton("Cancel");
    cancelButton.addListener(new ClickListener() {

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            super.touchUp(event, x, y, pointer, button);
            hide();
        }
    });
    row();
    add(table);
    row();
    add(saveButton).center().padLeft(5).padRight(5);
    add(cancelButton).center().padLeft(5).padRight(5);
    row();
    pack();
}
Also used : VisImageButton(com.kotcrab.vis.ui.widget.VisImageButton) VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) SelectBox(com.badlogic.gdx.scenes.scene2d.ui.SelectBox) VisSelectBox(com.kotcrab.vis.ui.widget.VisSelectBox) AlternativeAutoTileVO(games.rednblack.editor.plugin.tiled.data.AlternativeAutoTileVO) AlternativeAutoTileVO(games.rednblack.editor.plugin.tiled.data.AlternativeAutoTileVO) AutoTileVO(games.rednblack.editor.plugin.tiled.data.AutoTileVO) VisTable(com.kotcrab.vis.ui.widget.VisTable) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) FloatValidator(com.kotcrab.vis.ui.util.Validators.FloatValidator) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 2 with VisSelectBox

use of com.kotcrab.vis.ui.widget.VisSelectBox in project talos by rockbite.

the class GlobalScopeModuleWrapper method addSelectBox.

protected VisSelectBox addSelectBox(Array<String> values) {
    Table slotRow = new Table();
    final VisSelectBox selectBox = new VisSelectBox();
    selectBox.setItems(values);
    selectBox.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            updateFromSelectBox();
        }
    });
    slotRow.add(selectBox).width(50).left().padBottom(4).padLeft(5).padRight(10);
    leftWrapper.add(slotRow).left().expandX();
    leftWrapper.row();
    return selectBox;
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) VisSelectBox(com.kotcrab.vis.ui.widget.VisSelectBox)

Example 3 with VisSelectBox

use of com.kotcrab.vis.ui.widget.VisSelectBox 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)

Example 4 with VisSelectBox

use of com.kotcrab.vis.ui.widget.VisSelectBox in project gdx-graph by MarcinSc.

the class RemapValueShaderBoxProducer method createPipelineGraphBox.

@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
    GraphBoxImpl result = createGraphBox(id);
    addConfigurationInputsAndOutputs(result);
    final CurveWidget curveWidget = new CurveWidget(skin);
    if (data != null) {
        JsonValue points = data.get("points");
        for (String point : points.asStringArray()) {
            String[] split = point.split(",");
            curveWidget.createPoint(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
        }
    } else {
        curveWidget.createPoint(0, 0);
    }
    curveWidget.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            curveWidget.fire(new GraphChangedEvent(false, true));
        }
    });
    curveWidget.setSize(300, 200);
    result.addGraphBoxPart(new GraphBoxPartImpl(curveWidget, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(JsonValue object) {
            Array<Vector2> points = curveWidget.getPoints();
            JsonValue pointsValue = new JsonValue(JsonValue.ValueType.array);
            for (Vector2 point : points) {
                pointsValue.addChild(new JsonValue(SimpleNumberFormatter.format(point.x) + "," + SimpleNumberFormatter.format(point.y)));
            }
            object.addChild("points", pointsValue);
        }
    }));
    final VisSelectBox<ClampMethod> clampMethodSelectBox = new VisSelectBox<ClampMethod>();
    clampMethodSelectBox.setItems(ClampMethod.values());
    if (data != null)
        clampMethodSelectBox.setSelected(ClampMethod.valueOf(data.getString("clamp", "Normal")));
    clampMethodSelectBox.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            clampMethodSelectBox.fire(new GraphChangedEvent(false, true));
        }
    });
    VisTable clampActor = new VisTable();
    clampActor.add("Clamp method:").row();
    clampActor.add(clampMethodSelectBox).growX();
    result.addGraphBoxPart(new GraphBoxPartImpl(clampActor, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(JsonValue object) {
            object.addChild("clamp", new JsonValue(clampMethodSelectBox.getSelected().name()));
        }
    }));
    return result;
}
Also used : CurveWidget(com.talosvfx.talos.editor.widgets.CurveWidget) GraphBoxImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl) GraphChangedEvent(com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent) JsonValue(com.badlogic.gdx.utils.JsonValue) GraphBoxPartImpl(com.gempukku.libgdx.graph.ui.graph.GraphBoxPartImpl) VisSelectBox(com.kotcrab.vis.ui.widget.VisSelectBox) VisTable(com.kotcrab.vis.ui.widget.VisTable) Vector2(com.badlogic.gdx.math.Vector2) ClampMethod(com.gempukku.libgdx.graph.shader.ClampMethod) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)

Example 5 with VisSelectBox

use of com.kotcrab.vis.ui.widget.VisSelectBox in project gdx-graph by MarcinSc.

the class RemapVectorShaderBoxProducer method createSelectBox.

private VisSelectBox<String> createSelectBox(String defaultValue) {
    final VisSelectBox<String> result = new VisSelectBox<String>();
    result.setItems("0.0", "1.0", "X", "Y", "Z", "W");
    result.setSelected(defaultValue);
    result.setAlignment(Align.right);
    result.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            result.fire(new GraphChangedEvent(false, true));
        }
    });
    return result;
}
Also used : GraphChangedEvent(com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent) 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)7 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)7 VisSelectBox (com.kotcrab.vis.ui.widget.VisSelectBox)7 GraphChangedEvent (com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent)3 VisTable (com.kotcrab.vis.ui.widget.VisTable)3 JsonValue (com.badlogic.gdx.utils.JsonValue)2 ClampMethod (com.gempukku.libgdx.graph.shader.ClampMethod)2 GraphBoxImpl (com.gempukku.libgdx.graph.ui.graph.GraphBoxImpl)2 GraphBoxPartImpl (com.gempukku.libgdx.graph.ui.graph.GraphBoxPartImpl)2 Color (com.badlogic.gdx.graphics.Color)1 Vector2 (com.badlogic.gdx.math.Vector2)1 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)1 SelectBox (com.badlogic.gdx.scenes.scene2d.ui.SelectBox)1 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)1 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)1 Array (com.badlogic.gdx.utils.Array)1 FloatValidator (com.kotcrab.vis.ui.util.Validators.FloatValidator)1 VisImageButton (com.kotcrab.vis.ui.widget.VisImageButton)1 VisTextButton (com.kotcrab.vis.ui.widget.VisTextButton)1 ColorPicker (com.kotcrab.vis.ui.widget.color.ColorPicker)1