Search in sources :

Example 11 with VisLabel

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

the class ValueColorBoxProducer method createValuePart.

private GraphBoxPartImpl createValuePart(String value) {
    Color color = Color.valueOf(value);
    final TextureRegionDrawable drawable = new TextureRegionDrawable(WhitePixel.sharedInstance.texture);
    BaseDrawable baseDrawable = new BaseDrawable(drawable) {

        @Override
        public void draw(Batch batch, float x, float y, float width, float height) {
            drawable.draw(batch, x, y, width, height);
        }
    };
    baseDrawable.setMinSize(20, 20);
    final VisImage image = new VisImage(baseDrawable);
    image.setColor(color);
    final ColorPicker picker = new ColorPicker(new ColorPickerAdapter() {

        @Override
        public void finished(Color newColor) {
            image.setColor(newColor);
            image.fire(new GraphChangedEvent(false, true));
        }
    });
    picker.setColor(color);
    image.addListener(new ClickListener(Input.Buttons.LEFT) {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            // displaying picker with fade in animation
            image.getStage().addActor(picker.fadeIn());
        }
    });
    VisTable table = new VisTable();
    table.add(new VisLabel("Color")).growX();
    table.add(image);
    table.row();
    GraphBoxPartImpl colorPart = new GraphBoxPartImpl(table, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(JsonValue object) {
            object.addChild("color", new JsonValue(image.getColor().toString()));
        }
    }) {

        @Override
        public void dispose() {
            picker.dispose();
        }
    };
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("value"));
    return colorPart;
}
Also used : ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) Color(com.badlogic.gdx.graphics.Color) BaseDrawable(com.badlogic.gdx.scenes.scene2d.utils.BaseDrawable) JsonValue(com.badlogic.gdx.utils.JsonValue) TextureRegionDrawable(com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable) VisImage(com.kotcrab.vis.ui.widget.VisImage) VisTable(com.kotcrab.vis.ui.widget.VisTable) Batch(com.badlogic.gdx.graphics.g2d.Batch) VisLabel(com.kotcrab.vis.ui.widget.VisLabel) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 12 with VisLabel

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

the class ValueFloatBoxProducer method createValuePart.

private GraphBoxPartImpl createValuePart(float v1) {
    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));
        }
    });
    HorizontalGroup horizontalGroup = new HorizontalGroup();
    horizontalGroup.addActor(new VisLabel("x"));
    horizontalGroup.addActor(v1Input);
    GraphBoxPartImpl colorPart = new GraphBoxPartImpl(horizontalGroup, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(JsonValue object) {
            float value;
            try {
                value = Float.parseFloat(v1Input.getText());
            } catch (NumberFormatException exp) {
                value = 0f;
            }
            object.addChild("v1", new JsonValue(value));
        }
    });
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("value"));
    return colorPart;
}
Also used : Actor(com.badlogic.gdx.scenes.scene2d.Actor) JsonValue(com.badlogic.gdx.utils.JsonValue) VisLabel(com.kotcrab.vis.ui.widget.VisLabel) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) HorizontalGroup(com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField)

Example 13 with VisLabel

use of com.kotcrab.vis.ui.widget.VisLabel in project vis-ui by kotcrab.

the class TestMultiSplitPane method addVisWidgets.

private void addVisWidgets() {
    VisLabel label = new VisLabel("Label #1");
    VisLabel label2 = new VisLabel("Label #2");
    VisLabel label3 = new VisLabel("Label #3");
    MultiSplitPane splitPane = new MultiSplitPane(vertical);
    splitPane.setWidgets(label, label2, label3);
    add(splitPane).fill().expand();
}
Also used : VisLabel(com.kotcrab.vis.ui.widget.VisLabel) MultiSplitPane(com.kotcrab.vis.ui.widget.MultiSplitPane)

Example 14 with VisLabel

use of com.kotcrab.vis.ui.widget.VisLabel in project vis-ui by kotcrab.

the class TestGenerateDisabledImage method addVisWidgets.

private void addVisWidgets() {
    Drawable icon = VisUI.getSkin().getDrawable("icon-folder");
    VisImageButton normal = new VisImageButton(icon);
    VisImageButton disabled = new VisImageButton(icon);
    disabled.setGenerateDisabledImage(true);
    disabled.setDisabled(true);
    add(new VisLabel("VisImageButton normal"));
    add(normal).row();
    add(new VisLabel("VisImageButton disabled"));
    add(disabled).row();
    VisImageTextButton normalText = new VisImageTextButton("text", icon);
    VisImageTextButton disabledText = new VisImageTextButton("text", icon);
    disabledText.setGenerateDisabledImage(true);
    disabledText.setDisabled(true);
    add(new VisLabel("VisImageTextButton normal"));
    add(normalText).row();
    add(new VisLabel("VisImageTextButton disabled"));
    add(disabledText).padBottom(3f).row();
}
Also used : VisImageButton(com.kotcrab.vis.ui.widget.VisImageButton) VisImageTextButton(com.kotcrab.vis.ui.widget.VisImageTextButton) Drawable(com.badlogic.gdx.scenes.scene2d.utils.Drawable) VisLabel(com.kotcrab.vis.ui.widget.VisLabel)

Example 15 with VisLabel

use of com.kotcrab.vis.ui.widget.VisLabel in project vis-ui by kotcrab.

the class TestSplitPane method addVisWidgets.

private void addVisWidgets() {
    VisLabel label = new VisLabel("Lorem \nipsum \ndolor \nsit \namet");
    VisLabel label2 = new VisLabel("Consectetur \nadipiscing \nelit");
    VisTable table = new VisTable(true);
    VisTable table2 = new VisTable(true);
    table.add(label);
    table2.add(label2);
    VisSplitPane splitPane = new VisSplitPane(table, table2, vertical);
    add(splitPane).fill().expand();
}
Also used : VisSplitPane(com.kotcrab.vis.ui.widget.VisSplitPane) VisTable(com.kotcrab.vis.ui.widget.VisTable) VisLabel(com.kotcrab.vis.ui.widget.VisLabel)

Aggregations

VisLabel (com.kotcrab.vis.ui.widget.VisLabel)28 VisTable (com.kotcrab.vis.ui.widget.VisTable)10 Actor (com.badlogic.gdx.scenes.scene2d.Actor)4 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)4 JsonValue (com.badlogic.gdx.utils.JsonValue)4 VisValidatableTextField (com.kotcrab.vis.ui.widget.VisValidatableTextField)4 HorizontalGroup (com.badlogic.gdx.scenes.scene2d.ui.HorizontalGroup)3 TextureRegionDrawable (com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable)3 VisTextButton (com.kotcrab.vis.ui.widget.VisTextButton)3 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)2 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)2 VisImageButton (com.kotcrab.vis.ui.widget.VisImageButton)2 Color (com.badlogic.gdx.graphics.Color)1 Batch (com.badlogic.gdx.graphics.g2d.Batch)1 TextureAtlas (com.badlogic.gdx.graphics.g2d.TextureAtlas)1 Vector2 (com.badlogic.gdx.math.Vector2)1 TextButton (com.badlogic.gdx.scenes.scene2d.ui.TextButton)1 BaseDrawable (com.badlogic.gdx.scenes.scene2d.utils.BaseDrawable)1 Drawable (com.badlogic.gdx.scenes.scene2d.utils.Drawable)1