From a6b30a407163615cb86c07c00d09e00734f781b8 Mon Sep 17 00:00:00 2001
From: tobias <tobias.ullerich@icloud.com>
Date: Sat, 25 Jun 2016 20:41:14 +0200
Subject: [PATCH] Removed anomation toggle in modern cart layout

---
 .../view/option/layout/modernLayoutCart.fxml  |  6 -----
 .../layout/classic/ClassicCartLayout.java     |  2 +-
 .../layout/modern/ModernLayoutCart.java       | 27 ++-----------------
 .../pad/listener/PadPositionListener.java     |  2 +-
 .../ModernLayoutCartViewController.java       |  6 -----
 .../de/tobias/playpad/layout/CartLayout.java  |  4 +--
 6 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/PlayWall/assets/de/tobias/playpad/assets/view/option/layout/modernLayoutCart.fxml b/PlayWall/assets/de/tobias/playpad/assets/view/option/layout/modernLayoutCart.fxml
index 47f1ad84..0307ce2b 100644
--- a/PlayWall/assets/de/tobias/playpad/assets/view/option/layout/modernLayoutCart.fxml
+++ b/PlayWall/assets/de/tobias/playpad/assets/view/option/layout/modernLayoutCart.fxml
@@ -30,12 +30,6 @@
                   <Button fx:id="playColorButton" focusTraversable="false" mnemonicParsing="false" onAction="#playColorButtonHandler" prefWidth="150.0" />
                </children>
             </VBox>
-            <VBox maxWidth="1.7976931348623157E308" prefWidth="150.0" spacing="14.0" HBox.hgrow="ALWAYS">
-               <children>
-                  <Label alignment="BOTTOM_LEFT" layoutX="243.0" layoutY="8.0" prefHeight="60.0" prefWidth="150.0" text="%layout.label.animation" wrapText="true" VBox.vgrow="ALWAYS" />
-                  <CheckBox fx:id="warnAnimationCheckBox" mnemonicParsing="false" text="%layout.label.warnAnimation" />
-               </children>
-            </VBox>
          </children>
       </HBox>
       <Button fx:id="resetButton" mnemonicParsing="false" onAction="#resetButtonHandler" text="%layout.button.reset">
diff --git a/PlayWall/src/de/tobias/playpad/layout/classic/ClassicCartLayout.java b/PlayWall/src/de/tobias/playpad/layout/classic/ClassicCartLayout.java
index 7bd47b40..013765c7 100644
--- a/PlayWall/src/de/tobias/playpad/layout/classic/ClassicCartLayout.java
+++ b/PlayWall/src/de/tobias/playpad/layout/classic/ClassicCartLayout.java
@@ -210,7 +210,7 @@ public class ClassicCartLayout extends Layout implements CartLayout {
 	}
 
 	@Override
-	public void handleWarning(IPadViewController controller, Warning warning) {
+	public void handleWarning(IPadViewController controller, Warning warning, GlobalLayout layout) {
 		final IPadView view = controller.getParent();
 
 		try {
diff --git a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutCart.java b/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutCart.java
index cbc99d65..fef4f679 100644
--- a/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutCart.java
+++ b/PlayWall/src/de/tobias/playpad/layout/modern/ModernLayoutCart.java
@@ -25,8 +25,6 @@ public class ModernLayoutCart extends Layout implements CartLayout, LayoutColorA
 	private ModernColor backgroundColor = ModernColor.GRAY1;
 	private ModernColor playColor = ModernColor.RED3;
 
-	private boolean isWarnAnimation = true;
-
 	public ModernColor getBackgroundColor() {
 		return backgroundColor;
 	}
@@ -43,19 +41,9 @@ public class ModernLayoutCart extends Layout implements CartLayout, LayoutColorA
 		this.playColor = playColor;
 	}
 
-	public boolean isWarnAnimation() {
-		return isWarnAnimation;
-	}
-
-	public void setWarnAnimation(boolean isWarnAnimation) {
-		this.isWarnAnimation = isWarnAnimation;
-	}
-
 	public void reset() {
 		backgroundColor = ModernColor.GRAY1;
 		playColor = ModernColor.RED1;
-
-		isWarnAnimation = true;
 	}
 
 	@Override
@@ -77,28 +65,18 @@ public class ModernLayoutCart extends Layout implements CartLayout, LayoutColorA
 				e.printStackTrace();
 			}
 		}
-
-		Element animationElement = rootElement.element("Animation");
-		if (animationElement != null) {
-			Element warnAnimationElement = animationElement.element("Warn");
-			if (warnAnimationElement != null) {
-				isWarnAnimation = Boolean.valueOf(warnAnimationElement.getStringValue());
-			}
-		}
 	}
 
 	@Override
 	public void save(Element rootElement) {
 		rootElement.addElement("BackgroundColor").addText(backgroundColor.name());
 		rootElement.addElement("PlayColor").addText(playColor.name());
-		Element animationElement = rootElement.addElement("Animation");
-		animationElement.addElement("Warn").addText(String.valueOf(isWarnAnimation));
 	}
 
 	// Warn Handler -> Animation oder Blinken
 	@Override
-	public void handleWarning(IPadViewController controller, Warning warning) {
-		if (isWarnAnimation) {
+	public void handleWarning(IPadViewController controller, Warning warning, GlobalLayout layout) {
+		if (layout instanceof ModernLayoutGlobal && ((ModernLayoutGlobal) layout).isWarnAnimation()) {
 			warnAnimation(controller, warning);
 		} else {
 			ModernLayoutAnimator.warnFlash(controller);
@@ -204,7 +182,6 @@ public class ModernLayoutCart extends Layout implements CartLayout, LayoutColorA
 			ModernLayoutGlobal modernLayoutGlobal = (ModernLayoutGlobal) globalLayout;
 			backgroundColor = modernLayoutGlobal.getBackgroundColor();
 			playColor = modernLayoutGlobal.getPlayColor();
-			isWarnAnimation = modernLayoutGlobal.isWarnAnimation();
 		}
 	}
 }
diff --git a/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java b/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java
index 9f582ea5..b9f60d71 100644
--- a/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java
+++ b/PlayWall/src/de/tobias/playpad/pad/listener/PadPositionListener.java
@@ -88,7 +88,7 @@ public class PadPositionListener implements ChangeListener<Duration>, Runnable {
 		Warning warning = pad.getWarning();
 
 		if (pad.isCustomLayout()) {
-			pad.getLayout().handleWarning(controller, warning);
+			pad.getLayout().handleWarning(controller, warning, Profile.currentProfile().currentLayout());
 		} else {
 			Profile.currentProfile().currentLayout().handleWarning(controller, warning);
 		}
diff --git a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutCartViewController.java b/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutCartViewController.java
index dd3e7bd2..f5c5214f 100644
--- a/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutCartViewController.java
+++ b/PlayWall/src/de/tobias/playpad/viewcontroller/layout/ModernLayoutCartViewController.java
@@ -42,16 +42,10 @@ public class ModernLayoutCartViewController extends CartLayoutViewController {
 	private void setLayout() {
 		backgroundColorButton.setStyle(getLinearGradientCss(cartLayout.getBackgroundColor()));
 		playColorButton.setStyle(getLinearGradientCss(cartLayout.getPlayColor()));
-
-		warnAnimationCheckBox.setSelected(cartLayout.isWarnAnimation());
 	}
 
 	@Override
 	public void init() {
-		warnAnimationCheckBox.selectedProperty().addListener((a, b, c) ->
-		{
-			cartLayout.setWarnAnimation(c);
-		});
 	}
 
 	@FXML
diff --git a/PlayWallCore/src/de/tobias/playpad/layout/CartLayout.java b/PlayWallCore/src/de/tobias/playpad/layout/CartLayout.java
index 851d42c6..46dec367 100644
--- a/PlayWallCore/src/de/tobias/playpad/layout/CartLayout.java
+++ b/PlayWallCore/src/de/tobias/playpad/layout/CartLayout.java
@@ -25,11 +25,11 @@ public interface CartLayout {
 	 * @param controller
 	 * @param warning
 	 */
-	public abstract void handleWarning(IPadViewController controller, Warning warning);
+	public abstract void handleWarning(IPadViewController controller, Warning warning, GlobalLayout animate);
 
 	public default void stopWarning(IPadViewController controller) {}
 
 	public void reset();
-	
+
 	public void copyGlobalLayout(GlobalLayout globalLayout);
 }
-- 
GitLab