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 71ce890d..31368e32 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 @@ -66,8 +66,9 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { private void loadThemeDefaults(final Theme currentTheme, final UIDefaults defaults) { Properties uiProps = new Properties(); - currentTheme.loadDefaults(uiProps, defaults, DarkUIUtil.iconResolver()); + initPlatformPredefinitions(uiProps, defaults); + currentTheme.loadDefaults(uiProps, defaults, DarkUIUtil.iconResolver()); backupAccentColors(uiProps); /* @@ -96,6 +97,17 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { defaults.putAll(uiProps); } + private void initPlatformPredefinitions(final Properties uiProps, final UIDefaults defaults) { + IconResolver iconResolver = DarkUIUtil.iconResolver(); + Consumer osPlatformLoader = osName -> PropertyLoader.putProperties( + PropertyLoader.loadProperties( + DarkLaf.class, osName, "nativelaf/", + PropertyLoader.LoadMode.AllowMissing), + uiProps, defaults, iconResolver); + osPlatformLoader.accept("predef_base"); + setupOSSpecific("predef_", osPlatformLoader); + } + private void backupAccentColors(final Properties uiProps) { uiProps.put(ACCENT_COLOR_BACKUP_KEY, Objects.requireNonNull( uiProps.get(ACCENT_COLOR_SOURCE_KEY), ACCENT_COLOR_SOURCE_KEY)); @@ -162,13 +174,9 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { private void initPlatformProperties(final Theme currentTheme, final UIDefaults defaults, final Properties uiProps) { IconResolver iconResolver = DarkUIUtil.iconResolver(); - Consumer osPlatformLoader = osName -> PropertyLoader.putProperties( + setupOSSpecific("", osName -> PropertyLoader.putProperties( PropertyLoader.loadProperties(DarkLaf.class, osName, "nativelaf/"), - uiProps, defaults, iconResolver); - osPlatformLoader.accept(getOsName()); - if (SystemInfo.isWindows11()) { - osPlatformLoader.accept("windows11"); - } + uiProps, defaults, iconResolver)); currentTheme.customizePlatformProperties(uiProps, defaults, iconResolver); } @@ -177,6 +185,13 @@ public class ThemeDefaultsInitTask implements DefaultsInitTask { return osName != null ? osName : SystemInfo.getOsName(); } + private void setupOSSpecific(final String prefix, final Consumer setupFunction) { + setupFunction.accept(prefix + getOsName()); + if (SystemInfo.isWindows11()) { + setupFunction.accept(prefix + "windows11"); + } + } + private void adjustPlatformSpecifics(final Properties uiProps) { PropertyUtil.installSystemProperty(MAC_OS_MENU_BAR_KEY, "true"); boolean useScreenMenuBar = Boolean.getBoolean(MAC_OS_MENU_BAR_KEY); diff --git a/core/src/main/resources/com/github/weisj/darklaf/nativelaf/predef_base.properties b/core/src/main/resources/com/github/weisj/darklaf/nativelaf/predef_base.properties new file mode 100644 index 00000000..1d880b1a --- /dev/null +++ b/core/src/main/resources/com/github/weisj/darklaf/nativelaf/predef_base.properties @@ -0,0 +1,30 @@ +# MIT License +# +# Copyright (c) 2019-2023 Jannis Weis +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +# +# suppress inspection "UnusedProperty" for whole file +%os_arc = 5 +%os_arcFocus = 5 +%os_arcSecondary = 3 +%os_arcSecondaryFocus = 3 + +%os_borderThickness = 2 +%os_shadowHeight = 2 diff --git a/core/src/test/resources/com/github/weisj/darklaf/core/theme/my_custom_theme_defaults.properties b/core/src/test/resources/com/github/weisj/darklaf/core/theme/my_custom_theme_defaults.properties index 849afe84..e3457372 100644 --- a/core/src/test/resources/com/github/weisj/darklaf/core/theme/my_custom_theme_defaults.properties +++ b/core/src/test/resources/com/github/weisj/darklaf/core/theme/my_custom_theme_defaults.properties @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2019-2021 Jannis Weis +# Copyright (c) 2019-2023 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -131,10 +131,10 @@ %glowWarningLine = #F6CA7C #Arc -%arc = 5 -%arcFocus = 5 -%arcSecondary = 3 -%arcSecondaryFocus = 3 +%arc = %os_arc +%arcFocus = %os_arcFocus +%arcSecondary = %os_arcSecondary +%arcSecondaryFocus = %os_arcSecondaryFocus -%borderThickness = 2 -%shadowHeight = 2 +%borderThickness = %os_borderThickness +%shadowHeight = %os_shadowHeight diff --git a/property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java b/property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java index 5b7139cf..55d63181 100644 --- a/property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java +++ b/property-loader/src/main/java/com/github/weisj/darklaf/properties/PropertyLoader.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019-2021 Jannis Weis + * Copyright (c) 2019-2023 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -42,17 +42,30 @@ import com.github.weisj.darklaf.util.*; * @author Jannis Weis */ public final class PropertyLoader { + + public enum LoadMode { + Strict, + AllowMissing + } + private static final Logger LOGGER = LogUtil.getLogger(PropertyLoader.class); private static final char REFERENCE_PREFIX = '%'; public static Properties loadProperties(final Class clazz, final String name, final String path) { + return loadProperties(clazz, name, path, LoadMode.Strict); + } + + public static Properties loadProperties(final Class clazz, final String name, final String path, + final LoadMode mode) { final Properties properties = new Properties(); String p = path + name + ".properties"; try (InputStream stream = clazz.getResourceAsStream(p)) { properties.load(stream); } catch (IOException | NullPointerException e) { - LOGGER.log(Level.SEVERE, "Could not load " + p + " " + e.getMessage(), e); + if (mode == LoadMode.Strict) { + LOGGER.log(Level.SEVERE, "Could not load " + p + " " + e.getMessage(), e); + } } return properties; } diff --git a/theme/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 index 6f0bef2d..a52fb4da 100644 --- a/theme/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 @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2019-2021 Jannis Weis +# Copyright (c) 2019-2023 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -155,10 +155,10 @@ Theme.highContrast = false %glowWarningLine = #6e5324 #Arc -%arc = 5 -%arcFocus = 5 -%arcSecondary = 3 -%arcSecondaryFocus = 3 +%arc = %os_arc +%arcFocus = %os_arcFocus +%arcSecondary = %os_arcSecondary +%arcSecondaryFocus = %os_arcSecondaryFocus -%borderThickness = 2 -%shadowHeight = 2 +%borderThickness = %os_borderThickness +%shadowHeight = %os_shadowHeight diff --git a/theme/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 index bbfa5704..d56b75c2 100644 --- a/theme/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 @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2020-2021 Jannis Weis +# Copyright (c) 2020-2023 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -155,10 +155,10 @@ Theme.highContrast = true %glowWarningLine = #F58231 #Arc -%arc = 5 -%arcFocus = 5 -%arcSecondary = 3 -%arcSecondaryFocus = 3 +%arc = %os_arc +%arcFocus = %os_arcFocus +%arcSecondary = %os_arcSecondary +%arcSecondaryFocus = %os_arcSecondaryFocus -%borderThickness = 2 -%shadowHeight = 2 +%borderThickness = %os_borderThickness +%shadowHeight = %os_shadowHeight diff --git a/theme/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 index 857edd41..431722d5 100644 --- a/theme/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 @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2020-2021 Jannis Weis +# Copyright (c) 2020-2023 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -155,10 +155,10 @@ Theme.highContrast = true %glowWarningLine = #CE5B0A #Arc -%arc = 5 -%arcFocus = 5 -%arcSecondary = 3 -%arcSecondaryFocus = 3 +%arc = %os_arc +%arcFocus = %os_arcFocus +%arcSecondary = %os_arcSecondary +%arcSecondaryFocus = %os_arcSecondaryFocus -%borderThickness = 2 -%shadowHeight = 2 +%borderThickness = %os_borderThickness +%shadowHeight = %os_shadowHeight diff --git a/theme/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 index e5707a25..12ec4392 100644 --- a/theme/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 @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2019-2021 Jannis Weis +# Copyright (c) 2019-2023 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -157,10 +157,10 @@ Theme.highContrast = false %glowWarningLine = #ffd385 #Arc -%arc = 5 -%arcFocus = 5 -%arcSecondary = 3 -%arcSecondaryFocus = 3 +%arc = %os_arc +%arcFocus = %os_arcFocus +%arcSecondary = %os_arcSecondary +%arcSecondaryFocus = %os_arcSecondaryFocus -%borderThickness = 2 -%shadowHeight = 2 +%borderThickness = %os_borderThickness +%shadowHeight = %os_shadowHeight diff --git a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties index 7c0f3b71..9f376916 100644 --- a/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties +++ b/theme/src/main/resources/com/github/weisj/darklaf/theme/one_dark/one_dark_defaults.properties @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2020-2021 Jannis Weis +# Copyright (c) 2020-2023 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -155,10 +155,10 @@ Theme.highContrast = false %glowWarningLine = #5f4422 #Arc -%arc = 5 -%arcFocus = 5 -%arcSecondary = 3 -%arcSecondaryFocus = 3 +%arc = %os_arc +%arcFocus = %os_arcFocus +%arcSecondary = %os_arcSecondary +%arcSecondaryFocus = %os_arcSecondaryFocus -%borderThickness = 2 -%shadowHeight = 2 +%borderThickness = %os_borderThickness +%shadowHeight = %os_shadowHeight diff --git a/theme/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 index eebb99ef..64cf99d5 100644 --- a/theme/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 @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2019-2021 Jannis Weis +# Copyright (c) 2019-2023 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -156,10 +156,10 @@ Theme.highContrast = false %glowWarningLine = #93A16A #Arc -%arc = 5 -%arcFocus = 5 -%arcSecondary = 3 -%arcSecondaryFocus = 3 +%arc = %os_arc +%arcFocus = %os_arcFocus +%arcSecondary = %os_arcSecondary +%arcSecondaryFocus = %os_arcSecondaryFocus -%borderThickness = 2 -%shadowHeight = 2 +%borderThickness = %os_borderThickness +%shadowHeight = %os_shadowHeight diff --git a/theme/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 index 247d0bb3..de3e28aa 100644 --- a/theme/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 @@ -1,6 +1,6 @@ # MIT License # -# Copyright (c) 2019-2021 Jannis Weis +# Copyright (c) 2019-2023 Jannis Weis # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -155,10 +155,10 @@ Theme.highContrast = false %glowWarningLine = #F6CA7C #Arc -%arc = 5 -%arcFocus = 5 -%arcSecondary = 3 -%arcSecondaryFocus = 3 +%arc = %os_arc +%arcFocus = %os_arcFocus +%arcSecondary = %os_arcSecondary +%arcSecondaryFocus = %os_arcSecondaryFocus -%borderThickness = 2 -%shadowHeight = 2 +%borderThickness = %os_borderThickness +%shadowHeight = %os_shadowHeight