You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/04/17 13:11:44 UTC

[GitHub] [netbeans] eirikbakke opened a new pull request, #3992: Improve vertical centering of FlatLAF buttons on Windows

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

   On FlatLAF on Windows, improve vertical centering of labels in buttons. The solution was to make the buttons one pixel taller, as was done in the standard Swing Windows LAF.
   
   See before/after screenshots below.
   
   ![image](https://user-images.githubusercontent.com/886243/163715768-3842446e-1a05-4b43-a854-e9697e55a666.png)
   


-- 
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 merged pull request #3992: Improve vertical centering of FlatLAF buttons on Windows

Posted by GitBox <gi...@apache.org>.
eirikbakke merged PR #3992:
URL: https://github.com/apache/netbeans/pull/3992


-- 
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 #3992: Improve vertical centering of FlatLAF buttons on Windows

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on PR #3992:
URL: https://github.com/apache/netbeans/pull/3992#issuecomment-1167731843

   I've been using this patch in my working IDE and platform app since November now; I think it should be safe to apply.


-- 
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 #3992: Improve vertical centering of FlatLAF buttons on Windows

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on PR #3992:
URL: https://github.com/apache/netbeans/pull/3992#issuecomment-1169010384

   Applied fixes, tested on Windows with latest master to confirm that the adjustment still is applied. Now waiting for build checks...


-- 
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 #3992: Improve vertical centering of FlatLAF buttons on Windows

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on code in PR #3992:
URL: https://github.com/apache/netbeans/pull/3992#discussion_r908630386


##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java:
##########
@@ -120,6 +129,34 @@ public Object[] createApplicationSpecificKeysAndValues() {
             "Table.ancestorInputMap.RightToLeft", new LazyModifyInputMap( "Table.ancestorInputMap.RightToLeft", removeCtrlPageUpDownKeyBindings ), // NOI18N
             "Tree.focusInputMap", new LazyModifyInputMap( "Tree.focusInputMap", removeCtrlPageUpDownKeyBindings ), // NOI18N
         };
+        List<Object> result = new ArrayList<>();
+        result.addAll(Arrays.asList(constants));
+        if (Utilities.isWindows()) {
+          /* Make sure button labels appear vertically centered on Windows. On the standard
+          Windows LAF, WindowsButtonUI/WindowsRadioButtonUI/WindowsToggleButtonUI.getPreferredSize
+          add one pixel to the button's height to ensure that it is odd-numbered. This makes the
+          text centered with either Tahoma 11 (the default Swing Windows LAF font) or Segoe UI 12
+          (the default font on modern Windows versions, and on FlatLAF on Windows). */
+          for (String key : new String[] { "Button", "RadioButton", "ToggleButton" }) {
+            UIDefaults defaults = UIManager.getDefaults();
+            Font font = defaults.getFont(key + ".font");
+            Insets bm = defaults.getInsets(key + ".margin");
+            if (font != null && bm != null &&
+                font.getFamily().equals("Segoe UI") && font.getSize() == 12)
+            {
+              if (bm.top == bm.bottom) {
+                result.add(key + ".margin");
+                /* Create an InsetsUIResource rather than an Insets instance if necessary, as
+                FlatLAF treats them differently. Not doing this caused buttons in the main toolbar
+                to become very wide. */
+                result.add(bm instanceof InsetsUIResource

Review Comment:
   Oh, sure, that makes sense. Will change it.



-- 
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] neilcsmith-net commented on a diff in pull request #3992: Improve vertical centering of FlatLAF buttons on Windows

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on code in PR #3992:
URL: https://github.com/apache/netbeans/pull/3992#discussion_r908180412


##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java:
##########
@@ -120,6 +129,34 @@ public Object[] createApplicationSpecificKeysAndValues() {
             "Table.ancestorInputMap.RightToLeft", new LazyModifyInputMap( "Table.ancestorInputMap.RightToLeft", removeCtrlPageUpDownKeyBindings ), // NOI18N
             "Tree.focusInputMap", new LazyModifyInputMap( "Tree.focusInputMap", removeCtrlPageUpDownKeyBindings ), // NOI18N
         };
+        List<Object> result = new ArrayList<>();
+        result.addAll(Arrays.asList(constants));
+        if (Utilities.isWindows()) {
+          /* Make sure button labels appear vertically centered on Windows. On the standard
+          Windows LAF, WindowsButtonUI/WindowsRadioButtonUI/WindowsToggleButtonUI.getPreferredSize
+          add one pixel to the button's height to ensure that it is odd-numbered. This makes the
+          text centered with either Tahoma 11 (the default Swing Windows LAF font) or Segoe UI 12
+          (the default font on modern Windows versions, and on FlatLAF on Windows). */
+          for (String key : new String[] { "Button", "RadioButton", "ToggleButton" }) {
+            UIDefaults defaults = UIManager.getDefaults();
+            Font font = defaults.getFont(key + ".font");
+            Insets bm = defaults.getInsets(key + ".margin");
+            if (font != null && bm != null &&
+                font.getFamily().equals("Segoe UI") && font.getSize() == 12)
+            {

Review Comment:
   Niggle : please have brace on line above.



##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java:
##########
@@ -120,6 +129,34 @@ public Object[] createApplicationSpecificKeysAndValues() {
             "Table.ancestorInputMap.RightToLeft", new LazyModifyInputMap( "Table.ancestorInputMap.RightToLeft", removeCtrlPageUpDownKeyBindings ), // NOI18N
             "Tree.focusInputMap", new LazyModifyInputMap( "Tree.focusInputMap", removeCtrlPageUpDownKeyBindings ), // NOI18N
         };
+        List<Object> result = new ArrayList<>();
+        result.addAll(Arrays.asList(constants));
+        if (Utilities.isWindows()) {
+          /* Make sure button labels appear vertically centered on Windows. On the standard
+          Windows LAF, WindowsButtonUI/WindowsRadioButtonUI/WindowsToggleButtonUI.getPreferredSize
+          add one pixel to the button's height to ensure that it is odd-numbered. This makes the
+          text centered with either Tahoma 11 (the default Swing Windows LAF font) or Segoe UI 12
+          (the default font on modern Windows versions, and on FlatLAF on Windows). */
+          for (String key : new String[] { "Button", "RadioButton", "ToggleButton" }) {
+            UIDefaults defaults = UIManager.getDefaults();
+            Font font = defaults.getFont(key + ".font");
+            Insets bm = defaults.getInsets(key + ".margin");
+            if (font != null && bm != null &&
+                font.getFamily().equals("Segoe UI") && font.getSize() == 12)
+            {
+              if (bm.top == bm.bottom) {
+                result.add(key + ".margin");
+                /* Create an InsetsUIResource rather than an Insets instance if necessary, as
+                FlatLAF treats them differently. Not doing this caused buttons in the main toolbar
+                to become very wide. */
+                result.add(bm instanceof InsetsUIResource

Review Comment:
   My inclination is that this should only ever be InsetsUIResource.  Are there instances of plain Insets?  If so, from where, and should they be replaced?



-- 
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] neilcsmith-net commented on a diff in pull request #3992: Improve vertical centering of FlatLAF buttons on Windows

Posted by GitBox <gi...@apache.org>.
neilcsmith-net commented on code in PR #3992:
URL: https://github.com/apache/netbeans/pull/3992#discussion_r908538710


##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java:
##########
@@ -120,6 +129,34 @@ public Object[] createApplicationSpecificKeysAndValues() {
             "Table.ancestorInputMap.RightToLeft", new LazyModifyInputMap( "Table.ancestorInputMap.RightToLeft", removeCtrlPageUpDownKeyBindings ), // NOI18N
             "Tree.focusInputMap", new LazyModifyInputMap( "Tree.focusInputMap", removeCtrlPageUpDownKeyBindings ), // NOI18N
         };
+        List<Object> result = new ArrayList<>();
+        result.addAll(Arrays.asList(constants));
+        if (Utilities.isWindows()) {
+          /* Make sure button labels appear vertically centered on Windows. On the standard
+          Windows LAF, WindowsButtonUI/WindowsRadioButtonUI/WindowsToggleButtonUI.getPreferredSize
+          add one pixel to the button's height to ensure that it is odd-numbered. This makes the
+          text centered with either Tahoma 11 (the default Swing Windows LAF font) or Segoe UI 12
+          (the default font on modern Windows versions, and on FlatLAF on Windows). */
+          for (String key : new String[] { "Button", "RadioButton", "ToggleButton" }) {
+            UIDefaults defaults = UIManager.getDefaults();
+            Font font = defaults.getFont(key + ".font");
+            Insets bm = defaults.getInsets(key + ".margin");
+            if (font != null && bm != null &&
+                font.getFamily().equals("Segoe UI") && font.getSize() == 12)
+            {
+              if (bm.top == bm.bottom) {
+                result.add(key + ".margin");
+                /* Create an InsetsUIResource rather than an Insets instance if necessary, as
+                FlatLAF treats them differently. Not doing this caused buttons in the main toolbar
+                to become very wide. */
+                result.add(bm instanceof InsetsUIResource

Review Comment:
   I meant more that we should probably only replace it at all if it is already a `UIResource`.



-- 
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 #3992: Improve vertical centering of FlatLAF buttons on Windows

Posted by GitBox <gi...@apache.org>.
eirikbakke commented on code in PR #3992:
URL: https://github.com/apache/netbeans/pull/3992#discussion_r908528858


##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java:
##########
@@ -120,6 +129,34 @@ public Object[] createApplicationSpecificKeysAndValues() {
             "Table.ancestorInputMap.RightToLeft", new LazyModifyInputMap( "Table.ancestorInputMap.RightToLeft", removeCtrlPageUpDownKeyBindings ), // NOI18N
             "Tree.focusInputMap", new LazyModifyInputMap( "Tree.focusInputMap", removeCtrlPageUpDownKeyBindings ), // NOI18N
         };
+        List<Object> result = new ArrayList<>();
+        result.addAll(Arrays.asList(constants));
+        if (Utilities.isWindows()) {
+          /* Make sure button labels appear vertically centered on Windows. On the standard
+          Windows LAF, WindowsButtonUI/WindowsRadioButtonUI/WindowsToggleButtonUI.getPreferredSize
+          add one pixel to the button's height to ensure that it is odd-numbered. This makes the
+          text centered with either Tahoma 11 (the default Swing Windows LAF font) or Segoe UI 12
+          (the default font on modern Windows versions, and on FlatLAF on Windows). */
+          for (String key : new String[] { "Button", "RadioButton", "ToggleButton" }) {
+            UIDefaults defaults = UIManager.getDefaults();
+            Font font = defaults.getFont(key + ".font");
+            Insets bm = defaults.getInsets(key + ".margin");
+            if (font != null && bm != null &&
+                font.getFamily().equals("Segoe UI") && font.getSize() == 12)
+            {
+              if (bm.top == bm.bottom) {
+                result.add(key + ".margin");
+                /* Create an InsetsUIResource rather than an Insets instance if necessary, as
+                FlatLAF treats them differently. Not doing this caused buttons in the main toolbar
+                to become very wide. */
+                result.add(bm instanceof InsetsUIResource

Review Comment:
   It was just a precaution, not something I observed. But since FlatLAF treats Insets and InsetsUIResource differently, I'd imagine cases where FlatLAF customizations might pick one or the other (though this would be very weird). I figured that leaving the same kind of instance was the least likely to cause problems.



##########
platform/o.n.swing.laf.flatlaf/src/org/netbeans/swing/laf/flatlaf/FlatLFCustoms.java:
##########
@@ -120,6 +129,34 @@ public Object[] createApplicationSpecificKeysAndValues() {
             "Table.ancestorInputMap.RightToLeft", new LazyModifyInputMap( "Table.ancestorInputMap.RightToLeft", removeCtrlPageUpDownKeyBindings ), // NOI18N
             "Tree.focusInputMap", new LazyModifyInputMap( "Tree.focusInputMap", removeCtrlPageUpDownKeyBindings ), // NOI18N
         };
+        List<Object> result = new ArrayList<>();
+        result.addAll(Arrays.asList(constants));
+        if (Utilities.isWindows()) {
+          /* Make sure button labels appear vertically centered on Windows. On the standard
+          Windows LAF, WindowsButtonUI/WindowsRadioButtonUI/WindowsToggleButtonUI.getPreferredSize
+          add one pixel to the button's height to ensure that it is odd-numbered. This makes the
+          text centered with either Tahoma 11 (the default Swing Windows LAF font) or Segoe UI 12
+          (the default font on modern Windows versions, and on FlatLAF on Windows). */
+          for (String key : new String[] { "Button", "RadioButton", "ToggleButton" }) {
+            UIDefaults defaults = UIManager.getDefaults();
+            Font font = defaults.getFont(key + ".font");
+            Insets bm = defaults.getInsets(key + ".margin");
+            if (font != null && bm != null &&
+                font.getFamily().equals("Segoe UI") && font.getSize() == 12)
+            {

Review Comment:
   Will fix.



-- 
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