Add placeholder when no previous projects

pull/98/head
James Ball 2022-07-06 15:58:03 +01:00 zatwierdzone przez James H Ball
rodzic a068492a0d
commit 655f2ee90a
10 zmienionych plików z 190 dodań i 152 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
package sh.ball.gui; package sh.ball.gui;
@FunctionalInterface @FunctionalInterface
public interface ExceptionConsumer<T> { public interface ExceptionBiConsumer<T, S> {
void accept(T value) throws Exception; void accept(T value1, S value2) throws Exception;
} }

Wyświetl plik

@ -114,7 +114,7 @@ public class Gui extends Application {
root = loader.load(); root = loader.load();
MainController controller = loader.getController(); MainController controller = loader.getController();
projectSelectController.setApplicationLauncher(path -> launchMainApplication(controller, path)); projectSelectController.setApplicationLauncher((path, muted) -> launchMainApplication(controller, path, muted));
controller.setAddRecentFile(projectSelectController::addRecentFile); controller.setAddRecentFile(projectSelectController::addRecentFile);
@ -172,9 +172,12 @@ public class Gui extends Application {
editor.setCallback(controller::updateFileData); editor.setCallback(controller::updateFileData);
} }
public void launchMainApplication(MainController controller, String projectPath) throws Exception { public void launchMainApplication(MainController controller, String projectPath, Boolean muted) throws Exception {
scene.setRoot(root); scene.setRoot(root);
controller.openProject(projectPath); controller.openProject(projectPath);
if (muted) {
controller.setVolume(0);
}
} }
public static void launchCodeEditor(String code, String fileName) { public static void launchCodeEditor(String code, String fileName) {

Wyświetl plik

@ -321,4 +321,8 @@ public class EffectsController implements Initializable, SubController {
public void disableMouseTranslate() { public void disableMouseTranslate() {
translateCheckBox.setSelected(false); translateCheckBox.setSelected(false);
} }
public void setVolume(double volumeValue) {
volume.controller.slider.setValue(volumeValue);
}
} }

Wyświetl plik

@ -1433,6 +1433,10 @@ public class MainController implements Initializable, FrequencyListener, MidiLis
this.addRecentFile = addRecentFile; this.addRecentFile = addRecentFile;
} }
public void setVolume(double volume) {
effectsController.setVolume(volume);
}
private record PrintableSlider(Slider slider) { private record PrintableSlider(Slider slider) {
@Override @Override
public String toString() { public String toString() {

Wyświetl plik

@ -15,7 +15,7 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import org.w3c.dom.events.EventTarget; import org.w3c.dom.events.EventTarget;
import org.w3c.dom.html.HTMLAnchorElement; import org.w3c.dom.html.HTMLAnchorElement;
import sh.ball.gui.ExceptionConsumer; import sh.ball.gui.ExceptionBiConsumer;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -32,10 +32,11 @@ public class ProjectSelectController implements Initializable {
private static final int MAX_ITEMS = 20; private static final int MAX_ITEMS = 20;
private static final String RECENT_FILE = "RECENT_FILE_"; private static final String RECENT_FILE = "RECENT_FILE_";
private static final String START_MUTED = "START_MUTED";
private final Preferences userPreferences = Preferences.userNodeForPackage(getClass()); private final Preferences userPreferences = Preferences.userNodeForPackage(getClass());
private final ObservableList<String> recentFiles = FXCollections.observableArrayList(); private final ObservableList<String> recentFiles = FXCollections.observableArrayList();
private ExceptionConsumer<String> launchMainApplication; private ExceptionBiConsumer<String, Boolean> launchMainApplication;
private Consumer<String> openBrowser; private Consumer<String> openBrowser;
@FXML @FXML
@ -61,7 +62,7 @@ public class ProjectSelectController implements Initializable {
recentFilesListView.setItems(recentFiles); recentFilesListView.setItems(recentFiles);
recentFilesListView.setOnMouseClicked(e -> { recentFilesListView.setOnMouseClicked(e -> {
try { try {
launchMainApplication.accept(recentFilesListView.getSelectionModel().getSelectedItem()); launchMainApplication.accept(recentFilesListView.getSelectionModel().getSelectedItem(), startMutedCheckBox.isSelected());
} catch (Exception ex) { } catch (Exception ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex); logger.log(Level.SEVERE, ex.getMessage(), ex);
} }
@ -69,12 +70,15 @@ public class ProjectSelectController implements Initializable {
newProjectButton.setOnAction(e -> { newProjectButton.setOnAction(e -> {
try { try {
launchMainApplication.accept(null); launchMainApplication.accept(null, startMutedCheckBox.isSelected());
} catch (Exception ex) { } catch (Exception ex) {
logger.log(Level.SEVERE, ex.getMessage(), ex); logger.log(Level.SEVERE, ex.getMessage(), ex);
} }
}); });
startMutedCheckBox.setSelected(userPreferences.getBoolean(START_MUTED, false));
startMutedCheckBox.selectedProperty().addListener((e, old, startMuted) -> userPreferences.putBoolean(START_MUTED, startMuted));
try { try {
String changelogHtml = new String(getClass().getResourceAsStream("/html/changelog.html").readAllBytes(), StandardCharsets.UTF_8); String changelogHtml = new String(getClass().getResourceAsStream("/html/changelog.html").readAllBytes(), StandardCharsets.UTF_8);
changelogWebView.getEngine().loadContent(changelogHtml); changelogWebView.getEngine().loadContent(changelogHtml);
@ -132,7 +136,7 @@ public class ProjectSelectController implements Initializable {
} }
} }
public void setApplicationLauncher(ExceptionConsumer<String> launchMainApplication) { public void setApplicationLauncher(ExceptionBiConsumer<String, Boolean> launchMainApplication) {
this.launchMainApplication = launchMainApplication; this.launchMainApplication = launchMainApplication;
} }

Wyświetl plik

@ -386,3 +386,9 @@
-fx-border-radius: 0; -fx-border-radius: 0;
-fx-border-color: white; -fx-border-color: white;
} }
.white-border {
-fx-border-width: 1px;
-fx-border-radius: 0;
-fx-border-color: white;
}

Wyświetl plik

@ -63,7 +63,7 @@
</AnchorPane> </AnchorPane>
<EffectComponentGroup fx:id="translationScale" alwaysEnabled="true" increment="0.05" label="translationScale" majorTickUnit="1.0" max="10.0" min="0.0" name="Translation scale" type="TRANSLATE" value="1.0" /> <EffectComponentGroup fx:id="translationScale" alwaysEnabled="true" increment="0.05" label="translationScale" majorTickUnit="1.0" max="10.0" min="0.0" name="Translation scale" type="TRANSLATE" value="1.0" />
<EffectComponentGroup fx:id="translationSpeed" alwaysEnabled="true" increment="0.05" label="translationSpeed" majorTickUnit="1.0" max="10.0" min="0.0" name="Translation speed" type="TRANSLATE_SPEED" value="1.0" /> <EffectComponentGroup fx:id="translationSpeed" alwaysEnabled="true" increment="0.05" label="translationSpeed" majorTickUnit="1.0" max="10.0" min="0.0" name="Translation speed" type="TRANSLATE_SPEED" value="1.0" />
<EffectComponentGroup fx:id="volume" alwaysEnabled="true" increment="0.05" label="volume" majorTickUnit="1.0" max="10.0" min="0.0" name="Volume scale" type="SCALE" value="3.0" /> <EffectComponentGroup fx:id="volume" alwaysEnabled="true" increment="0.05" label="volume" majorTickUnit="1.0" max="10.0" min="0.0" name="Master volume" type="SCALE" value="3.0" />
<EffectComponentGroup fx:id="backingMidi" alwaysEnabled="true" increment="0.005" label="visibility" majorTickUnit="0.1" max="1.0" min="0.0" name="MIDI volume" type="VISIBILITY" value="0.25" /> <EffectComponentGroup fx:id="backingMidi" alwaysEnabled="true" increment="0.005" label="visibility" majorTickUnit="0.1" max="1.0" min="0.0" name="MIDI volume" type="VISIBILITY" value="0.25" />
<Label alignment="CENTER" prefWidth="601.0" text="Rotation" textAlignment="JUSTIFY"> <Label alignment="CENTER" prefWidth="601.0" text="Rotation" textAlignment="JUSTIFY">
<padding> <padding>

Wyświetl plik

@ -21,7 +21,6 @@
<menus> <menus>
<Menu mnemonicParsing="false" text="File"> <Menu mnemonicParsing="false" text="File">
<items> <items>
<MenuItem disable="true" mnemonicParsing="false" text="osci-render v1.26.4" />
<MenuItem fx:id="openProjectMenuItem" mnemonicParsing="false" text="Open Project"> <MenuItem fx:id="openProjectMenuItem" mnemonicParsing="false" text="Open Project">
<accelerator> <accelerator>
<KeyCodeCombination alt="UP" code="O" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> <KeyCodeCombination alt="UP" code="O" control="UP" meta="UP" shift="UP" shortcut="DOWN" />

Wyświetl plik

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.String?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.Button?> <?import javafx.scene.control.Button?>
<?import javafx.scene.control.CheckBox?> <?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?> <?import javafx.scene.control.Label?>
@ -17,12 +19,27 @@
<Image url="@../images/osci.png" /> <Image url="@../images/osci.png" />
</image> </image>
</ImageView> </ImageView>
<ListView fx:id="recentFilesListView" layoutX="28.0" layoutY="333.0" prefHeight="257.0" prefWidth="527.0" /> <ListView fx:id="recentFilesListView" layoutX="28.0" layoutY="333.0" prefHeight="257.0" prefWidth="527.0" styleClass="darkPane" >
<placeholder>
<Label text="No recent projects. Start a new project below." />
</placeholder>
</ListView>
<Button fx:id="newProjectButton" layoutX="222.0" layoutY="609.0" mnemonicParsing="false" prefHeight="40.0" prefWidth="131.0" text="Start new project" /> <Button fx:id="newProjectButton" layoutX="222.0" layoutY="609.0" mnemonicParsing="false" prefHeight="40.0" prefWidth="131.0" text="Start new project" />
<CheckBox fx:id="startMutedCheckBox" layoutX="240.0" layoutY="670.0" mnemonicParsing="false" text="Start muted" /> <CheckBox fx:id="startMutedCheckBox" layoutX="240.0" layoutY="670.0" mnemonicParsing="false" text="Start muted" />
<Label layoutX="188.0" layoutY="294.0" styleClass="title" text="Recently opened projects" /> <Label layoutX="188.0" layoutY="294.0" styleClass="title" text="Recently opened projects" />
<Label layoutX="14.0" layoutY="700.0" text="v1.26.4" /> <Label layoutX="14.0" layoutY="700.0" text="v1.26.4" />
<Label layoutX="727.0" layoutY="40.0" styleClass="title" text="Changelog" /> <Label layoutX="727.0" layoutY="20.0" styleClass="title" text="Changelog" />
<WebView fx:id="changelogWebView" layoutX="583.0" layoutY="104.0" prefHeight="590.0" prefWidth="376.0" /> <AnchorPane layoutX="582.0" layoutY="65.0" prefHeight="200.0" prefWidth="376.0">
<children>
<WebView fx:id="changelogWebView" layoutX="2.0" layoutY="2.0" prefHeight="638.0" prefWidth="376.0" />
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<styleClass>
<String fx:value="white-border" />
<String fx:value="darkPane" />
</styleClass>
</AnchorPane>
</children></AnchorPane> </children></AnchorPane>
</AnchorPane> </AnchorPane>

Wyświetl plik

@ -7,8 +7,9 @@
body { body {
background-color: #111111; background-color: #111111;
color: white; color: white;
font-family: Arial,serif; font-family: Segoe UI,Frutiger,Frutiger Linotype,Dejavu Sans,Helvetica Neue,Arial,sans-serif;
margin: 0 0.5em 0 0; margin: 0 0.5em 0 0;
font-size: 0.8em;
padding: 0; padding: 0;
} }