Search in sources :

Example 6 with ColorPickerAdapter

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

the class ColorPropertyWidget method getSubWidget.

@Override
public Actor getSubWidget() {
    Skin skin = TalosMain.Instance().getSkin();
    box = new Image(skin.newDrawable(ColorLibrary.SHAPE_SQUARE));
    box.setSize(20, 20);
    box.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {

                @Override
                public void changed(Color newColor) {
                    super.changed(newColor);
                    box.setColor(newColor);
                    callValueChanged(box.getColor());
                }
            });
        }
    });
    return box;
}
Also used : Color(com.badlogic.gdx.graphics.Color) Skin(com.badlogic.gdx.scenes.scene2d.ui.Skin) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 7 with ColorPickerAdapter

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

the class GradientColorModuleWrapper method configureSlots.

@Override
protected void configureSlots() {
    addInputSlot("alpha (0 to 1)", InterpolationModule.ALPHA);
    addOutputSlot("output", 0);
    gradientWidget = new GradientWidget(getSkin());
    contentWrapper.add(gradientWidget).expandX().fillX().growX().height(60).padTop(25).padRight(3).padBottom(3);
    leftWrapper.add(new Table()).expandY();
    rightWrapper.add(new Table()).expandY();
    picker = new ColorPicker();
    gradientWidget.setListener(new GradientWidget.GradientWidgetListener() {

        @Override
        public void colorPickerShow(final ColorPoint point) {
            picker.setListener(null);
            picker.setColor(point.color);
            TalosMain.Instance().UIStage().getStage().addActor(picker.fadeIn());
            picker.setListener(new ColorPickerAdapter() {

                @Override
                public void changed(Color newColor) {
                    super.changed(newColor);
                    point.color.set(newColor);
                    gradientWidget.updateGradientData();
                }
            });
        }
    });
    picker.padTop(32);
    picker.padLeft(16);
    picker.setHeight(330);
    picker.setWidth(430);
    picker.padRight(26);
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) GradientWidget(com.talosvfx.talos.editor.widgets.GradientWidget) ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) ColorPoint(com.talosvfx.talos.runtime.values.ColorPoint) Color(com.badlogic.gdx.graphics.Color) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter)

Example 8 with ColorPickerAdapter

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

the class ColorModuleWrapper method configureSlots.

@Override
protected void configureSlots() {
    rField = addInputSlotWithTextField("R: ", 0, 40);
    gField = addInputSlotWithTextField("G: ", 1, 40);
    bField = addInputSlotWithTextField("B: ", 2, 40);
    rField.setText("255");
    gField.setText("0");
    bField.setText("0");
    rField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            float r = floatFromText(rField);
            module.setR(r / 255f);
            update();
        }
    });
    gField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            float g = floatFromText(gField);
            module.setG(g / 255f);
            update();
        }
    });
    bField.addListener(new ChangeListener() {

        @Override
        public void changed(ChangeEvent event, Actor actor) {
            float b = floatFromText(bField);
            module.setB(b / 255f);
            update();
        }
    });
    addOutputSlot("position", 0);
    picker = new ColorPicker(new ColorPickerAdapter() {

        @Override
        public void changed(Color newColor) {
            if (colorBtn != null) {
                colorBtn.setColor(newColor);
                rField.setText("" + (int) (newColor.r * 255f));
                gField.setText("" + (int) (newColor.g * 255f));
                bField.setText("" + (int) (newColor.b * 255f));
                module.setR(newColor.r);
                module.setG(newColor.g);
                module.setB(newColor.b);
            }
        }
    });
    // create color picker Btn
    colorBtn = new Image(getSkin().getDrawable("white"));
    contentWrapper.add(colorBtn).width(50).height(50).right().padLeft(26);
    colorBtn.setColor(1f, 0, 0, 1f);
    colorBtn.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            TalosMain.Instance().UIStage().getStage().addActor(picker.fadeIn());
        }
    });
    picker.padTop(32);
    picker.padLeft(16);
    picker.setHeight(330);
    picker.setWidth(430);
    picker.padRight(26);
}
Also used : ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) Actor(com.badlogic.gdx.scenes.scene2d.Actor) Color(com.badlogic.gdx.graphics.Color) ChangeListener(com.badlogic.gdx.scenes.scene2d.utils.ChangeListener) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 9 with ColorPickerAdapter

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

the class NodeGroup method init.

public void init(Skin skin) {
    this.skin = skin;
    frameImage = new Image(skin.getDrawable("group_frame"));
    frameImage.setColor(44 / 255f, 140 / 255f, 209 / 255f, 1f);
    addActor(frameImage);
    topHit = new Actor();
    topHit.setTouchable(Touchable.enabled);
    addActor(topHit);
    title = new EditableLabel("GROUP NAME", skin);
    addActor(title);
    settings = new ImageButton(skin, "settings");
    settings.setSize(25, 25);
    addActor(settings);
    settings.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            final Vector2 vec = new Vector2(Gdx.input.getX(), Gdx.input.getY());
            (TalosMain.Instance().UIStage().getStage().getViewport()).unproject(vec);
            settingsPopup.showMenu(TalosMain.Instance().UIStage().getStage(), vec.x, vec.y);
        }
    });
    settingsPopup = new PopupMenu();
    MenuItem changeColorMenuItem = new MenuItem("Change Color");
    MenuItem ungroupMenuItem = new MenuItem("Ungroup");
    settingsPopup.addItem(changeColorMenuItem);
    settingsPopup.addItem(ungroupMenuItem);
    changeColorMenuItem.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {

                @Override
                public void changed(Color newColor) {
                    super.changed(newColor);
                    frameImage.setColor(newColor);
                }
            });
        }
    });
    ungroupMenuItem.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            super.clicked(event, x, y);
            nodeBoard.removeGroup(NodeGroup.this);
        }
    });
    topHit.addListener(new ClickListener() {

        Vector2 tmp = new Vector2();

        Vector2 pos = new Vector2();

        Vector2 diff = new Vector2();

        @Override
        public boolean touchDown(InputEvent event, float x, float y, int pointer, int button) {
            pos.set(x, y);
            topHit.localToStageCoordinates(pos);
            nodeBoard.setSelectedNodes(nodes);
            return true;
        }

        @Override
        public void touchDragged(InputEvent event, float x, float y, int pointer) {
            tmp.set(x, y);
            topHit.localToStageCoordinates(tmp);
            diff.set(tmp).sub(pos);
            moveGroupBy(diff.x, diff.y);
            pos.set(tmp);
            super.touchDragged(event, x, y, pointer);
        }

        @Override
        public void touchUp(InputEvent event, float x, float y, int pointer, int button) {
            event.cancel();
        }
    });
    setTouchable(Touchable.childrenOnly);
    frameImage.setTouchable(Touchable.disabled);
}
Also used : Color(com.badlogic.gdx.graphics.Color) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Image(com.badlogic.gdx.scenes.scene2d.ui.Image) EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) ImageButton(com.badlogic.gdx.scenes.scene2d.ui.ImageButton) Vector2(com.badlogic.gdx.math.Vector2) Actor(com.badlogic.gdx.scenes.scene2d.Actor) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) PopupMenu(com.kotcrab.vis.ui.widget.PopupMenu)

Example 10 with ColorPickerAdapter

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

the class ColorWidget method init.

@Override
public void init(Skin skin) {
    super.init(skin);
    Label label = new Label("Color", skin);
    colorButton = new Table();
    colorButton.setBackground(skin.newDrawable(ColorLibrary.SHAPE_SQUIRCLE));
    content.add(label).left().expandX().height(32);
    content.add(colorButton).right().expandX().height(32).width(96);
    color.set(Color.CORAL);
    colorButton.setColor(color);
    colorButton.setTouchable(Touchable.enabled);
    colorButton.addListener(new ClickListener() {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            TalosMain.Instance().UIStage().showColorPicker(new ColorPickerAdapter() {

                @Override
                public void changed(Color newColor) {
                    super.changed(newColor);
                    color.set(newColor);
                    colorButton.setColor(newColor);
                    fireChangedEvent();
                }
            });
        }
    });
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) Color(com.badlogic.gdx.graphics.Color) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Aggregations

Color (com.badlogic.gdx.graphics.Color)12 ColorPickerAdapter (com.kotcrab.vis.ui.widget.color.ColorPickerAdapter)12 InputEvent (com.badlogic.gdx.scenes.scene2d.InputEvent)8 ClickListener (com.badlogic.gdx.scenes.scene2d.utils.ClickListener)8 ColorPicker (com.kotcrab.vis.ui.widget.color.ColorPicker)8 Actor (com.badlogic.gdx.scenes.scene2d.Actor)4 HyperLapColorPicker (games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker)4 Image (com.badlogic.gdx.scenes.scene2d.ui.Image)3 Table (com.badlogic.gdx.scenes.scene2d.ui.Table)3 MenuItem (com.kotcrab.vis.ui.widget.MenuItem)3 Vector2 (com.badlogic.gdx.math.Vector2)2 Label (com.badlogic.gdx.scenes.scene2d.ui.Label)2 ChangeListener (com.badlogic.gdx.scenes.scene2d.utils.ChangeListener)2 JsonValue (com.badlogic.gdx.utils.JsonValue)2 PopupMenu (com.kotcrab.vis.ui.widget.PopupMenu)2 VisTable (com.kotcrab.vis.ui.widget.VisTable)2 GradientWidget (com.talosvfx.talos.editor.widgets.GradientWidget)2 EditableLabel (com.talosvfx.talos.editor.widgets.ui.EditableLabel)2 ColorPoint (com.talosvfx.talos.runtime.values.ColorPoint)2 Batch (com.badlogic.gdx.graphics.g2d.Batch)1