From d3f8f25a85f72087069c5f5dd7d5fbfbb1cfde81 Mon Sep 17 00:00:00 2001 From: crschnick Date: Fri, 5 Jul 2024 12:51:38 +0000 Subject: [PATCH] Style rework --- .../main/java/io/xpipe/app/core/AppTheme.java | 31 ++++++++++--------- .../io/xpipe/app/resources/style/style.css | 26 +++++++++++++--- .../app/resources/theme/cupertinoDark.css | 1 + .../io/xpipe/app/resources/theme/dark.css | 1 + .../io/xpipe/app/resources/theme/light.css | 1 + .../io/xpipe/app/resources/theme/nordDark.css | 1 + 6 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 app/src/main/resources/io/xpipe/app/resources/theme/cupertinoDark.css create mode 100644 app/src/main/resources/io/xpipe/app/resources/theme/dark.css create mode 100644 app/src/main/resources/io/xpipe/app/resources/theme/light.css create mode 100644 app/src/main/resources/io/xpipe/app/resources/theme/nordDark.css diff --git a/app/src/main/java/io/xpipe/app/core/AppTheme.java b/app/src/main/java/io/xpipe/app/core/AppTheme.java index cc0ed7593..34f84ac85 100644 --- a/app/src/main/java/io/xpipe/app/core/AppTheme.java +++ b/app/src/main/java/io/xpipe/app/core/AppTheme.java @@ -177,8 +177,8 @@ public class AppTheme { private final String name; - public DerivedTheme(String id, String cssId, String name, atlantafx.base.theme.Theme theme, String transparentColor) { - super(id, cssId, theme, transparentColor); + public DerivedTheme(String id, String cssId, String name, atlantafx.base.theme.Theme theme) { + super(id, cssId, theme); this.name = name; } @@ -213,17 +213,17 @@ public class AppTheme { @AllArgsConstructor public static class Theme implements PrefsChoiceValue { - public static final Theme PRIMER_LIGHT = new Theme("light", "primer", new PrimerLight(), "#ffffff88"); - public static final Theme PRIMER_DARK = new Theme("dark", "primer", new PrimerDark(), "#0d111788"); - public static final Theme NORD_LIGHT = new Theme("nordLight", "nord", new NordLight(), "#ffffff88"); - public static final Theme NORD_DARK = new Theme("nordDark", "nord", new NordDark(), "#0d111788"); - public static final Theme CUPERTINO_LIGHT = new Theme("cupertinoLight", "cupertino", new CupertinoLight(), "#ffffff88"); - public static final Theme CUPERTINO_DARK = new Theme("cupertinoDark", "cupertino", new CupertinoDark(), "#0d111788"); - public static final Theme DRACULA = new Theme("dracula", "dracula", new Dracula(), "#0d111788"); - public static final Theme MOCHA = new DerivedTheme("mocha", "primer", "Mocha", new PrimerDark(), "#0d111788"); + public static final Theme PRIMER_LIGHT = new Theme("light", "primer", new PrimerLight()); + public static final Theme PRIMER_DARK = new Theme("dark", "primer", new PrimerDark()); + public static final Theme NORD_LIGHT = new Theme("nordLight", "nord", new NordLight()); + public static final Theme NORD_DARK = new Theme("nordDark", "nord", new NordDark()); + public static final Theme CUPERTINO_LIGHT = new Theme("cupertinoLight", "cupertino", new CupertinoLight()); + public static final Theme CUPERTINO_DARK = new Theme("cupertinoDark", "cupertino", new CupertinoDark()); + public static final Theme DRACULA = new Theme("dracula", "dracula", new Dracula()); + public static final Theme MOCHA = new DerivedTheme("mocha", "primer", "Mocha", new PrimerDark()); // Adjust this to create your own theme - public static final Theme CUSTOM = new DerivedTheme("custom", "primer", "Custom", new PrimerDark(), "#0d111788"); + public static final Theme CUSTOM = new DerivedTheme("custom", "primer", "Custom", new PrimerDark()); // Also include your custom theme here public static final List ALL = List.of( @@ -235,8 +235,6 @@ public class AppTheme { protected final atlantafx.base.theme.Theme theme; - protected final String transparentBackground; - static Theme getDefaultLightTheme() { return switch (OsType.getLocal()) { case OsType.Windows windows -> PRIMER_LIGHT; @@ -262,7 +260,12 @@ public class AppTheme { } public List getAdditionalStylesheets() { - return List.of(Styles.toDataURI(".root { -color-bg-default-transparent: " + transparentBackground + "; }")); + var r = AppResources.getResourceURL(AppResources.XPIPE_MODULE, "theme/" + getId() + ".css"); + if (r.isEmpty()) { + return List.of(); + } else { + return List.of(r.get().toString()); + } } @Override diff --git a/app/src/main/resources/io/xpipe/app/resources/style/style.css b/app/src/main/resources/io/xpipe/app/resources/style/style.css index f396dda45..a19000a00 100644 --- a/app/src/main/resources/io/xpipe/app/resources/style/style.css +++ b/app/src/main/resources/io/xpipe/app/resources/style/style.css @@ -9,19 +9,37 @@ -fx-background-color: transparent; } -.root:dark .background { +.root:dark:separate-frame .background { + -fx-background-color: derive(-color-bg-default, 1%); +} + +.root:light:separate-frame .background { + -fx-background-color: derive(-color-bg-default, -9%); +} + +.root:dark:separate-frame.background { + -fx-background-color: derive(-color-bg-default, 1%); +} + +.root:light:separate-frame.background { + -fx-background-color: derive(-color-bg-default, -9%); +} + + + +.root:dark:seamless-frame .background { -fx-background-color: derive(-color-bg-default-transparent, 1%); } -.root:light .background { +.root:light:seamless-frame .background { -fx-background-color: derive(-color-bg-default-transparent, -9%); } -.root:dark.background { +.root:dark:seamless-frame.background { -fx-background-color: derive(-color-bg-default-transparent, 1%); } -.root:light.background { +.root:light:seamless-frame.background { -fx-background-color: derive(-color-bg-default-transparent, -9%); } diff --git a/app/src/main/resources/io/xpipe/app/resources/theme/cupertinoDark.css b/app/src/main/resources/io/xpipe/app/resources/theme/cupertinoDark.css new file mode 100644 index 000000000..e27a340b5 --- /dev/null +++ b/app/src/main/resources/io/xpipe/app/resources/theme/cupertinoDark.css @@ -0,0 +1 @@ +.root { -color-bg-default-transparent: #0d1117d2; } \ No newline at end of file diff --git a/app/src/main/resources/io/xpipe/app/resources/theme/dark.css b/app/src/main/resources/io/xpipe/app/resources/theme/dark.css new file mode 100644 index 000000000..e27a340b5 --- /dev/null +++ b/app/src/main/resources/io/xpipe/app/resources/theme/dark.css @@ -0,0 +1 @@ +.root { -color-bg-default-transparent: #0d1117d2; } \ No newline at end of file diff --git a/app/src/main/resources/io/xpipe/app/resources/theme/light.css b/app/src/main/resources/io/xpipe/app/resources/theme/light.css new file mode 100644 index 000000000..ea72bdf67 --- /dev/null +++ b/app/src/main/resources/io/xpipe/app/resources/theme/light.css @@ -0,0 +1 @@ +.root { -color-bg-default-transparent: #FFFFFF99; } \ No newline at end of file diff --git a/app/src/main/resources/io/xpipe/app/resources/theme/nordDark.css b/app/src/main/resources/io/xpipe/app/resources/theme/nordDark.css new file mode 100644 index 000000000..e27a340b5 --- /dev/null +++ b/app/src/main/resources/io/xpipe/app/resources/theme/nordDark.css @@ -0,0 +1 @@ +.root { -color-bg-default-transparent: #0d1117d2; } \ No newline at end of file