Skip to content
Snippets Groups Projects
Commit ba30c11b authored by tobias's avatar tobias
Browse files

Update Peakmeter UI

parent 7124cf00
Branches
No related tags found
No related merge requests found
...@@ -36,6 +36,7 @@ import de.tobias.playpad.viewcontroller.option.IProfileSettingsViewController; ...@@ -36,6 +36,7 @@ import de.tobias.playpad.viewcontroller.option.IProfileSettingsViewController;
import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.ApplicationUtils;
import de.tobias.utils.application.container.PathType; import de.tobias.utils.application.container.PathType;
import de.tobias.utils.util.FileUtils; import de.tobias.utils.util.FileUtils;
import de.tobias.utils.util.OS;
import de.tobias.utils.util.SystemUtils; import de.tobias.utils.util.SystemUtils;
import de.tobias.utils.util.Worker; import de.tobias.utils.util.Worker;
import javafx.scene.image.Image; import javafx.scene.image.Image;
...@@ -235,7 +236,9 @@ public class PlayPadImpl implements PlayPad { ...@@ -235,7 +236,9 @@ public class PlayPadImpl implements PlayPad {
registryCollection.getTriggerItems().loadComponentsFromFile("de/tobias/playpad/components/Trigger.xml"); registryCollection.getTriggerItems().loadComponentsFromFile("de/tobias/playpad/components/Trigger.xml");
registryCollection.getMainLayouts().loadComponentsFromFile("de/tobias/playpad/components/Layout.xml"); registryCollection.getMainLayouts().loadComponentsFromFile("de/tobias/playpad/components/Layout.xml");
if (OS.isMacOS()) {
registryCollection.getAudioHandlers().registerComponent(new NativeAudioMacHandlerConnect(), "Native"); registryCollection.getAudioHandlers().registerComponent(new NativeAudioMacHandlerConnect(), "Native");
}
// Set Default // Set Default
registryCollection.getAudioHandlers().setDefaultID(JavaFXAudioHandler.TYPE); registryCollection.getAudioHandlers().setDefaultID(JavaFXAudioHandler.TYPE);
......
...@@ -4,39 +4,65 @@ import de.tobias.playpad.audio.Peakable; ...@@ -4,39 +4,65 @@ import de.tobias.playpad.audio.Peakable;
import de.tobias.playpad.audio.Peakable.Channel; import de.tobias.playpad.audio.Peakable.Channel;
import de.tobias.playpad.settings.PeakType; import de.tobias.playpad.settings.PeakType;
import javafx.beans.value.ChangeListener; import javafx.beans.value.ChangeListener;
import javafx.scene.control.ProgressBar; import javafx.css.PseudoClass;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
public class PeakMeter extends VBox { public class PeakMeter extends VBox {
private ProgressBar progressbarLeft; private static final PseudoClass yellowClass = PseudoClass.getPseudoClass("yellow");
private ProgressBar progressbarRight; private static final PseudoClass redClass = PseudoClass.getPseudoClass("red");
private PeakTrack progressbarLeft;
private PeakTrack progressbarRight;
private ChangeListener<Number> leftListener; private ChangeListener<Number> leftListener;
private ChangeListener<Number> rightListener; private ChangeListener<Number> rightListener;
public PeakMeter(Peakable peakable, PeakType type) { public PeakMeter(Peakable peakable, PeakType type) {
progressbarLeft = new ProgressBar(0); progressbarLeft = new PeakTrack(this);
progressbarRight = new ProgressBar(0); progressbarRight = new PeakTrack(this);
leftListener = (a, b, c) -> leftListener = (a, b, c) ->
{ {
double value = (c.doubleValue() + 60) * 1 / 60; double dB = c.doubleValue();
double value = (dB + 60) * 1 / 60;
if (value < 0) if (value < 0)
value = 0; value = 0;
progressbarLeft.pseudoClassStateChanged(yellowClass, false);
progressbarLeft.pseudoClassStateChanged(redClass, false);
if (dB > -7) {
progressbarLeft.pseudoClassStateChanged(yellowClass, true);
}
if (dB > -3) {
progressbarLeft.pseudoClassStateChanged(redClass, true);
}
progressbarLeft.setProgress(value); progressbarLeft.setProgress(value);
}; };
rightListener = (a, b, c) -> rightListener = (a, b, c) ->
{ {
double value = (c.doubleValue() + 60) * 1 / 60; double dB = c.doubleValue();
double value = (dB + 60) * 1 / 60;
if (value < 0) if (value < 0)
value = 0; value = 0;
progressbarRight.pseudoClassStateChanged(yellowClass, false);
progressbarRight.pseudoClassStateChanged(redClass, false);
if (dB > -7) {
progressbarRight.pseudoClassStateChanged(yellowClass, true);
}
if (dB > -3) {
progressbarRight.pseudoClassStateChanged(redClass, true);
}
progressbarRight.setProgress(value); progressbarRight.setProgress(value);
}; };
progressbarLeft.getStyleClass().add("pad-playbar");
progressbarRight.getStyleClass().add("pad-playbar");
progressbarLeft.prefWidthProperty().bind(widthProperty()); progressbarLeft.prefWidthProperty().bind(widthProperty());
progressbarRight.prefWidthProperty().bind(widthProperty()); progressbarRight.prefWidthProperty().bind(widthProperty());
......
package de.tobias.playpad.pad.view;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.geometry.Insets;
import javafx.scene.layout.Background;
import javafx.scene.layout.BackgroundFill;
import javafx.scene.layout.Border;
import javafx.scene.layout.BorderStroke;
import javafx.scene.layout.BorderStrokeStyle;
import javafx.scene.layout.BorderWidths;
import javafx.scene.layout.CornerRadii;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
public class PeakTrack extends HBox {
private DoubleProperty progressProperty;
public PeakTrack(Pane parent) {
progressProperty = new SimpleDoubleProperty();
setPrefHeight(10);
setSpacing(2);
}
public void setProgress(double progress) {
progressProperty.set(progress);
getChildren().clear();
if (progress != 0) {
for (double i = 0; i <= progress; i += 0.05) {
Pane label = new Pane();
label.minHeightProperty().bind(minHeightProperty());
label.prefHeightProperty().bind(prefHeightProperty());
label.prefWidthProperty().bind(widthProperty().multiply(0.05).subtract(2));
label.setBorder(new Border(new BorderStroke(Color.BLACK, BorderStrokeStyle.SOLID, new CornerRadii(5), new BorderWidths(0.5))));
if (i < 0.75)
label.setBackground(new Background(new BackgroundFill(Color.GREEN, new CornerRadii(5), Insets.EMPTY)));
else if (i < 0.9)
label.setBackground(new Background(new BackgroundFill(Color.YELLOW, new CornerRadii(5), Insets.EMPTY)));
else
label.setBackground(new Background(new BackgroundFill(Color.RED, new CornerRadii(5), Insets.EMPTY)));
getChildren().add(label);
}
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment