Search in sources :

Example 1 with VisTextField

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

the class TagsPanel method updateView.

public void updateView() {
    mainTable.clear();
    tagTable = new VisTable();
    VisTable inputTable = new VisTable();
    List<String> sorted = new LinkedList<>(tags);
    Collections.sort(sorted);
    for (String tag : sorted) {
        tagTable.add(new TagItem(tag, tagItemListener)).pad(5).left().expandX().fillX();
        tagTable.row();
    }
    VisTextField newTagField = StandardWidgetsFactory.createTextField();
    VisTextButton createTagBtn = new VisTextButton("add");
    inputTable.add(newTagField).width(200);
    inputTable.add(createTagBtn).padLeft(5);
    createTagBtn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            String tag = newTagField.getText();
            if (!tagExists(tag)) {
                newTagField.setText("");
                addTag(tag);
                facade.sendNotification(ITEM_ADD, tag);
            }
        }
    });
    mainTable.add(inputTable);
    mainTable.row();
    mainTable.add(tagTable).expandX().fillX();
    invalidateHeight();
}
Also used : VisTextField(com.kotcrab.vis.ui.widget.VisTextField) VisTextButton(com.kotcrab.vis.ui.widget.VisTextButton) VisTable(com.kotcrab.vis.ui.widget.VisTable) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 2 with VisTextField

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

the class BasicColorPicker method createHexTable.

private VisTable createHexTable() {
    VisTable table = new VisTable(true);
    table.add(new VisLabel(HEX.get()));
    table.add(hexField = new VisValidatableTextField("00000000")).width(HEX_FIELD_WIDTH * sizes.scaleFactor);
    table.row();
    hexField.setMaxLength(HEX_COLOR_LENGTH);
    hexField.setProgrammaticChangeEvents(false);
    hexField.setTextFieldFilter(new TextFieldFilter() {

        @Override
        public boolean acceptChar(VisTextField textField, char c) {
            return Character.isDigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F');
        }
    });
    hexField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            if (hexField.getText().length() == (allowAlphaEdit ? HEX_COLOR_LENGTH_WITH_ALPHA : HEX_COLOR_LENGTH)) {
                setColor(Color.valueOf(hexField.getText()), false);
            }
        }
    });
    return table;
}
Also used : VisTextField(com.kotcrab.vis.ui.widget.VisTextField) VisTable(com.kotcrab.vis.ui.widget.VisTable) Actor(com.badlogic.gdx.scenes.scene2d.Actor) TextFieldFilter(com.kotcrab.vis.ui.widget.VisTextField.TextFieldFilter) VisLabel(com.kotcrab.vis.ui.widget.VisLabel) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) VisValidatableTextField(com.kotcrab.vis.ui.widget.VisValidatableTextField)

Example 3 with VisTextField

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

the class UILayerBox method addItem.

public void addItem(LayerItemVO itemVO) {
    UILayerItemSlot itemSlot = new UILayerItemSlot();
    UILayerItem item = new UILayerItem(itemVO, itemSlot);
    layersTable.add(itemSlot).left().expandX().fillX();
    layersTable.row().padTop(1);
    SlotSource sourceItem = new SlotSource(item, this);
    dragAndDrop.addSource(sourceItem);
    dragAndDrop.addTarget(new SlotTarget(itemSlot));
    dragAndDrop.setDragActorPosition(0, 0);
    rows.add(itemSlot);
    itemSlot.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            VisTextField textField = itemSlot.getUiLayerItem().getNameField();
            if (sourceInEdition != null) {
                VisTextField prevField = sourceInEdition.getActor().getNameField();
                if (textField != prevField) {
                    prevField.clearSelection();
                    prevField.setDisabled(true);
                    enableDraggingInEditedSlot();
                }
            }
            clearSelection();
            itemSlot.getUiLayerItem().setSelected(true);
            currentSelectedLayerIndex = rows.size - rows.indexOf(itemSlot, true) - 1;
            facade.sendNotification(LAYER_ROW_CLICKED, itemSlot.getUiLayerItem());
            // Change name mode on double click.
            if (getTapCount() == 2 && !itemSlot.getUiLayerItem().getData().isLocked && sourceInEdition == null) {
                sourceInEdition = sourceItem;
                textField.setDisabled(false);
                textField.focusField();
                textField.selectAll();
                disableDraggingInEditedSlot();
            }
        }
    });
}
Also used : VisTextField(com.kotcrab.vis.ui.widget.VisTextField) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 4 with VisTextField

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

the class UIResourcesTab method createTextField.

protected VisTextField createTextField() {
    VisTextField visTextField = StandardWidgetsFactory.createTextField();
    visTextField.setMessageText(getTabTitle());
    visTextField.setTextFieldListener(new VisTextField.TextFieldListener() {

        @Override
        public void keyTyped(VisTextField textField, char c) {
            searchString = textField.getText();
            HyperLap2DFacade facade = HyperLap2DFacade.getInstance();
            facade.sendNotification(MsgAPI.UPDATE_RESOURCES_LIST);
        }
    });
    return visTextField;
}
Also used : VisTextField(com.kotcrab.vis.ui.widget.VisTextField) HyperLap2DFacade(games.rednblack.editor.HyperLap2DFacade)

Aggregations

VisTextField (com.kotcrab.vis.ui.widget.VisTextField)4 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)2 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)2 VisTable (com.kotcrab.vis.ui.widget.VisTable)2 Actor (com.badlogic.gdx.scenes.scene2d.Actor)1 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)1 VisLabel (com.kotcrab.vis.ui.widget.VisLabel)1 VisTextButton (com.kotcrab.vis.ui.widget.VisTextButton)1 TextFieldFilter (com.kotcrab.vis.ui.widget.VisTextField.TextFieldFilter)1 VisValidatableTextField (com.kotcrab.vis.ui.widget.VisValidatableTextField)1 HyperLap2DFacade (games.rednblack.editor.HyperLap2DFacade)1