Search in sources :

Example 1 with ColorPicker

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

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

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

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

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

the class UIStage method init.

public void init() {
    fullScreenTable = new Table();
    fullScreenTable.setFillParent(true);
    stage.addActor(fullScreenTable);
    defaults();
    constructMenu();
    constructTabPane();
    constructSplitPanes();
    initFileChoosers();
    batchConvertDialog = new BatchConvertDialog();
    settingsDialog = new SettingsDialog();
    newProjectDialog = new NewProjectDialog();
    FileHandle list = Gdx.files.internal("modules.xml");
    XmlReader xmlReader = new XmlReader();
    XmlReader.Element root = xmlReader.parse(list);
    WrapperRegistry.map.clear();
    moduleListPopup = new ModuleListPopup(root);
    colorPicker = new ColorPicker();
    colorPicker.padTop(32);
    colorPicker.padLeft(16);
    colorPicker.setHeight(330);
    colorPicker.setWidth(430);
    colorPicker.padRight(26);
}
Also used : NewProjectDialog(com.talosvfx.talos.editor.dialogs.NewProjectDialog) Table(com.badlogic.gdx.scenes.scene2d.ui.Table) ColorPicker(com.kotcrab.vis.ui.widget.color.ColorPicker) FileHandle(com.badlogic.gdx.files.FileHandle) XmlReader(com.badlogic.gdx.utils.XmlReader) BatchConvertDialog(com.talosvfx.talos.editor.dialogs.BatchConvertDialog) SettingsDialog(com.talosvfx.talos.editor.dialogs.SettingsDialog)

Aggregations

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