This commit is contained in:
crschnick 2024-06-19 17:47:31 +00:00
parent 95db5e8e6f
commit 9e98004a71
5 changed files with 39 additions and 21 deletions

View file

@ -4,6 +4,7 @@ import io.xpipe.app.prefs.AppPrefs;
import io.xpipe.core.process.OsType;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
import javafx.css.PseudoClass;
import javafx.stage.Stage;
import javafx.stage.Window;
import lombok.SneakyThrows;
@ -33,6 +34,8 @@ public class ModifiedStage extends Stage {
var ctrl = new NativeWinWindowControl(stage);
ctrl.setWindowAttribute(DmwaWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE.getValue(), AppPrefs.get().theme.getValue().isDark());
ctrl.setWindowBackdrop(DwmSystemBackDropType.MICA);
var backdrop = ctrl.setWindowBackdrop(DwmSystemBackDropType.MICA_ALT);
stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("seamless-frame"), backdrop);
stage.getScene().getRoot().pseudoClassStateChanged(PseudoClass.getPseudoClass("separate-frame"), !backdrop);
}
}

View file

@ -40,26 +40,20 @@ public class NativeWinWindowControl {
User32.INSTANCE.SetWindowPos(windowHandle, new WinDef.HWND(), x, y, w, h, 0);
}
public void setWindowAttribute(int attribute, boolean attributeValue) {
DwmSupport.INSTANCE.DwmSetWindowAttribute(
public boolean setWindowAttribute(int attribute, boolean attributeValue) {
var r = DwmSupport.INSTANCE.DwmSetWindowAttribute(
windowHandle, attribute, new WinDef.BOOLByReference(new WinDef.BOOL(attributeValue)), WinDef.BOOL.SIZE);
return r.longValue() == 0;
}
public void setWindowAttribute(int attribute, long attributeValue) {
DwmSupport.INSTANCE.DwmSetWindowAttribute(
windowHandle,
attribute,
new WinDef.DWORDByReference(new WinDef.DWORD(attributeValue)),
WinDef.DWORD.SIZE);
}
public void setWindowBackdrop(DwmSystemBackDropType backdrop) {
DwmSupport.INSTANCE.DwmSetWindowAttribute(
public boolean setWindowBackdrop(DwmSystemBackDropType backdrop) {
var r = DwmSupport.INSTANCE.DwmSetWindowAttribute(
windowHandle,
DmwaWindowAttribute.DWMWA_SYSTEMBACKDROP_TYPE.getValue(),
new WinDef.DWORDByReference(new WinDef.DWORD(backdrop.getValue())),
WinDef.DWORD.SIZE
);
return r.longValue() == 0;
}
public interface DwmSupport extends Library {

View file

@ -27,7 +27,7 @@
}
.prefs {
-fx-background-color: -color-bg-default;
-fx-background-color: transparent;
}
.prefs .sidebar {

View file

@ -1,11 +1,30 @@
.sidebar-comp {
-fx-padding: 0;
-fx-background-insets: 0;
-fx-border-width: 0 0 0 1px;
-fx-border-color: -color-border-default;
}
.root:dark .sidebar-comp {
-fx-background-color: derive(-color-bg-default, 1%);
}
.root:light .sidebar-comp {
-fx-background-color: derive(-color-bg-default, -1%);
}
.root:seamless-frame .sidebar-comp {
-fx-border-width: 0;
-fx-border-color: transparent;
-fx-background-color: transparent;
}
.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;
}
@ -13,18 +32,14 @@
-fx-opacity: 1.0;
}
.sidebar-comp .icon-button-comp:hover, .root:key-navigation .sidebar-comp .icon-button-comp:focused {
.root .sidebar-comp .icon-button-comp:hover, .root:key-navigation .sidebar-comp .icon-button-comp:focused {
-fx-background-color: -color-neutral-muted;
}
.sidebar-comp .icon-button-comp:selected {
.root .sidebar-comp .icon-button-comp:selected {
-fx-background-color: -color-neutral-muted;
}
.sidebar-comp {
-fx-background-color: transparent;
}
.sidebar-comp .icon-button-comp {
-fx-padding: 1em;
}

View file

@ -17,11 +17,17 @@
-fx-background-color: derive(-color-bg-default, -9%);
}
.background {
.root:seamless-frame .background {
-fx-background-radius: 0 10 0 0;
-fx-border-radius: 0 10 0 0;
-fx-border-width: 1 1 0 0;
-fx-border-color: -color-border-default;
-fx-padding: 0 2 0 0;
}
.root:seamless-frame .background > * {
-fx-background-radius: 0 10 0 0;
-fx-border-radius: 0 10 0 0;
}
.toggle-switch:has-graphic .label {