Skip to content
Snippets Groups Projects
Commit bef250f6 authored by Tobias Ullerich's avatar Tobias Ullerich
Browse files

Add listener based style classes to touch pads

parent 7cf6e3f1
Branches
Tags
No related merge requests found
...@@ -18,8 +18,10 @@ import de.tobias.playpad.pad.viewcontroller.IPadViewController; ...@@ -18,8 +18,10 @@ import de.tobias.playpad.pad.viewcontroller.IPadViewController;
import de.tobias.playpad.profile.Profile; import de.tobias.playpad.profile.Profile;
import de.tobias.playpad.project.page.PadIndex; import de.tobias.playpad.project.page.PadIndex;
import de.tobias.playpad.registry.NoSuchComponentException; import de.tobias.playpad.registry.NoSuchComponentException;
import de.tobias.playpad.util.NodeWalker;
import de.tobias.playpad.view.EmptyPadView; import de.tobias.playpad.view.EmptyPadView;
import de.tobias.playpad.view.PseudoClasses; import de.tobias.playpad.view.PseudoClasses;
import de.tobias.playpad.view.pad.*;
import javafx.beans.property.Property; import javafx.beans.property.Property;
import javafx.css.PseudoClass; import javafx.css.PseudoClass;
import javafx.geometry.Pos; import javafx.geometry.Pos;
...@@ -29,6 +31,8 @@ import javafx.scene.control.ProgressBar; ...@@ -29,6 +31,8 @@ import javafx.scene.control.ProgressBar;
import javafx.scene.layout.*; import javafx.scene.layout.*;
import javafx.scene.paint.Color; import javafx.scene.paint.Color;
import static de.tobias.playpad.view.pad.PadStyleClasses.*;
public class TouchPadView implements IPadView { public class TouchPadView implements IPadView {
private Label indexLabel; private Label indexLabel;
...@@ -50,10 +54,9 @@ public class TouchPadView implements IPadView { ...@@ -50,10 +54,9 @@ public class TouchPadView implements IPadView {
private VBox root; private VBox root;
private BusyView busyView; private BusyView busyView;
private VBox cueInContainer;
private Label cueInLayer; private Label cueInLayer;
private transient TouchPadViewController controller; // Reference to its controller private final transient TouchPadViewController controller; // Reference to its controller
public TouchPadView() { public TouchPadView() {
controller = new TouchPadViewController(this); controller = new TouchPadViewController(this);
...@@ -61,31 +64,24 @@ public class TouchPadView implements IPadView { ...@@ -61,31 +64,24 @@ public class TouchPadView implements IPadView {
} }
private void setupView() { private void setupView() {
superRoot = new StackPane(); superRoot = new PadStackPane(STYLE_CLASS_PAD, STYLE_CLASS_PAD_INDEX);
root = new VBox(); root = new PadVBox(STYLE_CLASS_PAD_BUTTON_ROOT);
busyView = new BusyView(superRoot); busyView = new BusyView(superRoot);
cueInLayer = new Label(); cueInLayer = PadLabel.empty(STYLE_CLASS_PAD_CUE_IN, STYLE_CLASS_PAD_CUE_IN_INDEX);
cueInLayer.prefHeightProperty().bind(root.heightProperty()); cueInLayer.prefHeightProperty().bind(root.heightProperty());
cueInContainer = new VBox(cueInLayer); VBox cueInContainer = new VBox(cueInLayer);
indexLabel = new Label();
loopLabel = new Label(); // Active über Visible
loopLabel.setGraphic(new FontIcon(FontAwesomeType.REPEAT));
triggerLabel = new Label(); indexLabel = PadLabel.empty(STYLE_CLASS_PAD_INFO, STYLE_CLASS_PAD_INFO_INDEX);
triggerLabel.setGraphic(new FontIcon(FontAwesomeType.EXTERNAL_LINK)); timeLabel = PadLabel.empty(STYLE_CLASS_PAD_INFO, STYLE_CLASS_PAD_INFO_INDEX);
errorLabel = new Label(); loopLabel = new PadLabel(new FontIcon(FontAwesomeType.REPEAT));
errorLabel.setGraphic(new FontIcon(FontAwesomeType.WARNING)); triggerLabel = new PadLabel(new FontIcon(FontAwesomeType.EXTERNAL_LINK));
errorLabel = new PadLabel(new FontIcon(FontAwesomeType.WARNING));
timeLabel = new Label(); infoBox = new PadHBox(5);
infoBox = new HBox(); // childern in addDefaultButton() preview = PadHBox.deepStyled(STYLE_CLASS_PAD_TITLE, STYLE_CLASS_PAD_TITLE_INDEX);
infoBox.setSpacing(5);
preview = new HBox();
HBox.setHgrow(preview, Priority.ALWAYS); HBox.setHgrow(preview, Priority.ALWAYS);
VBox.setVgrow(preview, Priority.ALWAYS); VBox.setVgrow(preview, Priority.ALWAYS);
...@@ -93,16 +89,15 @@ public class TouchPadView implements IPadView { ...@@ -93,16 +89,15 @@ public class TouchPadView implements IPadView {
timeLabel.setMaxWidth(Double.MAX_VALUE); timeLabel.setMaxWidth(Double.MAX_VALUE);
timeLabel.setAlignment(Pos.CENTER_RIGHT); timeLabel.setAlignment(Pos.CENTER_RIGHT);
playBar = new ProgressBar(0); playBar = new PadProgressBar(0, STYLE_CLASS_PAD_PLAYBAR, STYLE_CLASS_PAD_PLAYBAR_INDEX);
playBar.prefWidthProperty().bind(root.widthProperty()); playBar.prefWidthProperty().bind(root.widthProperty());
// Not Found Label // Not Found Label
notFoundLabel = new FontIcon(FontAwesomeType.EXCLAMATION_TRIANGLE); notFoundLabel = new FontIcon(FontAwesomeType.EXCLAMATION_TRIANGLE);
notFoundLabel.getStyleClass().add("pad-notfound"); notFoundLabel.getStyleClass().clear();
notFoundLabel.setOpacity(0.5); notFoundLabel.setOpacity(0.5);
notFoundLabel.setSize(50); notFoundLabel.setSize(50);
notFoundLabel.setMouseTransparent(true); notFoundLabel.setMouseTransparent(true);
notFoundLabel.setVisible(false); notFoundLabel.setVisible(false);
root.getChildren().addAll(infoBox, preview, playBar); root.getChildren().addAll(infoBox, preview, playBar);
...@@ -135,8 +130,6 @@ public class TouchPadView implements IPadView { ...@@ -135,8 +130,6 @@ public class TouchPadView implements IPadView {
previewContent = connect.getPadContentPreview(pad, preview); previewContent = connect.getPadContentPreview(pad, preview);
Node node = previewContent.getNode(); Node node = previewContent.getNode();
node.getStyleClass().addAll("pad-title", "pad" + pad.getPadIndex() + "-title");
// Copy Pseudoclasses // Copy Pseudoclasses
for (PseudoClass pseudoClass : superRoot.getPseudoClassStates()) { for (PseudoClass pseudoClass : superRoot.getPseudoClassStates()) {
node.pseudoClassStateChanged(pseudoClass, true); node.pseudoClassStateChanged(pseudoClass, true);
...@@ -150,11 +143,6 @@ public class TouchPadView implements IPadView { ...@@ -150,11 +143,6 @@ public class TouchPadView implements IPadView {
} }
} }
EmptyPadView view = new EmptyPadView(preview); EmptyPadView view = new EmptyPadView(preview);
if (pad != null) {
view.getStyleClass().addAll("pad-title", "pad" + pad.getPadIndex() + "-title");
} else {
view.getStyleClass().addAll("pad-title");
}
preview.getChildren().setAll(view); preview.getChildren().setAll(view);
} }
...@@ -188,19 +176,8 @@ public class TouchPadView implements IPadView { ...@@ -188,19 +176,8 @@ public class TouchPadView implements IPadView {
@Override @Override
public void pseudoClassState(PseudoClass pseudoClass, boolean active) { public void pseudoClassState(PseudoClass pseudoClass, boolean active) {
superRoot.pseudoClassStateChanged(pseudoClass, active); NodeWalker.getAllNodes(getRootNode())
cueInLayer.pseudoClassStateChanged(pseudoClass, active); .forEach(node -> node.pseudoClassStateChanged(pseudoClass, active));
indexLabel.pseudoClassStateChanged(pseudoClass, active);
timeLabel.pseudoClassStateChanged(pseudoClass, active);
loopLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active);
triggerLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active);
errorLabel.getGraphic().pseudoClassStateChanged(pseudoClass, active);
if (preview != null) {
preview.getChildren().forEach(i -> i.pseudoClassStateChanged(pseudoClass, active));
}
playBar.pseudoClassStateChanged(pseudoClass, active);
} }
@Override @Override
...@@ -247,38 +224,18 @@ public class TouchPadView implements IPadView { ...@@ -247,38 +224,18 @@ public class TouchPadView implements IPadView {
@Override @Override
public void applyStyleClasses(PadIndex index) { public void applyStyleClasses(PadIndex index) {
superRoot.getStyleClass().addAll("pad", "pad" + index); NodeWalker.getAllNodes(getRootNode())
cueInLayer.getStyleClass().addAll("pad-cue-in", "pad" + index + "-cue-in"); .stream()
.filter(node -> node instanceof PadIndexable)
indexLabel.getStyleClass().addAll("pad-index", "pad" + index + "-index", "pad-info", "pad" + index + "-info"); .forEach(node -> ((PadIndexable) node).setIndex(index));
timeLabel.getStyleClass().addAll("pad-time", "pad" + index + "-time", "pad-info", "pad" + index + "-info");
loopLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon");
triggerLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon");
errorLabel.getGraphic().getStyleClass().addAll("pad-icon", "pad" + index + "-icon");
preview.getChildren().forEach(i -> i.getStyleClass().addAll("pad-title", "pad" + index + "-title"));
playBar.getStyleClass().addAll("pad-playbar", "pad" + index + "-playbar");
root.getStyleClass().add("pad-root");
} }
@Override @Override
public void removeStyleClasses() { public void removeStyleClasses() {
superRoot.getStyleClass().removeIf(c -> c.startsWith("pad")); NodeWalker.getAllNodes(getRootNode())
cueInLayer.getStyleClass().removeIf(c -> c.startsWith("pad")); .stream()
.filter(node -> node instanceof PadIndexable)
indexLabel.getStyleClass().removeIf(c -> c.startsWith("pad")); .forEach(node -> ((PadIndexable) node).setIndex(null));
timeLabel.getStyleClass().removeIf(c -> c.startsWith("pad"));
loopLabel.getGraphic().getStyleClass().removeIf(c -> c.startsWith("pad"));
triggerLabel.getGraphic().getStyleClass().removeIf(c -> c.startsWith("pad"));
errorLabel.getGraphic().getStyleClass().removeIf(c -> c.startsWith("pad"));
preview.getChildren().forEach(i -> i.getStyleClass().removeIf(c -> c.startsWith("pad")));
playBar.getStyleClass().removeIf(c -> c.startsWith("pad"));
root.getStyleClass().remove("pad-root");
} }
@Override @Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment