From 79c2070d19a11d277a4ea528688137ac5122ca25 Mon Sep 17 00:00:00 2001 From: crschnick Date: Wed, 19 Jun 2024 19:05:14 +0000 Subject: [PATCH] More fixes --- .../xpipe/app/comp/base/SideMenuBarComp.java | 1 - .../xpipe/app/core/window/AppMainWindow.java | 2 -- .../xpipe/app/core/window/ModifiedStage.java | 29 +++++++++++++++---- .../app/resources/style/sidebar-comp.css | 5 +--- 4 files changed, 25 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java b/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java index a6f7003b6..d862a9d48 100644 --- a/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java +++ b/app/src/main/java/io/xpipe/app/comp/base/SideMenuBarComp.java @@ -196,7 +196,6 @@ public class SideMenuBarComp extends Comp> { vbox.getChildren().add(filler); VBox.setVgrow(filler, Priority.ALWAYS); filler.prefWidthProperty().bind(((Region) vbox.getChildren().getFirst()).widthProperty()); - vbox.getStyleClass().add("sidebar-comp"); return new SimpleCompStructure<>(vbox); } diff --git a/app/src/main/java/io/xpipe/app/core/window/AppMainWindow.java b/app/src/main/java/io/xpipe/app/core/window/AppMainWindow.java index f0747e691..66af9119e 100644 --- a/app/src/main/java/io/xpipe/app/core/window/AppMainWindow.java +++ b/app/src/main/java/io/xpipe/app/core/window/AppMainWindow.java @@ -21,7 +21,6 @@ import javafx.scene.layout.Region; import javafx.scene.paint.Color; import javafx.stage.Screen; import javafx.stage.Stage; -import javafx.stage.StageStyle; import lombok.Builder; import lombok.Getter; import lombok.Value; @@ -53,7 +52,6 @@ public class AppMainWindow { INSTANCE = new AppMainWindow(stage); var scene = new Scene(new Region(), -1, -1, false); scene.setFill(Color.TRANSPARENT); - stage.initStyle(StageStyle.UNIFIED); stage.setScene(scene); AppWindowHelper.setupStylesheets(stage.getScene()); return INSTANCE; diff --git a/app/src/main/java/io/xpipe/app/core/window/ModifiedStage.java b/app/src/main/java/io/xpipe/app/core/window/ModifiedStage.java index 9826a180e..e89ca81bb 100644 --- a/app/src/main/java/io/xpipe/app/core/window/ModifiedStage.java +++ b/app/src/main/java/io/xpipe/app/core/window/ModifiedStage.java @@ -2,11 +2,14 @@ package io.xpipe.app.core.window; import io.xpipe.app.prefs.AppPrefs; import io.xpipe.core.process.OsType; +import javafx.animation.PauseTransition; +import javafx.application.Platform; import javafx.collections.ListChangeListener; import javafx.collections.ObservableList; import javafx.css.PseudoClass; import javafx.stage.Stage; import javafx.stage.Window; +import javafx.util.Duration; import lombok.SneakyThrows; public class ModifiedStage extends Stage { @@ -28,11 +31,9 @@ public class ModifiedStage extends Stage { } private static void applyStage(Stage stage) { - if (OsType.getLocal() != OsType.WINDOWS) { - return; - } - - if (AppPrefs.get() == null) { + if (OsType.getLocal() != OsType.WINDOWS || AppPrefs.get() == null) { + stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("seamless-frame"), false); + stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("separate-frame"), true); return; } @@ -46,5 +47,23 @@ public class ModifiedStage extends Stage { } stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("seamless-frame"), backdrop); stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("separate-frame"), !backdrop); + + AppPrefs.get().theme.addListener((observable, oldValue, newValue) -> { + if (!stage.isShowing()) { + return; + } + + Platform.runLater(() -> { + var transition = new PauseTransition(Duration.millis(300)); + transition.setOnFinished(e -> { + applyStage(stage); + stage.setWidth(stage.getWidth() - 1); + Platform.runLater(() -> { + stage.setWidth(stage.getWidth() + 1); + }); + }); + transition.play(); + }); + }); } } diff --git a/app/src/main/resources/io/xpipe/app/resources/style/sidebar-comp.css b/app/src/main/resources/io/xpipe/app/resources/style/sidebar-comp.css index 6be4e8366..37a0487fe 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/sidebar-comp.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/sidebar-comp.css @@ -6,7 +6,7 @@ } .root:dark .sidebar-comp { - -fx-background-color: derive(-color-bg-default, 1%); + -fx-background-color: derive(-color-bg-default, 10%); } .root:light .sidebar-comp { @@ -22,9 +22,6 @@ .sidebar-comp .icon-button-comp, .sidebar-comp .button { -fx-background-radius: 0; -fx-background-insets: 0; -} - -.root:seamless-frame .sidebar-comp .icon-button-comp, .root:seamless-frame .sidebar-comp .button { -fx-background-color: transparent; }