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