changed how the layer background uses css

This commit is contained in:
ramollia
2025-10-03 21:44:32 +02:00
parent 754c8fea2e
commit ac6de04e68
6 changed files with 12 additions and 10 deletions

View File

@@ -13,18 +13,22 @@ public abstract class Layer {
protected StackPane layer; protected StackPane layer;
protected Region background; protected Region background;
protected Layer(String cssFile) { protected Layer(String cssFile, String backgroundCssClass) {
layer = new StackPane(); layer = new StackPane();
layer.setPickOnBounds(false); layer.setPickOnBounds(false);
layer.getStylesheets().add(ResourceManager.get(CssAsset.class, cssFile).getUrl()); layer.getStylesheets().add(ResourceManager.get(CssAsset.class, cssFile).getUrl());
background = new Region(); background = new Region();
background.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE); background.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE);
background.getStyleClass().add("background"); background.getStyleClass().add(backgroundCssClass);
layer.getChildren().addLast(background); layer.getChildren().addLast(background);
} }
protected Layer(String cssFile) {
this(cssFile, "background");
}
protected void addContainer(Container container, Pos position, int xOffset, int yOffset) { protected void addContainer(Container container, Pos position, int xOffset, int yOffset) {
StackPane.setAlignment(container.getContainer(), position); StackPane.setAlignment(container.getContainer(), position);

View File

@@ -8,7 +8,7 @@ import javafx.geometry.Pos;
public final class QuitLayer extends Layer { public final class QuitLayer extends Layer {
public QuitLayer() { public QuitLayer() {
super("quit.css"); super("quit.css", "quit_background");
final Container mainContainer = Container.create(Container.Type.VERTICAL, 30); final Container mainContainer = Container.create(Container.Type.VERTICAL, 30);
mainContainer.addText("Are you sure?"); mainContainer.addText("Are you sure?");

View File

@@ -1,3 +1,7 @@
.background {
-fx-background-color: linear-gradient(to bottom right, #21a7b2, #8f32b9);
}
.container { .container {
-fx-background-color: linear-gradient(to bottom right, orange, indigo), #1d1d1d; -fx-background-color: linear-gradient(to bottom right, orange, indigo), #1d1d1d;
-fx-background-insets: 0, 2; -fx-background-insets: 0, 2;

View File

@@ -1,3 +0,0 @@
.background {
-fx-background-color: linear-gradient(to bottom right, #21a7b2, #8f32b9);
}

View File

@@ -1,3 +1,3 @@
.background { .quit_background {
-fx-background-color: #0000007f; -fx-background-color: #0000007f;
} }

View File

@@ -1,3 +0,0 @@
.background {
-fx-background-color: linear-gradient(to bottom right, #21a7b2, #8f32b9);
}