You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "DevCharly (via GitHub)" <gi...@apache.org> on 2023/04/08 00:23:30 UTC

[GitHub] [netbeans] DevCharly opened a new pull request, #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

DevCharly opened a new pull request, #5795:
URL: https://github.com/apache/netbeans/pull/5795

   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.
   
   ![grafik](https://user-images.githubusercontent.com/5604048/230694039-58bcd628-d42a-451a-b72f-2017d8e6939c.png)
   
   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.
   
   ![grafik](https://user-images.githubusercontent.com/5604048/230692669-ee92a742-d493-470a-ab04-4f594c6087c2.png)
   
   The colors are defined in `FlatLaf.properties` (key `nb.accentColors.predefined`).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on pull request #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

Posted by "eirikbakke (via GitHub)" <gi...@apache.org>.
eirikbakke commented on PR #5795:
URL: https://github.com/apache/netbeans/pull/5795#issuecomment-1504328367

   @DevCharly Great, that probably improves usability for this corner case. Thanks!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on a diff in pull request #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

Posted by "eirikbakke (via GitHub)" <gi...@apache.org>.
eirikbakke commented on code in PR #5795:
URL: https://github.com/apache/netbeans/pull/5795#discussion_r1163406496


##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/Installer.java:
##########
@@ -53,6 +53,10 @@ public void validate() throws IllegalStateException {
             FlatLaf.registerCustomDefaultsSource(customFolder.toURL());
         }
 
+		FlatLaf.setSystemColorGetter( name -> {
+			return name.equals( "accent" ) ? FlatLafPrefs.getAccentColor() : null;
+		} );

Review Comment:
   Some more tabs instead of spaces here...



##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLafPrefs.java:
##########
@@ -35,6 +37,28 @@ class FlatLafPrefs {
 
     private static final Preferences prefs = NbPreferences.forModule(FlatLafPrefs.class);
 
+	static Color getAccentColor() {
+        return parseColor(prefs.get(ACCENT_COLOR, null));
+	}
+
+	static Color parseColor(String s) {
+        try {
+            return (s != null && s.startsWith("#")) 
+                    ? new Color(Integer.parseInt(s.substring(1), 16)) 
+                    : null;
+        } catch (NumberFormatException ex) {
+            return null;
+        }
+	}

Review Comment:
   Some more tabs instead of spaces here...



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] DevCharly commented on pull request #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

Posted by "DevCharly (via GitHub)" <gi...@apache.org>.
DevCharly commented on PR #5795:
URL: https://github.com/apache/netbeans/pull/5795#issuecomment-1504308016

   > The user now gets two "Restart IDE" notifications, ...
   
   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.
   There are still two notifications, but now always the "look and feel" notification is show at the status bar.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] DevCharly commented on pull request #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

Posted by "DevCharly (via GitHub)" <gi...@apache.org>.
DevCharly commented on PR #5795:
URL: https://github.com/apache/netbeans/pull/5795#issuecomment-1505116710

   > Isn't the fact that the accent color in the properties files is ignored in the Cupertino themes a bug in FlatLaf?
   
   The `@accentColor` variable is indeed not used for all accent colors in Cupertino/macOS themes.
   
   But wouldn't say it is a bug. It's more a design decision to use `systemColor(accent)` (see PR https://github.com/JFormDesigner/FlatLaf/pull/607) as common way to get accent color (e.g. from operating system or from app preferences).
   
   But I must confess that I have not considered the NetBeans use case... 
   Probably will rework Cupertino themes...
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] eirikbakke commented on a diff in pull request #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

Posted by "eirikbakke (via GitHub)" <gi...@apache.org>.
eirikbakke commented on code in PR #5795:
URL: https://github.com/apache/netbeans/pull/5795#discussion_r1161342975


##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLafOptionsPanel.java:
##########
@@ -51,9 +64,49 @@ public class FlatLafOptionsPanel extends javax.swing.JPanel {
     public FlatLafOptionsPanel(FlatLafOptionsPanelController controller) {
         this.controller = controller;
         initComponents();
+		initAccentColor();

Review Comment:
   Some indent problems in this patch/file (mix of tabs and spaces). Existing indents are spaces, so maybe use spaces.



##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLafOptionsPanel.java:
##########
@@ -51,9 +64,49 @@ public class FlatLafOptionsPanel extends javax.swing.JPanel {
     public FlatLafOptionsPanel(FlatLafOptionsPanelController controller) {
         this.controller = controller;
         initComponents();
+		initAccentColor();
         updateEnabled();
     }
 
+	private void initAccentColor() {
+        ArrayList<String> names = new ArrayList<>();
+        ArrayList<Color> colors = new ArrayList<>();
+        names.add("default");
+        colors.add(DEFAULT);
+
+        String s = UIManager.getString("nb.accentColors.predefined");
+        if (s == null) {
+            // FlatLaf is not the current look and feel
+            Properties properties = new Properties();
+            try {
+                properties.load(getClass().getClassLoader().getResourceAsStream(
+                        "org/netbeans/swing/laf/flatlaf/FlatLaf.properties"));
+                s = properties.getProperty("nb.accentColors.predefined");
+            } catch (IOException ex) {
+                Exceptions.printStackTrace(ex);
+            }
+        }
+
+        if (s != null) {
+            for (String part : s.split(";")) {
+                int sepIndex = part.indexOf(':');
+                if (sepIndex > 1) {

Review Comment:
   Technically should be >= 1, but there are no single-character color names, so it doesn't really matter...



##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLafPrefs.java:
##########
@@ -35,6 +37,28 @@ class FlatLafPrefs {
 
     private static final Preferences prefs = NbPreferences.forModule(FlatLafPrefs.class);
 
+	static Color getAccentColor() {
+        return parseColor(prefs.get(ACCENT_COLOR, null));

Review Comment:
   What happens in this case when the "default" color was selected? Does the accent color then end up being taken from the various FlatLAF.properties files, or does it end up being explicitly set to the zero-alpha DEFAULT color, with invisible accents?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] DevCharly commented on pull request #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

Posted by "DevCharly (via GitHub)" <gi...@apache.org>.
DevCharly commented on PR #5795:
URL: https://github.com/apache/netbeans/pull/5795#issuecomment-1500848703

   BTW we can of course use other predefined accent colors. Maybe some from the Windows 11 accent colors. Suggestions are welcome.
   
   ![grafik](https://user-images.githubusercontent.com/5604048/230713965-945511af-411a-4b45-a6bd-15b80b7c1625.png)
   
   To try various accent colors I recommend using [FlatLaf Theme Editor](https://www.formdev.com/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:
   
   ~~~
   @accentColor = #FF453A
   ~~~
   
   Theme Editor preview now looks like this:
   
   ![grafik](https://user-images.githubusercontent.com/5604048/230714435-f8d9894f-5279-4db3-8e7d-8e13a81af92f.png)
   
   Select "Focused" checkbox to show all preview components in focused state.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] DevCharly commented on pull request #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

Posted by "DevCharly (via GitHub)" <gi...@apache.org>.
DevCharly commented on PR #5795:
URL: https://github.com/apache/netbeans/pull/5795#issuecomment-1504112946

   > 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?
   
   The accent color is stored in NB preferences store and overrides `@accentColor`.
   Function `systemColor(accent)` is used in properties files to get this color into FlatLaf UI defaults.
   See PR https://github.com/JFormDesigner/FlatLaf/pull/607
   
   > If the color is left at "default", is the behavior the same as before?
   
   Yes.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


[GitHub] [netbeans] mbien merged pull request #5795: FlatLaf: change accent color in Options dialog (Appearance > FlatLaf)

Posted by "mbien (via GitHub)" <gi...@apache.org>.
mbien merged PR #5795:
URL: https://github.com/apache/netbeans/pull/5795


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists