Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemColor() function and support changing accent color in macOS themes #607

Merged
merged 3 commits into from Nov 14, 2022

Conversation

DevCharly
Copy link
Collaborator

This PR adds a systemColor() function to FlatLaf properties files, that can be used to change accent color (or other colors). It is also a preparation for getting accent color from operating system later.

Syntax: systemColor(name[,defaultValue])

Parameters:

  • name: system color name (this can be any name)
  • defaultValue: default color value used if system color is not available

E.g.

@accentColor = systemColor(accent,#00f)

Where does FlatLaf get the system color from?
Well, it does not get it from the operating system 😞
You have to define a getter function that is invoked when a systemColor() function is found in FlatLaf properties.
E.g.:

FlatLaf.setSystemColorGetter( name -> {
    return name.equals( "accent" ) ? Color.red : null;
} );

This must be done before invoking FlatLightLaf.setup().

As soon as light/dark switching feature is implemented (sponsors wanted 😉 ),
above can be changed to following, which gets accent color from operating system:

FlatLaf.setSystemColorGetter( name -> {
    switch( name ) {
        case "accent":    return SystemTheming.getAccentColor();
        case "highlight": return SystemTheming.getHighlightColor();
        default:          return null;
    }
} );

This PR also adds support for changing accent and highlight colors in macOS themes (PR #533):

image

image

…ort `null` as result (preparation for systemColor() function)
… to change accent color (preparation for getting accent color from operating system)
@DevCharly DevCharly added this to the 3.0 milestone Nov 2, 2022
@DevCharly DevCharly merged commit 1e09ddf into main Nov 14, 2022
@DevCharly DevCharly deleted the system-color-function branch November 14, 2022 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant