use of blue.soundObject.editor.sound.TimeBar in project blue by kunstmusik.
the class SoundEditor method jbInit.
private void jbInit() throws Exception {
this.setLayout(new BorderLayout());
this.add(editor);
editor.setLabelText("[ Sound ]");
JFXPanel jfxPanel = new JFXPanel();
CountDownLatch latch = new CountDownLatch(1);
JFXPanel jfxCommentPanel = new JFXPanel();
BlueFX.runOnFXThread(() -> {
try {
MenuButton btn = new MenuButton("Automations");
BorderPane mainPane = new BorderPane();
lineView = new ParameterLineView(lineList);
lineSelector = new LineSelector(lineList);
lineView.widthProperty().bind(mainPane.widthProperty());
lineView.heightProperty().bind(mainPane.heightProperty().subtract(lineSelector.heightProperty()));
lineSelector.getChildren().add(0, btn);
lineSelector.setSpacing(5.0);
lineView.selectedLineProperty().bind(lineSelector.selectedLineProperty());
TimeBar tb = new TimeBar();
tb.startTimeProperty().bind(lineView.startTimeProperty());
tb.durationProperty().bind(lineView.durationProperty());
Pane p = new Pane(lineView, tb);
p.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
lineView.widthProperty().bind(p.widthProperty().subtract(20));
lineView.heightProperty().bind(p.heightProperty().subtract(40));
lineView.setLayoutX(10);
lineView.setLayoutY(30);
tb.widthProperty().bind(lineView.widthProperty());
tb.setHeight(20);
tb.setLayoutX(10);
tb.setLayoutY(10);
mainPane.setCenter(p);
mainPane.setTop(lineSelector);
btn.showingProperty().addListener((obs, old, newVal) -> {
if (newVal) {
if (sObj != null) {
sObj.getBlueSynthBuilder().getParameterList().sorted().forEach((param) -> {
MenuItem m = new MenuItem(param.getName());
m.setOnAction(e -> {
param.setAutomationEnabled(!param.isAutomationEnabled());
if (param.isAutomationEnabled()) {
Line line = param.getLine();
line.setVarName(param.getName());
List<LinePoint> points = line.getObservableList();
if (points.size() < 2) {
LinePoint lp = new LinePoint();
lp.setLocation(1.0, points.get(0).getY());
points.add(lp);
}
lineList.add(line);
} else {
lineList.remove(param.getLine());
}
int colorCount = 0;
for (Line line : lineList) {
line.setColor(LineColors.getColor(colorCount++));
}
});
if (param.isAutomationEnabled()) {
m.setStyle("-fx-text-fill: green;");
}
btn.getItems().add(m);
});
}
} else {
btn.getItems().clear();
}
});
final Scene scene = new Scene(mainPane);
BlueFX.style(scene);
jfxPanel.setScene(scene);
commentTextArea = new TextArea();
commentTextArea.setWrapText(true);
final Scene scene2 = new Scene(commentTextArea);
BlueFX.style(scene2);
jfxCommentPanel.setScene(scene2);
} finally {
latch.countDown();
}
});
try {
latch.await();
} catch (InterruptedException ex) {
Exceptions.printStackTrace(ex);
}
editor.getTabs().insertTab("Automation", null, jfxPanel, "", 1);
editor.getTabs().addTab("Comments", jfxCommentPanel);
}
Aggregations