diff --git a/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormBuilder.java b/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormBuilder.java index 5db129b..e7b65be 100644 --- a/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormBuilder.java +++ b/G-Earth/src/main/java/gearth/extensions/InternalExtensionFormBuilder.java @@ -55,6 +55,7 @@ public class InternalExtensionFormBuilder { + primaryStage.getScene().getRoot().getStyleClass().add(defaultTheme.title().replace(" ", "-").toLowerCase()); + primaryStage.getScene().getRoot().getStyleClass().add(defaultTheme.isDark() ? "g-dark" : "g-light"); + }); ExtensionForm extensionForm = loader.getController(); extensionForm.fieldsInitialized.addListener(() -> extensionForm.extension.observableHostInfo.addListener(hostInfo -> { @@ -42,12 +47,18 @@ public abstract class ThemedExtensionFormCreator extends ExtensionFormCreator { Theme theme = ThemeFactory.themeForTitle(themeTitle); if (config.getCurrentTheme() != theme) { String styleClassOld = config.getCurrentTheme().title().replace(" ", "-").toLowerCase(); + String lightClassOld = config.getCurrentTheme().isDark() ? "g-dark" : "g-light"; String styleClassNew = theme.title().replace(" ", "-").toLowerCase(); + String lightClassNew = theme.isDark() ? "g-dark" : "g-light"; config.setTheme(theme); Parent currentRoot = primaryStage.getScene().getRoot(); Platform.runLater(() -> { currentRoot.getStyleClass().remove(styleClassOld); currentRoot.getStyleClass().add(styleClassNew); + if (!lightClassOld.equals(lightClassNew)) { + currentRoot.getStyleClass().remove(lightClassOld); + currentRoot.getStyleClass().add(lightClassNew); + } }); } } diff --git a/G-Earth/src/main/java/gearth/ui/themes/DarkTheme.java b/G-Earth/src/main/java/gearth/ui/themes/DarkTheme.java index 25f90da..f7139cc 100644 --- a/G-Earth/src/main/java/gearth/ui/themes/DarkTheme.java +++ b/G-Earth/src/main/java/gearth/ui/themes/DarkTheme.java @@ -11,6 +11,11 @@ public class DarkTheme implements Theme { return "G-Earth_Dark"; } + @Override + public boolean isDark() { + return true; + } + @Override public boolean overridesLogo() { return false; diff --git a/G-Earth/src/main/java/gearth/ui/themes/LightTheme.java b/G-Earth/src/main/java/gearth/ui/themes/LightTheme.java index 6e131fe..f5738da 100644 --- a/G-Earth/src/main/java/gearth/ui/themes/LightTheme.java +++ b/G-Earth/src/main/java/gearth/ui/themes/LightTheme.java @@ -11,6 +11,11 @@ public class LightTheme implements Theme { return "G-Earth"; } + @Override + public boolean isDark() { + return false; + } + @Override public boolean overridesLogo() { return true; diff --git a/G-Earth/src/main/java/gearth/ui/themes/TanjiTheme.java b/G-Earth/src/main/java/gearth/ui/themes/TanjiTheme.java index abf3078..8d25128 100644 --- a/G-Earth/src/main/java/gearth/ui/themes/TanjiTheme.java +++ b/G-Earth/src/main/java/gearth/ui/themes/TanjiTheme.java @@ -11,6 +11,11 @@ public class TanjiTheme implements Theme { return "Tanji"; } + @Override + public boolean isDark() { + return false; + } + @Override public boolean overridesLogo() { return false; diff --git a/G-Earth/src/main/java/gearth/ui/themes/Theme.java b/G-Earth/src/main/java/gearth/ui/themes/Theme.java index ee50c28..73460d8 100644 --- a/G-Earth/src/main/java/gearth/ui/themes/Theme.java +++ b/G-Earth/src/main/java/gearth/ui/themes/Theme.java @@ -5,6 +5,7 @@ public interface Theme { String title(); String internalName(); + boolean isDark(); boolean overridesLogo(); boolean overridesTitle();