|
|
@ -24,6 +24,7 @@ package com.github.weisj.darklaf.platform.windows; |
|
|
|
import java.awt.*; |
|
|
|
import java.awt.*; |
|
|
|
import java.util.function.Consumer; |
|
|
|
import java.util.function.Consumer; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.github.weisj.darklaf.color.DarkColorModelHSB; |
|
|
|
import com.github.weisj.darklaf.theme.info.*; |
|
|
|
import com.github.weisj.darklaf.theme.info.*; |
|
|
|
|
|
|
|
|
|
|
|
public class WindowsThemePreferenceProvider implements ThemePreferenceProvider { |
|
|
|
public class WindowsThemePreferenceProvider implements ThemePreferenceProvider { |
|
|
@ -48,10 +49,18 @@ public class WindowsThemePreferenceProvider implements ThemePreferenceProvider { |
|
|
|
ContrastRule contrastRule = highContrast ? ContrastRule.HIGH_CONTRAST : ContrastRule.STANDARD; |
|
|
|
ContrastRule contrastRule = highContrast ? ContrastRule.HIGH_CONTRAST : ContrastRule.STANDARD; |
|
|
|
ColorToneRule toneRule = darkMode ? ColorToneRule.DARK : ColorToneRule.LIGHT; |
|
|
|
ColorToneRule toneRule = darkMode ? ColorToneRule.DARK : ColorToneRule.LIGHT; |
|
|
|
FontSizeRule fontSizeRule = FontSizeRule.relativeAdjustment(fontScaling / 100f); |
|
|
|
FontSizeRule fontSizeRule = FontSizeRule.relativeAdjustment(fontScaling / 100f); |
|
|
|
AccentColorRule accentColorRule = AccentColorRule.fromColor(createColorFromRGB(accentColorRGB)); |
|
|
|
Color accentColor = createColorFromRGB(accentColorRGB); |
|
|
|
|
|
|
|
Color selectionColor = deriveSelectionColor(accentColor); |
|
|
|
|
|
|
|
AccentColorRule accentColorRule = AccentColorRule.fromColor(accentColor, selectionColor); |
|
|
|
return new PreferredThemeStyle(contrastRule, toneRule, accentColorRule, fontSizeRule); |
|
|
|
return new PreferredThemeStyle(contrastRule, toneRule, accentColorRule, fontSizeRule); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Color deriveSelectionColor(final Color color) { |
|
|
|
|
|
|
|
if (color == null) return null; |
|
|
|
|
|
|
|
double[] hsb = DarkColorModelHSB.RGBtoHSBValues(color.getRed(), color.getGreen(), color.getBlue()); |
|
|
|
|
|
|
|
return DarkColorModelHSB.getColorFromHSBValues(hsb[0], hsb[1] / 2.5, Math.min(1, hsb[2] * 1.2)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Color createColorFromRGB(final int rgb) { |
|
|
|
private Color createColorFromRGB(final int rgb) { |
|
|
|
if (rgb == 0) return null; |
|
|
|
if (rgb == 0) return null; |
|
|
|
return new Color(rgb); |
|
|
|
return new Color(rgb); |
|
|
@ -98,6 +107,12 @@ public class WindowsThemePreferenceProvider implements ThemePreferenceProvider { |
|
|
|
return WindowsLibrary.get().isLoaded(); |
|
|
|
return WindowsLibrary.get().isLoaded(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean supportsNativeSelectionColor() { |
|
|
|
|
|
|
|
// Depends on accent color as it is derived from it.
|
|
|
|
|
|
|
|
return supportsNativeAccentColor(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean supportsNativeFontSize() { |
|
|
|
public boolean supportsNativeFontSize() { |
|
|
|
return WindowsLibrary.get().isLoaded(); |
|
|
|
return WindowsLibrary.get().isLoaded(); |
|
|
|