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;
}
}
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());
}
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;
}
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;
}
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);
}
Aggregations