Search in sources :

Example 1 with ColorPickerAdapter

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

the class UILightBodyPropertiesMediator method handleNotification.

@Override
public void handleNotification(INotification notification) {
    super.handleNotification(notification);
    switch(notification.getName()) {
        case UILightBodyProperties.CLOSE_CLICKED:
            HyperLap2DFacade.getInstance().sendNotification(MsgAPI.ACTION_REMOVE_COMPONENT, RemoveComponentFromItemCommand.payload(observableReference, LightBodyComponent.class));
            break;
        case UILightBodyProperties.LIGHT_COLOR_BUTTON_CLICKED:
            Color prevColor = viewComponent.getLightColor().cpy();
            ColorPicker picker = new HyperLapColorPicker(new ColorPickerAdapter() {

                @Override
                public void finished(Color newColor) {
                    lightComponent = SandboxComponentRetriever.get(observableReference, LightBodyComponent.class);
                    lightComponent.color[0] = prevColor.r;
                    lightComponent.color[1] = prevColor.g;
                    lightComponent.color[2] = prevColor.b;
                    lightComponent.color[3] = prevColor.a;
                    viewComponent.setLightColor(newColor);
                    facade.sendNotification(viewComponent.getUpdateEventName());
                }

                @Override
                public void changed(Color newColor) {
                    lightComponent = SandboxComponentRetriever.get(observableReference, LightBodyComponent.class);
                    lightComponent.color[0] = newColor.r;
                    lightComponent.color[1] = newColor.g;
                    lightComponent.color[2] = newColor.b;
                    lightComponent.color[3] = newColor.a;
                }
            });
            if (notification.getBody() != null) {
                viewComponent.setLightColor(notification.getBody());
            }
            picker.setColor(viewComponent.getLightColor());
            Sandbox.getInstance().getUIStage().addActor(picker.fadeIn());
            break;
    }
}
Also used : HyperLapColorPicker(games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker) ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) Color(com.badlogic.gdx.graphics.Color) LightBodyComponent(games.rednblack.editor.renderer.components.light.LightBodyComponent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) HyperLapColorPicker(games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker)

Example 2 with ColorPickerAdapter

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

the class StickyNoteActor method showPopupMenu.

private void showPopupMenu() {
    H2DPopupMenu popupMenu = new H2DPopupMenu();
    MenuItem rename = new MenuItem("Remove note");
    rename.addListener(new ClickListener(Input.Buttons.LEFT) {

        @Override
        public void clicked(InputEvent event, float x, float y) {
            facade.sendNotification(MsgAPI.ACTION_REMOVE_STICKY_NOTE, id);
        }
    });
    popupMenu.addItem(rename);
    MenuItem changeColor = new MenuItem("Change color");
    changeColor.addListener(new ClickListener(Input.Buttons.LEFT) {

        boolean init = false;

        @Override
        public void clicked(InputEvent event, float x, float y) {
            ColorPicker picker = new HyperLapColorPicker(new ColorPickerAdapter() {

                @Override
                public void finished(Color newColor) {
                    setColor(newColor);
                    StickyNoteVO payload = ModifyStickyNoteCommand.payload(StickyNoteActor.this);
                    facade.sendNotification(MsgAPI.ACTION_MODIFY_STICKY_NOTE, payload);
                }

                @Override
                public void changed(Color newColor) {
                    if (init)
                        setColor(newColor);
                }
            });
            init = true;
            picker.setColor(getColor());
            Sandbox.getInstance().getUIStage().addActor(picker.fadeIn());
        }
    });
    popupMenu.addItem(changeColor);
    Sandbox sandbox = Sandbox.getInstance();
    UIStage uiStage = sandbox.getUIStage();
    popupMenu.showMenu(Sandbox.getInstance().getUIStage(), sandbox.getInputX(), uiStage.getHeight() - sandbox.getInputY());
}
Also used : UIStage(games.rednblack.editor.view.stage.UIStage) HyperLapColorPicker(games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker) ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) Color(com.badlogic.gdx.graphics.Color) H2DPopupMenu(games.rednblack.h2d.common.view.ui.widget.H2DPopupMenu) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) Sandbox(games.rednblack.editor.view.stage.Sandbox) StickyNoteVO(games.rednblack.editor.renderer.data.StickyNoteVO) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener) HyperLapColorPicker(games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker)

Example 3 with ColorPickerAdapter

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

the class ValueColorBoxProducer method createValuePart.

private GraphBoxPartImpl<T> createValuePart(Skin skin, String value) {
    Color color = Color.valueOf(value);
    TintButton tintButton = StandardWidgetsFactory.createTintButton();
    tintButton.setColorValue(color);
    ColorPicker picker = new HyperLapColorPicker(new ColorPickerAdapter() {

        @Override
        public void finished(Color newColor) {
            tintButton.setColorValue(newColor);
            tintButton.fire(new GraphChangedEvent(false, true));
        }

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

        @Override
        public void clicked(InputEvent event, float x, float y) {
            // displaying picker with fade in animation
            Sandbox.getInstance().getUIStage().addActor(picker.fadeIn());
        }
    });
    Table table = new Table();
    table.add(new Label("Color", skin)).growX();
    table.add(tintButton);
    table.row();
    GraphBoxPartImpl<T> colorPart = new GraphBoxPartImpl<T>(table, new GraphBoxPartImpl.Callback() {

        @Override
        public void serialize(Map<String, String> object) {
            object.put("color", tintButton.getColorValue().toString());
        }
    }) {

        @Override
        public void dispose() {
            picker.dispose();
        }
    };
    colorPart.setOutputConnector(GraphBoxOutputConnector.Side.Right, configuration.getNodeOutputs().get("value"));
    return colorPart;
}
Also used : Table(com.badlogic.gdx.scenes.scene2d.ui.Table) HyperLapColorPicker(games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker) ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) Color(com.badlogic.gdx.graphics.Color) TintButton(games.rednblack.h2d.common.view.ui.widget.TintButton) Label(com.badlogic.gdx.scenes.scene2d.ui.Label) InputEvent(com.badlogic.gdx.scenes.scene2d.InputEvent) ColorPickerAdapter(com.kotcrab.vis.ui.widget.color.ColorPickerAdapter) HyperLapColorPicker(games.rednblack.h2d.common.view.ui.widget.HyperLapColorPicker) ClickListener(com.badlogic.gdx.scenes.scene2d.utils.ClickListener)

Example 4 with ColorPickerAdapter

use of com.kotcrab.vis.ui.widget.color.ColorPickerAdapter 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 5 with ColorPickerAdapter

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

the class ModuleWrapperGroup 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);
            TalosMain.Instance().NodeStage().moduleBoardWidget.removeGroup(ModuleWrapperGroup.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);
            TalosMain.Instance().NodeStage().moduleBoardWidget.setSelectedWrappers(wrappers);
            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);
        }
    });
    setTouchable(Touchable.childrenOnly);
    frameImage.setTouchable(Touchable.disabled);
}
Also used : Color(com.badlogic.gdx.graphics.Color) MenuItem(com.kotcrab.vis.ui.widget.MenuItem) EditableLabel(com.talosvfx.talos.editor.widgets.ui.EditableLabel) 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)

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