This commit is contained in:
sirjonasxx 2022-02-16 04:47:54 +01:00
parent 3d7b1fa7dd
commit 33afab4353
6 changed files with 29 additions and 1 deletions

View File

@ -55,6 +55,7 @@ public class InternalExtensionFormBuilder<L extends InternalExtensionFormLaunche
extensionForm.extension = internalExtension; extensionForm.extension = internalExtension;
extensionForm.primaryStage = stage; extensionForm.primaryStage = stage;
extensionForm.fieldsInitialized.fireEvent();
GEarthExtension gEarthExtension = new InternalExtensionBuilder(internalExtension); GEarthExtension gEarthExtension = new InternalExtensionBuilder(internalExtension);
observer.onExtensionProduced(gEarthExtension); observer.onExtensionProduced(gEarthExtension);

View File

@ -27,13 +27,18 @@ public abstract class ThemedExtensionFormCreator extends ExtensionFormCreator {
primaryStage.setResizable(false); primaryStage.setResizable(false);
primaryStage.sizeToScene(); primaryStage.sizeToScene();
DefaultTitleBarConfig config = new DefaultTitleBarConfig(primaryStage, ThemeFactory.getDefaultTheme()) { Theme defaultTheme = ThemeFactory.getDefaultTheme();
DefaultTitleBarConfig config = new DefaultTitleBarConfig(primaryStage, defaultTheme) {
@Override @Override
public boolean displayThemePicker() { public boolean displayThemePicker() {
return false; return false;
} }
}; };
TitleBarController.create(primaryStage, config); TitleBarController.create(primaryStage, config);
Platform.runLater(() -> {
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 extensionForm = loader.getController();
extensionForm.fieldsInitialized.addListener(() -> extensionForm.extension.observableHostInfo.addListener(hostInfo -> { extensionForm.fieldsInitialized.addListener(() -> extensionForm.extension.observableHostInfo.addListener(hostInfo -> {
@ -42,12 +47,18 @@ public abstract class ThemedExtensionFormCreator extends ExtensionFormCreator {
Theme theme = ThemeFactory.themeForTitle(themeTitle); Theme theme = ThemeFactory.themeForTitle(themeTitle);
if (config.getCurrentTheme() != theme) { if (config.getCurrentTheme() != theme) {
String styleClassOld = config.getCurrentTheme().title().replace(" ", "-").toLowerCase(); String styleClassOld = config.getCurrentTheme().title().replace(" ", "-").toLowerCase();
String lightClassOld = config.getCurrentTheme().isDark() ? "g-dark" : "g-light";
String styleClassNew = theme.title().replace(" ", "-").toLowerCase(); String styleClassNew = theme.title().replace(" ", "-").toLowerCase();
String lightClassNew = theme.isDark() ? "g-dark" : "g-light";
config.setTheme(theme); config.setTheme(theme);
Parent currentRoot = primaryStage.getScene().getRoot(); Parent currentRoot = primaryStage.getScene().getRoot();
Platform.runLater(() -> { Platform.runLater(() -> {
currentRoot.getStyleClass().remove(styleClassOld); currentRoot.getStyleClass().remove(styleClassOld);
currentRoot.getStyleClass().add(styleClassNew); currentRoot.getStyleClass().add(styleClassNew);
if (!lightClassOld.equals(lightClassNew)) {
currentRoot.getStyleClass().remove(lightClassOld);
currentRoot.getStyleClass().add(lightClassNew);
}
}); });
} }
} }

View File

@ -11,6 +11,11 @@ public class DarkTheme implements Theme {
return "G-Earth_Dark"; return "G-Earth_Dark";
} }
@Override
public boolean isDark() {
return true;
}
@Override @Override
public boolean overridesLogo() { public boolean overridesLogo() {
return false; return false;

View File

@ -11,6 +11,11 @@ public class LightTheme implements Theme {
return "G-Earth"; return "G-Earth";
} }
@Override
public boolean isDark() {
return false;
}
@Override @Override
public boolean overridesLogo() { public boolean overridesLogo() {
return true; return true;

View File

@ -11,6 +11,11 @@ public class TanjiTheme implements Theme {
return "Tanji"; return "Tanji";
} }
@Override
public boolean isDark() {
return false;
}
@Override @Override
public boolean overridesLogo() { public boolean overridesLogo() {
return false; return false;

View File

@ -5,6 +5,7 @@ public interface Theme {
String title(); String title();
String internalName(); String internalName();
boolean isDark();
boolean overridesLogo(); boolean overridesLogo();
boolean overridesTitle(); boolean overridesTitle();