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