Skip to content

Commit

Permalink
macOS themes: support changing accent and highlight colors (issue #497)
Browse files Browse the repository at this point in the history
  • Loading branch information
DevCharly committed Nov 2, 2022
1 parent c7bfd2e commit 664f5c9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Expand Up @@ -88,21 +88,21 @@
@menuBackground = lighten(@background,8%)

# selection
@selectionBackground = @nsSelectedContentBackgroundColor
@selectionBackground = if(systemColor(accent), shade(spin(systemColor(accent),4),20%), @nsSelectedContentBackgroundColor)
@selectionForeground = @nsSelectedMenuItemTextColor
@selectionInactiveBackground = @nsUnemphasizedSelectedContentBackgroundColor

# text selection
@textSelectionBackground = @nsSelectedTextBackgroundColor
@textSelectionBackground = systemColor(highlight,if(systemColor(accent), darken(desaturate(systemColor(accent),60%),10%), @nsSelectedTextBackgroundColor))
@textSelectionForeground = @nsSelectedTextColor

# menu
@menuSelectionBackground = desaturate(@selectionBackground,20%)
@menuItemMargin = 3,11,3,11

# accent colors (blueish)
@accentColor = @nsControlAccentColor
@accentFocusColor = @nsKeyboardFocusIndicatorColor
@accentColor = systemColor(accent,@nsControlAccentColor)
@accentFocusColor = if(systemColor(accent), fade(spin(systemColor(accent),-10),50%), @nsKeyboardFocusIndicatorColor)


#---- Button ----
Expand Down
Expand Up @@ -88,12 +88,12 @@
@menuBackground = darken(@background,4%)

# selection
@selectionBackground = @nsSelectedContentBackgroundColor
@selectionBackground = if(systemColor(accent), shade(spin(systemColor(accent),4),10%), @nsSelectedContentBackgroundColor)
@selectionForeground = @nsSelectedMenuItemTextColor
@selectionInactiveBackground = @nsUnemphasizedSelectedContentBackgroundColor

# text selection
@textSelectionBackground = @nsSelectedTextBackgroundColor
@textSelectionBackground = systemColor(highlight,if(systemColor(accent), tint(systemColor(accent),70%), @nsSelectedTextBackgroundColor))
@textSelectionForeground = @foreground

# menu
Expand All @@ -102,8 +102,8 @@
@menuItemMargin = 3,11,3,11

# accent colors (blueish)
@accentColor = @nsControlAccentColor
@accentFocusColor = @nsKeyboardFocusIndicatorColor
@accentColor = systemColor(accent,@nsControlAccentColor)
@accentFocusColor = if(systemColor(accent), fade(spin(systemColor(accent),4),50%), @nsKeyboardFocusIndicatorColor)


#---- Button ----
Expand Down
Expand Up @@ -44,6 +44,8 @@
import com.formdev.flatlaf.extras.components.FlatButton;
import com.formdev.flatlaf.extras.components.FlatButton.ButtonType;
import com.formdev.flatlaf.icons.FlatAbstractIcon;
import com.formdev.flatlaf.themes.FlatMacDarkLaf;
import com.formdev.flatlaf.themes.FlatMacLightLaf;
import com.formdev.flatlaf.extras.FlatSVGUtils;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.ui.JBRCustomDecorations;
Expand Down Expand Up @@ -455,7 +457,9 @@ private void updateAccentColorButtons() {
lafClass == FlatLightLaf.class ||
lafClass == FlatDarkLaf.class ||
lafClass == FlatIntelliJLaf.class ||
lafClass == FlatDarculaLaf.class;
lafClass == FlatDarculaLaf.class ||
lafClass == FlatMacLightLaf.class ||
lafClass == FlatMacDarkLaf.class;

accentColorLabel.setVisible( isAccentColorSupported );
for( int i = 0; i < accentColorButtons.length; i++ )
Expand Down

0 comments on commit 664f5c9

Please sign in to comment.