diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties index 986c8bfdf2e6336278cee61aa15e3d09fc8bc981..7cda71944b4eda57b40bca38771038fe61f132e1 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/_de.properties @@ -224,8 +224,8 @@ UI.Dialog.Save.Header=Speichern UI.Dialog.Save.Content=M�chten Sie das Projekt speichern? UI.Dialog.Save.Title=Speichern UI.Dialog.Save.Checkbox=Immer automatisch speichern und diesen Dialog nicht mehr anzeigen. -UI.Dialog.Save.Button.Yes=Speichern -UI.Dialog.Save.Button.No=Nicht Speichern +UI.Dialog.Save.Button.Yes=Ja +UI.Dialog.Save.Button.No=Nein UI.Dialog.Save.Button.Cancel=Abbrechen # Update Channel - BaseName @@ -267,4 +267,18 @@ MainLayout.Touch=Touchmodus # Suche Search.Button=Suchen Search.Placeholder=Suche -Search.Alert.NoMatches=Keine Treffer gefunden. \ No newline at end of file +Search.Alert.NoMatches=Keine Treffer gefunden. + +# UI - Dialog - Page - Delete +UI.Dialog.Page.Delete.Header=Seite L�schen? +UI.Dialog.Page.Delete.Content=M�chten Sie die Seite unwiederbringlich l�schen? + +# UI - Dialog - Name - Delete +UI.Dialog.Page.Name.Header=Seite umbenennen +UI.Dialog.Page.Name.Content=Geben Sie einen neuen Namen f�r die Seite ein. \n(Wenn die das Feld leer lassen, wird ein Standardname verwendet). + +# Tooltips +Tooltip.PlayButton=Wiedergabemodus +Tooltip.DragButton=Drag'n'Drop Modus +Tooltip.PageButton=Seiten bearbeiten +Tooltip.ColorButton=F�rbenmodus \ No newline at end of file diff --git a/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties b/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties index cdc05e376046c786b0040e53573933f7eef7f0a6..f3b3b63848ff7c2e539fa1973518684b6978cd92 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties +++ b/PlayWall/assets/de/tobias/playpad/assets/lang/ui_de.properties @@ -15,9 +15,14 @@ main.menuitem.recentFiles=Zuletzt verwendete Projekte main.menuitem.profile=Profile verwalten... main.menuitem.print=Drucken... main.menuitem.onTop=Fenster im Vordergrund -main.menuitem.plugins=Erweiterungen... -main.menuitem.dnd=Bearbeitungsmodus +#Begin TODO +main.menu.editmode=Modus +main.menuitem.play=Wiedergabe +main.menuitem.drag=Drag and Drop +main.menuitem.color=F�rben +#Ende TODO main.menuitem.errors=Fehlerbericht anzeigen... +main.menuitem.plugins=Erweiterungen... main.menuitem.projectSettings=Projekteinstellungen... main.menuitem.profileSettings=Profileinstellungen... main.menuitem.globalSettings=Globale Einstellungen... @@ -32,7 +37,6 @@ main.menuitem.searchPad=Kachel suchen... main.label.live=Live settings.gen.label.view=Ansicht: -settings.gen.label.pages=Anzahl der Seiten: settings.gen.label.columns=Anzahl der Spalten: settings.gen.label.rows=Anzahl der Reihen: settings.gen.label.liveMode=Live Modus: diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml index dd7c7d2aa525e7b2093debec88e177d3f3cdc92f..05ebf66e53a6a3094c50f87447f8b03cbbb8f00a 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/main/desktop/header.fxml @@ -39,11 +39,26 @@ </Menu> <Menu mnemonicParsing="false" text="%main.menu.option"> <items> - <CheckMenuItem fx:id="dndModeMenuItem" mnemonicParsing="false" onAction="#dndModeHandler" text="%main.menuitem.dnd"> - <accelerator> - <KeyCodeCombination alt="UP" code="M" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> - </accelerator> - </CheckMenuItem> + <Menu mnemonicParsing="false" text="%main.menu.editmode"> + <items> + <MenuItem fx:id="playMenu" mnemonicParsing="false" onAction="#playMenuHandler" text="%main.menuitem.play"> + <accelerator> + <KeyCodeCombination alt="UP" code="L" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> + </accelerator> + </MenuItem> + <MenuItem fx:id="dragMenu" mnemonicParsing="false" onAction="#dragMenuHandler" text="%main.menuitem.drag"> + <accelerator> + <KeyCodeCombination alt="UP" code="M" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> + </accelerator> + </MenuItem> + <MenuItem fx:id="colorMenu" mnemonicParsing="false" onAction="#colorMenuHandler" text="%main.menuitem.color"> + <accelerator> + <KeyCodeCombination alt="UP" code="K" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> + </accelerator> + </MenuItem> + </items> + </Menu> + <SeparatorMenuItem mnemonicParsing="false" /> <MenuItem fx:id="errorMenu" mnemonicParsing="false" onAction="#errorMenuHandler" text="%main.menuitem.errors"> <accelerator> <KeyCodeCombination alt="UP" code="E" control="UP" meta="UP" shift="UP" shortcut="DOWN" /> diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/project/generalTab.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/project/generalTab.fxml index 846711017bc96d87dc8447291d4c5d1bcec0184a..6bd490e9c7252f868b06f88972db4af325d03272 100644 --- a/PlayWall/assets/de/tobias/playpad/assets/view/option/project/generalTab.fxml +++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/project/generalTab.fxml @@ -5,16 +5,9 @@ <?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"> <children> <Label text="%settings.gen.label.view" underline="true" /> - <HBox spacing="14.0"> - <children> - <Label alignment="BASELINE_RIGHT" layoutX="21.0" layoutY="40.0" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.pages" /> - <TextField fx:id="pageCountTextField" prefWidth="50.0" /> - </children> - </HBox> <HBox spacing="14.0"> <children> <Label alignment="BASELINE_RIGHT" layoutX="20.0" layoutY="68.0" maxHeight="1.7976931348623157E308" prefWidth="150.0" text="%settings.gen.label.columns" /> diff --git a/PlayWall/src/de/tobias/playpad/Strings.java b/PlayWall/src/de/tobias/playpad/Strings.java index 8dfd96d7b1495d0065e465f69599fc655625a894..2db02c1e7a92a1dcb822c59c121c949369a0479b 100644 --- a/PlayWall/src/de/tobias/playpad/Strings.java +++ b/PlayWall/src/de/tobias/playpad/Strings.java @@ -257,4 +257,18 @@ public class Strings { public static final String Search_Button = "Search.Button"; public static final String Search_Placeholder = "Search.Placeholder"; public static final String Search_Alert_NoMatches = "Search.Alert.NoMatches"; + + // UI - Dialog - Page - Delete + public static final String UI_Dialog_Page_Delete_Header = "UI.Dialog.Page.Delete.Header"; + public static final String UI_Dialog_Page_Delete_Content = "UI.Dialog.Page.Delete.Content"; + + // UI - Dialog - Page - Name + public static final String UI_Dialog_Page_Name_Header = "UI.Dialog.Page.Name.Header"; + public static final String UI_Dialog_Page_Name_Content = "UI.Dialog.Page.Name.Content"; + + // Tooltip + public static final String Tooltip_PlayButton = "Tooltip.PlayButton"; + public static final String Tooltip_DragButton = "Tooltip.DragButton"; + public static final String Tooltip_PageButton = "Tooltip.PageButton"; + public static final String Tooltip_ColorButton = "Tooltip.ColorButton"; } diff --git a/PlayWall/src/de/tobias/playpad/VersionUpdater.java b/PlayWall/src/de/tobias/playpad/VersionUpdater.java index 7cc6280d1f22f6614e5207f330a1a37afc2f2e0e..34345c4bd77a1a12ffe8ece42a296354f0f6af08 100644 --- a/PlayWall/src/de/tobias/playpad/VersionUpdater.java +++ b/PlayWall/src/de/tobias/playpad/VersionUpdater.java @@ -64,7 +64,6 @@ public class VersionUpdater implements UpdateService { ProjectSettings projectSettings2 = new ProjectSettings(); projectSettings2.setColumns(columns); projectSettings2.setRows(rows); - projectSettings2.setPageCount(pages); projectSettings2.save(settingsElement); diff --git a/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java b/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java index f6f60e3937638419efae957f1133e34df713eee7..f4073ed53acb60792b896faff8737c8aa3d4dfa8 100644 --- a/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java +++ b/PlayWall/src/de/tobias/playpad/action/mapper/MidiMapper.java @@ -104,9 +104,9 @@ public class MidiMapper extends Mapper implements ColorAssociator, MapperFeedbac } @Override - public void setColor(FeedbackMessage feedbackMessage, int value) { + public void setColor(FeedbackMessage feedbackMessage, DisplayableFeedbackColor color) { if (feedbackMessage == FeedbackMessage.STANDARD || feedbackMessage == FeedbackMessage.EVENT) { - feedback.setFeedback(feedbackMessage, value); + feedback.setFeedback(feedbackMessage, color.mapperFeedbackValue()); } else { throw new IllegalArgumentException("Unexpected Message Type."); } diff --git a/PlayWall/src/de/tobias/playpad/components/Keys.xml b/PlayWall/src/de/tobias/playpad/components/Keys.xml index d5f0239e01f66870f30a2311003816151f3532af..589d9d4f5839573cd900fde9000cba4acdcb83fa 100644 --- a/PlayWall/src/de/tobias/playpad/components/Keys.xml +++ b/PlayWall/src/de/tobias/playpad/components/Keys.xml @@ -6,8 +6,12 @@ <Key id="save_proj" name="main.menuitem.save" key="S" ctrl="true" alt="false" meta="false" shift="false"/> <Key id="print_proj" name="main.menuitem.print" key="P" ctrl="true" alt="false" meta="false" shift="false"/> - <Key id="dnd" name="main.menuitem.dnd" key="M" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="play" name="main.menuitem.play" key="L" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="drag" name="main.menuitem.drag" key="M" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="color" name="main.menuitem.color" key="K" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="errors" name="main.menuitem.errors" key="E" ctrl="true" alt="false" meta="false" shift="false"/> + <Key id="plugins" name="main.menuitem.plugins"/> <Key id="project_settings" name="main.menuitem.projectSettings" key="Comma" ctrl="true" alt="true" meta="false" shift="false"/> <Key id="profile_settings" name="main.menuitem.profileSettings" key="Comma" ctrl="true" alt="false" meta="false" shift="false"/> @@ -23,8 +27,12 @@ <Key id="save_proj" name="main.menuitem.save" key="S" ctrl="false" alt="false" meta="true" shift="false"/> <Key id="print_proj" name="main.menuitem.print" key="P" ctrl="false" alt="false" meta="true" shift="false"/> - <Key id="dnd" name="main.menuitem.dnd" key="M" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="play" name="main.menuitem.play" key="L" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="drag" name="main.menuitem.drag" key="M" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="color" name="main.menuitem.color" key="K" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="errors" name="main.menuitem.errors" key="E" ctrl="false" alt="false" meta="true" shift="false"/> + <Key id="plugins" name="main.menuitem.plugins"/> <Key id="project_settings" name="main.menuitem.projectSettings" key="Comma" ctrl="false" alt="true" meta="true" shift="false"/> <Key id="profile_settings" name="main.menuitem.profileSettings" key="Comma" ctrl="false" alt="false" meta="true" shift="false"/> diff --git a/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java index 07f9abf3207ae4cdd9db2a421c782df52339d3c8..f0d33ad5c015c3b565ae67c437c1f136c589b457 100644 --- a/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/classic/ClassicGlobalDesign.java @@ -328,7 +328,7 @@ public class ClassicGlobalDesign extends Design implements GlobalDesign { PadSettings padSettings = pad.getPadSettings(); if (padSettings.isCustomLayout()) { - CartDesign layoutOpt = padSettings.getLayout(); + CartDesign layoutOpt = padSettings.getDesign(); css += "\n" + layoutOpt.convertToCss(pad.getPadIndex().toString(), true); } } diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java index 86fde0806c5beead2460a7394eddb8a40ccc9d97..1e7a28801bd5d8d54637039d78530a652ca900fa 100644 --- a/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernCartDesign.java @@ -166,6 +166,15 @@ public class ModernCartDesign extends Design implements CartDesign, DesignColorA endStyleClass(builder); } + @Override + public void copyGlobalLayout(GlobalDesign globalLayout) { + if (globalLayout instanceof ModernGlobalDesign) { + ModernGlobalDesign modernLayoutGlobal = (ModernGlobalDesign) globalLayout; + backgroundColor = modernLayoutGlobal.getBackgroundColor(); + playColor = modernLayoutGlobal.getPlayColor(); + } + } + // Color Associator @Override public Color getAssociatedEventColor() { @@ -177,12 +186,4 @@ public class ModernCartDesign extends Design implements CartDesign, DesignColorA return Color.web(backgroundColor.getColorHi()); } - @Override - public void copyGlobalLayout(GlobalDesign globalLayout) { - if (globalLayout instanceof ModernGlobalDesign) { - ModernGlobalDesign modernLayoutGlobal = (ModernGlobalDesign) globalLayout; - backgroundColor = modernLayoutGlobal.getBackgroundColor(); - playColor = modernLayoutGlobal.getPlayColor(); - } - } } diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignConnect.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignConnect.java index 4658e1a66596a0a05648a6817a84190f544861fd..f39235706560e340277ec0128e14fdad1a500103 100644 --- a/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignConnect.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernDesignConnect.java @@ -2,8 +2,8 @@ package de.tobias.playpad.design.modern; import de.tobias.playpad.Strings; import de.tobias.playpad.design.CartDesign; -import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.design.DesignConnect; +import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.viewcontroller.CartDesignViewController; import de.tobias.playpad.viewcontroller.GlobalDesignViewController; import de.tobias.playpad.viewcontroller.design.ModernCartDesignViewController; diff --git a/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java index bdb959e99cca8d4025b3311441eef00cfcce6a31..fbf9cde0aca9e49e99fb69043e9d889feccc24be 100644 --- a/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java +++ b/PlayWall/src/de/tobias/playpad/design/modern/ModernGlobalDesign.java @@ -3,11 +3,14 @@ package de.tobias.playpad.design.modern; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.function.Consumer; import org.dom4j.Element; +import de.tobias.playpad.DisplayableColor; import de.tobias.playpad.PseudoClasses; import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.ColorModeHandler; import de.tobias.playpad.design.Design; import de.tobias.playpad.design.DesignColorAssociator; import de.tobias.playpad.design.FadeableColor; @@ -19,14 +22,16 @@ import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.project.Project; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.Warning; +import de.tobias.playpad.view.ColorPickerView; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; +import javafx.scene.Node; import javafx.scene.paint.Color; import javafx.stage.Stage; import javafx.util.Duration; -public class ModernGlobalDesign extends Design implements GlobalDesign, DesignColorAssociator { +public class ModernGlobalDesign extends Design implements GlobalDesign, DesignColorAssociator, ColorModeHandler { public static final String TYPE = "modern"; @@ -313,4 +318,17 @@ public class ModernGlobalDesign extends Design implements GlobalDesign, DesignCo public Color getAssociatedStandardColor() { return Color.web(backgroundColor.getColorHi()); } + + // Color View + @Override + public Node getColorInterface(Consumer<DisplayableColor> onSelection) { + return new ColorPickerView(null, ModernColor.values(), onSelection); + } + + @Override + public void setColor(CartDesign design, DisplayableColor color) { + if (design instanceof ModernCartDesign && color instanceof ModernColor) { + ((ModernCartDesign) design).setBackgroundColor((ModernColor) color); + } + } } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopColorPickerView.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopColorPickerView.java new file mode 100644 index 0000000000000000000000000000000000000000..ae8537d032e7bb6c73892f129c1179d653b12574 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopColorPickerView.java @@ -0,0 +1,81 @@ +package de.tobias.playpad.layout.desktop; + +import java.util.function.Consumer; + +import org.controlsfx.control.PopOver; +import org.controlsfx.control.PopOver.ArrowLocation; + +import de.tobias.playpad.DisplayableColor; +import de.tobias.playpad.PlayPadMain; +import de.tobias.playpad.design.CartDesign; +import de.tobias.playpad.design.ColorModeHandler; +import de.tobias.playpad.pad.Pad; +import de.tobias.playpad.pad.PadSettings; +import javafx.event.EventHandler; +import javafx.scene.Node; +import javafx.scene.input.MouseButton; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; + +public class DesktopColorPickerView implements Consumer<DisplayableColor>, EventHandler<MouseEvent> { + + private ColorModeHandler colorModeHandler; + private DisplayableColor selectedColor; + + private PopOver colorChooser; + + public DesktopColorPickerView(ColorModeHandler colorModeHandler) { + this.colorModeHandler = colorModeHandler; + + Node node = colorModeHandler.getColorInterface(this); + VBox root = new VBox(node); + + // Init Stage + colorChooser = new PopOver(); + colorChooser.setContentNode(root); + colorChooser.setDetachable(false); + colorChooser.setOnHiding(e -> colorChooser = null); + colorChooser.setCornerRadius(5); + colorChooser.setArrowLocation(ArrowLocation.TOP_CENTER); + } + + public void show(Node anchorNode) { + colorChooser.show(anchorNode); + } + + public void hide() { + if (colorChooser != null) { + colorChooser.hide(); + } + } + + // Handle Selected Color from View. + @Override + public void accept(DisplayableColor t) { + selectedColor = t; + colorChooser.hide(); + } + + // Listener, wenn auf ein Pad Geclicked wurde, zum färben + @Override + public void handle(MouseEvent event) { + // TODO Rewrite this + if (event.getSource() instanceof StackPane) { + StackPane view = (StackPane) event.getSource(); + if (view.getUserData() instanceof Pad) { + Pad pad = (Pad) view.getUserData(); + PadSettings padSettings = pad.getPadSettings(); + + if (event.getButton() == MouseButton.PRIMARY) { + padSettings.setCustomLayout(true); + CartDesign design = padSettings.getDesign(); + colorModeHandler.setColor(design, selectedColor); + } else if (event.getButton() == MouseButton.SECONDARY) { + padSettings.setCustomLayout(false); + } + PlayPadMain.getProgramInstance().getMainViewController().loadUserCss(); + } + } + } +} diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopEditMode.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopEditMode.java new file mode 100644 index 0000000000000000000000000000000000000000..874ce0c5539b63dc4adab75d150e61e5bb101e19 --- /dev/null +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopEditMode.java @@ -0,0 +1,6 @@ +package de.tobias.playpad.layout.desktop; + +public enum DesktopEditMode { + + PLAY, DRAG, PAGE, COLOR; +} diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java index 9d9b3657b2436e236cf07934870d735adbc84ee4..9accf5d4df1d1b6da6de2812ecc72fa8b5b820c6 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMainLayoutConnect.java @@ -3,11 +3,15 @@ package de.tobias.playpad.layout.desktop; import java.util.Stack; import de.tobias.playpad.Strings; +import de.tobias.playpad.layout.desktop.pad.DesktopPadView; import de.tobias.playpad.pad.view.IPadView; +import de.tobias.playpad.settings.Profile; import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; import de.tobias.utils.util.Localization; +import javafx.beans.property.ObjectProperty; +import javafx.beans.property.SimpleObjectProperty; /** * Desktop Implmentierung des Main Layouts. @@ -21,6 +25,7 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { private static final String TYPE = "Desktop"; private DesktopMenuToolbarViewController desktopMenuToolbarViewController; + private ObjectProperty<DesktopEditMode> editMode = new SimpleObjectProperty<>(DesktopEditMode.PLAY); private Stack<IPadView> recyclingStack; @@ -41,7 +46,7 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { @Override public MenuToolbarViewController createMenuToolbar(IMainViewController mainViewRef) { if (desktopMenuToolbarViewController == null) { - desktopMenuToolbarViewController = new DesktopMenuToolbarViewController(mainViewRef); + desktopMenuToolbarViewController = new DesktopMenuToolbarViewController(mainViewRef, this); } return desktopMenuToolbarViewController; } @@ -51,7 +56,7 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { if (!recyclingStack.isEmpty()) { return recyclingStack.pop(); } - return new DesktopPadView(); + return new DesktopPadView(this); } @Override @@ -64,4 +69,18 @@ public class DesktopMainLayoutConnect implements MainLayoutConnect { return null; } + public DesktopEditMode getEditMode() { + return editMode.get(); + } + + public void setEditMode(DesktopEditMode editMode) { + if (editMode != DesktopEditMode.PLAY && Profile.currentProfile().getProfileSettings().isLocked()) { + return; + } + this.editMode.set(editMode); + } + + public ObjectProperty<DesktopEditMode> editModeProperty() { + return editMode; + } } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java index d130626ee700e48dae98cd463ce9d097000b2567..88164893c6a00bb18cbfd8dde5837d8dd8b55b65 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopMenuToolbarViewController.java @@ -8,12 +8,15 @@ import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; +import org.controlsfx.control.SegmentedButton; import org.controlsfx.control.textfield.TextFields; import de.tobias.playpad.AppUserInfoStrings; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; +import de.tobias.playpad.design.ColorModeHandler; +import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.midi.Midi; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadStatus; @@ -43,17 +46,20 @@ import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.global.GlobalSettingsViewController; import de.tobias.playpad.viewcontroller.option.profile.ProfileSettingsViewController; import de.tobias.playpad.viewcontroller.option.project.ProjectSettingsViewController; -import de.tobias.playpad.viewcontroller.pad.PadDragListener; import de.tobias.utils.application.ApplicationInfo; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.application.container.PathType; import de.tobias.utils.ui.Alertable; +import de.tobias.utils.ui.icon.FontAwesomeType; +import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.ui.scene.NotificationPane; import de.tobias.utils.util.Localization; import de.tobias.utils.util.Worker; import de.tobias.utils.util.net.FileUpload; import javafx.application.Platform; import javafx.beans.binding.Bindings; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.fxml.FXML; @@ -69,12 +75,18 @@ import javafx.scene.control.MenuBar; import javafx.scene.control.MenuItem; import javafx.scene.control.Slider; import javafx.scene.control.TextField; +import javafx.scene.control.ToggleButton; +import javafx.scene.control.Tooltip; import javafx.scene.input.KeyCombination; +import javafx.scene.input.MouseEvent; import javafx.scene.layout.HBox; import javafx.stage.Modality; import javafx.stage.Stage; -public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewController implements EventHandler<ActionEvent> { +public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewController + implements EventHandler<ActionEvent>, ChangeListener<DesktopEditMode> { + + // TODO Page Buttons gleicher Margin wie pads // meuBar @FXML protected MenuBar menuBar; @@ -85,7 +97,10 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML protected MenuItem profileMenu; @FXML protected MenuItem printProjectMenuItem; - @FXML protected CheckMenuItem dndModeMenuItem; + @FXML protected MenuItem playMenu; + @FXML protected MenuItem dragMenu; + @FXML protected MenuItem colorMenu; + @FXML protected MenuItem errorMenu; @FXML protected MenuItem pluginMenu; @@ -105,15 +120,30 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @FXML protected Label liveLabel; + protected SegmentedButton editButtons; + protected ToggleButton playButton; + protected ToggleButton dragButton; + protected ToggleButton pageButton; + protected ToggleButton colorButton; + private Button addPageButton; + private IMainViewController mainViewController; - private ProjectSettingsViewController projectSettingsViewController; - private ProfileSettingsViewController profileSettingsViewController; - private GlobalSettingsViewController globalSettingsViewController; + private transient ProjectSettingsViewController projectSettingsViewController; + private transient ProfileSettingsViewController profileSettingsViewController; + private transient GlobalSettingsViewController globalSettingsViewController; + private transient DesktopColorPickerView colorPickerView; + + private DesktopMainLayoutConnect connect; - public DesktopMenuToolbarViewController(IMainViewController controller) { + public DesktopMenuToolbarViewController(IMainViewController controller, DesktopMainLayoutConnect connect) { super("header", "de/tobias/playpad/assets/view/main/desktop/", PlayPadMain.getUiResourceBundle()); this.mainViewController = controller; + this.connect = connect; + this.connect.editModeProperty().addListener(this); + + // Ist Zustand herstellen, indem Listener mit dem Initialen Wert bekannt gemacht wird. + changed(connect.editModeProperty(), null, connect.getEditMode()); initLayoutMenu(); } @@ -130,6 +160,99 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro // Help Menu --> HIDDEN TODO helpMenu.setVisible(false); helpMenu.getItems().add(new HelpMenuItem(helpMenu)); + + // Edit Mode Buttons + editButtons = new SegmentedButton(); + playButton = new ToggleButton("", new FontIcon(FontAwesomeType.PLAY)); + playButton.setTooltip(new Tooltip(Localization.getString(Strings.Tooltip_PlayButton))); + playButton.setFocusTraversable(false); + dragButton = new ToggleButton("", new FontIcon(FontAwesomeType.ARROWS)); + dragButton.setTooltip(new Tooltip(Localization.getString(Strings.Tooltip_DragButton))); + dragButton.setFocusTraversable(false); + pageButton = new ToggleButton("", new FontIcon(FontAwesomeType.FILES_ALT)); + pageButton.setTooltip(new Tooltip(Localization.getString(Strings.Tooltip_PageButton))); + pageButton.setFocusTraversable(false); + colorButton = new ToggleButton("", new FontIcon(FontAwesomeType.PENCIL)); + colorButton.setTooltip(new Tooltip(Localization.getString(Strings.Tooltip_ColorButton))); + colorButton.setFocusTraversable(false); + // Zeigt die Farbauswahl + colorButton.setOnAction(e -> + { + GlobalDesign design = Profile.currentProfile().currentLayout(); + if (design instanceof ColorModeHandler) { + colorPickerView = new DesktopColorPickerView((ColorModeHandler) design); + colorPickerView.show(colorButton); + + // Add Listener for Pads + mainViewController.addListenerForPads(colorPickerView, MouseEvent.MOUSE_CLICKED); + } + }); + editButtons.getButtons().addAll(playButton, dragButton, pageButton, colorButton); + editButtons.getToggleGroup().selectedToggleProperty().addListener((a, b, c) -> + { + if (c == playButton) { + connect.setEditMode(DesktopEditMode.PLAY); + } else if (c == dragButton) { + connect.setEditMode(DesktopEditMode.DRAG); + } else if (c == pageButton) { + connect.setEditMode(DesktopEditMode.PAGE); + } else if (c == colorButton) { + connect.setEditMode(DesktopEditMode.COLOR); + } else if (c == null) { + // select Old Button, if new selecting is empty + editButtons.getToggleGroup().selectToggle(b); + } + }); + + // Add Page Button for Drag Mode (Page Edit Mode) + addPageButton = new Button("", new FontIcon(FontAwesomeType.PLUS)); + addPageButton.setFocusTraversable(false); + addPageButton.setOnAction(e -> + { + openProject.addPage(); + initPageButtons(); + highlightPageButton(mainViewController.getPage()); + }); + + iconHbox.getChildren().add(editButtons); + } + + // Desktop Edit Mode Change Listener --> Update Button + @Override + public void changed(ObservableValue<? extends DesktopEditMode> observable, DesktopEditMode oldValue, DesktopEditMode newValue) { + // handle old mode + if (oldValue == DesktopEditMode.DRAG) { + for (IPadView view : mainViewController.getPadViews()) { + view.enableDragAndDropDesignMode(false); + } + } else if (oldValue == DesktopEditMode.PAGE) { + highlightPageButton(currentSelectedPageButton); + iconHbox.getChildren().remove(addPageButton); + } else if (oldValue == DesktopEditMode.COLOR) { + if (colorPickerView != null) { + mainViewController.removeListenerForPads(colorPickerView, MouseEvent.MOUSE_CLICKED); + colorPickerView.hide(); + colorPickerView = null; + } + } + + // handle new mode + if (newValue == DesktopEditMode.PLAY) { + playButton.setSelected(true); + } else if (newValue == DesktopEditMode.DRAG) { + // TODO Live Mode Check + dragButton.setSelected(true); + for (IPadView view : mainViewController.getPadViews()) { + view.enableDragAndDropDesignMode(true); + } + } else if (newValue == DesktopEditMode.PAGE) { + pageButton.setSelected(true); + iconHbox.getChildren().add(0, addPageButton); + highlightPageButton(currentSelectedPageButton); + } else if (newValue == DesktopEditMode.COLOR) { + colorButton.setSelected(true); + } + } private void initLayoutMenu() { @@ -172,14 +295,14 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @Override public void initPageButtons() { - currentPage = -1; + currentSelectedPageButton = -1; pageHBox.getChildren().clear(); if (openProject == null) { return; } - for (int i = 0; i < openProject.getSettings().getPageCount(); i++) { + for (int i = 0; i < openProject.getPages().size(); i++) { Page page = openProject.getPage(i); String name = page.getName(); @@ -203,7 +326,10 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro setKeyBindingForMenu(saveProjectMenuItem, keys.getKey("save_proj")); setKeyBindingForMenu(printProjectMenuItem, keys.getKey("print_proj")); - setKeyBindingForMenu(dndModeMenuItem, keys.getKey("dnd")); + setKeyBindingForMenu(playMenu, keys.getKey("play")); + setKeyBindingForMenu(dragMenu, keys.getKey("drag")); + setKeyBindingForMenu(colorMenu, keys.getKey("color")); + setKeyBindingForMenu(errorMenu, keys.getKey("errors")); setKeyBindingForMenu(pluginMenu, keys.getKey("plugins")); setKeyBindingForMenu(projectSettingsMenuItem, keys.getKey("project_settings")); @@ -219,7 +345,10 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro saveProjectMenuItem.setDisable(false); printProjectMenuItem.setDisable(false); - dndModeMenuItem.setDisable(false); + playMenu.setDisable(false); + dragMenu.setDisable(false); + colorMenu.setDisable(false); + errorMenu.setDisable(false); pluginMenu.setDisable(false); projectSettingsMenuItem.setDisable(false); @@ -233,7 +362,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro @Override public void setLocked(boolean looked) { - dndModeMenuItem.setDisable(looked); + connect.setEditMode(DesktopEditMode.PLAY); } @Override @@ -276,7 +405,10 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro saveProjectMenuItem.setDisable(true); printProjectMenuItem.setDisable(true); - dndModeMenuItem.setDisable(true); + playMenu.setDisable(true); + dragMenu.setDisable(true); + colorMenu.setDisable(true); + errorMenu.setDisable(true); pluginMenu.setDisable(true); projectSettingsMenuItem.setDisable(true); @@ -287,13 +419,7 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro alwaysOnTopItem.setDisable(true); searchPadMenuItem.setDisable(true); - // Disable Drag Mode wenn aktiv und diese Toolbar deaktiviert wird. - if (dndModeMenuItem.isSelected()) { - PadDragListener.setDndMode(false); - for (IPadView view : mainViewController.getPadViews()) { - view.enableDragAndDropDesignMode(false); - } - } + connect.setEditMode(DesktopEditMode.PLAY); } @Override @@ -301,13 +427,13 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro return volumeSlider; } - private int currentPage = 0; + private int currentSelectedPageButton = 0; @Override public void highlightPageButton(int index) { if (index >= 0) { - if (pageHBox.getChildren().size() > currentPage && currentPage >= 0) { - Node removeNode = pageHBox.getChildren().get(currentPage); + if (pageHBox.getChildren().size() > currentSelectedPageButton && currentSelectedPageButton >= 0) { + Node removeNode = pageHBox.getChildren().get(currentSelectedPageButton); removeNode.getStyleClass().remove(CURRENT_PAGE_BUTTON); if (removeNode instanceof Button) { @@ -315,14 +441,14 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro } } - if (pageHBox.getChildren().size() > index) { + if (index < pageHBox.getChildren().size()) { Node newNode = pageHBox.getChildren().get(index); newNode.getStyleClass().add(CURRENT_PAGE_BUTTON); - currentPage = index; + currentSelectedPageButton = index; - if (newNode instanceof Button && dndModeMenuItem.isSelected()) { // Nur bei Drag And Drop mode + if (newNode instanceof Button && connect.getEditMode() == DesktopEditMode.PAGE) { // Nur bei Drag And Drop mode Button button = (Button) newNode; - DesktopButtonEditView editBox = new DesktopButtonEditView(openProject.getPage(index), button); + DesktopPageEditButtonView editBox = new DesktopPageEditButtonView(this, openProject.getPage(index), button); button.setGraphic(editBox); } } @@ -411,26 +537,18 @@ public class DesktopMenuToolbarViewController extends BasicMenuToolbarViewContro } @FXML - void dndModeHandler(ActionEvent event) { - if (dndModeMenuItem.isSelected()) { - GlobalSettings settings = PlayPadPlugin.getImplementation().getGlobalSettings(); - Project currentProject = PlayPadMain.getProgramInstance().getCurrentProject(); - - if (settings.isLiveMode() && settings.isLiveModeDrag() && currentProject.getActivePlayers() == 0) { - PadDragListener.setDndMode(true); - for (IPadView view : mainViewController.getPadViews()) { - view.enableDragAndDropDesignMode(true); - } - } - } else { - PadDragListener.setDndMode(false); - for (IPadView view : mainViewController.getPadViews()) { - view.enableDragAndDropDesignMode(false); - } - } + void playMenuHandler(ActionEvent event) { + connect.setEditMode(DesktopEditMode.PLAY); + } + + @FXML + void dragMenuHandler(ActionEvent event) { + connect.setEditMode(DesktopEditMode.DRAG); + } - // Damit werden Page Buttons editierbar (die 3 Button vom DesktopButtonEditView) - highlightPageButton(currentPage); + @FXML + void colorMenuHandler(ActionEvent event) { + connect.setEditMode(DesktopEditMode.COLOR); } @FXML diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopButtonEditView.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPageEditButtonView.java similarity index 57% rename from PlayWall/src/de/tobias/playpad/layout/desktop/DesktopButtonEditView.java rename to PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPageEditButtonView.java index a4a3f4daf4a9a630940baecf9eb99c2e3bb950ee..98839443e2daa7ffaac05ad893c7325c7addbdc6 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopButtonEditView.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPageEditButtonView.java @@ -2,32 +2,42 @@ package de.tobias.playpad.layout.desktop; import java.util.Optional; +import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; import de.tobias.playpad.project.Project; import de.tobias.playpad.project.page.Page; import de.tobias.playpad.viewcontroller.main.IMainViewController; +import de.tobias.playpad.viewcontroller.main.MenuToolbarViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; import de.tobias.utils.util.Localization; import javafx.event.ActionEvent; import javafx.event.EventHandler; +import javafx.scene.control.Alert; +import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; +import javafx.scene.control.ButtonType; import javafx.scene.control.TextInputDialog; import javafx.scene.layout.HBox; +import javafx.stage.Modality; +import javafx.stage.Stage; -public class DesktopButtonEditView extends HBox implements EventHandler<ActionEvent> { +public class DesktopPageEditButtonView extends HBox implements EventHandler<ActionEvent> { private Page page; private Button leftMoveButton; private Button rightMoveButton; private Button editTextButton; + private Button deleteButton; private transient Button pageButton; + private transient MenuToolbarViewController controller; - public DesktopButtonEditView(Page page, Button pageButton) { + public DesktopPageEditButtonView(MenuToolbarViewController controller, Page page, Button pageButton) { this.page = page; this.pageButton = pageButton; + this.controller = controller; leftMoveButton = new Button("", new FontIcon(FontAwesomeType.ARROW_LEFT)); leftMoveButton.setOnAction(this); @@ -41,7 +51,11 @@ public class DesktopButtonEditView extends HBox implements EventHandler<ActionEv editTextButton.setOnAction(this); editTextButton.setFocusTraversable(false); - getChildren().addAll(leftMoveButton, rightMoveButton, editTextButton); + deleteButton = new Button("", new FontIcon(FontAwesomeType.TRASH)); + deleteButton.setOnAction(this); + deleteButton.setFocusTraversable(false); + + getChildren().addAll(leftMoveButton, rightMoveButton, editTextButton, deleteButton); setSpacing(7); } @@ -66,7 +80,7 @@ public class DesktopButtonEditView extends HBox implements EventHandler<ActionEv event.consume(); } else if (event.getSource() == rightMoveButton) { Project project = page.getProjectReference(); - if (page.getId() < project.getSettings().getPageCount()) { + if (page.getId() < project.getPages().size()) { Page rightPage = project.getPage(page.getId() + 1); int rightIndex = rightPage.getId(); @@ -83,20 +97,47 @@ public class DesktopButtonEditView extends HBox implements EventHandler<ActionEv event.consume(); } else if (event.getSource() == editTextButton) { TextInputDialog dialog = new TextInputDialog(); + + dialog.setHeaderText(Localization.getString(Strings.UI_Dialog_Page_Name_Header)); + dialog.setContentText(Localization.getString(Strings.UI_Dialog_Page_Name_Content)); + dialog.initOwner(controller.getStage()); + dialog.initModality(Modality.WINDOW_MODAL); + Stage stage = (Stage) dialog.getDialogPane().getScene().getWindow(); + PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); + Optional<String> result = dialog.showAndWait(); - // TODO Owner, Modal, Icon, Text - result.ifPresent(name -> + + result.filter(name -> name != null && !name.isEmpty()).ifPresent(name -> { page.setName(name); }); + // Update Page Button in Toolbar String name = page.getName(); - if (name.isEmpty()) { - name = Localization.getString(Strings.UI_Window_Main_PageButton, (page.getId() + 1)); - } + if (name.isEmpty()) + name = Localization.getString(Strings.UI_Window_Main_PageButton, (page.getId() + 1)); // Default Text pageButton.setText(name); - + event.consume(); + } else if (event.getSource() == deleteButton) { + Alert alert = new Alert(AlertType.CONFIRMATION); + + alert.setHeaderText(Localization.getString(Strings.UI_Dialog_Page_Delete_Header)); + alert.setContentText(Localization.getString(Strings.UI_Dialog_Page_Delete_Content)); + alert.initOwner(controller.getStage()); + alert.initModality(Modality.WINDOW_MODAL); + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + PlayPadMain.stageIcon.ifPresent(stage.getIcons()::add); + + Optional<ButtonType> result = alert.showAndWait(); + System.out.println(result); + result.filter(r -> r == ButtonType.OK).ifPresent(r -> + { + Project project = page.getProjectReference(); + project.removePage(page); + controller.initPageButtons(); + controller.highlightPageButton(0); // Show first page + }); } } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java index df1a4f755e5b2ac012e813bb722a9a2f2c658793..eb061618c9bf592c3b26977bfbc55e104701b7c0 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopSearchController.java @@ -5,6 +5,7 @@ import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.control.TextField; +// TODO Search Pads public class DesktopSearchController implements EventHandler<ActionEvent> { private TextField textField; diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/PageButtonDragHandler.java b/PlayWall/src/de/tobias/playpad/layout/desktop/PageButtonDragHandler.java index 64b67e7204d8d147366d572b64b8d2b2954da50b..3043e41a3c33b0e17a1273fe906003b85d4eaf64 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/PageButtonDragHandler.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/PageButtonDragHandler.java @@ -4,6 +4,13 @@ import de.tobias.playpad.viewcontroller.main.IMainViewController; import javafx.event.EventHandler; import javafx.scene.input.DragEvent; +/** + * Drag and Drop eines Pads auf ein Page Button (umschalten auf neue Page), wird im DesktopMenuToolbarController verwaltet. + * + * @author tobias + * + * @since 5.1.0 + */ public class PageButtonDragHandler implements EventHandler<DragEvent> { private IMainViewController controller; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java b/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadDragListener.java similarity index 87% rename from PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java rename to PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadDragListener.java index 814032b715b6e22f7c8ba572ae00f3080cbaf32e..63a8d82677e310d65d7e4a23337dc366485cfc82 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadDragListener.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadDragListener.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.viewcontroller.pad; +package de.tobias.playpad.layout.desktop.pad; import java.io.File; import java.io.IOException; @@ -6,6 +6,8 @@ import java.util.Collection; import java.util.Set; import de.tobias.playpad.PlayPadPlugin; +import de.tobias.playpad.layout.desktop.DesktopEditMode; +import de.tobias.playpad.layout.desktop.DesktopMainLayoutConnect; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadContentRegistry; import de.tobias.playpad.pad.conntent.PadContent; @@ -19,6 +21,7 @@ import de.tobias.playpad.settings.GlobalSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.view.FileDragOptionView; import de.tobias.playpad.view.PadDragOptionView; +import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.utils.util.FileUtils; import javafx.scene.SnapshotParameters; import javafx.scene.image.WritableImage; @@ -31,12 +34,12 @@ import javafx.scene.input.TransferMode; import javafx.scene.layout.Pane; import javafx.scene.paint.Color; -public class PadDragListener { +public class DesktopPadDragListener { private Pad sourcePad; final private Pane view; - private static boolean dndMode; + private DesktopMainLayoutConnect connect; private static Project project; private PadDragOptionView padHud; @@ -44,8 +47,10 @@ public class PadDragListener { private static DataFormat dataFormat = new DataFormat("de.tobias.playpad.padindex"); - public PadDragListener(Pad pad, IPadView view) { + public DesktopPadDragListener(Pad pad, IPadView view, DesktopMainLayoutConnect connect) { this.sourcePad = pad; + this.connect = connect; + this.view = view.getRootNode(); // Drag and Drop @@ -157,12 +162,12 @@ public class PadDragListener { PadIndex padID = (PadIndex) db.getContent(dataFormat); // TODO Check Cast PadDragMode mode = padHud.getSelectedPadDragMode(); - + mode.handle(padID, sourcePad.getPadIndex(), project); padHud.hide(); - PlayPadPlugin.getImplementation().getMainViewController() - .showPage(PlayPadPlugin.getImplementation().getMainViewController().getPage()); + IMainViewController mainViewController = PlayPadPlugin.getImplementation().getMainViewController(); + mainViewController.showPage(mainViewController.getPage()); event.setDropCompleted(success); event.consume(); @@ -170,7 +175,7 @@ public class PadDragListener { } private void dragDetacted(MouseEvent event) { - if (dndMode) { + if (connect.getEditMode() == DesktopEditMode.DRAG) { GlobalSettings globalSettings = PlayPadPlugin.getImplementation().getGlobalSettings(); if (sourcePad.getProject() != null) { @@ -187,8 +192,8 @@ public class PadDragListener { for (int x = 0; x < snapshot.getWidth(); x++) { for (int y = 0; y < snapshot.getHeight(); y++) { Color oldColor = snapshot.getPixelReader().getColor(x, y).darker().darker(); - snapshot.getPixelWriter().setColor(x, y, - new Color(oldColor.getRed(), oldColor.getGreen(), oldColor.getBlue(), oldColor.getOpacity() * 0.5)); + Color newColor = new Color(oldColor.getRed(), oldColor.getGreen(), oldColor.getBlue(), oldColor.getOpacity() * 0.5); + snapshot.getPixelWriter().setColor(x, y, newColor); } } @@ -202,23 +207,8 @@ public class PadDragListener { } } - /** - * Aktiviert den Drag And Drop Modus für Kacheln. Diese Methode muss vom Menu / KeyShortcut aufgerufen werden. - * - * @param dndMode - * <code>true</code> Aktiv - */ - public static void setDndMode(boolean dndMode) { - PadDragListener.dndMode = dndMode; - } - - @Deprecated - public void setPad(Pad pad) { - this.sourcePad = pad; - } - public static void setProject(Project project) { - PadDragListener.project = project; + DesktopPadDragListener.project = project; } } diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java b/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadView.java similarity index 97% rename from PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java rename to PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadView.java index 9a4553e856323f4e244ba85b1e3bb05ff7a1bdd7..4b3c8b858131dd24d0ca4e9d57e33d7253e46f61 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadView.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadView.java @@ -1,7 +1,8 @@ -package de.tobias.playpad.layout.desktop; +package de.tobias.playpad.layout.desktop.pad; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.PseudoClasses; +import de.tobias.playpad.layout.desktop.DesktopMainLayoutConnect; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadContentRegistry; import de.tobias.playpad.pad.conntent.PadContent; @@ -57,9 +58,9 @@ public class DesktopPadView implements IPadView { private BusyView busyView; private transient DesktopPadViewController controller; // Reference to its controller - - public DesktopPadView() { - controller = new DesktopPadViewController(this); + + public DesktopPadView(DesktopMainLayoutConnect connect) { + controller = new DesktopPadViewController(this, connect); setupView(); } @@ -126,6 +127,8 @@ public class DesktopPadView implements IPadView { @Override public void setContentView(Pad pad) { + superRoot.setUserData(pad); + if (previewContent != null) { previewContent.deinit(); } @@ -334,7 +337,7 @@ public class DesktopPadView implements IPadView { @Override public void removeStyleClasses() { Pad pad = getViewController().getPad(); - PadIndex index = pad.getPadIndex(); + int index = pad.getIndex(); superRoot.getStyleClass().removeAll("pad", "pad" + index); diff --git a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java similarity index 91% rename from PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java rename to PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java index 1b14efa61954078b2d9d588f0cd835f422ab02ff..83794b007579e3565d00072ef614a73f5bc3209f 100644 --- a/PlayWall/src/de/tobias/playpad/layout/desktop/DesktopPadViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/desktop/pad/DesktopPadViewController.java @@ -1,4 +1,4 @@ -package de.tobias.playpad.layout.desktop; +package de.tobias.playpad.layout.desktop.pad; import java.io.File; import java.io.IOException; @@ -7,6 +7,8 @@ import java.util.Set; import de.tobias.playpad.PlayPadPlugin; import de.tobias.playpad.Strings; +import de.tobias.playpad.layout.desktop.DesktopEditMode; +import de.tobias.playpad.layout.desktop.DesktopMainLayoutConnect; import de.tobias.playpad.pad.Pad; import de.tobias.playpad.pad.PadContentRegistry; import de.tobias.playpad.pad.PadStatus; @@ -29,7 +31,6 @@ import de.tobias.playpad.settings.ProfileSettings; import de.tobias.playpad.view.FileDragOptionView; import de.tobias.playpad.viewcontroller.main.IMainViewController; import de.tobias.playpad.viewcontroller.option.pad.PadSettingsViewController; -import de.tobias.playpad.viewcontroller.pad.PadDragListener; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.util.FileUtils; import de.tobias.utils.util.Localization; @@ -44,7 +45,6 @@ import javafx.util.Duration; public class DesktopPadViewController implements IPadViewController, EventHandler<ActionEvent> { - protected static final String CURRENT_PAGE_BUTTON = "current-page-button"; private static final String OPEN_FOLDER = "openFolder"; private static final String DURATION_FORMAT = "%d:%02d"; @@ -57,10 +57,13 @@ public class DesktopPadViewController implements IPadViewController, EventHandle private PadDurationListener padDurationListener; private IPadPositionListener padPositionListener; - private PadDragListener padDragListener; + private DesktopPadDragListener padDragListener; - public DesktopPadViewController(DesktopPadView padView) { + private DesktopMainLayoutConnect connect; + + public DesktopPadViewController(DesktopPadView padView, DesktopMainLayoutConnect connect) { this.padView = padView; + this.connect = connect; padLockedListener = new PadLockedListener(this); padStatusListener = new PadStatusListener(this); @@ -109,7 +112,7 @@ public class DesktopPadViewController implements IPadViewController, EventHandle padContentListener.changed(null, null, pad.getContent()); // Add Duration listener padStatusListener.changed(null, null, pad.getStatus()); - padDragListener = new PadDragListener(pad, padView); + padDragListener = new DesktopPadDragListener(pad, padView, connect); } catch (Exception e) { e.printStackTrace(); } @@ -157,21 +160,23 @@ public class DesktopPadViewController implements IPadViewController, EventHandle @Override public void handle(ActionEvent event) { - if (event.getSource() == padView.getPlayButton()) { - onPlay(); - } else if (event.getSource() == padView.getPauseButton()) { - onPause(); - } else if (event.getSource() == padView.getStopButton()) { - onStop(); - } else if (event.getSource() == padView.getNewButton()) { - try { - onNew(event); - } catch (NoSuchComponentException e) { - // TODO Error Handling - e.printStackTrace(); + if (connect.getEditMode() == DesktopEditMode.PLAY) { + if (event.getSource() == padView.getPlayButton()) { + onPlay(); + } else if (event.getSource() == padView.getPauseButton()) { + onPause(); + } else if (event.getSource() == padView.getStopButton()) { + onStop(); + } else if (event.getSource() == padView.getNewButton()) { + try { + onNew(event); + } catch (NoSuchComponentException e) { + // TODO Error Handling + e.printStackTrace(); + } + } else if (event.getSource() == padView.getSettingsButton()) { + onSettings(); } - } else if (event.getSource() == padView.getSettingsButton()) { - onSettings(); } } @@ -393,7 +398,7 @@ public class DesktopPadViewController implements IPadViewController, EventHandle return padDurationListener; } - public PadDragListener getPadDragListener() { + public DesktopPadDragListener getPadDragListener() { return padDragListener; } } diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java index 347361cd08b6c8ebde4b661e2259f438e71df8fe..8e56e4ba21984506aa3de729b38409ddd66cdf5c 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchMenuToolbarViewController.java @@ -50,7 +50,7 @@ public class TouchMenuToolbarViewController extends BasicMenuToolbarViewControll return; } - for (int i = 0; i < openProject.getSettings().getPageCount(); i++) { + for (int i = 0; i < openProject.getPages().size(); i++) { Button button = new Button(Localization.getString(Strings.UI_Window_Main_PageButton, (i + 1))); button.setUserData(i); button.setFocusTraversable(false); diff --git a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java index 38c35cca8b74fb9fa24b34cfca52f810b6dadf5a..eb3df64993ddcc97eb98238f148c6be79e08283e 100644 --- a/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java +++ b/PlayWall/src/de/tobias/playpad/layout/touch/TouchPadViewController.java @@ -14,7 +14,6 @@ import de.tobias.playpad.pad.view.IPadView; import de.tobias.playpad.pad.viewcontroller.IPadViewController; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.viewcontroller.pad.PadDragListener; import javafx.beans.value.ChangeListener; import javafx.event.Event; import javafx.event.EventHandler; @@ -37,8 +36,6 @@ public class TouchPadViewController implements IPadViewController, EventHandler< private PadDurationListener padDurationListener; private IPadPositionListener padPositionListener; - private PadDragListener padDragListener; - public TouchPadViewController(TouchPadView padView) { this.padView = padView; @@ -89,8 +86,6 @@ public class TouchPadViewController implements IPadViewController, EventHandler< // 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(); } @@ -120,14 +115,12 @@ public class TouchPadViewController implements IPadViewController, EventHandler< durationable.positionProperty().removeListener(padPositionListener); } pad.setController(null); - padDragListener = null; // GUI Cleaning padPositionListener.stopWaning(); padView.removeStyleClasses(); } - this.padDragListener = null; this.pad = null; } @@ -230,8 +223,4 @@ public class TouchPadViewController implements IPadViewController, EventHandler< public ChangeListener<Duration> getPadDurationListener() { return padDurationListener; } - - public PadDragListener getPadDragListener() { - return padDragListener; - } } diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java index f1ddd7d222840089fb73f7f63bbf8a69f6e783e2..e1438baff5ac2aba882efa7c3dce463862b593a6 100644 --- a/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java +++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java @@ -91,7 +91,7 @@ public class PadPositionListener implements Runnable, IPadPositionListener { Warning warning = padSettings.getWarning(); if (padSettings.isCustomLayout()) { - padSettings.getLayout().handleWarning(controller, warning, Profile.currentProfile().currentLayout()); + padSettings.getDesign().handleWarning(controller, warning, Profile.currentProfile().currentLayout()); } else { Profile.currentProfile().currentLayout().handleWarning(controller, warning); } @@ -115,7 +115,7 @@ public class PadPositionListener implements Runnable, IPadPositionListener { PadSettings padSettings = pad.getPadSettings(); if (padSettings.isCustomLayout()) { - padSettings.getLayout().stopWarning(controller); + padSettings.getDesign().stopWarning(controller); } else { Profile.currentProfile().currentLayout().stopWarning(controller); } diff --git a/PlayWall/src/de/tobias/playpad/update/PlayPadUpdater.java b/PlayWall/src/de/tobias/playpad/update/PlayPadUpdater.java index f7d3c16f59e26a6e2b604215d50327333c54c2db..2ba459e5dd0d50b6e6a5739c57ba88ecc0bf225f 100644 --- a/PlayWall/src/de/tobias/playpad/update/PlayPadUpdater.java +++ b/PlayWall/src/de/tobias/playpad/update/PlayPadUpdater.java @@ -8,8 +8,6 @@ import java.nio.file.Path; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.YamlConfiguration; -import de.tobias.playpad.update.Updatable; -import de.tobias.playpad.update.UpdateChannel; import de.tobias.utils.application.App; import de.tobias.utils.application.ApplicationUtils; import de.tobias.utils.util.SystemUtils; diff --git a/PlayWall/src/de/tobias/playpad/view/ColorView.java b/PlayWall/src/de/tobias/playpad/view/ColorPickerView.java similarity index 65% rename from PlayWall/src/de/tobias/playpad/view/ColorView.java rename to PlayWall/src/de/tobias/playpad/view/ColorPickerView.java index ff09b68021852c4ebf68451ece4cb165c952fccf..06718f47d9dffbb984ced623dd16eb4391248cfc 100644 --- a/PlayWall/src/de/tobias/playpad/view/ColorView.java +++ b/PlayWall/src/de/tobias/playpad/view/ColorPickerView.java @@ -7,9 +7,11 @@ import javafx.geometry.Insets; import javafx.scene.layout.GridPane; import javafx.scene.shape.Rectangle; -public class ColorView extends GridPane { +public class ColorPickerView extends GridPane { - public ColorView(DisplayableColor startColor, DisplayableColor[] colors, Consumer<DisplayableColor> finish) { + private Rectangle currentSelected; + + public ColorPickerView(DisplayableColor startColor, DisplayableColor[] colors, Consumer<DisplayableColor> finish) { double size = Math.sqrt(colors.length); int iSize = (int) size; if (size != iSize) { @@ -39,7 +41,15 @@ public class ColorView extends GridPane { } // EventHandler - rectangle.setOnMouseReleased(event -> finish.accept(color)); + rectangle.setOnMouseReleased(event -> + { + if (currentSelected != null) { + currentSelected.getStrokeDashArray().clear(); + } + rectangle.getStrokeDashArray().addAll(3.0); + currentSelected = rectangle; + finish.accept(color); + }); add(rectangle, x, y); } } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java index fbda591aa744faa54b000b0b47622d76fbd5de94..99644a917a096a1badef9824f179e1d6c77fe9ab 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernCartDesignViewController.java @@ -10,7 +10,7 @@ import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.design.CartDesign; import de.tobias.playpad.design.modern.ModernCartDesign; import de.tobias.playpad.design.modern.ModernColor; -import de.tobias.playpad.view.ColorView; +import de.tobias.playpad.view.ColorPickerView; import de.tobias.playpad.viewcontroller.CartDesignViewController; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -65,7 +65,7 @@ public class ModernCartDesignViewController extends CartDesignViewController { } private void colorChooser(Button anchorNode, ModernColor startColor, Consumer<ModernColor> onFinish) { - ColorView view = new ColorView(startColor, ModernColor.values(), (DisplayableColor t) -> + ColorPickerView view = new ColorPickerView(startColor, ModernColor.values(), (DisplayableColor t) -> { colorChooser.hide(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java index 19811e5ca8d27854d38315930f809f245f152bb3..d90331f55d16e2b23717cbfa8517dfee0c81a460 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/design/ModernGlobalDesignViewController.java @@ -10,7 +10,7 @@ import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.design.modern.ModernColor; import de.tobias.playpad.design.modern.ModernGlobalDesign; -import de.tobias.playpad.view.ColorView; +import de.tobias.playpad.view.ColorPickerView; import de.tobias.playpad.viewcontroller.GlobalDesignViewController; import javafx.event.ActionEvent; import javafx.fxml.FXML; @@ -94,7 +94,7 @@ public class ModernGlobalDesignViewController extends GlobalDesignViewController } private void colorChooser(Button anchorNode, ModernColor startColor, Consumer<ModernColor> onFinish) { - ColorView view = new ColorView(startColor, ModernColor.values(), (DisplayableColor t) -> + ColorPickerView view = new ColorPickerView(startColor, ModernColor.values(), (DisplayableColor t) -> { colorChooser.hide(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java index 8c895f0c67858fe7ce2520f83c19da7c27ea96fb..c4ad55310bf2f14a76fa7fc71b7d18487228daab 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/PrintDialog.java @@ -11,8 +11,8 @@ import com.hp.gagawa.java.elements.Tr; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.project.page.PadIndex; import de.tobias.playpad.settings.Profile; import de.tobias.utils.application.ApplicationUtils; @@ -46,7 +46,7 @@ public class PrintDialog extends ViewController { super("printDialog", "de/tobias/playpad/assets/dialog/project/", null, PlayPadMain.getUiResourceBundle()); this.project = project; - int pages = project.getSettings().getPageCount(); + int pages = project.getPages().size(); for (int i = 0; i < pages; i++) { pageComboBox.getItems().add(i + 1); } diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java index 91e587b5206c5e48b2e025314f30288d8f73b2db..17ad484e8762d50b8d7785244dfd26a6e7a3684c 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/dialog/ProjectManagerDialog.java @@ -9,8 +9,8 @@ import org.dom4j.DocumentException; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; -import de.tobias.playpad.project.ProjectImporter; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectImporter; import de.tobias.playpad.project.ref.ProjectReference; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.settings.ProfileReference; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java index b260afc55ff730a6f5126a9ac2fa592223e1b485..c16a3acc5d18b2b3237cc7991cb85a6c6da7a061 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/main/MainViewController.java @@ -15,6 +15,7 @@ import de.tobias.playpad.action.mapper.listener.KeyboardHandler; import de.tobias.playpad.action.mapper.listener.MidiHandler; import de.tobias.playpad.design.GlobalDesign; import de.tobias.playpad.layout.desktop.DesktopMainLayoutConnect; +import de.tobias.playpad.layout.desktop.pad.DesktopPadDragListener; import de.tobias.playpad.midi.Midi; import de.tobias.playpad.midi.MidiListener; import de.tobias.playpad.pad.Pad; @@ -34,7 +35,6 @@ import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.view.main.MainLayoutHandler; import de.tobias.playpad.viewcontroller.dialog.ErrorSummaryDialog; import de.tobias.playpad.viewcontroller.dialog.SaveDialog; -import de.tobias.playpad.viewcontroller.pad.PadDragListener; import de.tobias.utils.ui.BasicControllerSettings; import de.tobias.utils.ui.NotificationHandler; import de.tobias.utils.ui.ViewController; @@ -45,6 +45,7 @@ import de.tobias.utils.util.OS.OSType; import de.tobias.utils.util.Worker; import javafx.application.Platform; import javafx.beans.property.DoubleProperty; +import javafx.event.Event; import javafx.event.EventHandler; import javafx.event.EventType; import javafx.fxml.FXML; @@ -386,7 +387,7 @@ public class MainViewController extends ViewController implements IMainViewContr midiHandler.setProject(project); keyboardHandler.setProject(project); - PadDragListener.setProject(project); + DesktopPadDragListener.setProject(project); ErrorSummaryDialog.getInstance().setProject(openProject); menuToolbarViewController.setOpenProject(openProject); @@ -490,9 +491,8 @@ public class MainViewController extends ViewController implements IMainViewContr if (openProject == null) { return false; } - ProjectSettings projectSettings = openProject.getSettings(); - if (page < 0 || page >= projectSettings.getPageCount()) { + if (page < 0 || page >= openProject.getPages().size()) { return false; } @@ -504,6 +504,7 @@ public class MainViewController extends ViewController implements IMainViewContr if (menuToolbarViewController != null) { menuToolbarViewController.highlightPageButton(page); } + return true; } @@ -644,6 +645,18 @@ public class MainViewController extends ViewController implements IMainViewContr getParent().getScene().addEventHandler(eventType, listener); } + public <T extends Event> void addListenerForPads(EventHandler<? super T> handler, EventType<T> eventType) { + for (IPadView view : padViews) { + view.getRootNode().addEventFilter(eventType, handler); + } + } + + public <T extends Event> void removeListenerForPads(EventHandler<? super T> handler, EventType<T> eventType) { + for (IPadView view : padViews) { + view.getRootNode().removeEventFilter(eventType, handler); + } + } + @Override public void loadUserCss() { Scene scene = getStage().getScene(); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java index 81b5e1992d378e5a8c151cdcf0896b5ee17d0104..8a9fbce01763b5933bb0c16ae160f6e45e039f1d 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/DoubleFeedbackViewController.java @@ -11,7 +11,7 @@ import de.tobias.playpad.action.feedback.FeedbackMessage; import de.tobias.playpad.action.mapper.feedback.DoubleMidiFeedback; import de.tobias.playpad.action.mididevice.Device; import de.tobias.playpad.midi.Midi; -import de.tobias.playpad.view.ColorView; +import de.tobias.playpad.view.ColorPickerView; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -84,7 +84,7 @@ public class DoubleFeedbackViewController extends ContentViewController { color = device.getColor(feedback.getValueForFeedbackMessage(FeedbackMessage.EVENT)); } - ColorView colorView = new ColorView(color, device.getColors(), item -> + ColorPickerView colorView = new ColorPickerView(color, device.getColors(), item -> { colorChooser.hide(); if (item instanceof DisplayableFeedbackColor) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java index 94cfd8b3228a1e354861e70e34948b09e345036b..b29ff5718a8d4d2e294b3f9d272588bbd686bdf4 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/feedback/SingleFeedbackViewController.java @@ -11,7 +11,7 @@ import de.tobias.playpad.action.feedback.FeedbackMessage; import de.tobias.playpad.action.mapper.feedback.SingleMidiFeedback; import de.tobias.playpad.action.mididevice.Device; import de.tobias.playpad.midi.Midi; -import de.tobias.playpad.view.ColorView; +import de.tobias.playpad.view.ColorPickerView; import de.tobias.utils.ui.ContentViewController; import de.tobias.utils.ui.icon.FontAwesomeType; import de.tobias.utils.ui.icon.FontIcon; @@ -65,7 +65,7 @@ public class SingleFeedbackViewController extends ContentViewController { { DisplayableFeedbackColor color = device.getColor(feedback.getValueForFeedbackMessage(FeedbackMessage.STANDARD)); - ColorView colorView = new ColorView(color, device.getColors(), item -> + ColorPickerView colorView = new ColorPickerView(color, device.getColors(), item -> { colorChooser.hide(); if (item instanceof DisplayableFeedbackColor) { diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java index 05315f5d6a113a20bb838b5f8a0048c0a9fa186f..f1fb5142df4839f85760a0c8df77d9e7f1282fc8 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/GeneralTabViewController.java @@ -25,7 +25,6 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController i private Screen mainWindowScreen; private Alertable parentController; // Für Benachrichtungen - @FXML private TextField pageCountTextField; @FXML private TextField columnTextField; @FXML private TextField rowTextField; @@ -38,27 +37,12 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController i if (activePlayer) { rowTextField.setDisable(true); columnTextField.setDisable(true); - pageCountTextField.setDisable(true); } } @Override public void init() { - pageCountTextField.textProperty().addListener((a, b, c) -> - { - if (c.matches(DIGIT_POSITIV) && !c.isEmpty()) { - int number = Integer.valueOf(c); - if (number > ProjectSettings.MAX_PAGES) { - pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Zahl zu groß - } else { - pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, false); // Zahl ok - } - } else { - pageCountTextField.pseudoClassStateChanged(PseudoClasses.ERROR_CLASS, true); // Negativ oder leer - } - }); - columnTextField.textProperty().addListener((a, b, c) -> { if (c.matches(DIGIT_POSITIV) && !c.isEmpty()) { @@ -98,14 +82,12 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController i if (neededHeight <= height && neededWidth <= width) return true; - } catch (NumberFormatException e) { - } + } catch (NumberFormatException e) {} return false; } @Override public void loadSettings(ProjectSettings settings) { - pageCountTextField.setText(String.valueOf(settings.getPageCount())); columnTextField.setText(String.valueOf(settings.getColumns())); rowTextField.setText(String.valueOf(settings.getRows())); @@ -125,9 +107,8 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController i public void saveSettings(ProjectSettings settings) { int columns = Integer.valueOf(columnTextField.getText()); int rows = Integer.valueOf(rowTextField.getText()); - int pageCount = Integer.valueOf(pageCountTextField.getText()); - if (settings.getColumns() != columns || settings.getRows() != rows || settings.getPageCount() != pageCount) + if (settings.getColumns() != columns || settings.getRows() != rows) changeSettings = true; else changeSettings = false; @@ -135,7 +116,6 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController i // Copy Settings settings.setColumns(columns); settings.setRows(rows); - settings.setPageCount(pageCount); } @Override @@ -169,6 +149,7 @@ public class GeneralTabViewController extends ProjectSettingsTabViewController i @Override public Task<Void> getTask(ProjectSettings settings, Project project, IMainViewController controller) { return new Task<Void>() { + @Override protected Void call() throws Exception { updateTitle(name()); diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java index fe181cae7122c8eaf94e8a1ae7e887434cb03851..e5bcc71048895486d6dc71664977e6ca6bd89a3a 100644 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java +++ b/PlayWall/src/de/tobias/playpad/viewcontroller/option/project/ProjectSettingsViewController.java @@ -7,12 +7,12 @@ import org.controlsfx.control.TaskProgressView; import de.tobias.playpad.PlayPadMain; import de.tobias.playpad.Strings; -import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.project.Project; +import de.tobias.playpad.project.ProjectSettings; import de.tobias.playpad.settings.Profile; import de.tobias.playpad.viewcontroller.main.IMainViewController; -import de.tobias.playpad.viewcontroller.option.IProjectSettingsViewController; import de.tobias.playpad.viewcontroller.option.IProjectReloadTask; +import de.tobias.playpad.viewcontroller.option.IProjectSettingsViewController; import de.tobias.playpad.viewcontroller.option.ProjectSettingsTabViewController; import de.tobias.utils.ui.ViewController; import de.tobias.utils.util.Localization; diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadViewController.java deleted file mode 100644 index 47372327084c09e2b17c49f972f6956a1e89f1f6..0000000000000000000000000000000000000000 --- a/PlayWall/src/de/tobias/playpad/viewcontroller/pad/PadViewController.java +++ /dev/null @@ -1,395 +0,0 @@ -package de.tobias.playpad.viewcontroller.pad; - -import java.io.File; -import java.nio.file.Path; - -import de.tobias.playpad.PlayPadPlugin; -import de.tobias.playpad.PseudoClasses; -import de.tobias.playpad.pad.Pad; -import de.tobias.playpad.pad.PadStatus; -import de.tobias.playpad.pad.TimeMode; -import de.tobias.playpad.pad.conntent.PadContent; -import de.tobias.playpad.pad.conntent.PadContentConnect; -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.IPadViewController; -import de.tobias.playpad.registry.NoSuchComponentException; -import de.tobias.playpad.settings.Profile; -import de.tobias.playpad.settings.ProfileSettings; -import de.tobias.playpad.view.PadView; -import de.tobias.playpad.viewcontroller.IPadView; -import de.tobias.playpad.viewcontroller.main.IMainViewController; -import de.tobias.playpad.viewcontroller.option.pad.PadSettingsViewController; -import de.tobias.utils.util.FileUtils; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.stage.Stage; -import javafx.util.Duration; - -public class PadViewController implements EventHandler<ActionEvent>, IPadViewController { - - private static final String DURATION_FORMAT = "%d:%02d"; - private static final String OPEN_FOLDER = "openFolder"; - - private PadView view; - private Pad pad; - - private PadLockedListener padLockedListener; - private PadStatusListener padStatusListener; - private PadContentListener padContentListener; - private PadDurationListener padDurationListener; - private PadPositionListener padPositionListener; - - private PadDragListener padDragListener; - private transient PadSettingsViewController padSettingsViewController; - - public PadViewController() { - view = new PadView(this); - - // TODO Disable this - /*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 IPadView getParent() { - return view; - } - - @Override - public void handle(ActionEvent event) { - if (event.getSource() == view.getPlayButton()) { - onPlay(); - } else if (event.getSource() == view.getPauseButton()) { - onPause(); - } else if (event.getSource() == view.getStopButton()) { - onStop(); - } else if (event.getSource() == view.getNewButton()) { - onNew(event); - } else if (event.getSource() == view.getSettingsButton()) { - 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) { -// ProfileSettings settings = Profile.currentProfile().getProfileSettings(); -// if (pad.getProject() != null) { -// if (settings.isLiveMode() && settings.isLiveModeFile() && pad.getProject().getPlayedPlayers() > 0) { -// PlayPadPlugin.getImplementation().getMainViewController().showLiveInfo(); -// return; -// } -// } -// -// FileChooser chooser = new FileChooser(); -// -// // File Extension -// ExtensionFilter extensionFilter = new ExtensionFilter(Localization.getString(Strings.File_Filter_Media), -// PadContentRegistry.getSupportedFileTypes()); -// chooser.getExtensionFilters().add(extensionFilter); -// -// // Last Folder -// Object openFolder = ApplicationUtils.getApplication().getUserDefaults().getData(OPEN_FOLDER); -// if (openFolder != null) { -// File folder = new File(openFolder.toString()); -// chooser.setInitialDirectory(folder); -// } -// -// File file = chooser.showOpenDialog(((Node) event.getTarget()).getScene().getWindow()); -// if (file != null) { -// Path path = file.toPath(); -// -// try { -// Set<PadContentConnect> connects = PadContentRegistry.getPadContentConnectsForFile(file.toPath()); -// if (!connects.isEmpty()) { -// if (connects.size() > 1) { -// FileDragOptionView hud = new FileDragOptionView(view); -// hud.showDropOptions(connects, connect -> -// { -// if (connect != null) { -// setNewPadContent(file, path, connect); -// hud.hide(); -// } -// }); -// } else { -// PadContentConnect connect = connects.iterator().next(); -// setNewPadContent(file, path, connect); -// } -// } -// } catch (UnkownPadContentException e) { -// e.printStackTrace(); -// } -// -// ApplicationUtils.getApplication().getUserDefaults().setData(OPEN_FOLDER, path.getParent().toString()); -// } - } - - private void setNewPadContent(File file, Path path, PadContentConnect connect) { - PadContent content = pad.getContent(); - if (pad.getContent() == null || !pad.getContent().getType().equals(connect.getType())) { - content = connect.newInstance(pad); - this.pad.setContent(content); - } - - try { - content.handlePath(file.toPath()); - } catch (NoSuchComponentException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - this.pad.setName(FileUtils.getFilenameWithoutExtention(path.getFileName())); - } - - 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 (view != null && pad != null) - view.setTriggerLabelActive(pad.hasTriggerItems()); - }); - } - padSettingsViewController.getStage().show(); - } - } - - @Override - public void unconnectPad() { - view.getIndexLabel().setText(""); - view.clearPreviewContent(); - view.getTimeLabel().setText(""); - - view.setTriggerLabelActive(false); - - view.getLoopLabel().visibleProperty().unbind(); - - if (pad != null) { - 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 - getPadPositionListener().stopWaning(); - view.removeStyleClasses(pad); - } - this.pad = null; - } - - @Override - public Pad getPad() { - return pad; - } - - @Override - public void setPad(Pad pad) { - unconnectPad(); - - this.pad = pad; - - view.setPreviewContent(pad); - view.addStyleClasses(pad); - - connectPad(); - } - - @Override - public void connectPad() { -// pad.setController(this); TODO - - try { - // Settings - view.getIndexLabel().setText(String.valueOf(pad.getIndexReadable())); - view.getLoopLabel().visibleProperty().bind(pad.loopProperty()); - - view.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, view); TODO - } catch (Exception e) { - e.printStackTrace(); - } - } - - public void updateTimeLabel() { - 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); - view.getTimeLabel().setText(time); - view.getPlayBar().setProgress(0); - } else { - // Play/Gesamtzeit anzeigen - TimeMode timeMode = pad.getTimeMode(); - - if (timeMode == TimeMode.REST) { - Duration leftTime = duration.subtract(position); - - view.getTimeLabel().setText("- " + durationToString(leftTime)); - } else if (timeMode == TimeMode.PLAYED) { - view.getTimeLabel().setText(durationToString(position)); - } else if (timeMode == TimeMode.BOTH) { - String time = durationToString(position); - String totalTime = durationToString(duration); - - view.getTimeLabel().setText(time + "/" + totalTime); - } - } - } - return; - } - } - view.getPlayBar().setProgress(0); - view.getTimeLabel().setText(""); - } - - 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; - } - } - - public void updateButtonDisable() { - if (pad == null) { - return; - } - if (pad.getContent() != null) { - if (pad.getStatus() == PadStatus.PLAY) { - view.getPlayButton().setDisable(true); - view.getPauseButton().setDisable(false); - view.getStopButton().setDisable(false); - view.getNewButton().setDisable(true); - view.getSettingsButton().setDisable(false); - } else if (pad.getStatus() == PadStatus.PAUSE) { - view.getPlayButton().setDisable(false); - view.getPauseButton().setDisable(true); - view.getStopButton().setDisable(false); - view.getNewButton().setDisable(true); - view.getSettingsButton().setDisable(false); - } else if (pad.getStatus() == PadStatus.STOP) { - view.getPlayButton().setDisable(false); - view.getPauseButton().setDisable(true); - view.getStopButton().setDisable(true); - view.getNewButton().setDisable(true); - view.getSettingsButton().setDisable(false); - } else if (pad.getStatus() == PadStatus.READY) { - view.getPlayButton().setDisable(false); - view.getPauseButton().setDisable(true); - view.getStopButton().setDisable(true); - view.getNewButton().setDisable(false); - view.getSettingsButton().setDisable(false); - } else if (pad.getStatus() == PadStatus.ERROR) { - view.getPlayButton().setDisable(true); - view.getPauseButton().setDisable(true); - view.getStopButton().setDisable(true); - view.getNewButton().setDisable(false); - view.getSettingsButton().setDisable(false); - } - } else if (pad.getStatus() == PadStatus.EMPTY || pad.getStatus() == PadStatus.ERROR || pad.getContent() == null - || !pad.getContent().isPadLoaded()) { - view.getPlayButton().setDisable(true); - view.getPauseButton().setDisable(true); - view.getStopButton().setDisable(true); - view.getNewButton().setDisable(false); - view.getSettingsButton().setDisable(false); - } - - if (Profile.currentProfile().getProfileSettings().isLocked()) { - view.getNewButton().setDisable(true); - view.getSettingsButton().setDisable(true); - } - } - - @Override - public void showDnDLayout(boolean b) { - view.pseudoClassState(PseudoClasses.DRAG_CLASS, b); - } - - // getter for listener - public PadDurationListener getPadDurationListener() { - return padDurationListener; - } - - public PadStatusListener getPadStatusListener() { - return padStatusListener; - } - - public IPadPositionListener getPadPositionListener() { - return padPositionListener; - } - - public PadDragListener getPadDragListener() { - return padDragListener; - } -} diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjustable.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjustable.java index 01df8244bc74cce60d4a58507f1ba2f49bf119da..5e03b647873e27cf7e417b750eaedba1b6ee6e40 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjustable.java +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjustable.java @@ -2,10 +2,27 @@ package de.tobias.playpad.action.feedback; import de.tobias.playpad.pad.Pad; +/** + * Eine Action implementiert dieses Interface, falls die Feedbackfarbe automatisch an die Farbe der Kachel angepasst werden soll. + * + * @author tobias + * @since 5.0.0 + * + */ public interface ColorAdjustable { + /** + * Ist dieses Feature ative. + * + * @return <code>true</code> Active + */ public boolean isAutoFeedbackColors(); - + + /** + * Kachel, die mit dieser Action verkünpft ist. + * + * @return Pad + */ public Pad getPad(); - + } diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java index 301578f1bec761e09dcac3f463303e70a776a481..44129b469e5e5bde06b1ff28a40b0ae3582c483d 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAdjuster.java @@ -59,7 +59,7 @@ public class ColorAdjuster { Color layoutEvColor = null; if (pad.getPadSettings().isCustomLayout()) { - CartDesign layout = pad.getPadSettings().getLayout(); + CartDesign layout = pad.getPadSettings().getDesign(); if (layout instanceof DesignColorAssociator) { DesignColorAssociator associator = (DesignColorAssociator) layout; layoutStdColor = associator.getAssociatedStandardColor(); @@ -75,13 +75,13 @@ public class ColorAdjuster { } if (layoutStdColor != null) { - DisplayableFeedbackColor associator = searchColor(colorAssociator, FeedbackMessage.STANDARD, layoutStdColor); - colorAssociator.setColor(FeedbackMessage.STANDARD, associator.mapperFeedbackValue()); + DisplayableFeedbackColor matchedColor = searchColor(colorAssociator, FeedbackMessage.STANDARD, layoutStdColor); + colorAssociator.setColor(FeedbackMessage.STANDARD, matchedColor); } if (layoutEvColor != null) { - DisplayableFeedbackColor associator = searchColor(colorAssociator, FeedbackMessage.EVENT, layoutEvColor); - colorAssociator.setColor(FeedbackMessage.EVENT, associator.mapperFeedbackValue()); + DisplayableFeedbackColor matchedColor = searchColor(colorAssociator, FeedbackMessage.EVENT, layoutEvColor); + colorAssociator.setColor(FeedbackMessage.EVENT, matchedColor); } } } diff --git a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAssociator.java b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAssociator.java index abdda9d2d12de6665cf8539801d2c57966df1b9f..339f72a96b19971bb2a388c3afc1b018ee13a42b 100644 --- a/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAssociator.java +++ b/PlayWallCore/src/de/tobias/playpad/action/feedback/ColorAssociator.java @@ -2,15 +2,51 @@ package de.tobias.playpad.action.feedback; import javafx.scene.paint.Color; +/** + * Dieses Interface wird in einem Mapper implementiert. Dabei handelt er die Anfragen für das Mapping von Farben. + * + * @author tobias + * @since 5.0.0 + */ public interface ColorAssociator { + /** + * Gibt die Gerätefarben zurück. Dabei enthalten diese ein Int Value und ein Paint. + * + * @return Liste an Farben + */ public DisplayableFeedbackColor[] getColors(); + /** + * Standardfarbe, falls nichts passendes gefunden wurde. + * + * @return Standardfarbe + */ public DisplayableFeedbackColor getDefaultStandardColor(); + /** + * Eventfarbe, falls nichts passendes gefunden wurde. + * + * @return Eventfarbe + */ public DisplayableFeedbackColor getDefaultEventColor(); - public void setColor(FeedbackMessage feedbackMessage, int value); + /** + * Setzt die Feedback Farbe für die Instanz des Mappers. + * + * @param feedbackMessage + * Art der Feedbacknachricht + * @param color + * Matched Color + */ + public void setColor(FeedbackMessage feedbackMessage, DisplayableFeedbackColor color); + /** + * Sucht zu einer {@link Color} die passende FeedbackColor, falls vorhanden. + * + * @param color + * Kachel Farbe + * @return Feedback Farbe oder null. + */ public DisplayableFeedbackColor map(Color color); } diff --git a/PlayWallCore/src/de/tobias/playpad/design/ColorModeHandler.java b/PlayWallCore/src/de/tobias/playpad/design/ColorModeHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..b8ddf1a2874624b57c2f166da5e7baaad0fdae97 --- /dev/null +++ b/PlayWallCore/src/de/tobias/playpad/design/ColorModeHandler.java @@ -0,0 +1,19 @@ +package de.tobias.playpad.design; + +import java.util.function.Consumer; + +import de.tobias.playpad.DisplayableColor; +import javafx.scene.Node; + +/** + * Wenn vom Design unterstützt, wird hier die GUI für Farbeinstellungen erstellt. + * + * @author tobias + * + */ +public interface ColorModeHandler { + + public Node getColorInterface(Consumer<DisplayableColor> onSelection); + + public void setColor(CartDesign design, DisplayableColor color); +} diff --git a/PlayWallCore/src/de/tobias/playpad/design/DesignColorAssociator.java b/PlayWallCore/src/de/tobias/playpad/design/DesignColorAssociator.java index 1fc348f64781d214661cfb62e72cef4f61563dec..958a5e3360d49b7339f8d0da70298f6d0aebd42e 100644 --- a/PlayWallCore/src/de/tobias/playpad/design/DesignColorAssociator.java +++ b/PlayWallCore/src/de/tobias/playpad/design/DesignColorAssociator.java @@ -2,10 +2,27 @@ package de.tobias.playpad.design; import javafx.scene.paint.Color; +/** + * Methoden für die Verwaltung der Farben, die an einer Kachel eingestellt sind. Das ist wichtig, falls Kachel eine andere Farbverwaltung + * verwendet (beispiel Lineare Gradient). + * + * @author tobias + * @since 5.0.0 + */ public interface DesignColorAssociator { + /** + * Gibt die Standardfarbe (Kacheln ohne Aktion) zurück. + * + * @return Farbe der Kachel + */ public Color getAssociatedStandardColor(); + /** + * Gibt die Eventfarbe (Kacheln mit Aktion) zurück. + * + * @return Farbe der Kachel + */ public Color getAssociatedEventColor(); } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/PadSettings.java b/PlayWallCore/src/de/tobias/playpad/pad/PadSettings.java index 7c46e1ac6437b3ce2eacdf37ca5da79b62969767..f0fd7b3d1d40c0d058b962947798fff75ba29750 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/PadSettings.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/PadSettings.java @@ -152,7 +152,7 @@ public class PadSettings { return customLayoutProperty; } - public CartDesign getLayout() { + public CartDesign getDesign() { return getLayout(Profile.currentProfile().getProfileSettings().getLayoutType()); } diff --git a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java index 8cda8936e8c843a492f971e3d6509858bd75818b..b9c0cfcbd07b75dd299af1456a3e5880b4f6d79e 100644 --- a/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java +++ b/PlayWallCore/src/de/tobias/playpad/pad/view/IPadView.java @@ -39,7 +39,7 @@ public interface IPadView { public IPadViewController getViewController(); /** - * Gibt das oberste GUI Element zurück, welche im MainView verwendet wird. + * Gibt das oberste GUI Element des Pads zurück, welche im MainView verwendet wird. * * @return root node */ diff --git a/PlayWallCore/src/de/tobias/playpad/project/Project.java b/PlayWallCore/src/de/tobias/playpad/project/Project.java index 086282dd501c830e54d23fef0e24a1be808dc523..cdc25bd2465c56263158b87fee130043591782ee 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/Project.java +++ b/PlayWallCore/src/de/tobias/playpad/project/Project.java @@ -5,7 +5,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Collection; -import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.UUID; @@ -47,16 +46,17 @@ public class Project { * Pattern für den Namen des Projekts */ public static final String PROJECT_NAME_PATTERN = "[\\p{L}0-9]{1}[\\p{L}\\s-_0-9]{0,}"; + /** * Dateiendung für eine projekt Datei */ public static final String FILE_EXTENSION = ".xml"; - private final HashMap<Integer, Page> pages; + private final List<Page> pages; private final ProjectReference projectReference; private ProjectSettings settings; - + /** * Liste mit den aktuellen Laufzeitfehlern. */ @@ -65,9 +65,9 @@ public class Project { public Project(ProjectReference ref) { this.projectReference = ref; - this.pages = new HashMap<>(); + this.pages = new ArrayList<>(); this.settings = new ProjectSettings(); - + this.exceptions = FXCollections.observableArrayList(); this.activePlayers = new SimpleIntegerProperty(); } @@ -98,7 +98,7 @@ public class Project { } public Pad getPad(UUID uuid) { - for (Page page : pages.values()) { + for (Page page : pages) { for (Pad pad : page.getPads()) { if (pad.getUuid().equals(uuid)) { return pad; @@ -119,25 +119,29 @@ public class Project { public Collection<Pad> getPads() { List<Pad> pads = new ArrayList<>(); - pages.values().stream().map(page -> page.getPads()).forEach(pads::addAll); + pages.stream().map(page -> page.getPads()).forEach(pads::addAll); return pads; } // Pages public Page getPage(int index) { - if (!pages.containsKey(index) && index < settings.getPageCount()) { - pages.put(index, new Page(index, this)); + if (index >= pages.size() && index < ProjectSettings.MAX_PAGES) { + pages.add(new Page(index, this)); } return pages.get(index); } public Collection<Page> getPages() { - return pages.values(); + // Create new page if all is empty (automaticlly) + if (pages.isEmpty()) { + pages.add(new Page(0, this)); + } + return pages; } public void setPage(int index, Page page) { - pages.put(index, page); + pages.set(index, page); page.setId(index); } @@ -170,7 +174,7 @@ public class Project { XMLHandler<Page> handler = new XMLHandler<>(rootElement); List<Page> pages = handler.loadElements(PAGE_ELEMENT, new PageSerializer(project)); for (Page page : pages) { - project.pages.put(page.getId(), page); + project.pages.add(page); } // Lädt die Einstellungen @@ -200,7 +204,7 @@ public class Project { // Speichern der Pads XMLHandler<Page> handler = new XMLHandler<>(rootElement); - handler.saveElements(PAGE_ELEMENT, pages.values(), new PageSerializer(this)); + handler.saveElements(PAGE_ELEMENT, pages, new PageSerializer(this)); // Speichern der Settings Element settingsElement = rootElement.addElement(SETTINGS_ELEMENT); @@ -269,7 +273,7 @@ public class Project { public ObservableList<PadException> getExceptions() { return exceptions; } - + // Utils public void loadPadsContent() { getPads().forEach(pad -> @@ -295,4 +299,21 @@ public class Project { pad.getContent().unloadMedia(); }); } + + public void removePage(Page page) { + pages.remove(page.getId()); + // Neue Interne Indies für die Pages + for (int i = page.getId(); i < pages.size(); i++) { + Page tempPage = pages.get(i); + tempPage.setId(i); + } + } + + public void addPage() { + if (pages.size() == ProjectSettings.MAX_PAGES) { + return; + } + int index = pages.size(); + pages.add(new Page(index, this)); + } } diff --git a/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java b/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java index 31e1cc9e2a50f208f91ee9065d44a8aa7c44b371..487e1d2603f12ad3e1eeed2a5266aab757623c38 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java +++ b/PlayWallCore/src/de/tobias/playpad/project/ProjectSettings.java @@ -13,17 +13,12 @@ public class ProjectSettings { public static final int MAX_COLUMNS = 10; public static final int MAX_ROWS = 10; - @Storable private int pageCount = 2; @Storable private int columns = 6; @Storable private int rows = 5; private boolean useMediaPath = false; private Path mediaPath = null; - public int getPageCount() { - return pageCount; - } - /** * Returns the value of colums (Number of cells form left to right) * @@ -50,12 +45,6 @@ public class ProjectSettings { return useMediaPath; } - public void setPageCount(int pageCount) { - if (pageCount > MAX_PAGES) - pageCount = MAX_PAGES; - this.pageCount = pageCount; - } - public void setColumns(int columns) { if (columns > MAX_COLUMNS) columns = MAX_COLUMNS; @@ -78,15 +67,12 @@ public class ProjectSettings { private static final String ROWS_ELEMENT = "Rows"; private static final String COLUMNS_ELEMENT = "Columns"; - private static final String PAGE_COUNT_ELEMENT = "PageCount"; private static final String MEDIA_PATH_ELEMENT = "MediaPath"; private static final String MEDIA_PATH_ACTIVE_ATTR = "active"; public static ProjectSettings load(Element element) { ProjectSettings settings = new ProjectSettings(); - if (element.element(PAGE_COUNT_ELEMENT) != null) - settings.setPageCount(Integer.valueOf(element.element(PAGE_COUNT_ELEMENT).getStringValue())); if (element.element(COLUMNS_ELEMENT) != null) settings.setColumns(Integer.valueOf(element.element(COLUMNS_ELEMENT).getStringValue())); if (element.element(ROWS_ELEMENT) != null) @@ -102,7 +88,6 @@ public class ProjectSettings { } public void save(Element element) { - element.addElement(PAGE_COUNT_ELEMENT).addText(String.valueOf(pageCount)); element.addElement(COLUMNS_ELEMENT).addText(String.valueOf(columns)); element.addElement(ROWS_ELEMENT).addText(String.valueOf(rows)); diff --git a/PlayWallCore/src/de/tobias/playpad/project/page/Page.java b/PlayWallCore/src/de/tobias/playpad/project/page/Page.java index c76eac00f33a56d775cd744909c641109b1e5be9..749cf16329c093f4dee30f44ea164eba86d7cb99 100644 --- a/PlayWallCore/src/de/tobias/playpad/project/page/Page.java +++ b/PlayWallCore/src/de/tobias/playpad/project/page/Page.java @@ -76,6 +76,7 @@ public class Page { public void setPad(int id, Pad pad) { pads.put(id, pad); + pad.setPage(this.id); pad.setIndex(id); } @@ -86,4 +87,9 @@ public class Page { public void removePade(int id) { pads.remove(id); } + + @Override + public String toString() { + return "Page [id=" + id + "]"; + } } diff --git a/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java b/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java index 24bb8f34311c9d92f944e7a4c089f676be2e62bd..511f6ca92ea4191ecde3b168f6d0bd23ab78211d 100644 --- a/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java +++ b/PlayWallCore/src/de/tobias/playpad/settings/ProfileReference.java @@ -65,6 +65,7 @@ public class ProfileReference implements Displayable { public ProfileReference(UUID uuid, String name) { this.uuid = uuid; this.name = name; + requestedModules = new HashSet<>(); updateDisplayProperty(); } diff --git a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java index 29941d200665aeea35c4eee8d0b4ad4b13c4dda4..5451c138c78e59a849766ce2ba5d41d700531c68 100644 --- a/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java +++ b/PlayWallCore/src/de/tobias/playpad/viewcontroller/main/IMainViewController.java @@ -9,6 +9,7 @@ import de.tobias.playpad.view.main.MainLayoutConnect; import de.tobias.playpad.view.main.MainLayoutHandler; import de.tobias.utils.ui.NotificationHandler; import de.tobias.utils.ui.scene.NotificationPane; +import javafx.event.Event; import javafx.event.EventHandler; import javafx.event.EventType; import javafx.scene.Parent; @@ -149,4 +150,8 @@ public interface IMainViewController extends NotificationHandler { * @return NotificationPane */ public NotificationPane getNotificationPane(); + + public <T extends Event> void addListenerForPads(EventHandler<? super T> handler, EventType<T> eventType); + + public <T extends Event> void removeListenerForPads(EventHandler<? super T> handler, EventType<T> eventType); } diff --git a/PlayWallNative/bin/de/tobias/playpad/NativeAudio$NativeAudioDelegate.class b/PlayWallNative/bin/de/tobias/playpad/NativeAudio$NativeAudioDelegate.class new file mode 100644 index 0000000000000000000000000000000000000000..94add9016c45847affc7a8504c1f1c7098ba07d7 Binary files /dev/null and b/PlayWallNative/bin/de/tobias/playpad/NativeAudio$NativeAudioDelegate.class differ diff --git a/PlayWallNative/bin/de/tobias/playpad/NativeAudio.class b/PlayWallNative/bin/de/tobias/playpad/NativeAudio.class new file mode 100644 index 0000000000000000000000000000000000000000..c5f0439f799d55d65ce9dee93b08243b9b005557 Binary files /dev/null and b/PlayWallNative/bin/de/tobias/playpad/NativeAudio.class differ diff --git a/PlayWallNative/bin/de/tobias/playpad/NativeAudioMacHandler.class b/PlayWallNative/bin/de/tobias/playpad/NativeAudioMacHandler.class new file mode 100644 index 0000000000000000000000000000000000000000..e65fdb615d0905222d4e5ac3e7e17bc396deaeb6 Binary files /dev/null and b/PlayWallNative/bin/de/tobias/playpad/NativeAudioMacHandler.class differ diff --git a/PlayWallNative/bin/de/tobias/playpad/NativeAudioMacHandlerConnect.class b/PlayWallNative/bin/de/tobias/playpad/NativeAudioMacHandlerConnect.class new file mode 100644 index 0000000000000000000000000000000000000000..bd8edabc909d978389efd81ed7a6e477b245fdcd Binary files /dev/null and b/PlayWallNative/bin/de/tobias/playpad/NativeAudioMacHandlerConnect.class differ diff --git a/PlayWallNative/bin/de/tobias/playpad/NativeAudioTest.class b/PlayWallNative/bin/de/tobias/playpad/NativeAudioTest.class new file mode 100644 index 0000000000000000000000000000000000000000..3228cfd18da92c2aab164674a4ea0aaf208e1cf8 Binary files /dev/null and b/PlayWallNative/bin/de/tobias/playpad/NativeAudioTest.class differ diff --git a/PlayWallNative/bin/de_tobias_playpad_NativeAudio.h b/PlayWallNative/bin/de_tobias_playpad_NativeAudio.h new file mode 100644 index 0000000000000000000000000000000000000000..4bd710308b879f953bd90b3e96a9aa1ec1e2ef92 --- /dev/null +++ b/PlayWallNative/bin/de_tobias_playpad_NativeAudio.h @@ -0,0 +1,85 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include <jni.h> +/* Header for class de_tobias_playpad_NativeAudio */ + +#ifndef _Included_de_tobias_playpad_NativeAudio +#define _Included_de_tobias_playpad_NativeAudio +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: de_tobias_playpad_NativeAudio + * Method: play + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_play + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: pause + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_pause + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: stop + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_stop + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: getVolume + * Signature: (I)D + */ +JNIEXPORT jdouble JNICALL Java_de_tobias_playpad_NativeAudio_getVolume + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: setVolume + * Signature: (ID)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_setVolume + (JNIEnv *, jclass, jint, jdouble); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: load + * Signature: (ILjava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL Java_de_tobias_playpad_NativeAudio_load + (JNIEnv *, jclass, jint, jstring); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: dispose + * Signature: (I)V + */ +JNIEXPORT void JNICALL Java_de_tobias_playpad_NativeAudio_dispose + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: getDuration + * Signature: (I)D + */ +JNIEXPORT jdouble JNICALL Java_de_tobias_playpad_NativeAudio_getDuration + (JNIEnv *, jclass, jint); + +/* + * Class: de_tobias_playpad_NativeAudio + * Method: getPosition + * Signature: (I)D + */ +JNIEXPORT jdouble JNICALL Java_de_tobias_playpad_NativeAudio_getPosition + (JNIEnv *, jclass, jint); + +#ifdef __cplusplus +} +#endif +#endif