use of com.talosvfx.talos.editor.widgets.GradientWidget 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);
}
use of com.talosvfx.talos.editor.widgets.GradientWidget in project gdx-graph by MarcinSc.
the class GradientShaderBoxProducer method createPipelineGraphBox.
@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
final GraphBoxImpl result = createGraphBox(id);
addConfigurationInputsAndOutputs(result);
final GradientWidget gradientWidget = new GradientWidget();
gradientWidget.setSize(300, 40);
if (data != null) {
JsonValue points = data.get("points");
for (String point : points.asStringArray()) {
String[] split = point.split(",");
gradientWidget.createPoint(Color.valueOf(split[0]), Float.parseFloat(split[1]));
}
} else {
gradientWidget.createPoint(Color.WHITE, 0);
}
gradientWidget.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
gradientWidget.fire(new GraphChangedEvent(false, true));
}
});
gradientWidget.setListener(new GradientWidget.GradientWidgetListener() {
@Override
public void colorPickerShow(final ColorPoint point, final Runnable onSuccess) {
final ColorPicker picker = new ColorPicker();
picker.setColor(point.color);
picker.setListener(new ColorPickerAdapter() {
@Override
public void finished(Color newColor) {
point.color.set(newColor);
picker.dispose();
onSuccess.run();
result.getActor().fire(new GraphChangedEvent(false, true));
}
@Override
public void canceled(Color oldColor) {
picker.dispose();
}
});
gradientWidget.getStage().addActor(picker.fadeIn());
}
});
result.addGraphBoxPart(new GraphBoxPartImpl(gradientWidget, new GraphBoxPartImpl.Callback() {
@Override
public void serialize(JsonValue object) {
Array<ColorPoint> points = gradientWidget.getPoints();
JsonValue pointsValue = new JsonValue(JsonValue.ValueType.array);
for (ColorPoint point : points) {
pointsValue.addChild(new JsonValue(point.color.toString() + "," + SimpleNumberFormatter.format(point.pos)));
}
object.addChild("points", pointsValue);
}
}));
final VisSelectBox<ClampMethod> clampMethodSelectBox = new VisSelectBox<ClampMethod>();
clampMethodSelectBox.setItems(ClampMethod.values());
if (data != null)
clampMethodSelectBox.setSelected(ClampMethod.valueOf(data.getString("clamp", "Normal")));
clampMethodSelectBox.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
result.getActor().fire(new GraphChangedEvent(false, true));
}
});
VisTable clampActor = new VisTable();
clampActor.add("Clamp method:").row();
clampActor.add(clampMethodSelectBox).growX();
result.addGraphBoxPart(new GraphBoxPartImpl(clampActor, new GraphBoxPartImpl.Callback() {
@Override
public void serialize(JsonValue object) {
object.addChild("clamp", new JsonValue(clampMethodSelectBox.getSelected().name()));
}
}));
return result;
}
Aggregations