From caf2cd8487088a1fa5590961171781474609d200 Mon Sep 17 00:00:00 2001 From: Karl Tauber Date: Mon, 27 Sep 2021 12:24:45 +0200 Subject: [PATCH] Accent color: fixed text colors if using light accent color (issue #233) --- .../formdev/flatlaf/FlatDarkLaf.properties | 20 +++++++++---------- .../formdev/flatlaf/FlatLightLaf.properties | 19 +++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties index 0d459064..7845d865 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatDarkLaf.properties @@ -35,8 +35,8 @@ @background = #3c3f41 @foreground = #bbb @selectionBackground = @accentSelectionBackground -@selectionForeground = @foreground -@selectionInactiveBackground =spin(saturate(shade(@selectionBackground,70%),20%),-15) +@selectionForeground = contrast(@selectionBackground,@background,@foreground,39%) +@selectionInactiveBackground = spin(saturate(shade(@selectionBackground,70%),20%),-15) @selectionInactiveForeground = @foreground @disabledText = #888 @textComponentBackground = #45494A @@ -54,12 +54,12 @@ @accentColor = null @accentBaseColor = #4B6EAF # accent color variations -@accentFocusColor = if(@accentColor, @accentColor, shade(spin(@accentBaseColor,-8),20%)) -@accentLinkColor = if(@accentColor, @accentColor, lighten(saturate(spin(@accentBaseColor,-5),50%),16%)) -@accentSelectionBackground = if(@accentColor, @accentColor, @accentBaseColor) -@accentSliderColor = if(@accentColor, @accentColor, @accentUnderlineColor) -@accentUnderlineColor = if(@accentColor, @accentColor, lighten(saturate(spin(@accentBaseColor,-8),13%),5%)) -@accentButtonDefaultBackground = if(@accentColor, @accentColor, darken(spin(@accentBaseColor,-8),13%)) +@accentFocusColor = if(@accentColor, @accentColor, shade(spin(@accentBaseColor,-8),20%)) +@accentLinkColor = if(@accentColor, @accentColor, lighten(saturate(spin(@accentBaseColor,-5),50%),16%)) +@accentSelectionBackground = if(@accentColor, @accentColor, @accentBaseColor) +@accentSliderColor = if(@accentColor, @accentColor, @accentUnderlineColor) +@accentUnderlineColor = if(@accentColor, @accentColor, lighten(saturate(spin(@accentBaseColor,-8),13%),5%)) +@accentButtonDefaultBackground = if(@accentColor, @accentColor, darken(spin(@accentBaseColor,-8),13%)) # for buttons within components (e.g. combobox or spinner) @buttonArrowColor = #9A9DA1 @@ -100,7 +100,7 @@ Button.hoverBorderColor = $Button.focusedBorderColor Button.innerFocusWidth = 1 Button.default.background = @accentButtonDefaultBackground -Button.default.foreground = @foreground +Button.default.foreground = contrast($Button.default.background,@background,@foreground,25%) Button.default.hoverBackground = lighten($Button.default.background,3%,derived) Button.default.pressedBackground = lighten($Button.default.background,6%,derived) Button.default.borderColor = tint($Button.default.background,15%) @@ -240,8 +240,8 @@ PopupMenu.borderColor = #5e5e5e ProgressBar.background = #555 ProgressBar.foreground = @accentSliderColor -ProgressBar.selectionForeground = @foreground ProgressBar.selectionBackground = @foreground +ProgressBar.selectionForeground = contrast($ProgressBar.foreground,@background,@foreground,39%) #---- RootPane ---- diff --git a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties index 86541caa..2bd0a9e5 100644 --- a/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties +++ b/flatlaf-core/src/main/resources/com/formdev/flatlaf/FlatLightLaf.properties @@ -35,7 +35,7 @@ @background = #f2f2f2 @foreground = #000 @selectionBackground = @accentSelectionBackground -@selectionForeground = #fff +@selectionForeground = contrast(@selectionBackground,@foreground,#fff) @selectionInactiveBackground = #d4d4d4 @selectionInactiveForeground = @foreground @disabledText = #8C8C8C @@ -54,12 +54,13 @@ @accentColor = null @accentBaseColor = #2675BF # accent color variations -@accentCheckmarkColor = if(@accentColor, @accentColor, tint(@accentSliderColor,20%)) -@accentFocusColor = if(@accentColor, @accentColor, lighten(@accentBaseColor,31%)) -@accentLinkColor = if(@accentColor, @accentColor, darken(@accentBaseColor,3%)) -@accentSelectionBackground = if(@accentColor, @accentColor, @accentBaseColor) -@accentSliderColor = if(@accentColor, @accentColor, lighten(saturate(@accentBaseColor,10%),6%)) -@accentUnderlineColor = if(@accentColor, @accentColor, tint(@accentBaseColor,10%)) +@accentCheckmarkColor = if(@accentColor, @accentColor, tint(@accentSliderColor,20%)) +@accentFocusColor = if(@accentColor, @accentColor, lighten(@accentBaseColor,31%)) +@accentLinkColor = if(@accentColor, @accentColor, darken(@accentBaseColor,3%)) +@accentSelectionBackground = if(@accentColor, @accentColor, @accentBaseColor) +@accentSliderColor = if(@accentColor, @accentColor, lighten(saturate(@accentBaseColor,10%),6%)) +@accentUnderlineColor = if(@accentColor, @accentColor, tint(@accentBaseColor,10%)) +@accentButtonDefaultBorderColor = if(@accentColor, @accentColor, tint(@accentSliderColor,20%)) # for buttons within components (e.g. combobox or spinner) @buttonArrowColor = #666 @@ -105,7 +106,7 @@ Button.default.foreground = @foreground Button.default.focusedBackground = $Button.focusedBackground Button.default.hoverBackground = darken($Button.default.background,3%,derived) Button.default.pressedBackground = darken($Button.default.background,10%,derived) -Button.default.borderColor = @accentCheckmarkColor +Button.default.borderColor = @accentButtonDefaultBorderColor Button.default.hoverBorderColor = $Button.hoverBorderColor Button.default.focusedBorderColor = $Button.focusedBorderColor Button.default.focusColor = $Component.focusColor @@ -251,8 +252,8 @@ PopupMenu.borderColor = #adadad ProgressBar.background = #D1D1D1 ProgressBar.foreground = @accentSliderColor -ProgressBar.selectionForeground = @textComponentBackground ProgressBar.selectionBackground = @foreground +ProgressBar.selectionForeground = contrast($ProgressBar.foreground,@foreground,@textComponentBackground) #---- RootPane ----