diff --git a/core/src/main/java/com/github/weisj/darklaf/settings/SettingsConfiguration.java b/core/src/main/java/com/github/weisj/darklaf/settings/SettingsConfiguration.java index 29c8d9bd..def44a10 100644 --- a/core/src/main/java/com/github/weisj/darklaf/settings/SettingsConfiguration.java +++ b/core/src/main/java/com/github/weisj/darklaf/settings/SettingsConfiguration.java @@ -73,6 +73,16 @@ public class SettingsConfiguration implements Serializable { return baseTheme.derive(fontSizeRule, getFontPrototype(), accentColorRule); } + public final PreferredThemeStyle getEffectiveThemeStyle(final PreferredThemeStyle themeStyle) { + Theme baseTheme = getEffectiveBaseTheme(themeStyle); + + FontSizeRule fontSizeRule = getEffectiveFontSizeRule(themeStyle); + AccentColorRule accentColorRule = getEffectiveAccentColorRule(baseTheme, themeStyle); + + return new PreferredThemeStyle(themeStyle.getContrastRule(), themeStyle.getColorToneRule(), + accentColorRule, fontSizeRule); + } + private AccentColorRule getEffectiveAccentColorRule(final Theme baseTheme, final PreferredThemeStyle preferredThemeStyle) { AccentColorRule accentColorRule = getAccentColorRule(); @@ -81,10 +91,10 @@ public class SettingsConfiguration implements Serializable { AccentColorRule systemAccentColorRule = preferredThemeStyle.getAccentColorRule(); Color accentColor = accentColorRule.getAccentColor(); Color selectionColor = accentColorRule.getSelectionColor(); - if (isAccentColorFollowsSystem() && baseTheme.supportsCustomAccentColor()) { + if (isAccentColorFollowsSystem() && (baseTheme == null || baseTheme.supportsCustomAccentColor())) { accentColor = systemAccentColorRule.getAccentColor(); } - if (isSelectionColorFollowsSystem() && baseTheme.supportsCustomSelectionColor()) { + if (isSelectionColorFollowsSystem() && (baseTheme == null || baseTheme.supportsCustomSelectionColor())) { selectionColor = systemAccentColorRule.getSelectionColor(); } diff --git a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java index 527d9dde..0b1ae15f 100644 --- a/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java +++ b/core/src/main/java/com/github/weisj/darklaf/settings/ThemeSettings.java @@ -38,6 +38,7 @@ import com.github.weisj.darklaf.theme.event.ThemePreferenceListener; import com.github.weisj.darklaf.theme.spec.AccentColorRule; import com.github.weisj.darklaf.theme.spec.FontPrototype; import com.github.weisj.darklaf.theme.spec.FontSizeRule; +import com.github.weisj.darklaf.theme.spec.PreferredThemeStyle; import com.github.weisj.darklaf.ui.util.DarkUIUtil; import com.github.weisj.darklaf.ui.util.UIThread; import com.github.weisj.darklaf.util.LazyValue; @@ -496,6 +497,16 @@ public class ThemeSettings implements ThemePreferenceListener { applyTheme(currentConfiguration.getEffectiveTheme()); } + /** + * Compute the effective preferred theme style adhering to the current ThemeSettings + * + * @param style the preferred theme style prototype + * @return the effective preferred theme style + */ + public PreferredThemeStyle computeEffectiveStyle(final PreferredThemeStyle style) { + return currentConfiguration.getEffectiveThemeStyle(style); + } + /** * Revert the settings to the last time they have been saved. *