diff --git a/PlayWall/assets/de/tobias/playpad/assets/style/touch.css b/PlayWall/assets/de/tobias/playpad/assets/style/touch.css new file mode 100644 index 0000000000000000000000000000000000000000..8ae65926cfaa567e2d4094aea017dab40d8dd67f --- /dev/null +++ b/PlayWall/assets/de/tobias/playpad/assets/style/touch.css @@ -0,0 +1,12 @@ +.menu .label { + -fx-font-size: 25px; + -fx-padding: 10px; +} + +.label { + -fx-font-size: 17px; +} + +.button { + -fx-font-size : 20px; +} \ No newline at end of file diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml index 6bfb1a31f55408e838d5f8bb5d506aefb4f7077b..a9ea5cfc77eae95c5604f52b621883d4867ae3e0 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/touch/header.fxml @@ -8,7 +8,7 @@ <HBox xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"> <children> -<MenuBar fx:id="menuBar" maxHeight="1.7976931348623157E308" prefWidth="600.0" HBox.hgrow="ALWAYS"> +<MenuBar fx:id="menuBar" maxHeight="1.7976931348623157E308"> <menus> <Menu mnemonicParsing="false" text="%main.menu.file"> <items> @@ -81,7 +81,7 @@ </Menu> </menus> </MenuBar> -<ToolBar fx:id="toolbar" VBox.vgrow="ALWAYS"> +<ToolBar fx:id="toolbar" maxHeight="1.7976931348623157E308" maxWidth="1.7976931348623157E308" HBox.hgrow="ALWAYS" VBox.vgrow="ALWAYS"> <items> <HBox fx:id="toolbarHBox" alignment="CENTER_LEFT" maxWidth="1.7976931348623157E308" prefHeight="28.0" prefWidth="586.0" spacing="14.0"> <children> diff --git a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java index dc87787fe046a3a0016c16246dd4091e68eed158..d0a1828b92e8afb6a25a687366ca9812330e371b 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadImpl.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadImpl.java @@ -44,7 +44,7 @@ public class PlayPadImpl implements PlayPad { private MainViewControllerV2 mainViewController; private Project currentProject; - + public PlayPadImpl() { pluginManager = PluginManagerFactory.createPluginManager(); deletedPlugins = new HashSet<>(); @@ -55,6 +55,10 @@ public class PlayPadImpl implements PlayPad { mainViewListeners.add(listener); } + public List<WindowListener<IMainViewController>> getMainViewListeners() { + return mainViewListeners; + } + @Override public void addSettingsListener(SettingsListener listener) { settingsListeners.add(listener); diff --git a/PlayWall/src/de/tobias/playpad/PlayPadMain.java b/PlayWall/src/de/tobias/playpad/PlayPadMain.java index dbf437a19b17e708d86a77cc6fb249076d25a634..3efcb2c05a4840f37e88e82e8eca750becb34e8a 100644 --- a/PlayWall/src/de/tobias/playpad/PlayPadMain.java +++ b/PlayWall/src/de/tobias/playpad/PlayPadMain.java @@ -171,21 +171,13 @@ public class PlayPadMain extends Application implements LocalizationDelegate, Pr ProjectReference.loadProjects(); // Changelog nach Update anzeigen - try { - ViewController.create(ChangelogDialog.class); - } catch (Exception e) { - e.printStackTrace(); - } + ViewController.create(ChangelogDialog.class); // Auto Open Project if (getParameters().getRaw().size() > 0) { - try { - UUID uuid = UUID.fromString(getParameters().getNamed().get("project")); - impl.openProject(Project.load(ProjectReference.getProject(uuid), true, null)); - return; - } catch (IllegalArgumentException | NullPointerException e) {} catch (Exception e) { - e.printStackTrace(); - } + UUID uuid = UUID.fromString(getParameters().getNamed().get("project")); + impl.openProject(Project.load(ProjectReference.getProject(uuid), true, null)); + return; } ViewController.create(LaunchDialog.class, stage); diff --git a/PlayWall/src/de/tobias/playpad/RegistryCollectionImpl.java b/PlayWall/src/de/tobias/playpad/RegistryCollectionImpl.java index 672126602794356c2ed5400a396c02301adb8f41..12d4b0fe594f1c12be839fa66fd6f129c1424acc 100644 --- a/PlayWall/src/de/tobias/playpad/RegistryCollectionImpl.java +++ b/PlayWall/src/de/tobias/playpad/RegistryCollectionImpl.java @@ -22,7 +22,7 @@ public class RegistryCollectionImpl implements RegistryCollection { private Registry<MapperConnect> mapperRegistry; private PadContentRegistry padContentRegistry; private Registry<TriggerItemConnect> triggerItemRegistry; - private Registry<MainLayoutConnect> mainLayoutRegistry; + private DefaultRegistry<MainLayoutConnect> mainLayoutRegistry; public RegistryCollectionImpl() { actionRegistry = new ComponentRegistry<>("Action"); @@ -32,7 +32,7 @@ public class RegistryCollectionImpl implements RegistryCollection { mapperRegistry = new ComponentRegistry<>("Mapper"); padContentRegistry = new PadContentRegistry("PadContent"); triggerItemRegistry = new ComponentRegistry<>("Trigger"); - mainLayoutRegistry = new ComponentRegistry<>("MainLayout"); + mainLayoutRegistry = new DefaultComponentRegistry<>("MainLayout"); } @Override @@ -71,7 +71,7 @@ public class RegistryCollectionImpl implements RegistryCollection { } @Override - public Registry<MainLayoutConnect> getMainLayouts() { + public DefaultRegistry<MainLayoutConnect> getMainLayouts() { return mainLayoutRegistry; } diff --git a/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java index 5fdea5f9ebcc8b07e56ae97116d0032e4f80169f..a8d6a00d5178692af7cb57afc6477888704b76a6 100644 --- a/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java @@ -299,9 +299,6 @@ public class ClassicGlobalDesign extends Design implements GlobalDesign { @Override public void applyCss(Stage stage) { - // Clear Old - stage.getScene().getStylesheets().clear(); - // Add Build in Default stage.getScene().getStylesheets().add("de/tobias/playpad/assets/style.css"); stage.getScene().getStylesheets().add("de/tobias/playpad/assets/classic_style.css"); diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java index 0316c2b8acce388c6bdf96cab23c25819123b210..70558a0a237656c2489c7f9cfdff523d4b2c4320 100644 --- a/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java @@ -173,9 +173,6 @@ public class ModernGlobalDesign extends Design implements GlobalDesign, DesignCo @Override public void applyCss(Stage stage) { - // Clear Old - stage.getScene().getStylesheets().clear(); - // Add Build in Default stage.getScene().getStylesheets().add("de/tobias/playpad/assets/style.css"); stage.getScene().getStylesheets().add("de/tobias/playpad/assets/modern_style.css"); diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java index ab47b0db75b41ca03ed53f0977481eb6d350216b..e0c9e2b651c2b9cff4e5a4f7fa15db7a10c8f4be 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java @@ -9,7 +9,7 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { @Override public String getType() { - return "desktop"; + return "Desktop"; } @Override @@ -26,5 +26,10 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { public IPadViewV2 createPadView() { return new DesktopPadView(); } + + @Override + public String getStylesheet() { + return null; + } } diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java index 8b231ae891e57d9da36367c854c5757f55ccb307..0dac72d7504196f14cad72fdb4c631d0c117edb1 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMainLayoutConnect.java @@ -9,7 +9,7 @@ public class TouchMainLayoutConnect implements MainLayoutConnect { @Override public String getType() { - return "touch"; + return "Touch"; } @Override @@ -27,5 +27,9 @@ public class TouchMainLayoutConnect implements MainLayoutConnect { return new TouchPadView(); } - + @Override + public String getStylesheet() { + return "de/tobias/playpad/assets/style/touch.css"; + } + } diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java index eea53c7dd3d9abe8fc3c625901b9b0379a5777a7..17e1ff5b6c3be058ab96117df7d1a6e5c440d08c 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java @@ -1,24 +1,50 @@ package de.tobias.playpad.layout.touch; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.Strings; +import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectNotFoundException; +import de.tobias.playpad.project.ProjectReference; +import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileNotFoundException; +import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.view.main.MenuType; +import de.tobias.playpad.viewcontroller.dialog.ImportDialog; import de.tobias.playpad.viewcontroller.main.BasicMenuToolbarViewController; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.scene.Node; +import javafx.scene.control.Button; import javafx.scene.control.MenuItem; import javafx.scene.control.Slider; import javafx.scene.image.Image; public class TouchMenuToolbarViewController extends BasicMenuToolbarViewController { + private IMainViewController mainViewController; + public TouchMenuToolbarViewController(IMainViewController mainViewController) { super("header", "de/tobias/playpad/assets/view/main/touch/", PlayPadMain.getUiResourceBundle(), mainViewController); + this.mainViewController = mainViewController; + + toolbarHBox.prefWidthProperty().bind(toolbar.widthProperty().subtract(25)); + toolbarHBox.prefHeightProperty().bind(toolbar.minHeightProperty()); } @Override public void initPageButtons() { + pageHBox.getChildren().clear(); + + ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + for (int i = 0; i < settings.getPageCount(); i++) { + Button button = new Button(Localization.getString(Strings.UI_Window_Main_PageButton, (i + 1))); + button.setUserData(i); + button.setFocusTraversable(false); + button.setOnAction(this); + pageHBox.getChildren().add(button); + } } @Override @@ -28,49 +54,56 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll @Override public void addToolbarIcon(Image icon) { - + // TODO Implement } @Override public void removeToolbarIcon(Image icon) { - + // TODO Implement } @Override public void addToolbarItem(Node node) { - // TODO Auto-generated method stub - + iconHbox.getChildren().add(node); } @Override public void removeToolbarItem(Node node) { - // TODO Auto-generated method stub - + iconHbox.getChildren().remove(node); } @Override public void addMenuItem(MenuItem item, MenuType type) { - + if (type == MenuType.EXTENSION) { + extensionMenu.getItems().add(item); + } else if (type == MenuType.SETTINGS) { + // TODO Implement + } } @Override public void removeMenuItem(MenuItem item) { + if (extensionMenu.getItems().contains(item)) + extensionMenu.getItems().remove(item); + // TODO Implement } @Override public boolean isAlwaysOnTopActive() { - return false; + return alwaysOnTopItem.isSelected(); } @Override public boolean isFullscreenActive() { - return false; + return fullScreenMenuItem.isSelected(); } @Override public void deinit() { - + super.deinit(); + toolbarHBox.prefWidthProperty().unbind(); + toolbarHBox.prefHeightProperty().unbind(); } @Override @@ -80,7 +113,38 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll @Override public void handle(ActionEvent event) { - + if (event.getSource() instanceof Button) { + Button button = (Button) event.getSource(); + int page = (int) button.getUserData(); + mainViewController.showPage(page); + } else if (event.getSource() instanceof MenuItem) { + // Zuletzt verwendete Projects + doAction(() -> + { + // TODO Rewrite mit openProject von BasicMenuToolbarViewController + MenuItem item = (MenuItem) event.getSource(); + ProjectReference ref = (ProjectReference) item.getUserData(); + try { + // Speichern das alte Project in mvc.setProject(Project) + Project project = Project.load(ref, true, ImportDialog.getInstance(mainViewController.getStage())); + PlayPadMain.getProgramInstance().openProject(project); + } catch (ProfileNotFoundException e) { + e.printStackTrace(); + mainViewController.showError( + Localization.getString(Strings.Error_Profile_NotFound, ref.getProfileReference(), e.getLocalizedMessage())); + + // Neues Profile wählen + Profile profile = ImportDialog.getInstance(mainViewController.getStage()).getUnkownProfile(); + ref.setProfileReference(profile.getRef()); + } catch (ProjectNotFoundException e) { + e.printStackTrace(); + mainViewController.showError(Localization.getString(Strings.Error_Project_NotFound, ref, e.getLocalizedMessage())); + } catch (Exception e) { + e.printStackTrace(); + mainViewController.showError(Localization.getString(Strings.Error_Project_Open, ref, e.getLocalizedMessage())); + } + }); + } } } \ No newline at end of file diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java index bba559dedc77332195d396ca8e35ebad117f976a..115adbccd53445c32310ded29f1635e9d122f03f 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadView.java @@ -1,90 +1,278 @@ package de.tobias.playpad.layout.touch; +import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.PseudoClasses; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.conntent.PadContent; +import de.tobias.playpad.pad.conntent.PadContentConnect; import de.tobias.playpad.pad.view.IPadContentView; import de.tobias.playpad.pad.view.IPadViewV2; import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.registry.NoSuchComponentException; +import de.tobias.playpad.view.EmptyPadView; +import de.tobias.utils.ui.icon.FontAwesomeType; +import de.tobias.utils.ui.icon.FontIcon; +import de.tobias.utils.ui.scene.BusyView; +import javafx.beans.property.Property; import javafx.css.PseudoClass; +import javafx.geometry.Pos; +import javafx.scene.Node; +import javafx.scene.control.Label; import javafx.scene.control.ProgressBar; +import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; public class TouchPadView implements IPadViewV2 { + private Label indexLabel; + private Label loopLabel; + private Label triggerLabel; + private Label errorLabel; + + private HBox infoBox; + private Label timeLabel; + + private HBox preview; + private IPadContentView previewContent; + + private ProgressBar playBar; + + private StackPane superRoot; + private VBox root; + private BusyView busyView; + + private transient TouchPadViewController controller; // Reference to its controller + + public TouchPadView() { + controller = new TouchPadViewController(this); + setupView(); + } + + private void setupView() { + superRoot = new StackPane(); + root = new VBox(); + busyView = new BusyView(superRoot); + + indexLabel = new Label(); + + loopLabel = new Label(); // Active über Visible + loopLabel.setGraphic(new FontIcon(FontAwesomeType.REPEAT)); + + triggerLabel = new Label(); + triggerLabel.setGraphic(new FontIcon(FontAwesomeType.EXTERNAL_LINK)); + + errorLabel = new Label(); + errorLabel.setGraphic(new FontIcon(FontAwesomeType.WARNING)); + + timeLabel = new Label(); + + infoBox = new HBox(); // childern in addDefaultButton() + infoBox.setSpacing(5); + + preview = new HBox(); + HBox.setHgrow(preview, Priority.ALWAYS); + VBox.setVgrow(preview, Priority.ALWAYS); + + HBox.setHgrow(timeLabel, Priority.ALWAYS); + timeLabel.setMaxWidth(Double.MAX_VALUE); + timeLabel.setAlignment(Pos.CENTER_RIGHT); + + playBar = new ProgressBar(0); + playBar.prefWidthProperty().bind(root.widthProperty()); + + root.getChildren().addAll(infoBox, preview, playBar); + superRoot.getChildren().addAll(root); + + superRoot.setOnTouchPressed(controller); + superRoot.setOnMouseClicked(controller); + } + @Override public IPadContentView getContentView() { - return null; + return previewContent; } @Override public void setContentView(Pad pad) { + if (previewContent != null) { + previewContent.deinit(); + } + if (pad != null) { + PadContent content = pad.getContent(); + if (content != null) { + try { + PadContentConnect connect = PlayPadPlugin.getRegistryCollection().getPadContents().getComponent(content.getType()); + previewContent = connect.getPadContentPreview(pad, preview); + Node node = previewContent.getNode(); + + node.getStyleClass().addAll("pad-title", "pad" + pad.getIndex() + "-title"); + preview.getChildren().setAll(node); + return; + } catch (NoSuchComponentException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + EmptyPadView view = new EmptyPadView(preview); + if (pad != null) { + view.getStyleClass().addAll("pad-title", "pad" + pad.getIndex() + "-title"); + } else { + view.getStyleClass().addAll("pad-title"); + } + preview.getChildren().setAll(view); } @Override public IPadViewControllerV2 getViewController() { - return null; + return controller; } @Override public Pane getRootNode() { - return null; + return superRoot; } @Override public void enableDragAndDropDesignMode(boolean enable) { - + pseudoClassState(PseudoClasses.DRAG_CLASS, enable); } @Override public void showBusyView(boolean enable) { + busyView.showProgress(enable); + } + + public void setTitle(String text) { + this.indexLabel.setText(text); + } + + public void setProgress(double progress) { + this.playBar.setProgress(progress); + } + @Override + public ProgressBar getPlayBar() { + return playBar; } @Override - public void pseudoClassState(PseudoClass playCalss, boolean b) { - // TODO Auto-generated method stub + public void pseudoClassState(PseudoClass pseudoClass, boolean active) { + superRoot.pseudoClassStateChanged(pseudoClass, active); + indexLabel.pseudoClassStateChanged(pseudoClass, active); + timeLabel.pseudoClassStateChanged(pseudoClass, active); + loopLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + triggerLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + errorLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active); + + if (preview != null) { + preview.getChildren().forEach(i -> i.pseudoClassStateChanged(pseudoClass, active)); + } + playBar.pseudoClassStateChanged(pseudoClass, active); } @Override public void setStyle(String string) { - // TODO Auto-generated method stub - + superRoot.setStyle(string); } @Override public void setErrorLabelActive(boolean b) { - // TODO Auto-generated method stub + errorLabel.setVisible(b); + } + public void setIndex(int indexReadable) { + indexLabel.setText(String.valueOf(indexReadable)); } - @Override - public ProgressBar getPlayBar() { - // TODO Auto-generated method stub - return null; + public Property<Boolean> loopLabelVisibleProperty() { + return loopLabel.visibleProperty(); + } + + public void setTriggerLabelActive(boolean hasTriggerItems) { + triggerLabel.setVisible(hasTriggerItems); + } + + public void setTime(String time) { + if (time == null) { + timeLabel.setText(""); + } else { + timeLabel.setText(time); + } } @Override public void addDefaultButton(Pad pad) { - // TODO Auto-generated method stub + infoBox.getChildren().setAll(indexLabel, loopLabel, triggerLabel, errorLabel, timeLabel); + // alle Labels in der InfoBox sollen die gleiche Höhe haben, damit die Icons auf gleicher höhe sind + for (Node child : infoBox.getChildren()) { + if (child instanceof Label) { + ((Label) child).setMaxHeight(Double.MAX_VALUE); + } + } } @Override public void applyStyleClasses() { - // TODO Auto-generated method stub + Pad pad = getViewController().getPad(); + + superRoot.getStyleClass().addAll("pad", "pad" + pad.getIndex()); + + indexLabel.getStyleClass().addAll("pad-index", "pad" + pad.getIndex() + "-index", "pad-info", "pad" + pad.getIndex() + "-info"); + timeLabel.getStyleClass().addAll("pad-time", "pad" + pad.getIndex() + "-time", "pad-info", "pad" + pad.getIndex() + "-info"); + loopLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + pad.getIndex() + "-icon"); + triggerLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + pad.getIndex() + "-icon"); + errorLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + pad.getIndex() + "-icon"); + preview.getChildren().forEach(i -> i.getStyleClass().addAll("pad-title", "pad" + pad.getIndex() + "-title")); + + playBar.getStyleClass().addAll("pad-playbar", "pad" + pad.getIndex() + "-playbar"); + + root.getStyleClass().add("pad-root"); } @Override public void removeStyleClasses() { - // TODO Auto-generated method stub + Pad pad = getViewController().getPad(); + + superRoot.getStyleClass().removeAll("pad", "pad" + pad.getIndex()); + + indexLabel.getStyleClass().removeAll("pad-index", "pad" + pad.getIndex() + "-index", "pad-info", "pad" + pad.getIndex() + "-info"); + timeLabel.getStyleClass().removeAll("pad-time", "pad" + pad.getIndex() + "-time", "pad-info", "pad" + pad.getIndex() + "-info"); + loopLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + pad.getIndex() + "-icon"); + triggerLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + pad.getIndex() + "-icon"); + errorLabel.getGraphic().getStyleClass().removeAll("pad-icon", "pad" + pad.getIndex() + "-icon"); + preview.getChildren().forEach(i -> i.getStyleClass().removeAll("pad-title", "pad" + pad.getIndex() + "-title")); + + playBar.getStyleClass().removeAll("pad-playbar", "pad" + pad.getIndex() + "-playbar"); + + root.getStyleClass().add("pad-root"); + } + + public void clearIndex() { + indexLabel.setText(""); + } + + public void clearTime() { + timeLabel.setText(""); + } + + public void clearPreviewContent() { + if (previewContent != null) { + previewContent.deinit(); + } + setContentView(null); } @Override public void setPlaybarVisible(boolean visible) { - // TODO Auto-generated method stub - + playBar.setVisible(visible); } } diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java index 9d0601b31310aaa18b725e3cde22830aab07cd03..0eadc9706453a410967abebffcd6063e1d9839c6 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java @@ -1,56 +1,288 @@ package de.tobias.playpad.layout.touch; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadStatus; +import de.tobias.playpad.pad.TimeMode; +import de.tobias.playpad.pad.conntent.play.Durationable; import de.tobias.playpad.pad.listener.IPadPositionListener; +import de.tobias.playpad.pad.listener.PadContentListener; +import de.tobias.playpad.pad.listener.PadDurationListener; +import de.tobias.playpad.pad.listener.PadLockedListener; +import de.tobias.playpad.pad.listener.PadPositionListener; +import de.tobias.playpad.pad.listener.PadStatusListener; import de.tobias.playpad.pad.view.IPadViewV2; import de.tobias.playpad.pad.viewcontroller.IPadViewControllerV2; +import de.tobias.playpad.settings.Profile; +import de.tobias.playpad.settings.ProfileSettings; +import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.option.pad.PadSettingsViewController; +import de.tobias.playpad.viewcontroller.pad.PadDragListener; import javafx.beans.value.ChangeListener; +import javafx.event.ActionEvent; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.scene.input.MouseButton; +import javafx.scene.input.MouseEvent; +import javafx.scene.input.TouchEvent; +import javafx.stage.Stage; import javafx.util.Duration; -public class TouchPadViewController implements IPadViewControllerV2 { +public class TouchPadViewController implements IPadViewControllerV2, EventHandler<Event> { + + protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; + + private static final String DURATION_FORMAT = "%d:%02d"; + + private TouchPadView padView; + private Pad pad; + + private PadLockedListener padLockedListener; + private PadStatusListener padStatusListener; + private PadContentListener padContentListener; + private PadDurationListener padDurationListener; + private IPadPositionListener padPositionListener; + + private PadDragListener padDragListener; + private transient PadSettingsViewController padSettingsViewController; + + public TouchPadViewController(TouchPadView padView) { + this.padView = padView; + + padLockedListener = new PadLockedListener(this); + padStatusListener = new PadStatusListener(this); + padContentListener = new PadContentListener(this); + padDurationListener = new PadDurationListener(this); + padPositionListener = new PadPositionListener(this); + + // Listener muss nur einmal hier hinzugefügt werden, weil bei einem neuen Profile, werden neue PadViewController erzeugt + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); + profileSettings.lockedProperty().addListener(padLockedListener); + } @Override public Pad getPad() { - return null; + return pad; } @Override public IPadViewV2 getView() { - return null; + return padView; } @Override public void setupPad(Pad pad) { - + pad.setController(this); + + this.pad = pad; + + try { + // Settings + padView.setIndex(pad.getIndexReadable()); + padView.loopLabelVisibleProperty().bind(pad.loopProperty()); + + padView.setTriggerLabelActive(pad.hasTriggerItems()); + + // Update Listener + padContentListener.setPad(pad); + padPositionListener.setPad(pad); + + // Pad Content Chnage + pad.contentProperty().addListener(padContentListener); + // Pad Status Change + pad.statusProperty().addListener(padStatusListener); + + // First Listener call with new data + padContentListener.changed(null, null, pad.getContent()); // Add Duration listener + padStatusListener.changed(null, null, pad.getStatus()); + + padDragListener = new PadDragListener(pad, padView); + } catch (Exception e) { + e.printStackTrace(); + } + + padView.applyStyleClasses(); + padView.setContentView(pad); } @Override public void removePad() { - + if (padView != null && pad != null) { + + padView.clearIndex(); + padView.clearPreviewContent(); + padView.clearTime(); + + padView.setTriggerLabelActive(false); + + padView.loopLabelVisibleProperty().unbind(); + + pad.contentProperty().removeListener(padContentListener); + pad.statusProperty().removeListener(padStatusListener); + + if (pad.getContent() instanceof Durationable) { + Durationable durationable = (Durationable) pad.getContent(); + durationable.durationProperty().removeListener(padDurationListener); + durationable.positionProperty().removeListener(padPositionListener); + } + pad.setController(null); + padDragListener = null; + + // GUI Cleaning + padPositionListener.stopWaning(); + padView.removeStyleClasses(); + } + + this.padDragListener = null; + this.pad = null; + } + + @Override + public void handle(Event event) { + if (event instanceof TouchEvent) { + TouchEvent touchEvent = (TouchEvent) event; + if (event.getEventType() == TouchEvent.TOUCH_PRESSED) { + if (touchEvent.getTouchCount() == 1) { + if (pad.getStatus() == PadStatus.PLAY) { + onStop(); + } else { + onPlay(); + } + } else if (touchEvent.getTouchCount() == 2) { + onSettings(); + } + } + } else if (event instanceof MouseEvent) { + if (event.getEventType() == MouseEvent.MOUSE_CLICKED) { + MouseEvent mouseEvent = (MouseEvent) event; + if (mouseEvent.getButton() == MouseButton.PRIMARY) { + if (pad.getStatus() == PadStatus.PLAY) { + onStop(); + } else { + onPlay(); + } + } else if (mouseEvent.getButton() == MouseButton.SECONDARY) { + onSettings(); + } + } + + } + } + + private void onPlay() { + if (pad.getContent() != null) { + pad.setStatus(PadStatus.PLAY); + } + } + + private void onPause() { + if (pad.getContent() != null) { + pad.setStatus(PadStatus.PAUSE); + } + } + + private void onStop() { + if (pad.getContent() != null) { + pad.setStatus(PadStatus.STOP); + } + } + + private void onNew(ActionEvent event) { + // TODO Implement + } + + private void onSettings() { + ProfileSettings settings = Profile.currentProfile().getProfileSettings(); + IMainViewController mvc = PlayPadPlugin.getImplementation().getMainViewController(); + + if (mvc != null) { + if (pad.getProject() != null) { + if (settings.isLiveMode() && settings.isLiveModeSettings() && pad.getProject().getPlayedPlayers() > 0) { + mvc.showLiveInfo(); + return; + } + } + + Stage owner = mvc.getStage(); + if (padSettingsViewController == null) { + padSettingsViewController = new PadSettingsViewController(pad, owner); + padSettingsViewController.getStage().setOnHiding(ev -> + { + if (padView != null && pad != null) + padView.setTriggerLabelActive(pad.hasTriggerItems()); + }); + } + padSettingsViewController.getStage().show(); + } } @Override public void updateTimeLabel() { - // TODO Auto-generated method stub - + if (pad.getContent() != null && pad.getStatus() != PadStatus.EMPTY && pad.getStatus() != PadStatus.ERROR) { + if (pad.getContent() instanceof Durationable) { + Durationable durationable = (Durationable) pad.getContent(); + + Duration duration = durationable.getDuration(); + Duration position = durationable.getPosition(); + + if (duration != null) { + // Nur Gesamtzeit anzeigen + if (pad.getStatus() == PadStatus.READY || position == null) { + String time = durationToString(duration); + padView.setTime(time); + padView.getPlayBar().setProgress(0); + } else { + // Play/Gesamtzeit anzeigen + TimeMode timeMode = pad.getTimeMode(); + + if (timeMode == TimeMode.REST) { + Duration leftTime = duration.subtract(position); + + padView.setTime("- " + durationToString(leftTime)); + } else if (timeMode == TimeMode.PLAYED) { + padView.setTime(durationToString(position)); + } else if (timeMode == TimeMode.BOTH) { + String time = durationToString(position); + String totalTime = durationToString(duration); + + padView.setTime(time + "/" + totalTime); + } + } + } + return; + } + } + padView.getPlayBar().setProgress(0); + padView.setTime(null); + } + + public String durationToString(Duration value) { + if (value != null) { + int secounds = (int) ((value.toMillis() / 1000) % 60); + int minutes = (int) ((value.toMillis() / (1000 * 60)) % 60); + String time = String.format(DURATION_FORMAT, minutes, secounds); + return time; + } else { + return null; + } } @Override public void updateButtonDisable() { - // TODO Auto-generated method stub - + // Not needed in touch mode } @Override public IPadPositionListener getPadPositionListener() { - // TODO Auto-generated method stub - return null; + return padPositionListener; } @Override public ChangeListener<Duration> getPadDurationListener() { - // TODO Auto-generated method stub - return null; + return padDurationListener; } + public PadDragListener getPadDragListener() { + return padDragListener; + } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java index 7f6a66274c4f2a69a75e48bd5e691ba5daf8f9dc..5dc4751a4315c7ee54b2c628f5606ac2e7ebd285 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/BasicMenuToolbarViewController.java @@ -55,6 +55,7 @@ import javafx.scene.control.RadioMenuItem; import javafx.scene.control.Slider; import javafx.scene.control.ToggleGroup; import javafx.scene.control.ToolBar; +import javafx.scene.input.KeyCombination; import javafx.scene.layout.HBox; import javafx.stage.Modality; import javafx.stage.Stage; @@ -101,9 +102,11 @@ public abstract class BasicMenuToolbarViewController extends MenuToolbarViewCont volumeSlider.setValue(volumeSlider.getValue() + ev.getDeltaX() * 0.001); }); + ProfileSettings profileSettings = Profile.currentProfile().getProfileSettings(); Registry<MainLayoutConnect> mainLayouts = PlayPadPlugin.getRegistryCollection().getMainLayouts(); ToggleGroup group = new ToggleGroup(); + int index = 1; // Für Tastenkombination for (String layoutType : mainLayouts.getTypes()) { try { MainLayoutConnect connect = mainLayouts.getComponent(layoutType); @@ -113,17 +116,28 @@ public abstract class BasicMenuToolbarViewController extends MenuToolbarViewCont item.setOnAction((e) -> { mainViewController.setMainLayout(connect); + Profile.currentProfile().getProfileSettings().setMainLayoutType(connect.getType()); }); + + // Key Combi + if (index < 10) { + item.setAccelerator(KeyCombination.keyCombination("Shortcut+" + index)); + } + + if (connect.getType().equals(profileSettings.getMainLayoutType())) { + item.setSelected(true); + } + layoutMenu.getItems().add(item); } catch (NoSuchComponentException e) { e.printStackTrace(); } + index++; } } @Override - public void deinit() { - } + public void deinit() {} // Basic Event Handler @FXML diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/LayoutChangedListener.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/LayoutChangedListener.java new file mode 100644 index 0000000000000000000000000000000000000000..a170a7772458688491db0d50b764188aa5359211 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/LayoutChangedListener.java @@ -0,0 +1,12 @@ +package de.tobias.playpad.viewcontroller.main; + +import java.util.List; + +public class LayoutChangedListener { + + public void handle(List<Runnable> runnables) { + for (Runnable run : runnables) { + run.run(); + } + } +} diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java index 6cc641e9b9b0f28a0e591a06c1889cf232382184..04b6503415a452c82087fe5a35b09dc54c662b1d 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java @@ -21,8 +21,8 @@ import de.tobias.playpad.action.mapper.MapperFeedbackable; import de.tobias.playpad.action.mapper.listener.KeyboardHandler; import de.tobias.playpad.action.mapper.listener.MidiHandler; import de.tobias.playpad.design.CartDesign; -import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.design.DesignColorAssociator; +import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.midi.Midi; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.view.IPadViewController; @@ -610,8 +610,7 @@ public class MainViewController extends ViewController implements IMainViewContr { try { Thread.sleep(PlayPadMain.displayTimeMillis * 2); - } catch (Exception e) { - } + } catch (Exception e) {} Platform.runLater(() -> { toolbarController.getToolbarHBox().setOpacity(1); @@ -671,7 +670,6 @@ public class MainViewController extends ViewController implements IMainViewContr showPage(pageNumber); // Show Mapper Feedback und apply css und zeigt pads } - @Override public Project getProject() { return project; } @@ -737,6 +735,11 @@ public class MainViewController extends ViewController implements IMainViewContr @Override public void setMainLayout(MainLayoutConnect mainLayoutConnect) { // TODO Auto-generated method stub + } + + @Override + public void performLayoutDependendAction(Runnable runnable) { + // TODO Auto-generated method stub } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java index ed2fa39868b0897924f5a00085734f73871b2922..745b57589c93fed7757c14e0b57c7baecad41f4b 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewControllerV2.java @@ -8,6 +8,7 @@ import java.util.Optional; import javax.sound.midi.MidiUnavailableException; import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.action.Mapping; import de.tobias.playpad.action.mapper.listener.KeyboardHandler; @@ -20,6 +21,8 @@ import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.view.IPadViewV2; import de.tobias.playpad.plugin.WindowListener; import de.tobias.playpad.project.Project; +import de.tobias.playpad.registry.DefaultRegistry; +import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileListener; import de.tobias.playpad.settings.ProfileSettings; @@ -40,6 +43,7 @@ import javafx.event.EventType; import javafx.fxml.FXML; import javafx.scene.Group; import javafx.scene.Node; +import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; @@ -84,23 +88,39 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon // Style private Color gridColor; + // Layout + private List<Runnable> layoutActions; + // Listener private VolumeChangeListener volumeChangeListener; private LockedListener lockedListener; + private LayoutChangedListener layoutChangedListener; public MainViewControllerV2(List<WindowListener<IMainViewController>> listener) { super("mainViewV2", "de/tobias/playpad/assets/view/main/", null, PlayPadMain.getUiResourceBundle()); padViews = new ArrayList<>(); - setMainLayout(new DesktopMainLayoutConnect()); // DEBUG + // Layout Init + layoutActions = new ArrayList<>(); // Init Listener volumeChangeListener = new VolumeChangeListener(this); lockedListener = new LockedListener(this); + layoutChangedListener = new LayoutChangedListener(); + + setMainLayout(new DesktopMainLayoutConnect()); // DEBUG Profile.registerListener(this); reloadSettings(null, Profile.currentProfile()); + // Wenn sich die Toolbar ändert werden die Button neu erstellt. Das ist hier, weil es nur einmal als Listener da sein muss. Die + // Methode wird aber an unterschiedlichen stellen mehrmals aufgerufen + performLayoutDependendAction(() -> + { + if (menuToolbarViewController != null) + menuToolbarViewController.initPageButtons(); + }); + /* * Gridline Color */ @@ -121,6 +141,16 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon } catch (Exception e) { e.printStackTrace(); } + + // Plugin Listener + listener.forEach(l -> + { + try { + l.onInit(this); + } catch (Exception e) { + e.printStackTrace(); + } + }); } private void initMapper(Project project) { @@ -153,6 +183,7 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon public void setMainLayout(MainLayoutConnect mainLayoutConnect) { this.mainLayout = mainLayoutConnect; initMainLayout(); + layoutChangedListener.handle(layoutActions); } private void initMainLayout() { @@ -160,10 +191,15 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon menuToolbarViewController.deinit(); } + removePadsFromView(); + headerBox.getChildren().clear(); menuToolbarViewController = mainLayout.createMenuToolbar(this); headerBox.getChildren().add(menuToolbarViewController.getParent()); + createPadViews(); + showPage(currentPageShowing); + loadUserCss(); } @@ -313,7 +349,6 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon if (project != null) removePadsFromView(); - // createPadViews(); // TODO Weg hier, nur wenn sich profile ändert openProject = project; @@ -414,8 +449,10 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon this.currentPageShowing = page; - // New - addPadsToView(); + if (openProject != null) { + // New + addPadsToView(); + } } @Override @@ -447,7 +484,7 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon // Clear Feedback on Devie (LaunchPad Light off) old.getMappings().getActiveMapping().getActions().forEach(action -> action.clearFeedback()); - + // LockedListener old.getProfileSettings().lockedProperty().removeListener(lockedListener); } @@ -458,7 +495,7 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon final ProfileSettings profileSettings = currentProfile.getProfileSettings(); final Mapping activeMapping = currentProfile.getMappings().getActiveMapping(); - + // LockedListener profileSettings.lockedProperty().addListener(lockedListener); @@ -482,6 +519,15 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon }); } + try { + DefaultRegistry<MainLayoutConnect> registry = PlayPadPlugin.getRegistryCollection().getMainLayouts(); + MainLayoutConnect connect = registry.getComponent(currentProfile.getProfileSettings().getMainLayoutType()); + setMainLayout(connect); + } catch (NoSuchComponentException e) { + // TODO Error Handling + e.printStackTrace(); + } + loadUserCss(); if (old != null && currentProfile != null) { showPage(currentPageShowing); @@ -552,8 +598,20 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon @Override public void loadUserCss() { - if (openProject != null) + Scene scene = getStage().getScene(); + + // Clear Old + scene.getStylesheets().clear(); + + // Layout Spezifisches CSS (Base) + if (mainLayout.getStylesheet() != null) { + scene.getStylesheets().add(mainLayout.getStylesheet()); + } + + // design spezific css + if (openProject != null) { Profile.currentProfile().currentLayout().applyCssMainView(this, getStage(), openProject); + } applyColorsToMappers(); } @@ -605,4 +663,10 @@ public class MainViewControllerV2 extends ViewController implements IMainViewCon public MenuToolbarViewController getMenuToolbarController() { return menuToolbarViewController; } + + @Override + public void performLayoutDependendAction(Runnable runnable) { + runnable.run(); + layoutActions.add(runnable); + } } diff --git a/PlayWallCore/src/de/tobias/playpad/RegistryCollection.java b/PlayWallCore/src/de/tobias/playpad/RegistryCollection.java index 3030315552ee1c4f37f28b1f96518a76e9e9b79e..c13e9df65df0fb3af5e87eb45c06d1a3b127ebbb 100644 --- a/PlayWallCore/src/de/tobias/playpad/RegistryCollection.java +++ b/PlayWallCore/src/de/tobias/playpad/RegistryCollection.java @@ -35,5 +35,5 @@ public interface RegistryCollection { public Registry<TriggerItemConnect> getTriggerItems(); - public Registry<MainLayoutConnect> getMainLayouts(); + public DefaultRegistry<MainLayoutConnect> getMainLayouts(); } \ No newline at end of file diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java index 456473a57cd885308d96eb92f0ef07306a2e592f..ea0e10f48df2b66c8f59d11d31cdb2b0b0ba934f 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/ProfileSettings.java @@ -16,7 +16,6 @@ import org.dom4j.io.SAXReader; import org.dom4j.io.XMLWriter; import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.design.LayoutRegistry; import de.tobias.playpad.pad.TimeMode; import de.tobias.playpad.update.UpdateChannel; import de.tobias.utils.application.ApplicationUtils; @@ -52,7 +51,8 @@ public class ProfileSettings implements SettingsSerializable { @Storable private HashMap<String, Object> audioUserInfo = new HashMap<>(); // Layout - @Storable private String layoutType = LayoutRegistry.getDefaultLayout(); + @Storable private String layoutType = PlayPadPlugin.getRegistryCollection().getDesigns().getDefaultID(); // Rather DesignType + @Storable private String mainLayoutType = PlayPadPlugin.getRegistryCollection().getMainLayouts().getDefaultID(); // Cart Settings @Storable private Warning warningFeedback = new Warning(Duration.seconds(5)); @@ -124,6 +124,10 @@ public class ProfileSettings implements SettingsSerializable { return layoutType; } + public String getMainLayoutType() { + return mainLayoutType; + } + public Warning getWarningFeedback() { return warningFeedback; } @@ -211,6 +215,10 @@ public class ProfileSettings implements SettingsSerializable { this.layoutType = layoutType; } + public void setMainLayoutType(String mainLayoutType) { + this.mainLayoutType = mainLayoutType; + } + public void setWarningFeedback(Warning warningFeedback) { this.warningFeedback = warningFeedback; } @@ -291,6 +299,7 @@ public class ProfileSettings implements SettingsSerializable { private static final String FADE_ELEMENT = "Fade"; private static final String WARNING_ELEMENT = "Warning"; private static final String LAYOUT_TYPE_ELEMENT = "LayoutType"; + private static final String MAIN_LAYOUT_TYPE_ELEMENT = "MainLayoutType"; private static final String ROWS_ELEMENT = "Rows"; private static final String COLUMNS_ELEMENT = "Columns"; private static final String PAGE_COUNT_ELEMENT = "PageCount"; @@ -323,6 +332,9 @@ public class ProfileSettings implements SettingsSerializable { if (root.element(LAYOUT_TYPE_ELEMENT) != null) { profileSettings.setLayoutType(root.element(LAYOUT_TYPE_ELEMENT).getStringValue()); } + if (root.element(MAIN_LAYOUT_TYPE_ELEMENT) != null) { + profileSettings.setMainLayoutType(root.element(MAIN_LAYOUT_TYPE_ELEMENT).getStringValue()); + } if (root.element(WARNING_ELEMENT) != null) { Warning warning = Warning.load(root.element(WARNING_ELEMENT)); @@ -413,6 +425,7 @@ public class ProfileSettings implements SettingsSerializable { root.addElement(ROWS_ELEMENT).addText(String.valueOf(rows)); root.addElement(LAYOUT_TYPE_ELEMENT).addText(layoutType); + root.addElement(MAIN_LAYOUT_TYPE_ELEMENT).addText(mainLayoutType); warningFeedback.save(root.addElement(WARNING_ELEMENT)); fade.save(root.addElement(FADE_ELEMENT)); @@ -438,7 +451,7 @@ public class ProfileSettings implements SettingsSerializable { // Paths root.addElement(CACHE_PATH_ELEMENT).addText(cachePath.toString()); - + // Update root.addElement(AUTO_UPDATE_ELEMENT).addText(String.valueOf(autoUpdate)); root.addElement(UPDATE_CHANNEL_ELEMENT).addText(updateChannel.name()); diff --git a/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java b/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java index 7e0ceee1d05bd876d087e62d849a32c4a33ed458..92bd7dbed064089d083f2957bc6b9e196e47b45a 100644 --- a/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java +++ b/PlayWallCore/src/de/tobias/playpad/view/main/MainLayoutConnect.java @@ -44,5 +44,12 @@ public interface MainLayoutConnect { * @see IPadViewControllerV2 ViewController zum Pad */ public IPadViewV2 createPadView(); - + + /** + * Gibt das Layout sepzifische Stylesheet zurück. + * + * @return path in jar + */ + public String getStylesheet(); + } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java index 52582987afb9676152faca61a6cca2a09302220d..4c25fe9463e20e9e4a2b8f5f54733534a5e8ed66 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java @@ -10,7 +10,6 @@ import de.tobias.utils.ui.NotificationHandler; import javafx.event.EventHandler; import javafx.event.EventType; import javafx.scene.Parent; -import javafx.scene.control.MenuItem; import javafx.scene.control.Slider; import javafx.scene.input.KeyEvent; import javafx.scene.paint.Color; @@ -23,29 +22,12 @@ public interface IMainViewController extends NotificationHandler { public Stage getStage(); - public default void addMenuItem(MenuItem item) {} - public int getPage(); public Parent getParent(); public void registerKeyboardListener(EventType<KeyEvent> eventType, EventHandler<KeyEvent> listener); - @Deprecated - public default Project getProject() { - return null; - } - - @Deprecated - public default Slider getVolumeSlider() { - return null; - } - - @Deprecated - public default IMainToolbarViewController getToolbarController() { - return null; - } - public void createPadViews(); /** @@ -70,10 +52,12 @@ public interface IMainViewController extends NotificationHandler { public Screen getScreen(); public MidiListener getMidiHandler(); - + public MenuToolbarViewController getMenuToolbarController(); public void setPadVolume(double doubleValue); - + public void setMainLayout(MainLayoutConnect mainLayoutConnect); + + public void performLayoutDependendAction(Runnable runnable); } diff --git a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java index 2f20eb50dfe6b8b8728339202b73bf0251e9b5b1..d83f077d99191dfc018e95987aac518bc1b04fdf 100644 --- a/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java +++ b/PlayWallPlugins/actionsplugin/de/tobias/playpad/actionsplugin/impl/ActionsPluginImpl.java @@ -72,7 +72,9 @@ public class ActionsPluginImpl implements ActionsPlugin, ChangeListener<Boolean> @Override public void onInit(IMainViewController t) { - t.getVolumeSlider().valueChangingProperty().addListener(new ChangeListener<Boolean>() { + // TODO NullPointer + /* + t.getMenuToolbarController().getVolumeSlider().valueChangingProperty().addListener(new ChangeListener<Boolean>() { @Override public void changed(ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) { @@ -83,6 +85,7 @@ public class ActionsPluginImpl implements ActionsPlugin, ChangeListener<Boolean> } } }); + */ } }); diff --git a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java index 42b536e0ec16ed773b68a36db6a505652ed05dab..292b838d9ab3d26fccffc3be729a360cb24c561e 100644 --- a/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java +++ b/PlayWallPlugins/awakeplugin/de/tobias/playpad/awakeplugin/impl/AwakePluginImpl.java @@ -16,8 +16,9 @@ import de.tobias.playpad.plugin.SettingsListener; import de.tobias.playpad.plugin.WindowListener; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.update.UpdateRegistery; -import de.tobias.playpad.viewcontroller.main.IMainToolbarViewController; +import de.tobias.playpad.view.main.MenuType; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; import de.tobias.utils.ui.icon.FontAwesomeType; @@ -146,7 +147,7 @@ public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewCon activeMenu.setOnAction(this); activeMenu.setText(bundle.getString("menutitle")); activeMenu.setSelected(settings.active); - t.addMenuItem(activeMenu); + t.getMenuToolbarController().addMenuItem(activeMenu, MenuType.EXTENSION); iconLabel = new Label(); iconLabel.setGraphic(new FontIcon(FontAwesomeType.MOON_ALT)); @@ -157,11 +158,11 @@ public class AwakePluginImpl implements AwakePlugin, WindowListener<IMainViewCon activeSleep(activeMenu.isSelected()); settings.active = activeMenu.isSelected(); - IMainToolbarViewController toolbarController = PlayPadPlugin.getImplementation().getMainViewController().getToolbarController(); + MenuToolbarViewController toolbarController = PlayPadPlugin.getImplementation().getMainViewController().getMenuToolbarController(); if (settings.active) { - toolbarController.showIcon(iconLabel); + toolbarController.addToolbarItem(iconLabel); } else { - toolbarController.hideIcon(iconLabel); + toolbarController.removeToolbarItem(iconLabel); } } diff --git a/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java b/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java index 54282b74205cbd36efc93cc0d8b20964c81a7f1c..c8ff9867535e30b7d1f9967202b63b4ac120e382 100644 --- a/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java +++ b/PlayWallPlugins/equalizerplugin/de/tobias/playpad/equalizerplugin/main/impl/EqualizerPluginImpl.java @@ -14,6 +14,7 @@ import de.tobias.playpad.pad.conntent.PadContent; import de.tobias.playpad.plugin.PadListener; import de.tobias.playpad.plugin.WindowListener; import de.tobias.playpad.update.UpdateRegistery; +import de.tobias.playpad.view.main.MenuType; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; @@ -68,10 +69,13 @@ public class EqualizerPluginImpl implements EqualizerPlugin, WindowListener<IMai public void onInit(IMainViewController t) { mainStage = t.getStage(); - eqMenuItem = new MenuItem(); - eqMenuItem.setText(bundle.getString("eq.menuitem.name")); - eqMenuItem.setOnAction(this); - t.addMenuItem(eqMenuItem); + t.performLayoutDependendAction(() -> + { + eqMenuItem = new MenuItem(); + eqMenuItem.setText(bundle.getString("eq.menuitem.name")); + eqMenuItem.setOnAction(this); + t.getMenuToolbarController().addMenuItem(eqMenuItem, MenuType.EXTENSION); + }); } @Override