From f866e503a731d98f9e489da87f71d65e4fbd2d36 Mon Sep 17 00:00:00 2001 From: weisj Date: Tue, 31 Mar 2020 15:55:13 +0200 Subject: [PATCH] Moved themes to own module. Decoupled loading of ui properties from theme properties. --- core/build.gradle.kts | 1 + .../darklaf/task/FontDefaultsInitTask.java | 5 +- .../{theme => task}/PropertyFontMapper.java | 13 +++- .../darklaf/task/ThemeDefaultsInitTask.java | 63 ++++++++++++++++--- core/src/test/java/theme/MyCustomTheme.java | 12 ++-- settings.gradle.kts | 1 + theme/build.gradle.kts | 7 +++ .../weisj/darklaf/theme/ColorToneRule.java | 0 .../weisj/darklaf/theme/ContrastRule.java | 0 .../weisj/darklaf/theme/DarculaTheme.java | 0 .../darklaf/theme/DefaultThemeProvider.java | 0 .../weisj/darklaf/theme/FontMapper.java | 0 .../weisj/darklaf/theme/FontSizeRule.java | 6 -- .../darklaf/theme/HighContrastDarkTheme.java | 8 +-- .../darklaf/theme/HighContrastLightTheme.java | 8 +-- .../weisj/darklaf/theme/IntelliJTheme.java | 4 +- .../darklaf/theme/PreferredThemeStyle.java | 0 .../weisj/darklaf/theme/PresetIconRule.java | 0 .../darklaf/theme/SolarizedDarkTheme.java | 4 +- .../darklaf/theme/SolarizedLightTheme.java | 4 +- .../com/github/weisj/darklaf/theme/Theme.java | 53 ++++------------ .../weisj/darklaf/theme/ThemeProvider.java | 0 .../theme/UnsupportedThemeException.java | 0 .../theme/darcula/darcula_defaults.properties | 0 .../theme/darcula/darcula_styleSheet.css | 0 .../high_contrast_dark_defaults.properties | 0 .../high_contrast_dark_icons.properties | 0 .../high_contrast_dark_platform.properties | 0 .../high_contrast_dark_styleSheet.css | 0 .../high_contrast_dark_ui.properties | 0 .../high_contrast_light_defaults.properties | 0 .../high_contrast_light_icons.properties | 0 .../high_contrast_light_platform.properties | 0 .../high_contrast_light_styleSheet.css | 0 .../high_contrast_light_ui.properties | 0 .../theme/icon_presets}/dark_icons.properties | 0 .../icon_presets}/light_icons.properties | 0 .../intellij/intellij_defaults.properties | 0 .../theme/intellij/intellij_styleSheet.css | 0 .../theme/intellij/intellij_ui.properties | 0 .../solarized_dark_defaults.properties | 0 .../solarized_dark_icons.properties | 0 .../solarized_dark_styleSheet.css | 0 .../solarized_dark_ui.properties | 0 .../solarized_light_defaults.properties | 0 .../solarized_light_icons.properties | 0 .../solarized_light_styleSheet.css | 0 .../solarized_light_ui.properties | 0 48 files changed, 109 insertions(+), 80 deletions(-) rename core/src/main/java/com/github/weisj/darklaf/{theme => task}/PropertyFontMapper.java (88%) create mode 100644 theme/build.gradle.kts rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/ColorToneRule.java (100%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/ContrastRule.java (100%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java (100%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/DefaultThemeProvider.java (100%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/FontMapper.java (100%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/FontSizeRule.java (89%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java (86%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java (86%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java (92%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/PreferredThemeStyle.java (100%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/PresetIconRule.java (100%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java (92%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java (92%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/Theme.java (80%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/ThemeProvider.java (100%) rename {core => theme}/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_styleSheet.css (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_styleSheet.css (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_styleSheet.css (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties (100%) rename {core/src/main/resources/com/github/weisj/darklaf/properties/icons/presets => theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets}/dark_icons.properties (100%) rename {core/src/main/resources/com/github/weisj/darklaf/properties/icons/presets => theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets}/light_icons.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_styleSheet.css (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_styleSheet.css (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_styleSheet.css (100%) rename {core => theme}/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties (100%) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 53dfa75e..d9c498f2 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -8,6 +8,7 @@ plugins { } dependencies { + implementation(project(":darklaf-theme")) implementation(project(":darklaf-native-utils")) implementation(project(":darklaf-utils")) implementation(project(":darklaf-platform-base")) diff --git a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java index 88bd59ba..a6559266 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/FontDefaultsInitTask.java @@ -47,6 +47,7 @@ public class FontDefaultsInitTask implements DefaultsInitTask { private static final String MAC_OS_CATALINA_FONT_NAME = ".AppleSystemUIFont"; private static final String MAC_OS_FONT_NAME = ".SF NS Text"; + private final PropertyFontMapper fontMapper = new PropertyFontMapper(); @Override public void run(final Theme currentTheme, final Map defaults) { @@ -108,7 +109,7 @@ public class FontDefaultsInitTask implements DefaultsInitTask { } private FontMapper getFontMapper(final FontSizeRule rule) { - if (rule == null) return (font, defaults) -> font; - return rule.getFontMapper(); + fontMapper.setPropertyKey(rule == null ? null : rule.getPropertyKey()); + return fontMapper; } } diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/PropertyFontMapper.java b/core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java similarity index 88% rename from core/src/main/java/com/github/weisj/darklaf/theme/PropertyFontMapper.java rename to core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java index dee11a07..44604713 100644 --- a/core/src/main/java/com/github/weisj/darklaf/theme/PropertyFontMapper.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/PropertyFontMapper.java @@ -21,9 +21,11 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -package com.github.weisj.darklaf.theme; +package com.github.weisj.darklaf.task; import com.github.weisj.darklaf.LafManager; +import com.github.weisj.darklaf.theme.FontMapper; +import com.github.weisj.darklaf.theme.Theme; import java.awt.*; import java.util.Map; @@ -37,12 +39,21 @@ public class PropertyFontMapper implements FontMapper { private int adjustment; private String propertyKey; + public PropertyFontMapper() { + this(null); + } + public PropertyFontMapper(final String propertyKey) { this.propertyKey = propertyKey; } + public void setPropertyKey(final String propertyKey) { + this.propertyKey = propertyKey; + } + @Override public Font map(final Font font, final Map defaults) { + if (propertyKey == null) return font; adjustment = getSize(defaults); // No need to create a new font. if (adjustment == 0) return font; diff --git a/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java b/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java index e1e6272c..8b50d383 100644 --- a/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java +++ b/core/src/main/java/com/github/weisj/darklaf/task/ThemeDefaultsInitTask.java @@ -23,13 +23,14 @@ */ package com.github.weisj.darklaf.task; +import com.github.weisj.darklaf.DarkLaf; +import com.github.weisj.darklaf.PropertyLoader; import com.github.weisj.darklaf.platform.Decorations; import com.github.weisj.darklaf.theme.Theme; import com.github.weisj.darklaf.util.SystemInfo; import javax.swing.*; import javax.swing.text.html.HTMLEditorKit; -import javax.swing.text.html.StyleSheet; import java.util.HashMap; import java.util.Map; import java.util.Properties; @@ -38,6 +39,16 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { private static final String GLOBAL_PREFIX = "global."; private static final String MAC_OS_MENU_BAR_KEY = "apple.laf.useScreenMenuBar"; + private static final String[] UI_PROPERTIES = new String[]{ + "borders", "button", "checkBox", "colorChooser", "comboBox", "fileChooser", "tristate", + "internalFrame", "label", "list", "menu", "menuBar", "menuItem", "numberingPane", "optionPane", "panel", + "popupMenu", "progressBar", "radioButton", "rootPane", "scrollBar", "scrollPane", "separator", + "slider", "spinner", "splitPane", "statusBar", "tabbedPane", "tabFrame", "table", "taskPane", "text", + "toggleButton", "toolBar", "toolTip", "tree", + }; + private static final String[] ICON_PROPERTIES = new String[]{ + "control", "dialog", "files", "frame", "indicator", "menu", "misc", "navigation" + }; private final DefaultsInitTask userPreferenceInitTask = new UserPreferenceInitTask(); @Override @@ -56,17 +67,24 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { */ userPreferenceInitTask.run(currentTheme, uiProps); - currentTheme.loadGlobals(uiProps, defaults); - installGlobals(uiProps, defaults); - currentTheme.loadUIProperties(uiProps, defaults); - currentTheme.loadIconProperties(uiProps, defaults); + initGlobals(currentTheme, defaults, uiProps); + initUIProperties(currentTheme, defaults, uiProps); + initIconTheme(currentTheme, defaults, uiProps); + initPlatformProperties(currentTheme, defaults, uiProps); + Decorations.loadDecorationProperties(uiProps, defaults); - currentTheme.loadPlatformProperties(uiProps, defaults); adjustPlatformSpecifics(uiProps); defaults.putAll(uiProps); - StyleSheet styleSheet = currentTheme.loadStyleSheet(); - new HTMLEditorKit().setStyleSheet(styleSheet); + new HTMLEditorKit().setStyleSheet(currentTheme.loadStyleSheet()); + } + + private void initGlobals(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { + PropertyLoader.putProperties( + PropertyLoader.loadProperties(DarkLaf.class, "globals", "properties/"), uiProps, defaults); + + currentTheme.customizeGlobals(uiProps, defaults); + installGlobals(uiProps, defaults); } private void installGlobals(final Properties uiProps, final Map defaults) { @@ -88,7 +106,30 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { } } - protected void adjustPlatformSpecifics(final Properties uiProps) { + private void initUIProperties(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { + for (String property : UI_PROPERTIES) { + PropertyLoader.putProperties( + PropertyLoader.loadProperties(DarkLaf.class, property, "properties/ui/"), uiProps, defaults); + } + currentTheme.customizeUIProperties(uiProps, defaults); + } + + private void initIconTheme(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { + currentTheme.loadIconTheme(uiProps, defaults); + for (String property : ICON_PROPERTIES) { + PropertyLoader.putProperties( + PropertyLoader.loadProperties(DarkLaf.class, property, "properties/icons/"), uiProps, defaults); + } + currentTheme.customizeIconTheme(uiProps, defaults); + } + + private void initPlatformProperties(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { + PropertyLoader.putProperties( + PropertyLoader.loadProperties(DarkLaf.class, getOsName(), "properties/platform/"), uiProps, defaults); + currentTheme.customizePlatformProperties(uiProps, defaults); + } + + private void adjustPlatformSpecifics(final Properties uiProps) { boolean useScreenMenuBar = Boolean.getBoolean(MAC_OS_MENU_BAR_KEY); // If user wants to use Apple menu bar, then we need to keep the default // component for MenuBarUI and MenuUI @@ -96,4 +137,8 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { uiProps.remove("MenuBarUI"); } } + + private String getOsName() { + return SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux"; + } } diff --git a/core/src/test/java/theme/MyCustomTheme.java b/core/src/test/java/theme/MyCustomTheme.java index 8bc0a60c..96892b6c 100644 --- a/core/src/test/java/theme/MyCustomTheme.java +++ b/core/src/test/java/theme/MyCustomTheme.java @@ -34,8 +34,8 @@ import java.util.Properties; public class MyCustomTheme extends Theme { @Override - public void loadGlobals(final Properties properties, final UIDefaults currentDefaults) { - super.loadGlobals(properties, currentDefaults); + public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults) { + super.customizeGlobals(properties, currentDefaults); /* * Properties in the globals file should have a 'globals.' to be applied globally. */ @@ -43,8 +43,8 @@ public class MyCustomTheme extends Theme { } @Override - public void loadPlatformProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadPlatformProperties(properties, currentDefaults); + public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizePlatformProperties(properties, currentDefaults); /* * Loading this file (and having it present) is optional. */ @@ -53,8 +53,8 @@ public class MyCustomTheme extends Theme { } @Override - public void loadUIProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadUIProperties(properties, currentDefaults); + public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizeUIProperties(properties, currentDefaults); /* * Loading this file (and having it present) is optional. */ diff --git a/settings.gradle.kts b/settings.gradle.kts index 3b4a6524..0f171330 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -18,6 +18,7 @@ include( "dependencies-bom", "native-utils", "core", + "theme", "property-loader", "utils", "platform-base", diff --git a/theme/build.gradle.kts b/theme/build.gradle.kts new file mode 100644 index 00000000..d1578cf0 --- /dev/null +++ b/theme/build.gradle.kts @@ -0,0 +1,7 @@ +plugins { + `java-library` +} + +dependencies { + implementation(project(":darklaf-property-loader")) +} diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/ColorToneRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/ColorToneRule.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/ColorToneRule.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/ColorToneRule.java diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/ContrastRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/ContrastRule.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/ContrastRule.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/ContrastRule.java diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/DarculaTheme.java diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/DefaultThemeProvider.java b/theme/src/main/java/com/github/weisj/darklaf/theme/DefaultThemeProvider.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/DefaultThemeProvider.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/DefaultThemeProvider.java diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/FontMapper.java b/theme/src/main/java/com/github/weisj/darklaf/theme/FontMapper.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/FontMapper.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/FontMapper.java diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/FontSizeRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/FontSizeRule.java similarity index 89% rename from core/src/main/java/com/github/weisj/darklaf/theme/FontSizeRule.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/FontSizeRule.java index 7d6f9321..4184467c 100644 --- a/core/src/main/java/com/github/weisj/darklaf/theme/FontSizeRule.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/FontSizeRule.java @@ -34,18 +34,12 @@ public enum FontSizeRule { HUGE("huge"); private final String propertyKey; - private final PropertyFontMapper fontMapper; FontSizeRule(final String propertyKey) { this.propertyKey = propertyKey; - fontMapper = new PropertyFontMapper(getPropertyKey()); } public String getPropertyKey() { return "fontSize." + propertyKey; } - - public FontMapper getFontMapper() { - return fontMapper; - } } diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java similarity index 86% rename from core/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java index 839f40d9..5c9ea6ad 100644 --- a/core/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastDarkTheme.java @@ -64,14 +64,14 @@ public class HighContrastDarkTheme extends Theme { } @Override - public void loadUIProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadUIProperties(properties, currentDefaults); + public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizeUIProperties(properties, currentDefaults); loadCustomProperties("ui", properties, currentDefaults); } @Override - public void loadPlatformProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadPlatformProperties(properties, currentDefaults); + public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizePlatformProperties(properties, currentDefaults); loadCustomProperties("platform", properties, currentDefaults); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java similarity index 86% rename from core/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java index 1c87950b..033933d4 100644 --- a/core/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/HighContrastLightTheme.java @@ -64,14 +64,14 @@ public class HighContrastLightTheme extends Theme { } @Override - public void loadUIProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadUIProperties(properties, currentDefaults); + public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizeUIProperties(properties, currentDefaults); loadCustomProperties("ui", properties, currentDefaults); } @Override - public void loadPlatformProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadPlatformProperties(properties, currentDefaults); + public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizePlatformProperties(properties, currentDefaults); loadCustomProperties("platform", properties, currentDefaults); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java similarity index 92% rename from core/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java index ad426891..002bf4cf 100644 --- a/core/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/IntelliJTheme.java @@ -62,8 +62,8 @@ public class IntelliJTheme extends Theme { } @Override - public void loadUIProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadUIProperties(properties, currentDefaults); + public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizeUIProperties(properties, currentDefaults); loadCustomProperties("ui", properties, currentDefaults); } } diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/PreferredThemeStyle.java b/theme/src/main/java/com/github/weisj/darklaf/theme/PreferredThemeStyle.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/PreferredThemeStyle.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/PreferredThemeStyle.java diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/PresetIconRule.java b/theme/src/main/java/com/github/weisj/darklaf/theme/PresetIconRule.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/PresetIconRule.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/PresetIconRule.java diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java similarity index 92% rename from core/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java index efe8b306..148e4477 100644 --- a/core/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedDarkTheme.java @@ -54,8 +54,8 @@ public class SolarizedDarkTheme extends Theme { } @Override - public void loadUIProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadUIProperties(properties, currentDefaults); + public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizeUIProperties(properties, currentDefaults); loadCustomProperties("ui", properties, currentDefaults); } diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java similarity index 92% rename from core/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java index 3ff1489a..38f9fa79 100644 --- a/core/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/SolarizedLightTheme.java @@ -54,8 +54,8 @@ public class SolarizedLightTheme extends Theme { } @Override - public void loadUIProperties(final Properties properties, final UIDefaults currentDefaults) { - super.loadUIProperties(properties, currentDefaults); + public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { + super.customizeUIProperties(properties, currentDefaults); loadCustomProperties("ui", properties, currentDefaults); } diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/Theme.java b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java similarity index 80% rename from core/src/main/java/com/github/weisj/darklaf/theme/Theme.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java index e949db53..36265b20 100644 --- a/core/src/main/java/com/github/weisj/darklaf/theme/Theme.java +++ b/theme/src/main/java/com/github/weisj/darklaf/theme/Theme.java @@ -23,9 +23,7 @@ */ package com.github.weisj.darklaf.theme; -import com.github.weisj.darklaf.DarkLaf; import com.github.weisj.darklaf.PropertyLoader; -import com.github.weisj.darklaf.util.SystemInfo; import javax.swing.*; import javax.swing.text.html.StyleSheet; @@ -39,22 +37,10 @@ import java.util.logging.Level; import java.util.logging.Logger; /** - * Theme for {@link DarkLaf}. - * * @author Jannis Weis */ public abstract class Theme { private static final Logger LOGGER = Logger.getLogger(Theme.class.getName()); - private static final String[] UI_PROPERTIES = new String[]{ - "borders", "button", "checkBox", "colorChooser", "comboBox", "fileChooser", "tristate", - "internalFrame", "label", "list", "menu", "menuBar", "menuItem", "numberingPane", "optionPane", "panel", - "popupMenu", "progressBar", "radioButton", "rootPane", "scrollBar", "scrollPane", "separator", - "slider", "spinner", "splitPane", "statusBar", "tabbedPane", "tabFrame", "table", "taskPane", "text", - "toggleButton", "toolBar", "toolTip", "tree", - }; - private static final String[] ICON_PROPERTIES = new String[]{ - "control", "dialog", "files", "frame", "indicator", "menu", "misc", "navigation" - }; private FontSizeRule fontSizeRule; @@ -96,7 +82,7 @@ public abstract class Theme { } /** - * Load the global values. + * Customize the global values. *

* Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} to return the class of the theme * you are overwriting. In this case you should use {@link #loadWithClass(String, Class)} instead of {@link @@ -105,13 +91,11 @@ public abstract class Theme { * @param properties the properties to load the values into. * @param currentDefaults the current ui defaults. */ - public void loadGlobals(final Properties properties, final UIDefaults currentDefaults) { - PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, "globals", "properties/"), - properties, currentDefaults); + public void customizeGlobals(final Properties properties, final UIDefaults currentDefaults) { } /** - * Load the icon defaults. + * Customize the icon defaults. *

* Note: When overwriting a theme you also have overwrite {@link #getLoaderClass()} to return the class of the theme * you are overwriting. In this case you should use {@link #loadWithClass(String, Class)} instead of {@link @@ -120,12 +104,7 @@ public abstract class Theme { * @param properties the properties to load the value into. * @param currentDefaults the current ui defaults. */ - public void loadIconProperties(final Properties properties, final UIDefaults currentDefaults) { - loadIconTheme(properties, currentDefaults); - for (String property : ICON_PROPERTIES) { - PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, property, "properties/icons/"), - properties, currentDefaults); - } + public void customizeIconTheme(final Properties properties, final UIDefaults currentDefaults) { } /** @@ -138,15 +117,15 @@ public abstract class Theme { * @param properties the properties to load the value into. * @param currentDefaults the current ui defaults. */ - protected void loadIconTheme(final Properties properties, final UIDefaults currentDefaults) { + public void loadIconTheme(final Properties properties, final UIDefaults currentDefaults) { PresetIconRule iconTheme = getPresetIconRule(); Properties props; switch (iconTheme) { case DARK: - props = PropertyLoader.loadProperties(DarkLaf.class, "dark_icons", "properties/icons/presets/"); + props = PropertyLoader.loadProperties(Theme.class, "dark_icons", "icon_presets/"); break; case LIGHT: - props = PropertyLoader.loadProperties(DarkLaf.class, "light_icons", "properties/icons/presets/"); + props = PropertyLoader.loadProperties(Theme.class, "light_icons", "icon_presets/"); break; case NONE: default: @@ -156,7 +135,7 @@ public abstract class Theme { } /** - * Load the platform defaults. + * Customize the platform defaults. *

* Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} instead of {@link * #load(String)}. @@ -164,17 +143,11 @@ public abstract class Theme { * @param properties the properties to load the values into. * @param currentDefaults the current ui defaults. */ - public void loadPlatformProperties(final Properties properties, final UIDefaults currentDefaults) { - PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, getOsName(), "properties/platform/"), - properties, currentDefaults); - } - - private String getOsName() { - return SystemInfo.isMac ? "mac" : SystemInfo.isWindows ? "windows" : "linux"; + public void customizePlatformProperties(final Properties properties, final UIDefaults currentDefaults) { } /** - * Load the ui defaults. + * Customize the ui defaults. *

* Note: When overwriting a theme you should use {@link #loadWithClass(String, Class)} instead of {@link * #load(String)}. @@ -182,11 +155,7 @@ public abstract class Theme { * @param properties the properties to load the values into. * @param currentDefaults the current ui defaults. */ - public void loadUIProperties(final Properties properties, final UIDefaults currentDefaults) { - for (String property : UI_PROPERTIES) { - PropertyLoader.putProperties(PropertyLoader.loadProperties(DarkLaf.class, property, "properties/ui/"), - properties, currentDefaults); - } + public void customizeUIProperties(final Properties properties, final UIDefaults currentDefaults) { } /** diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/ThemeProvider.java b/theme/src/main/java/com/github/weisj/darklaf/theme/ThemeProvider.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/ThemeProvider.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/ThemeProvider.java diff --git a/core/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java b/theme/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java similarity index 100% rename from core/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java rename to theme/src/main/java/com/github/weisj/darklaf/theme/UnsupportedThemeException.java diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_defaults.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_styleSheet.css b/theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_styleSheet.css similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_styleSheet.css rename to theme/src/main/resources/com/github/weisj/darklaf/theme/darcula/darcula_styleSheet.css diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_defaults.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_icons.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_platform.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_styleSheet.css b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_styleSheet.css similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_styleSheet.css rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_styleSheet.css diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_dark/high_contrast_dark_ui.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_defaults.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_icons.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_platform.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_styleSheet.css b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_styleSheet.css similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_styleSheet.css rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_styleSheet.css diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/high_contrast_light/high_contrast_light_ui.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/presets/dark_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/dark_icons.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/properties/icons/presets/dark_icons.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/dark_icons.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/properties/icons/presets/light_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/light_icons.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/properties/icons/presets/light_icons.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/icon_presets/light_icons.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_defaults.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_styleSheet.css b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_styleSheet.css similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_styleSheet.css rename to theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_styleSheet.css diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/intellij/intellij_ui.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_defaults.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_icons.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_styleSheet.css b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_styleSheet.css similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_styleSheet.css rename to theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_styleSheet.css diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_dark/solarized_dark_ui.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_defaults.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_icons.properties diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_styleSheet.css b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_styleSheet.css similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_styleSheet.css rename to theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_styleSheet.css diff --git a/core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties similarity index 100% rename from core/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties rename to theme/src/main/resources/com/github/weisj/darklaf/theme/solarized_light/solarized_light_ui.properties