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.primaryStage = stage;
extensionForm.fieldsInitialized.fireEvent();
GEarthExtension gEarthExtension = new InternalExtensionBuilder(internalExtension);
observer.onExtensionProduced(gEarthExtension);

View File

@ -27,13 +27,18 @@ public abstract class ThemedExtensionFormCreator extends ExtensionFormCreator {
primaryStage.setResizable(false);
primaryStage.sizeToScene();
DefaultTitleBarConfig config = new DefaultTitleBarConfig(primaryStage, ThemeFactory.getDefaultTheme()) {
Theme defaultTheme = ThemeFactory.getDefaultTheme();
DefaultTitleBarConfig config = new DefaultTitleBarConfig(primaryStage, defaultTheme) {
@Override
public boolean displayThemePicker() {
return false;
}
};
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.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);
}
});
}
}

View File

@ -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;

View File

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

View File

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

View File

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