use of com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent in project gdx-graph by MarcinSc.
the class Vector2BoxPart method createInput.
private VisValidatableTextField createInput(InputValidator inputValidator, float defaultValue) {
final VisValidatableTextField result;
if (inputValidator != null) {
result = new VisValidatableTextField(Validators.FLOATS, inputValidator) {
@Override
public float getPrefWidth() {
return 50;
}
};
} else
result = new VisValidatableTextField(Validators.FLOATS) {
@Override
public float getPrefWidth() {
return 50;
}
};
result.setText(String.valueOf(defaultValue));
result.setAlignment(Align.right);
result.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
result.fire(new GraphChangedEvent(false, true));
}
});
return result;
}
use of com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent in project gdx-graph by MarcinSc.
the class EndScreenShaderBoxProducer method createPipelineGraphBox.
@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
final ScreenShaderPreviewBoxPart previewBoxPart = new ScreenShaderPreviewBoxPart();
previewBoxPart.initialize(data);
GraphBoxImpl result = new GraphBoxImpl(id, getConfiguration()) {
@Override
public void graphChanged(GraphChangedEvent event, boolean hasErrors, Graph<? extends GraphNode, ? extends GraphConnection, ? extends GraphProperty> graph) {
if (event.isData() || event.isStructure()) {
previewBoxPart.graphChanged(hasErrors, graph);
}
}
};
addConfigurationInputsAndOutputs(result);
result.addGraphBoxPart(new SectionBoxPart("Rendering config"));
BlendingBoxPart blendingBox = new BlendingBoxPart();
blendingBox.initialize(data);
result.addGraphBoxPart(blendingBox);
result.addGraphBoxPart(new SectionBoxPart("Preview"));
result.addGraphBoxPart(previewBoxPart);
return result;
}
use of com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent in project gdx-graph by MarcinSc.
the class RemapValueShaderBoxProducer method createPipelineGraphBox.
@Override
public GraphBox createPipelineGraphBox(Skin skin, String id, JsonValue data) {
GraphBoxImpl result = createGraphBox(id);
addConfigurationInputsAndOutputs(result);
final CurveWidget curveWidget = new CurveWidget(skin);
if (data != null) {
JsonValue points = data.get("points");
for (String point : points.asStringArray()) {
String[] split = point.split(",");
curveWidget.createPoint(Float.parseFloat(split[0]), Float.parseFloat(split[1]));
}
} else {
curveWidget.createPoint(0, 0);
}
curveWidget.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
curveWidget.fire(new GraphChangedEvent(false, true));
}
});
curveWidget.setSize(300, 200);
result.addGraphBoxPart(new GraphBoxPartImpl(curveWidget, new GraphBoxPartImpl.Callback() {
@Override
public void serialize(JsonValue object) {
Array<Vector2> points = curveWidget.getPoints();
JsonValue pointsValue = new JsonValue(JsonValue.ValueType.array);
for (Vector2 point : points) {
pointsValue.addChild(new JsonValue(SimpleNumberFormatter.format(point.x) + "," + SimpleNumberFormatter.format(point.y)));
}
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) {
clampMethodSelectBox.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;
}
use of com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent in project gdx-graph by MarcinSc.
the class RemapVectorShaderBoxProducer method createSelectBox.
private VisSelectBox<String> createSelectBox(String defaultValue) {
final VisSelectBox<String> result = new VisSelectBox<String>();
result.setItems("0.0", "1.0", "X", "Y", "Z", "W");
result.setSelected(defaultValue);
result.setAlignment(Align.right);
result.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
result.fire(new GraphChangedEvent(false, true));
}
});
return result;
}
use of com.gempukku.libgdx.graph.ui.graph.GraphChangedEvent 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