diff --git a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/DesktopMainLayoutFactory.java b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/DesktopMainLayoutFactory.java index ef01fa96ae6a41cef3f5c94a11d706aa28e51410..a3aa32c486a7ef02b1d297b042edbfe8249baafb 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/DesktopMainLayoutFactory.java +++ b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/DesktopMainLayoutFactory.java @@ -21,9 +21,9 @@ import java.util.Deque; public class DesktopMainLayoutFactory extends MainLayoutFactory { private DesktopMenuToolbarViewController desktopMenuToolbarViewController; - private ObjectProperty<DesktopEditMode> editMode = new SimpleObjectProperty<>(DesktopEditMode.PLAY); + private final ObjectProperty<DesktopEditMode> editMode = new SimpleObjectProperty<>(DesktopEditMode.PLAY); - private Deque<IPadView> recyclingStack; + private final Deque<IPadView> recyclingStack; public DesktopMainLayoutFactory(String type) { super(type); diff --git a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index 696d5b1430b785007cf369f918ba2b6455a6064c..aacddf3f434ca9ed7d05381521cfaeb3d870b95b 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -66,6 +66,7 @@ import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.control.TextField; import javafx.scene.control.*; +import javafx.scene.input.KeyCode; import javafx.scene.input.KeyCombination; import javafx.scene.input.MouseEvent; import javafx.scene.layout.HBox; @@ -156,7 +157,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro private transient DesktopColorPickerView colorPickerView; private transient PadRemoveMouseListener padRemoveMouseListener; - private DesktopMainLayoutFactory connect; + private final DesktopMainLayoutFactory connect; DesktopMenuToolbarViewController(IMainViewController controller, DesktopMainLayoutFactory connect) { super("Header", "view/main/desktop", Localization.getBundle()); @@ -756,6 +757,12 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro NotificationPane pane = mainViewController.getNotificationPane(); pane.setOnShown(e -> searchField.requestFocus()); pane.show("", box); + + searchField.setOnKeyPressed(e -> { + if (e.getCode() == KeyCode.ESCAPE) { + pane.hide(); + } + }); } @FXML diff --git a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/listener/PadNewContentListener.java b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/listener/PadNewContentListener.java new file mode 100644 index 0000000000000000000000000000000000000000..a2470391be71a7117f460051e78c274d269877e8 --- /dev/null +++ b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/listener/PadNewContentListener.java @@ -0,0 +1,86 @@ +package de.tobias.playpad.layout.desktop.listener; + +import de.thecodelabs.utils.application.ApplicationUtils; +import de.thecodelabs.utils.util.Localization; +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.Strings; +import de.tobias.playpad.layout.desktop.pad.DesktopPadViewController; +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.content.PadContentFactory; +import de.tobias.playpad.pad.content.PadContentRegistry; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.settings.GlobalSettings; +import javafx.event.ActionEvent; +import javafx.scene.Node; +import javafx.stage.FileChooser; + +import java.io.File; +import java.nio.file.Path; +import java.util.Set; + +public class PadNewContentListener { + + private final Pad pad; + + public PadNewContentListener(Pad pad) { + this.pad = pad; + } + + public void onNew(ActionEvent event, PadContentFactory.PadContentTypeChooser padContentTypeChooser) throws NoSuchComponentException { + GlobalSettings settings = PlayPadPlugin.getInstance().getGlobalSettings(); + if (pad.getProject() != null && settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getActivePlayers() > 0) { + return; + } + + final FileChooser chooser = new FileChooser(); + PadContentRegistry registry = PlayPadPlugin.getRegistries().getPadContents(); + + // File Extension + final FileChooser.ExtensionFilter extensionFilter = new FileChooser.ExtensionFilter(Localization.getString(Strings.FILE_FILTER_MEDIA), registry.getSupportedFileTypes()); + chooser.getExtensionFilters().add(extensionFilter); + + // Last Folder + final Object openFolder = ApplicationUtils.getApplication().getUserDefaults().getData(DesktopPadViewController.OPEN_FOLDER); + if (openFolder != null) { + File folder = new File(openFolder.toString()); + if (folder.exists()) { + chooser.setInitialDirectory(folder); + } + } + + final File file = chooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow()); + if (file != null) { + Path path = file.toPath(); + + final Set<PadContentFactory> connects = registry.getPadContentConnectsForFile(file.toPath()); + if (!connects.isEmpty()) { + if (connects.size() > 1) { // Multiple content types possible + padContentTypeChooser.showOptions(connects, padContent -> + { + if (padContent != null) { + setNewPadContent(path, padContent); + } + }); + } else { + PadContentFactory padContent = connects.iterator().next(); + setNewPadContent(path, padContent); + } + } + + ApplicationUtils.getApplication().getUserDefaults().setData(DesktopPadViewController.OPEN_FOLDER, path.getParent().toString()); + } + } + + private void setNewPadContent(Path path, PadContentFactory connect) { + if (pad.getContent() == null || !pad.getContent().getType().equals(connect.getType())) { + this.pad.setContentType(connect.getType()); + } + + if (pad.isPadVisible()) { + pad.getController().getView().showBusyView(true); + } + + pad.setPath(path); + } + +} diff --git a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadDragListener.java b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadDragListener.java index 86347f6aa5f964cc26359dbbe7d49bbfdc102ad5..637686246100491b6b093d6fd525637741fcd489 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadDragListener.java +++ b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadDragListener.java @@ -95,7 +95,7 @@ public class DesktopPadDragListener implements EventHandler<DragEvent> { if (fileHud == null) { fileHud = new FileDragOptionView(padView); } - fileHud.showDropOptions(connects); + fileHud.showOptions(connects); event.acceptTransferModes(TransferMode.LINK); return; diff --git a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadView.java b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadView.java index c0b51ccd73d4745c67319e4b96adfef30e5cd181..cf386db0dc79a412de7c8d0b132aaf034bafb562 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadView.java +++ b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadView.java @@ -267,12 +267,12 @@ public class DesktopPadView implements IPadView { if (pad.getContent() != null) { if (pad.getContent() instanceof Pauseable) { if (pad.getStatus() == PadStatus.PLAY) { - buttonBox.getChildren().setAll(pauseButton, stopButton, newButton, settingsButton); + buttonBox.getChildren().setAll(pauseButton, stopButton, settingsButton); } else { - buttonBox.getChildren().setAll(playButton, stopButton, newButton, settingsButton); + buttonBox.getChildren().setAll(playButton, stopButton, settingsButton); } } else { - buttonBox.getChildren().setAll(playButton, stopButton, newButton, settingsButton); + buttonBox.getChildren().setAll(playButton, stopButton, settingsButton); } } else { buttonBox.getChildren().setAll(newButton, settingsButton); diff --git a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java index 21700d33e55e8d33b0dd52bc5e10075c6f48b331..2c1973d80cd16a167511c4e3f0f371e6fa16e899 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java +++ b/PlayWall/src/main/java/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java @@ -1,18 +1,14 @@ package de.tobias.playpad.layout.desktop.pad; import de.thecodelabs.logger.Logger; -import de.thecodelabs.utils.application.ApplicationUtils; import de.thecodelabs.utils.ui.NVCStage; -import de.thecodelabs.utils.util.Localization; import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.Strings; import de.tobias.playpad.layout.desktop.DesktopEditMode; import de.tobias.playpad.layout.desktop.DesktopMainLayoutFactory; +import de.tobias.playpad.layout.desktop.listener.PadNewContentListener; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.TimeMode; -import de.tobias.playpad.pad.content.PadContentFactory; -import de.tobias.playpad.pad.content.PadContentRegistry; import de.tobias.playpad.pad.content.play.Durationable; import de.tobias.playpad.pad.listener.*; import de.tobias.playpad.pad.view.IPadView; @@ -27,16 +23,9 @@ import de.tobias.playpad.viewcontroller.option.pad.PadSettingsViewController; import javafx.beans.value.ChangeListener; import javafx.event.ActionEvent; import javafx.event.EventHandler; -import javafx.scene.Node; -import javafx.stage.FileChooser; -import javafx.stage.FileChooser.ExtensionFilter; import javafx.stage.Stage; import javafx.util.Duration; -import java.io.File; -import java.nio.file.Path; -import java.util.Set; - public class DesktopPadViewController implements IPadViewController, EventHandler<ActionEvent> { public static final String OPEN_FOLDER = "openFolder"; @@ -196,66 +185,9 @@ public class DesktopPadViewController implements IPadViewController, EventHandle } } - private void onNew(ActionEvent event) throws NoSuchComponentException { - GlobalSettings settings = PlayPadPlugin.getInstance().getGlobalSettings(); - if (pad.getProject() != null) { - if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getActivePlayers() > 0) { - return; - } - } - - FileChooser chooser = new FileChooser(); - PadContentRegistry registry = PlayPadPlugin.getRegistries().getPadContents(); - - // File Extension - ExtensionFilter extensionFilter = new ExtensionFilter(Localization.getString(Strings.FILE_FILTER_MEDIA), - registry.getSupportedFileTypes()); - chooser.getExtensionFilters().add(extensionFilter); - - // Last Folder - Object openFolder = ApplicationUtils.getApplication().getUserDefaults().getData(OPEN_FOLDER); - if (openFolder != null) { - File folder = new File(openFolder.toString()); - if (folder.exists()) { - chooser.setInitialDirectory(folder); - } - } - - File file = chooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow()); - if (file != null) { - Path path = file.toPath(); - - Set<PadContentFactory> connects = registry.getPadContentConnectsForFile(file.toPath()); - if (!connects.isEmpty()) { - if (connects.size() > 1) { // Multiple content types possible - FileDragOptionView hud = new FileDragOptionView(padView.getRootNode()); - hud.showDropOptions(connects, connect -> - { - if (connect != null) { - setNewPadContent(path, connect); - hud.hide(); - } - }); - } else { - PadContentFactory connect = connects.iterator().next(); - setNewPadContent(path, connect); - } - } - - ApplicationUtils.getApplication().getUserDefaults().setData(OPEN_FOLDER, path.getParent().toString()); - } - } - - private void setNewPadContent(Path path, PadContentFactory connect) { - if (pad.getContent() == null || !pad.getContent().getType().equals(connect.getType())) { - this.pad.setContentType(connect.getType()); - } - - if (pad.isPadVisible()) { - pad.getController().getView().showBusyView(true); - } - - pad.setPath(path); + public void onNew(ActionEvent event) throws NoSuchComponentException { + final PadNewContentListener listener = new PadNewContentListener(pad); + listener.onNew(event, new FileDragOptionView(padView.getRootNode())); } private void onSettings() { diff --git a/PlayWall/src/main/java/de/tobias/playpad/pad/content/AudioContent.java b/PlayWall/src/main/java/de/tobias/playpad/pad/content/AudioContent.java index 426d058b27de8b181450cc7727dbf0e3c7a0335d..d7a2663fe9022555d5720efd7b433189b4d445d0 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/pad/content/AudioContent.java +++ b/PlayWall/src/main/java/de/tobias/playpad/pad/content/AudioContent.java @@ -33,10 +33,10 @@ public class AudioContent extends PadContent implements Pauseable, Durationable, private ObjectProperty<Duration> durationProperty = new SimpleObjectProperty<>(); private ObjectProperty<Duration> positionProperty = new SimpleObjectProperty<>(); - private ChangeListener<Number> volumeListener; - private ChangeListener<Number> rateListener; + private final ChangeListener<Number> volumeListener; + private final ChangeListener<Number> rateListener; - private Fade fade; + private final Fade fade; AudioContent(String type, Pad pad) { super(pad); diff --git a/PlayWall/src/main/java/de/tobias/playpad/view/FileDragOptionView.java b/PlayWall/src/main/java/de/tobias/playpad/view/FileDragOptionView.java index e04e34fbe511be49ef008abbdd6963f1219026db..56510779c24c25d86b66f9872048e3173576364e 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/view/FileDragOptionView.java +++ b/PlayWall/src/main/java/de/tobias/playpad/view/FileDragOptionView.java @@ -17,13 +17,13 @@ import javafx.scene.text.TextAlignment; import java.util.Set; import java.util.function.Consumer; -public class FileDragOptionView { +public class FileDragOptionView implements PadContentFactory.PadContentTypeChooser { - private HBox optionPane; - private Pane parent; + private final HBox optionPane; + private final Pane parent; - private Transition inTransition; - private Transition outTransition; + private final Transition inTransition; + private final Transition outTransition; public FileDragOptionView(Pane pane) { parent = pane; @@ -31,7 +31,7 @@ public class FileDragOptionView { optionPane = new HBox(); optionPane.prefWidthProperty().bind(parent.widthProperty()); optionPane.prefHeightProperty().bind(parent.heightProperty()); - optionPane.setBackground(new Background(new BackgroundFill(new Color(0.2, 0.2, 0.2, 0.8), new CornerRadii(10), new Insets(0)))); + optionPane.setBackground(new Background(new BackgroundFill(new Color(0.2, 0.2, 0.2, 0.8), new CornerRadii(5), new Insets(0)))); optionPane.setAlignment(Pos.CENTER); optionPane.setPadding(new Insets(5)); optionPane.setSpacing(5); @@ -78,7 +78,7 @@ public class FileDragOptionView { private PadContentFactory selectedConnect; - public void showDropOptions(Set<PadContentFactory> options) { + public void showOptions(Set<PadContentFactory> options) { if (!parent.getChildren().contains(optionPane)) { selectedConnect = null; @@ -125,14 +125,16 @@ public class FileDragOptionView { } - public void showDropOptions(Set<PadContentFactory> options, Consumer<PadContentFactory> onFinish) { - showDropOptions(options); + public void showOptions(Set<PadContentFactory> options, Consumer<PadContentFactory> onFinish) { + showOptions(options); for (Node node : optionPane.getChildren()) { if (node instanceof Label) { Label label = (Label) node; - label.setOnMouseClicked(ev -> - onFinish.accept((PadContentFactory) label.getUserData())); + label.setOnMouseClicked(ev -> { + onFinish.accept((PadContentFactory) label.getUserData()); + hide(); + }); label.setOnMouseEntered(e -> label.pseudoClassStateChanged(PseudoClasses.HOVER_CLASS, true)); label.setOnMouseExited(e -> diff --git a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java index cd36d822fa42ae26dac33467de7f3b1434e23e7a..a840e2a61794571929f1526de89b3b276c4a146f 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java +++ b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/GeneralPadTabViewController.java @@ -1,11 +1,14 @@ package de.tobias.playpad.viewcontroller.option.pad; +import de.thecodelabs.utils.application.system.NativeApplication; import de.thecodelabs.utils.util.Localization; import de.tobias.playpad.Strings; +import de.tobias.playpad.layout.desktop.listener.PadNewContentListener; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadSettings; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.TimeMode; +import de.tobias.playpad.pad.content.PadContentFactory; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; import de.tobias.playpad.viewcontroller.cell.EnumCell; import javafx.beans.value.ChangeListener; @@ -14,8 +17,13 @@ import javafx.fxml.FXML; import javafx.scene.control.*; import javafx.stage.Stage; +import java.util.Optional; + public class GeneralPadTabViewController extends PadSettingsTabViewController { + @FXML + private Label pathLabel; + @FXML private TextField titleTextField; @FXML @@ -31,12 +39,14 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { @FXML private Button deleteButton; - private Pad pad; + private final Pad pad; GeneralPadTabViewController(Pad pad) { load("view/option/pad", "GeneralTab", Localization.getBundle()); this.pad = pad; + pathLabel.setText(pad.getPath().toString()); + if (pad.getStatus() == PadStatus.PLAY || pad.getStatus() == PadStatus.PAUSE) { deleteButton.setDisable(true); } @@ -44,7 +54,6 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { @Override public void init() { - // Init Listener ChangeListener<Number> volumeListener = (a, b, c) -> pad.getPadSettings().setVolume(c.doubleValue() / 100.0); volumeSlider.valueProperty().addListener(volumeListener); @@ -71,16 +80,14 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { @Override public void loadSettings(Pad pad) { - PadSettings padSettings = pad.getPadSettings(); + final PadSettings padSettings = pad.getPadSettings(); - // Bindings titleTextField.textProperty().bindBidirectional(pad.nameProperty()); repeatCheckBox.selectedProperty().bindBidirectional(padSettings.loopProperty()); timeDisplayComboBox.valueProperty().bindBidirectional(padSettings.timeModeProperty()); volumeSlider.setValue(padSettings.getVolume() * 100); - // is Custom TimeMode Actvie customTimeDisplayCheckBox.setSelected(padSettings.isCustomTimeMode()); if (!padSettings.isCustomTimeMode()) { timeDisplayComboBox.setDisable(true); @@ -96,7 +103,21 @@ public class GeneralPadTabViewController extends PadSettingsTabViewController { timeDisplayComboBox.valueProperty().unbindBidirectional(padSettings.timeModeProperty()); } - // Listener + @FXML + private void showPathButtonHandler() { + NativeApplication.sharedInstance().showFileInFileViewer(pad.getPath()); + } + + @FXML + private void chooseButtonHandler(ActionEvent event) { + final PadNewContentListener listener = new PadNewContentListener(pad); + listener.onNew(event, (options, onSelected) -> { + ChoiceDialog<PadContentFactory> dialog = new ChoiceDialog<>(null, options); + final Optional<PadContentFactory> padContentFactory = dialog.showAndWait(); + padContentFactory.ifPresent(onSelected); + }); + } + @FXML private void deleteButtonHandler(ActionEvent event) { pad.clear(); diff --git a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java index 90c49a89b0ed5b8325f6afa207d62357aa8af4ec..9cb33f084def3bdefe0a5610a70e8fc4bf146350 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java +++ b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PadSettingsViewController.java @@ -10,16 +10,14 @@ import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; import de.tobias.playpad.pad.content.PadContentFactory; import de.tobias.playpad.pad.content.PadContentRegistry; -import de.tobias.playpad.pad.mediapath.MediaPath; import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.viewcontroller.IPadSettingsViewController; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; -import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; -import javafx.scene.Parent; -import javafx.scene.control.*; -import javafx.scene.layout.AnchorPane; +import javafx.scene.control.Button; +import javafx.scene.control.Tab; +import javafx.scene.control.TabPane; import javafx.stage.Stage; import javafx.stage.Window; @@ -28,13 +26,11 @@ import java.util.List; public class PadSettingsViewController extends NVC implements IPadSettingsViewController { - private Pad pad; + private final Pad pad; @FXML private TabPane tabPane; - private List<PadSettingsTabViewController> tabs = new ArrayList<>(); - - private Control pathLookupButton; + private final List<PadSettingsTabViewController> tabs = new ArrayList<>(); @FXML private Button finishButton; @@ -50,22 +46,20 @@ public class PadSettingsViewController extends NVC implements IPadSettingsViewCo if (pad.getContent() != null) { try { - // Get Pad Type specific tab - String type = pad.getContent().getType(); - PadContentRegistry registry = PlayPadPlugin.getRegistries().getPadContents(); + final String type = pad.getContent().getType(); + final PadContentRegistry registry = PlayPadPlugin.getRegistries().getPadContents(); - PadContentFactory padContentFactory = registry.getFactory(type); - PadSettingsTabViewController contentTab = padContentFactory.getSettingsViewController(pad); + final PadContentFactory padContentFactory = registry.getFactory(type); + final PadSettingsTabViewController contentTab = padContentFactory.getSettingsViewController(pad); - if (contentTab != null) + if (contentTab != null) { addTab(contentTab); + } } catch (NoSuchComponentException e) { Logger.error(e); } } - setupPathLookupButton(); - NVCStage nvcStage = applyViewControllerToStage(); nvcStage.initOwner(owner); nvcStage.addCloseHook(this::onFinish); @@ -76,44 +70,6 @@ public class PadSettingsViewController extends NVC implements IPadSettingsViewCo setTitle(pad); } - private void setupPathLookupButton() { - PathLookupListener pathLookupListener = new PathLookupListener(); - - if (pad.getContent() != null) { - final ObservableList<MediaPath> paths = pad.getPaths(); - if (paths.size() == 1) { - Button button = new Button(Localization.getString("padSettings.button.path")); - - MediaPath path = paths.get(0); - button.setUserData(path); - button.setOnAction(pathLookupListener); - - pathLookupButton = button; - } else if (paths.size() > 1) { - MenuButton button = new MenuButton(Localization.getString("padSettings.button.path")); - - for (MediaPath path : paths) { - MenuItem item = new MenuItem(path.getFileName()); - button.getItems().add(item); - - item.setUserData(path); - item.setOnAction(pathLookupListener); - } - - pathLookupButton = button; - } - - Parent parent = getParent(); - if (parent instanceof AnchorPane && pathLookupButton != null) { - AnchorPane anchorPane = (AnchorPane) parent; - anchorPane.getChildren().add(pathLookupButton); - - AnchorPane.setLeftAnchor(pathLookupButton, 14.0); - AnchorPane.setBottomAnchor(pathLookupButton, 14.0); - } - } - } - private void setTitle(Pad pad) { String title; if (pad.getStatus() != PadStatus.EMPTY) { @@ -124,11 +80,6 @@ public class PadSettingsViewController extends NVC implements IPadSettingsViewCo getStageContainer().ifPresent(nvcStage -> nvcStage.getStage().setTitle(title)); } - @Override - public void init() { - - } - @Override public void initStage(Stage stage) { stage.getIcons().add(PlayPadPlugin.getInstance().getIcon()); diff --git a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java deleted file mode 100644 index 148f385f1de2c8c9018086a80087c4ef6a8ba314..0000000000000000000000000000000000000000 --- a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PathLookupListener.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.tobias.playpad.viewcontroller.option.pad; - -import de.thecodelabs.utils.application.system.NativeApplication; -import de.tobias.playpad.pad.mediapath.MediaPath; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.scene.control.Button; -import javafx.scene.control.MenuItem; - -import java.nio.file.Path; - -public class PathLookupListener implements EventHandler<ActionEvent> { - - @Override - public void handle(ActionEvent event) { - Object source = event.getSource(); - if (source instanceof Button) { - // single path - Object userData = ((Button) source).getUserData(); - if (userData instanceof MediaPath) { - showPath((MediaPath) userData); - } - } else if (source instanceof MenuItem) { - // multiple path - Object userData = ((MenuItem) source).getUserData(); - if (userData instanceof Path) { - showPath((MediaPath) userData); - } - } - } - - private void showPath(MediaPath path) { - NativeApplication.sharedInstance().showFileInFileViewer(path.getPath()); - } -} \ No newline at end of file diff --git a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java index 67d71214c4bd6b72e4eab97da3d926de39f302d5..647b513e1e6d112118f8003e4c9fe2a1247354cb 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java +++ b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/pad/PlayerPadTabViewController.java @@ -4,7 +4,7 @@ import de.thecodelabs.utils.util.Localization; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadSettings; -import de.tobias.playpad.settings.Fade; +import de.tobias.playpad.settings.FadeSettings; import de.tobias.playpad.view.PseudoClasses; import de.tobias.playpad.viewcontroller.PadSettingsTabViewController; import de.tobias.playpad.viewcontroller.settings.FadeViewController; @@ -54,12 +54,12 @@ public class PlayerPadTabViewController extends PadSettingsTabViewController { PadSettings padSettings = pad.getPadSettings(); if (c && !padSettings.isCustomFade()) - padSettings.setFade(new Fade()); + padSettings.setFade(new FadeSettings()); else if (!c && padSettings.isCustomFade()) padSettings.setFade(null); if (c) - fadeViewController.setFade(padSettings.getFade()); + fadeViewController.setFadeSettings(padSettings.getFade()); }); warningEnableCheckBox.selectedProperty().addListener((a, b, c) -> @@ -104,7 +104,7 @@ public class PlayerPadTabViewController extends PadSettingsTabViewController { PadSettings padSettings = pad.getPadSettings(); if (padSettings.isCustomFade()) - fadeViewController.setFade(padSettings.getFade()); + fadeViewController.setFadeSettings(padSettings.getFade()); customFadeCheckBox.setSelected(padSettings.isCustomFade()); if (!padSettings.isCustomFade()) { diff --git a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java index 384bb2ed2a3fc5a673a82827410e905ca302a45d..87df4b78a70e406d3c1f733dcbc271f8d9532520 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java +++ b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/option/profile/PlayerTabViewController.java @@ -33,7 +33,7 @@ public class PlayerTabViewController extends ProfileSettingsTabViewController { // Player FadeViewController fadeViewController = new FadeViewController(); - fadeViewController.setFade(Profile.currentProfile().getProfileSettings().getFade()); + fadeViewController.setFadeSettings(Profile.currentProfile().getProfileSettings().getFade()); fadeContainer.getChildren().add(fadeViewController.getParent()); setAnchor(fadeViewController.getParent(), 0, 0, 0, 0); } diff --git a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/settings/FadeViewController.java b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/settings/FadeViewController.java index 14515382904128e4e49c021e0431c02f4a4981fe..2793f4269c8bf6533c8e80ca66b932c2b5a8a118 100644 --- a/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/settings/FadeViewController.java +++ b/PlayWall/src/main/java/de/tobias/playpad/viewcontroller/settings/FadeViewController.java @@ -3,7 +3,7 @@ package de.tobias.playpad.viewcontroller.settings; import de.thecodelabs.utils.ui.NVC; import de.thecodelabs.utils.util.Localization; import de.tobias.playpad.Strings; -import de.tobias.playpad.settings.Fade; +import de.tobias.playpad.settings.FadeSettings; import javafx.fxml.FXML; import javafx.scene.control.CheckBox; import javafx.scene.control.Label; @@ -29,8 +29,10 @@ public class FadeViewController extends NVC { private CheckBox fadeOutPauseCheckBox; @FXML private CheckBox fadeOutStopCheckBox; + @FXML + private CheckBox fadeOutEofCheckBox; - private Fade fade; + private FadeSettings fade; public FadeViewController() { load("view/settings", "FadeView", Localization.getBundle()); @@ -54,13 +56,14 @@ public class FadeViewController extends NVC { fade.setFadeOut(seconds); }); - fadeInStartCheckBox.selectedProperty().addListener((a, b, c) -> fade.setFadeInStart(c)); - fadeInPauseCheckBox.selectedProperty().addListener((a, b, c) -> fade.setFadeInPause(c)); - fadeOutPauseCheckBox.selectedProperty().addListener((a, b, c) -> fade.setFadeOutPause(c)); - fadeOutStopCheckBox.selectedProperty().addListener((a, b, c) -> fade.setFadeOutStop(c)); + fadeInStartCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> fade.setFadeInStart(newValue)); + fadeInPauseCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> fade.setFadeInPause(newValue)); + fadeOutPauseCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> fade.setFadeOutPause(newValue)); + fadeOutStopCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> fade.setFadeOutStop(newValue)); + fadeOutEofCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> fade.setFadeOutEof(newValue)); } - public void setFade(Fade fade) { + public void setFadeSettings(FadeSettings fade) { this.fade = fade; if (fade != null) { @@ -76,6 +79,7 @@ public class FadeViewController extends NVC { fadeInPauseCheckBox.setSelected(fade.isFadeInPause()); fadeOutPauseCheckBox.setSelected(fade.isFadeOutPause()); fadeOutStopCheckBox.setSelected(fade.isFadeOutStop()); + fadeOutEofCheckBox.setSelected(fade.isFadeOutEof()); } } } diff --git a/PlayWall/src/main/resources/lang/ui_de.properties b/PlayWall/src/main/resources/lang/ui_de.properties index 4879253468109289fd391d849ab6a4bbcb48cf4e..b6bb0956509a4bea965de5dda78f869754debd26 100755 --- a/PlayWall/src/main/resources/lang/ui_de.properties +++ b/PlayWall/src/main/resources/lang/ui_de.properties @@ -64,14 +64,16 @@ settings.player.label.modus=Wiedergabemodus: settings.player.checkbox.modus=Mehrere Player gleichzeitig wiedergeben settings.player.label.warning=Warnhinweise: settings.player.label.fade=Ein-/Ausblenden: -settings.player.label.fadeIn=Einblenden (in s): -settings.player.label.fadeOut=Ausblenden (in s): +settings.player.label.fadeIn=Einblenden: +settings.player.label.fadeOut=Ausblenden: settings.player.label.startIn=... nach Start settings.player.label.pauseIn=... bei Pause settings.player.label.pauseOut=... bei Pause -settings.player.label.stopOut=... bei Stop/EoF -settings.player.label.fadeInfo=Wird beim Ein- oder Ausblenden die Dauer auf 0 gesetzt, so findet keine \u00DCberblendung statt. Wenn die Datei zu Ende ist, findet kein Ausblenden statt. +settings.player.label.stopOut=... bei Stop +settings.player.label.eofOut=... bei End of File +settings.player.label.fadeInfo=Wird beim Ein- oder Ausblenden die Dauer auf 0 gesetzt, so findet keine \u00DCberblendung statt. settings.player.label.timeDisplay=Zeitanzeige: +settings.warning.label.time=Warnhinweis ab Restdauer: settings.update.label.current=Installierte Version: settings.update.label.search=Nach Updates suchen: settings.update.label.available=Verf\u00FCgbare Updates: @@ -116,7 +118,9 @@ midi.button.new=\u00C4ndern keyboard.label.key=Taste (Tastatur): keyboard.button.new=\u00C4ndern padSettings.button.delete=L\u00F6schen -padSettings.button.path=Pfad zeigen +padSettings.button.path.show=Pfad zeigen +padSettings.button.path.choose=Pfad w\u00E4hlen +padSettings.gen.label.media=Medien: padSettings.gen.label.title=Titel: padSettings.gen.label.volume=Lautst\u00E4rke: padSettings.gen.label.timeDisplay=Zeitanzeige: @@ -155,7 +159,7 @@ project.import.label.media=Medien: project.import.label.name=Name: project.import.label.path=Mediendateien: project.import.label.sync= -project.import.checkbox.sync=Cloud-Sychronisation aktivieren +project.import.checkbox.sync=Cloud-Synchronisation aktivieren project.import.checkbox.profile=Profil importieren project.import.checkbox.media=Medien importieren project.import.button.choose=Ordner ausw\u00E4hlen... @@ -180,7 +184,6 @@ profile.button.new=Neu profile.button.delete=L\u00F6schen profile.button.duplicate=Duplizieren profile.button.choose=Profil w\u00E4hlen -warning.label.time=Warnhinweis ab Restdauer: (Sek) print.label.page=Seite: print.button.cancel=Abbrechen print.button.print=Drucken diff --git a/PlayWall/src/main/resources/view/option/pad/GeneralTab.fxml b/PlayWall/src/main/resources/view/option/pad/GeneralTab.fxml index bbbfc204f67a81ad39794136484871888554f9a3..2e1c993fa424f409a09b658bbd6f66276a9cf9a1 100644 --- a/PlayWall/src/main/resources/view/option/pad/GeneralTab.fxml +++ b/PlayWall/src/main/resources/view/option/pad/GeneralTab.fxml @@ -3,48 +3,56 @@ <?import javafx.geometry.Insets?> <?import javafx.scene.control.*?> <?import javafx.scene.layout.*?> -<VBox spacing="14.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> +<VBox spacing="14.0" xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1"> <children> - <VBox layoutX="14.0" layoutY="14.0" spacing="14.0" AnchorPane.leftAnchor="14.0" AnchorPane.rightAnchor="14.0" - AnchorPane.topAnchor="14.0"> + <HBox alignment="CENTER_LEFT" spacing="14.0"> <children> - <HBox alignment="CENTER_LEFT" layoutX="14.0" layoutY="14.0" spacing="14.0"> - <children> - <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="19.0" prefWidth="150.0" - text="%padSettings.gen.label.title" AnchorPane.leftAnchor="14.0"/> - <TextField fx:id="titleTextField" layoutX="125.0" layoutY="14.0" prefWidth="250.0" - AnchorPane.leftAnchor="127.0"/> - <VBox HBox.hgrow="ALWAYS"/> - <Button fx:id="deleteButton" mnemonicParsing="false" onAction="#deleteButtonHandler" - text="%padSettings.button.delete"/> - </children> - </HBox> - <HBox alignment="CENTER_LEFT" layoutX="14.0" layoutY="48.0" spacing="14.0"> - <children> - <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="50.0" prefWidth="150.0" - text="%padSettings.gen.label.volume" AnchorPane.leftAnchor="14.0"/> - <Slider fx:id="volumeSlider" layoutX="122.0" layoutY="54.0" prefWidth="250.0" - showTickLabels="true" showTickMarks="true" snapToTicks="true" value="100.0" - AnchorPane.leftAnchor="127.0"/> - <VBox HBox.hgrow="ALWAYS"/> - <CheckBox fx:id="repeatCheckBox" mnemonicParsing="false" text="%padSettings.checkbox.loop"/> - </children> - </HBox> - <HBox alignment="CENTER_LEFT" layoutX="14.0" layoutY="84.0" spacing="14.0"> - <children> - <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="89.0" prefWidth="150.0" - text="%padSettings.gen.label.timeDisplay" AnchorPane.leftAnchor="14.0"/> - <ComboBox fx:id="timeDisplayComboBox" layoutX="127.0" layoutY="84.0" prefWidth="250.0" - AnchorPane.leftAnchor="127.0"/> - <VBox HBox.hgrow="ALWAYS"/> - <CheckBox fx:id="customTimeDisplayCheckBox" layoutX="406.0" layoutY="88.0" - mnemonicParsing="false" text="%padSettings.gen.checkbox.customSettings"/> - </children> - </HBox> + <Label alignment="CENTER_RIGHT" prefWidth="150.0" text="%padSettings.gen.label.media" /> + <Label fx:id="pathLabel" text="Label" textOverrun="CENTER_ELLIPSIS" /> + <VBox HBox.hgrow="ALWAYS" /> + <Button mnemonicParsing="false" text="%padSettings.button.path.show" onAction="#showPathButtonHandler"/> </children> - </VBox> + </HBox> + <HBox spacing="14.0"> + <children> + <Button mnemonicParsing="false" onAction="#chooseButtonHandler" text="%padSettings.button.path.choose" /> + <Button fx:id="deleteButton" mnemonicParsing="false" onAction="#deleteButtonHandler" text="%padSettings.button.delete" /> + </children> + <padding> + <Insets left="164.0" /> + </padding> + </HBox> + <Separator prefWidth="200.0" /> + <HBox alignment="CENTER_LEFT" spacing="14.0"> + <children> + <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="19.0" prefWidth="150.0" text="%padSettings.gen.label.title" AnchorPane.leftAnchor="14.0" /> + <TextField fx:id="titleTextField" layoutX="125.0" layoutY="14.0" prefWidth="250.0" AnchorPane.leftAnchor="127.0" /> + </children> + </HBox> + <HBox alignment="CENTER_LEFT" spacing="14.0"> + <children> + <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="50.0" prefWidth="150.0" text="%padSettings.gen.label.volume" AnchorPane.leftAnchor="14.0" /> + <Slider fx:id="volumeSlider" layoutX="122.0" layoutY="54.0" prefWidth="250.0" showTickLabels="true" showTickMarks="true" snapToTicks="true" value="100.0" AnchorPane.leftAnchor="127.0" /> + <VBox HBox.hgrow="ALWAYS" /> + <CheckBox fx:id="repeatCheckBox" mnemonicParsing="false" text="%padSettings.checkbox.loop" /> + </children> + </HBox> + <HBox alignment="CENTER_LEFT" spacing="14.0"> + <children> + <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="89.0" prefWidth="150.0" text="%padSettings.gen.label.timeDisplay" AnchorPane.leftAnchor="14.0" /> + <CheckBox fx:id="customTimeDisplayCheckBox" layoutX="406.0" layoutY="88.0" mnemonicParsing="false" text="%padSettings.gen.checkbox.customSettings" /> + </children> + </HBox> + <HBox> + <children> + <ComboBox fx:id="timeDisplayComboBox" prefWidth="250.0" /> + </children> + <padding> + <Insets left="164.0" /> + </padding> + </HBox> </children> <padding> - <Insets bottom="14.0" left="14.0" right="14.0" top="14.0"/> + <Insets bottom="14.0" left="14.0" right="14.0" top="14.0" /> </padding> </VBox> diff --git a/PlayWall/src/main/resources/view/settings/FadeView.fxml b/PlayWall/src/main/resources/view/settings/FadeView.fxml index 41b62886108419caa49806c4e3d2b6b21080ad40..94c88e46b71d49e1d6329457922e436f8c375690 100644 --- a/PlayWall/src/main/resources/view/settings/FadeView.fxml +++ b/PlayWall/src/main/resources/view/settings/FadeView.fxml @@ -51,6 +51,8 @@ text="%settings.player.label.pauseOut"/> <CheckBox fx:id="fadeOutStopCheckBox" mnemonicParsing="false" text="%settings.player.label.stopOut"/> + <CheckBox fx:id="fadeOutEofCheckBox" mnemonicParsing="false" + text="%settings.player.label.eofOut"/> </children> </HBox> </children> diff --git a/PlayWall/src/main/resources/view/settings/WarningFeedbackSettingsView.fxml b/PlayWall/src/main/resources/view/settings/WarningFeedbackSettingsView.fxml index 115ed50e46fbf3987e97541afe8bd1782b246400..27801c98ba344874f9658e81722cee69720e32e0 100644 --- a/PlayWall/src/main/resources/view/settings/WarningFeedbackSettingsView.fxml +++ b/PlayWall/src/main/resources/view/settings/WarningFeedbackSettingsView.fxml @@ -10,7 +10,7 @@ <HBox alignment="CENTER_LEFT" spacing="14.0"> <children> <Label alignment="CENTER_RIGHT" layoutX="14.0" layoutY="14.0" prefWidth="150.0" - text="%warning.label.time" textAlignment="RIGHT" wrapText="true" AnchorPane.leftAnchor="14.0"/> + text="%settings.warning.label.time" textAlignment="RIGHT" wrapText="true" AnchorPane.leftAnchor="14.0"/> <Slider fx:id="warningFeedbackTimeSlider" blockIncrement="0.1" majorTickUnit="1.0" max="10.0" minorTickCount="9" showTickLabels="true" showTickMarks="true" snapToTicks="true" value="5.0" HBox.hgrow="ALWAYS"/> diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/design/ModernDesignSizeHelper.java b/PlayWallCore/src/main/java/de/tobias/playpad/design/ModernDesignSizeHelper.java index d06dbc7a7c6619d5dedb9389c9124e680fe0bb53..91939942841248f3799c5dcf7b6b9e738b5b9831 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/design/ModernDesignSizeHelper.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/design/ModernDesignSizeHelper.java @@ -2,7 +2,7 @@ package de.tobias.playpad.design; public class ModernDesignSizeHelper { - private static final double MIN_WIDTH = 165; + private static final double MIN_WIDTH = 140; private static final double MIN_HEIGHT = 115; private ModernDesignSizeHelper() { diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/PadSettings.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/PadSettings.java index f85ef7e4c280e323aebcc5ea805e94a0cd5e5dd2..a935edd4808ae2d9f1c92c99286591e429334cd8 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/PadSettings.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/PadSettings.java @@ -7,7 +7,7 @@ import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.server.sync.command.CommandManager; import de.tobias.playpad.server.sync.command.Commands; import de.tobias.playpad.server.sync.listener.upstream.PadSettingsUpdateListener; -import de.tobias.playpad.settings.Fade; +import de.tobias.playpad.settings.FadeSettings; import de.tobias.playpad.tigger.Trigger; import de.tobias.playpad.tigger.TriggerPoint; import javafx.beans.binding.BooleanBinding; @@ -31,7 +31,7 @@ public class PadSettings { private DoubleProperty speedProperty = new SimpleDoubleProperty(1.0); private BooleanProperty loopProperty = new SimpleBooleanProperty(false); private ObjectProperty<TimeMode> timeModeProperty = new SimpleObjectProperty<>(); - private ObjectProperty<Fade> fadeProperty = new SimpleObjectProperty<>(); + private ObjectProperty<FadeSettings> fadeProperty = new SimpleObjectProperty<>(); private ObjectProperty<Duration> warningProperty = new SimpleObjectProperty<>(); private ObjectProperty<Duration> cueInProperty = new SimpleObjectProperty<>(); @@ -137,18 +137,18 @@ public class PadSettings { * * @return Fade */ - public Fade getFade() { + public FadeSettings getFade() { if (fadeProperty.isNull().get() && Profile.currentProfile() != null) { return Profile.currentProfile().getProfileSettings().getFade(); } return fadeProperty.get(); } - public void setFade(Fade fade) { + public void setFade(FadeSettings fade) { this.fadeProperty.set(fade); } - public ObjectProperty<Fade> fadeProperty() { + public ObjectProperty<FadeSettings> fadeProperty() { return fadeProperty; } diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/PadSettingsSerializer.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/PadSettingsSerializer.java index f3fc932cdbf7cce0760bea4f78bb7955214e8451..82e70e61fcdcf7c06ccc037ad6296898528be82b 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/PadSettingsSerializer.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/PadSettingsSerializer.java @@ -4,7 +4,7 @@ import de.thecodelabs.logger.Logger; import de.thecodelabs.storage.settings.UserDefaults; import de.tobias.playpad.design.modern.model.ModernCartDesign; import de.tobias.playpad.design.modern.serializer.ModernCartDesignSerializer; -import de.tobias.playpad.settings.Fade; +import de.tobias.playpad.settings.FadeSettings; import de.tobias.playpad.tigger.Trigger; import de.tobias.playpad.tigger.TriggerPoint; import javafx.util.Duration; @@ -51,7 +51,7 @@ public class PadSettingsSerializer { if (settingsElement.element(TIME_MODE_ELEMENT) != null) padSettings.setTimeMode(TimeMode.valueOf(settingsElement.element(TIME_MODE_ELEMENT).getStringValue())); if (settingsElement.element(FADE_ELEMENT) != null) - padSettings.setFade(Fade.load(settingsElement.element(FADE_ELEMENT))); + padSettings.setFade(FadeSettings.load(settingsElement.element(FADE_ELEMENT))); if (settingsElement.element(WARNING_ELEMENT) != null) { try { Duration duration = Duration.valueOf(settingsElement.element(WARNING_ELEMENT).getStringValue().replace(" ", "")); diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/content/PadContentFactory.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/content/PadContentFactory.java index 5b34c1653f0bd0836507fc4a7af1a4082c48dbd2..e300c5a8b8f5f2c5a2c711bbce42629a541d51ef 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/content/PadContentFactory.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/content/PadContentFactory.java @@ -9,10 +9,15 @@ import de.tobias.playpad.viewcontroller.option.ProfileSettingsTabViewController; import javafx.scene.layout.Pane; import java.nio.file.Path; +import java.util.Set; +import java.util.function.Consumer; -// COMMENT PadContentFactory public abstract class PadContentFactory extends Component implements Comparable<PadContentFactory> { + public interface PadContentTypeChooser { + void showOptions(Set<PadContentFactory> options, Consumer<PadContentFactory> onSelected); + } + public PadContentFactory(String type) { super(type); } diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/Fade.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/Fade.java index de3828da7264143b30c1c0a49f94b58407d4919a..086f8ede86bdb9f9e313bd74c541223dfb43bd82 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/Fade.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/Fade.java @@ -11,10 +11,10 @@ import javafx.util.Duration; */ public class Fade { - private FadeDelegate fadeDelegate; - private Transition currentFadeTransition; + private static final double VELOCITY = 1; - private double velocity = 1; + private final FadeDelegate fadeDelegate; + private Transition currentFadeTransition; public Fade(FadeDelegate fadeDelegate) { this.fadeDelegate = fadeDelegate; @@ -60,10 +60,10 @@ public class Fade { protected void interpolate(double frac) { double diff = Math.abs(to - from); if (from < to) { // Fade In - double fade = fadeInVolumeMultiplier(frac, velocity); + double fade = fadeInVolumeMultiplier(frac); fadeDelegate.onFadeLevelChange(from + fade * diff); } else { // Fade Out - double fade = fadeOutVolumeMultiplier(frac, velocity); + double fade = fadeOutVolumeMultiplier(frac); double newValue = to + fade * diff; fadeDelegate.onFadeLevelChange(newValue); } @@ -79,12 +79,12 @@ public class Fade { currentFadeTransition.play(); } - private double fadeInVolumeMultiplier(double time, double velocity) { - return Math.pow(Math.E, velocity * (time - 1)) * time; + private double fadeInVolumeMultiplier(double time) { + return Math.pow(Math.E, VELOCITY * (time - 1)) * time; } - private double fadeOutVolumeMultiplier(double time, double velocity) { - return Math.pow(Math.E, -velocity * time) * (1 - time); + private double fadeOutVolumeMultiplier(double time) { + return Math.pow(Math.E, -VELOCITY * time) * (1 - time); } } diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/Fadeable.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/Fadeable.java index a0f5444cd47f4548471c82f34bad43b006f693dc..7e343f61b3d67bcd1b92703ec14cc2837c259835 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/Fadeable.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/Fadeable.java @@ -7,6 +7,10 @@ public interface Fadeable { void fadeIn(); + default void fadeOut() { + fadeOut(null); + } + void fadeOut(Runnable runnable); boolean isFadeActive(); diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/listener/PadFadeDurationListener.java b/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/listener/PadFadeDurationListener.java index d9eee37384b5f462200ec2e45f18b1e9b630e56e..b795033f65d4b4004432d8c53d82a8ee0f115939 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/listener/PadFadeDurationListener.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/pad/fade/listener/PadFadeDurationListener.java @@ -9,7 +9,7 @@ import javafx.util.Duration; public class PadFadeDurationListener implements ChangeListener<Duration> { - private Pad pad; + private final Pad pad; public PadFadeDurationListener(Pad pad) { this.pad = pad; @@ -17,15 +17,17 @@ public class PadFadeDurationListener implements ChangeListener<Duration> { @Override public void changed(ObservableValue<? extends Duration> observable, Duration oldValue, Duration newValue) { - if (pad.getPadSettings().getFade().isFadeOutStop()) { + if (pad.getPadSettings().getFade().isFadeOutEof()) { final Duration fadeDuration = pad.getPadSettings().getFade().getFadeOut(); if (pad.getContent() instanceof Durationable) { - Durationable durationable = (Durationable) pad.getContent(); - if (durationable.getPosition() != null && durationable.getDuration() != null) { - if (durationable.getPosition().add(fadeDuration).greaterThan(durationable.getDuration())) { - fadeOut(); - } + final Durationable durationable = (Durationable) pad.getContent(); + + final Duration position = durationable.getPosition(); + final Duration duration = durationable.getDuration(); + + if (position != null && duration != null && position.add(fadeDuration).greaterThan(duration)) { + fadeOut(); } } } @@ -33,11 +35,10 @@ public class PadFadeDurationListener implements ChangeListener<Duration> { private void fadeOut() { if (pad.getContent() instanceof Fadeable) { - Fadeable fadeable = (Fadeable) pad.getContent(); + final Fadeable fadeable = (Fadeable) pad.getContent(); if (!fadeable.isFadeActive()) { - fadeable.fadeOut(null); + fadeable.fadeOut(); } - } } } diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/profile/ProfileSettings.java b/PlayWallCore/src/main/java/de/tobias/playpad/profile/ProfileSettings.java index a2039d5c3d0b27febb982aff03ae0d02e0bcd698..0b20a03f7e516161a6507e746031236a4c02c80e 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/profile/ProfileSettings.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/profile/ProfileSettings.java @@ -8,7 +8,7 @@ import de.tobias.playpad.action.feedback.LightMode; import de.tobias.playpad.design.modern.model.ModernGlobalDesign; import de.tobias.playpad.design.modern.serializer.ModernGlobalDesignSerializer; import de.tobias.playpad.pad.TimeMode; -import de.tobias.playpad.settings.Fade; +import de.tobias.playpad.settings.FadeSettings; import javafx.beans.property.BooleanProperty; import javafx.beans.property.DoubleProperty; import javafx.beans.property.SimpleBooleanProperty; @@ -66,7 +66,7 @@ public class ProfileSettings { private boolean windowAlwaysOnTop = false; @Key - private Fade fade = new Fade(); + private FadeSettings fade = new FadeSettings(); @Key private TimeMode playerTimeDisplayMode = TimeMode.REST; @@ -115,7 +115,7 @@ public class ProfileSettings { return windowAlwaysOnTop; } - public Fade getFade() { + public FadeSettings getFade() { return fade; } @@ -168,7 +168,7 @@ public class ProfileSettings { this.windowAlwaysOnTop = windowAlwaysOnTop; } - public void setFade(Fade fade) { + public void setFade(FadeSettings fade) { this.fade = fade; } @@ -247,7 +247,7 @@ public class ProfileSettings { } if (root.element(FADE_ELEMENT) != null) { - Fade fade = Fade.load(root.element(FADE_ELEMENT)); + FadeSettings fade = FadeSettings.load(root.element(FADE_ELEMENT)); profileSettings.setFade(fade); } diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/registry/Component.java b/PlayWallCore/src/main/java/de/tobias/playpad/registry/Component.java index 8c645af1e6e2119ed09f38d44926e05531039ba0..6f42120f2074321041352844c3e100bbb0271ff4 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/registry/Component.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/registry/Component.java @@ -12,8 +12,8 @@ import javafx.scene.Node; */ public class Component implements Displayable { - private String type; - private StringProperty displayProperty; + private final String type; + private final StringProperty displayProperty; private FontIcon graphics; public Component(String type) { diff --git a/PlayWallCore/src/main/java/de/tobias/playpad/settings/Fade.java b/PlayWallCore/src/main/java/de/tobias/playpad/settings/FadeSettings.java similarity index 81% rename from PlayWallCore/src/main/java/de/tobias/playpad/settings/Fade.java rename to PlayWallCore/src/main/java/de/tobias/playpad/settings/FadeSettings.java index 4b30a96f2101acc9136fb218a92918d1edea5a69..f5202e68e0a92a2ef66f85ad8523c41a4b04a4c6 100644 --- a/PlayWallCore/src/main/java/de/tobias/playpad/settings/Fade.java +++ b/PlayWallCore/src/main/java/de/tobias/playpad/settings/FadeSettings.java @@ -14,7 +14,7 @@ import org.dom4j.Element; * @see PadSettings#getFade() * @since 6.0.0 */ -public class Fade { +public class FadeSettings { private Duration fadeIn; private Duration fadeOut; @@ -23,11 +23,12 @@ public class Fade { private boolean fadeInPause; private boolean fadeOutPause; private boolean fadeOutStop; + private boolean fadeOutEof; /** * Erstellt ein neues Fade mit den Default Werten. (Fade Dauer: 0 sec) */ - public Fade() { + public FadeSettings() { this(Duration.ONE, Duration.ONE); } @@ -37,8 +38,8 @@ public class Fade { * @param fadeIn Fade In Dauer * @param fadeOut Fade Out Dauer */ - public Fade(Duration fadeIn, Duration fadeOut) { - this(fadeIn, fadeOut, false, true, true, true); + public FadeSettings(Duration fadeIn, Duration fadeOut) { + this(fadeIn, fadeOut, false, true, true, true, false); } /** @@ -51,13 +52,14 @@ public class Fade { * @param fadeOutPause Fade vor Pause * @param fadeOutStop Fade vor Stop */ - public Fade(Duration fadeIn, Duration fadeOut, boolean fadeInStart, boolean fadeInPause, boolean fadeOutPause, boolean fadeOutStop) { + public FadeSettings(Duration fadeIn, Duration fadeOut, boolean fadeInStart, boolean fadeInPause, boolean fadeOutPause, boolean fadeOutStop, boolean fadeOutEof) { this.fadeIn = fadeIn; this.fadeOut = fadeOut; this.fadeInStart = fadeInStart; this.fadeInPause = fadeInPause; this.fadeOutPause = fadeOutPause; this.fadeOutStop = fadeOutStop; + this.fadeOutEof = fadeOutEof; } public Duration getFadeIn() { @@ -108,6 +110,14 @@ public class Fade { this.fadeOutStop = fadeOutStop; } + public boolean isFadeOutEof() { + return fadeOutEof; + } + + public void setFadeOutEof(boolean fadeOutEof) { + this.fadeOutEof = fadeOutEof; + } + /* * Serialize */ @@ -116,6 +126,7 @@ public class Fade { private static final String FADE_IN = "FadeIn"; private static final String ON_STOP_ATTR = "onStop"; + private static final String ON_EOF_ATTR = "onEof"; private static final String ON_PAUSE_ATTR = "onPause"; private static final String ON_START_ATTR = "onStart"; @@ -129,11 +140,12 @@ public class Fade { fadeOutElement.addText(fadeOut.toString()); fadeOutElement.addAttribute(ON_PAUSE_ATTR, String.valueOf(fadeOutPause)); fadeOutElement.addAttribute(ON_STOP_ATTR, String.valueOf(fadeOutStop)); + fadeOutElement.addAttribute(ON_EOF_ATTR, String.valueOf(fadeOutEof)); } - public static Fade load(Element container) { + public static FadeSettings load(Element container) { try { - Fade fade = new Fade(); + FadeSettings fade = new FadeSettings(); Element fadeInElement = container.element(FADE_IN); if (fadeInElement.attributeValue(ON_PAUSE_ATTR) != null) @@ -147,6 +159,8 @@ public class Fade { fade.setFadeOutPause(Boolean.parseBoolean(fadeOutElement.attributeValue(ON_PAUSE_ATTR))); if (fadeOutElement.attributeValue(ON_STOP_ATTR) != null) fade.setFadeOutStop(Boolean.parseBoolean(fadeOutElement.attributeValue(ON_STOP_ATTR))); + if (fadeOutElement.attributeValue(ON_EOF_ATTR) != null) + fade.setFadeOutEof(Boolean.parseBoolean(fadeOutElement.attributeValue(ON_EOF_ATTR))); fade.setFadeOut(Duration.valueOf(fadeOutElement.getStringValue().replace(" ", ""))); return fade; } catch (Exception e) {