Replace audio device and font dropdowns with a list

pull/108/head v1.27.7
James Ball 2022-08-08 19:54:05 +01:00 zatwierdzone przez James H Ball
rodzic 305837eb12
commit 1e0af7c233
6 zmienionych plików z 30 dodań i 18 usunięć

Wyświetl plik

@ -6,7 +6,7 @@
<groupId>sh.ball</groupId> <groupId>sh.ball</groupId>
<artifactId>osci-render</artifactId> <artifactId>osci-render</artifactId>
<version>1.27.6</version> <version>1.27.7</version>
<name>osci-render</name> <name>osci-render</name>

Wyświetl plik

@ -4,10 +4,15 @@ import java.util.Objects;
public record SimpleAudioDevice(String id, String name, int sampleRate, AudioSample sample, int channels) implements AudioDevice { public record SimpleAudioDevice(String id, String name, int sampleRate, AudioSample sample, int channels) implements AudioDevice {
private static final int MAX_NAME_LENGTH = 30;
@Override @Override
public String toString() { public String toString() {
String simplifiedName = name.replaceFirst(" \\(Shared\\)", ""); String simplifiedName = name.replaceFirst(" \\(Shared\\)", "");
simplifiedName = simplifiedName.replaceFirst(" \\(NVIDIA High Definition Audio\\)", ""); simplifiedName = simplifiedName.replaceFirst(" \\(NVIDIA High Definition Audio\\)", "");
if (simplifiedName.length() > MAX_NAME_LENGTH) {
simplifiedName = simplifiedName.substring(0, MAX_NAME_LENGTH - 3) + "...";
}
simplifiedName += " @ " + sampleRate + "Hz, " + sample + ", "; simplifiedName += " @ " + sampleRate + "Hz, " + sample + ", ";
if (channels == 1) { if (channels == 1) {
simplifiedName += "mono"; simplifiedName += "mono";

Wyświetl plik

@ -170,7 +170,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
@FXML @FXML
private CheckMenuItem renderUsingGpuCheckMenuItem; private CheckMenuItem renderUsingGpuCheckMenuItem;
@FXML @FXML
private ComboBox<String> fontFamilyComboBox; private ListView<String> fontFamilyListView;
@FXML @FXML
private ComboBox<FontStyle> fontStyleComboBox; private ComboBox<FontStyle> fontStyleComboBox;
@FXML @FXML
@ -190,7 +190,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
@FXML @FXML
private Spinner<Integer> deadzoneSpinner; private Spinner<Integer> deadzoneSpinner;
@FXML @FXML
private ComboBox<AudioDevice> deviceComboBox; private ListView<AudioDevice> deviceListView;
@FXML @FXML
private CustomMenuItem audioDeviceMenuItem; private CustomMenuItem audioDeviceMenuItem;
@FXML @FXML
@ -251,7 +251,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
private void toggleRecord() { private void toggleRecord() {
recording = !recording; recording = !recording;
audioSampleComboBox.setDisable(recording); audioSampleComboBox.setDisable(recording);
deviceComboBox.setDisable(recording); deviceListView.setDisable(recording);
boolean timedRecord = recordCheckBox.isSelected(); boolean timedRecord = recordCheckBox.isSelected();
if (recording) { if (recording) {
// if it is a timed recording then a timeline is scheduled to start and // if it is a timed recording then a timeline is scheduled to start and
@ -278,7 +278,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
recording = false; recording = false;
Platform.runLater(() -> { Platform.runLater(() -> {
audioSampleComboBox.setDisable(false); audioSampleComboBox.setDisable(false);
deviceComboBox.setDisable(false); deviceListView.setDisable(false);
}); });
} }
); );
@ -463,13 +463,14 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
sliderComboBox.setValue(printableSliders.get(0)); sliderComboBox.setValue(printableSliders.get(0));
String[] installedFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); String[] installedFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames();
fontFamilyComboBox.setItems(FXCollections.observableList(Arrays.stream(installedFonts).toList())); fontFamilyListView.setItems(FXCollections.observableList(Arrays.stream(installedFonts).toList()));
if (fontFamilyComboBox.getItems().contains("SansSerif")) { if (fontFamilyListView.getItems().contains("SansSerif")) {
fontFamilyComboBox.setValue("SansSerif"); fontFamilyListView.getSelectionModel().select("SansSerif");
} else { } else {
fontFamilyComboBox.setValue(installedFonts[0]); fontFamilyListView.getSelectionModel().select(installedFonts[0]);
} }
fontFamilyComboBox.valueProperty().addListener((e, old, family) -> updateFileData(openFiles.get(currentFrameSource), frameSourcePaths.get(currentFrameSource))); fontFamilyListView.getSelectionModel().selectedItemProperty().addListener((e, old, family) -> updateFileData(openFiles.get(currentFrameSource), frameSourcePaths.get(currentFrameSource)));
fontStyleComboBox.setItems(FXCollections.observableList(Arrays.stream(FontStyle.values()).toList())); fontStyleComboBox.setItems(FXCollections.observableList(Arrays.stream(FontStyle.values()).toList()));
fontStyleComboBox.setValue(FontStyle.PLAIN); fontStyleComboBox.setValue(FontStyle.PLAIN);
@ -513,9 +514,9 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
new Thread(() -> { new Thread(() -> {
List<AudioDevice> devices = audioPlayer.devices(); List<AudioDevice> devices = audioPlayer.devices();
Platform.runLater(() -> { Platform.runLater(() -> {
deviceComboBox.setItems(FXCollections.observableList(devices)); deviceListView.setItems(FXCollections.observableList(devices));
deviceComboBox.setValue(defaultDevice); deviceListView.getSelectionModel().select(defaultDevice);
deviceComboBox.valueProperty().addListener((options, oldDevice, newDevice) -> { deviceListView.getSelectionModel().selectedItemProperty().addListener((options, oldDevice, newDevice) -> {
if (newDevice != null) { if (newDevice != null) {
switchAudioDevice(newDevice); switchAudioDevice(newDevice);
} }
@ -738,7 +739,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
Platform.runLater(() -> luaController.updateLuaVariables()); Platform.runLater(() -> luaController.updateLuaVariables());
frameSources.add(null); frameSources.add(null);
} else { } else {
frameSources.add(ParserFactory.getParser(name, fileData, fontFamilyComboBox.getValue(), fontStyleComboBox.getValue()).parse()); frameSources.add(ParserFactory.getParser(name, fileData, fontFamilyListView.getSelectionModel().getSelectedItem(), fontStyleComboBox.getValue()).parse());
sampleParsers.add(null); sampleParsers.add(null);
} }
frameSourcePaths.add(name); frameSourcePaths.add(name);
@ -799,7 +800,7 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
frameSources.set(index, null); frameSources.set(index, null);
} else { } else {
FrameSource<List<Shape>> frameSource = frameSources.get(index); FrameSource<List<Shape>> frameSource = frameSources.get(index);
frameSources.set(index, ParserFactory.getParser(name, file, fontFamilyComboBox.getValue(), fontStyleComboBox.getValue()).parse()); frameSources.set(index, ParserFactory.getParser(name, file, fontFamilyListView.getSelectionModel().getSelectedItem(), fontStyleComboBox.getValue()).parse());
frameSource.disable(); frameSource.disable();
sampleParsers.set(index, null); sampleParsers.set(index, null);
} }

Wyświetl plik

@ -1,3 +1,7 @@
- 1.27.7
- Change audio selection and text font selection to be lists rather than dropdowns
- 1.27.6 - 1.27.6
- Fix trace min effect being hidden at bottom of effects section - Fix trace min effect being hidden at bottom of effects section

Wyświetl plik

@ -6,6 +6,7 @@
<?import javafx.scene.control.ComboBox?> <?import javafx.scene.control.ComboBox?>
<?import javafx.scene.control.CustomMenuItem?> <?import javafx.scene.control.CustomMenuItem?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
<?import javafx.scene.control.ListView?>
<?import javafx.scene.control.Menu?> <?import javafx.scene.control.Menu?>
<?import javafx.scene.control.MenuBar?> <?import javafx.scene.control.MenuBar?>
<?import javafx.scene.control.MenuItem?> <?import javafx.scene.control.MenuItem?>
@ -45,7 +46,8 @@
<content> <content>
<AnchorPane focusTraversable="true"> <AnchorPane focusTraversable="true">
<children> <children>
<ComboBox fx:id="deviceComboBox" prefHeight="26.0" prefWidth="376.0" /> <Label prefHeight="25.0" text="Audio Device" textFill="WHITE" />
<ListView fx:id="deviceListView" layoutY="25.0" prefHeight="200.0" prefWidth="400.0" />
</children> </children>
</AnchorPane> </AnchorPane>
</content> </content>
@ -158,7 +160,7 @@
<AnchorPane> <AnchorPane>
<children> <children>
<Label prefHeight="25.0" text="Text File Font" textFill="WHITE" /> <Label prefHeight="25.0" text="Text File Font" textFill="WHITE" />
<ComboBox fx:id="fontFamilyComboBox" layoutY="25.0" prefHeight="26.0" prefWidth="376.0" /> <ListView fx:id="fontFamilyListView" layoutY="25.0" prefHeight="200.0" prefWidth="400.0" />
</children> </children>
</AnchorPane> </AnchorPane>
</content> </content>

Wyświetl plik

@ -27,7 +27,7 @@
<Button fx:id="newProjectButton" layoutX="222.0" layoutY="562.0" mnemonicParsing="false" prefHeight="40.0" prefWidth="131.0" text="Start new project" /> <Button fx:id="newProjectButton" layoutX="222.0" layoutY="562.0" mnemonicParsing="false" prefHeight="40.0" prefWidth="131.0" text="Start new project" />
<CheckBox fx:id="startMutedCheckBox" layoutX="240.0" layoutY="623.0" mnemonicParsing="false" text="Start muted" /> <CheckBox fx:id="startMutedCheckBox" layoutX="240.0" layoutY="623.0" mnemonicParsing="false" text="Start muted" />
<Label layoutX="188.0" layoutY="247.0" styleClass="title" text="Recently opened projects" /> <Label layoutX="188.0" layoutY="247.0" styleClass="title" text="Recently opened projects" />
<Label layoutX="14.0" layoutY="700.0" text="v1.27.6" /> <Label layoutX="14.0" layoutY="700.0" text="v1.27.7" />
<Label layoutX="727.0" layoutY="20.0" styleClass="title" text="Changelog" /> <Label layoutX="727.0" layoutY="20.0" styleClass="title" text="Changelog" />
<AnchorPane layoutX="582.0" layoutY="65.0" prefHeight="200.0" prefWidth="380.0"> <AnchorPane layoutX="582.0" layoutY="65.0" prefHeight="200.0" prefWidth="380.0">
<children> <children>