Search in sources :

Example 1 with VisValidatableTextField

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

the class ValueFloatBoxProducer method createValuePart.

private GraphBoxPartImpl<T> createValuePart(Skin skin, float v1) {
    final VisValidatableTextField v1Input = new VisValidatableTextField(Validators.FLOATS) {

        @Override
        public float getPrefWidth() {
            return 80;
        }
    };
    v1Input.setText(String.valueOf(v1));
    v1Input.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            v1Input.fire(new GraphChangedEvent(false, true));
        }
    });
    HorizontalGroup horizontalGroup = new HorizontalGroup();
    horizontalGroup.addActor(new Label("Value: ", skin));
    horizontalGroup.addActor(v1Input);
    GraphBoxPartImpl<T> colorPart = new GraphBoxPartImpl<T>(horizontalGroup, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(Map<String, String> object) {
            object.put("v1", v1Input.getText());
        }
    });
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("value"));
    return colorPart;
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Example 2 with VisValidatableTextField

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

the class ValueParamBoxProducer method createValuePart.

private GraphBoxPartImpl<T> createValuePart(Skin skin, String name) {
    final VisValidatableTextField v1Input = new VisValidatableTextField(new StringNameValidator()) {

        @Override
        public float getPrefWidth() {
            return 80;
        }
    };
    v1Input.setText(name);
    v1Input.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            v1Input.fire(new GraphChangedEvent(false, true));
        }
    });
    HorizontalGroup horizontalGroup = new HorizontalGroup();
    horizontalGroup.addActor(new Label("Name: ", skin));
    horizontalGroup.addActor(v1Input);
    GraphBoxPartImpl<T> colorPart = new GraphBoxPartImpl<T>(horizontalGroup, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(Map<String, String> object) {
            object.put("v", v1Input.getText());
        }
    });
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("value"));
    return colorPart;
}
Also used : StringNameValidator(games.rednblack.editor.view.ui.validator.StringNameValidator) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Example 3 with VisValidatableTextField

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

the class ValueVector2BoxProducer method createValuePart.

private GraphBoxPartImpl<T> createValuePart(Skin skin, float v1, float v2) {
    final VisValidatableTextField v1Input = new VisValidatableTextField(Validators.FLOATS) {

        @Override
        public float getPrefWidth() {
            return 50;
        }
    };
    v1Input.setText(String.valueOf(v1));
    v1Input.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            v1Input.fire(new GraphChangedEvent(false, true));
        }
    });
    final VisValidatableTextField v2Input = new VisValidatableTextField(Validators.FLOATS) {

        @Override
        public float getPrefWidth() {
            return 50;
        }
    };
    v2Input.setText(String.valueOf(v2));
    v2Input.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            v2Input.fire(new GraphChangedEvent(false, true));
        }
    });
    HorizontalGroup horizontalGroup = new HorizontalGroup();
    horizontalGroup.addActor(new Label("X: ", skin));
    horizontalGroup.addActor(v1Input);
    horizontalGroup.addActor(new Label(" Y: ", skin));
    horizontalGroup.addActor(v2Input);
    GraphBoxPartImpl<T> colorPart = new GraphBoxPartImpl<T>(horizontalGroup, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(Map<String, String> object) {
            object.put("v1", v1Input.getText());
            object.put("v2", v2Input.getText());
        }
    });
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("value"));
    return colorPart;
}
Also used : Label(com.badlogic.gdx.scenes.scene2d.ui.Label) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Example 4 with VisValidatableTextField

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

the class EventActionBoxProducer method createValuePart.

private GraphBoxPartImpl<T> createValuePart(Skin skin, String name) {
    final VisValidatableTextField v1Input = new VisValidatableTextField(new StringNameValidator()) {

        @Override
        public float getPrefWidth() {
            return 80;
        }
    };
    v1Input.setText(name);
    v1Input.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            v1Input.fire(new GraphChangedEvent(false, true));
        }
    });
    HorizontalGroup horizontalGroup = new HorizontalGroup();
    horizontalGroup.addActor(new Label("Name: ", skin));
    horizontalGroup.addActor(v1Input);
    GraphBoxPartImpl<T> colorPart = new GraphBoxPartImpl<T>(horizontalGroup, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(Map<String, String> object) {
            object.put("v", v1Input.getText());
        }
    });
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("action"));
    return colorPart;
}
Also used : StringNameValidator(games.rednblack.editor.view.ui.validator.StringNameValidator) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField) Actor(com.badlogic.gdx.scenes.scene2d.Actor) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)

Example 5 with VisValidatableTextField

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

the class Vector4BoxPart method createInput.

private VisValidatableTextField createInput(InputValidator inputValidator, float defaultValue) {
    final VisValidatableTextField result;
    if (inputValidator != null) {
        result = new VisValidatableTextField(Validators.FLOATS, inputValidator) {

            @Override
            public float getPrefWidth() {
                return 50;
            }
        };
    } else
        result = new VisValidatableTextField(Validators.FLOATS) {

            @Override
            public float getPrefWidth() {
                return 50;
            }
        };
    result.setText(String.valueOf(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) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField)

Aggregations

VisValidatableTextField (com.kotcrab.vis.ui.widget.VisValidatableTextField)15 Actor (com.badlogic.gdx.scenes.scene2d.Actor)11 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)11 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)7 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)4 VisLabel (com.kotcrab.vis.ui.widget.VisLabel)4 JsonValue (com.badlogic.gdx.utils.JsonValue)3 GraphChangedEvent (com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent)3 StringNameValidator (games.rednblack.editor.view.ui.validator.StringNameValidator)2 InputValidator (com.kotcrab.vis.ui.util.InputValidator)1 IntDigitsOnlyFilter (com.kotcrab.vis.ui.util.IntDigitsOnlyFilter)1 VisTable (com.kotcrab.vis.ui.widget.VisTable)1 VisTextField (com.kotcrab.vis.ui.widget.VisTextField)1 TextFieldFilter (com.kotcrab.vis.ui.widget.VisTextField.TextFieldFilter)1