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
FlatLaf: change accent color in Options dialog (Appearance > FlatLaf) #5795
Conversation
BTW we can of course use other predefined accent colors. Maybe some from the Windows 11 accent colors. Suggestions are welcome. To try various accent colors I recommend using FlatLaf Theme Editor because it has live preview and a color picker: To do so, create/open an empty directory in theme editor, create two properties files, one for light and one for dark, and add following:
Theme Editor preview now looks like this: Select "Focused" checkbox to show all preview components in focused state. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to do a UI for exactly this after doing the initial properties file support. Generally in favour.
Isn't the fact that the accent color in the properties files is ignored in the Cupertino themes a bug in FlatLaf?
Ideally we'd find a way to store the setting in the properties file, rather than Preferences. I initially wanted to find a way to have 2-way editing (UI and text) for that. And load/save support (eg. share NetBeans themes). The file is deliberately read from the system config filesystem too, eg. so that platform developers can provide an alternative non-empty implementation via the layer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! How does this setting interact with other ways of manipulating FlatLAF properties, such as the "Edit custom properties" button, or changing platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLightLaf.properties/FlatDarkLaf.properties? If the color is left at "default", is the behavior the same as before?
Code formatting: Tabs in the patch should be replaced by four spaces as in the rest of the file.
(In the future it would be cool if the entire FlatLAF Theme Editor could just be exposed from a button in the Options dialog.)
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLafOptionsPanel.java
Outdated
Show resolved
Hide resolved
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLafOptionsPanel.java
Outdated
Show resolved
Hide resolved
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLafPrefs.java
Show resolved
Hide resolved
43fed35
to
70e652e
Compare
The accent color is stored in NB preferences store and overrides
Yes. |
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/Installer.java
Outdated
Show resolved
Hide resolved
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLafPrefs.java
Outdated
Show resolved
Hide resolved
70e652e
to
1cd2a7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the latest version of the patch and it works, including the following cases:
- Selecting the default accent color after previously having one of the other presets selected
- Overriding with the "Edit custom properties" button. If the accent color is set here, it overrides the setting from the combo box, which makes sense given the label over the button. Removing the accent color from the properties file makes the combo box choice work again.
- Custom accent color from color chooser works.
One small hiccup:
- Picking a different accent color and switching to Cupertino Light works except: The user now gets two "Restart IDE" notifications, and if they restart from the one that was triggered by the accent color change, they won't have the chance to get the effect of "Switch to matching editor colors profile."
Not sure it's worth doing something about the latter case, though, unless it's trivial to fix...
1cd2a7a
to
e2c1ee7
Compare
I think it is difficult to avoid the two notifications because they are implemented in different modules. However I've changed the priority of the "accent color" notification from HIGH to NORMAL. |
@DevCharly Great, that probably improves usability for this corner case. Thanks! |
The But wouldn't say it is a bug. It's more a design decision to use But I must confess that I have not considered the NetBeans use case... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
played with it a bit and it worked great. (code looks good too)
please merge when ready to reduce PR backlog before freeze.
Since changing accent color in FlatLaf custom properties does not work as expected for Cupertino themes (see issue #5461),
I've added a combobox to the options dialog to allow setting accent color in UI. FlatLaf API is used to enable accent color so that it works correctly in Cupertino themes.
There are some predefined accent colors, which work good for light and dark themes. These are the same colors that macOS (and FlatLaf Demo app) uses. There is also a "Custom" item in the combobox that allows to set any color.
The colors are defined in
FlatLaf.properties
(keynb.accentColors.predefined
).