From 4e76d05f86451e608fa1b5d5bee2bf279ac915b8 Mon Sep 17 00:00:00 2001 From: Aleksey Pivovarov Date: Fri, 25 May 2018 19:09:09 +0300 Subject: [PATCH] ui: fix rendering of separators with text on toolbar Restore preferred width for text separator, that was mistakenly increased in previous fix. follow-up: 93573017e221bbe1b366e9a6eba02c5d816a29dd --- .../actionSystem/impl/ActionToolbarImpl.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java index 9f5de6fcdc86..4062e9a18990 100644 --- a/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/actionSystem/impl/ActionToolbarImpl.java @@ -982,6 +982,11 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct @Override public Dimension getPreferredSize() { + int gap = JBUI.scale(2); + int center = JBUI.scale(3); + int width = gap * 2 + center; + int height = JBUI.scale(24); + if (myOrientation == SwingConstants.HORIZONTAL) { if (myText != null) { FontMetrics fontMetrics = getFontMetrics(getFont()); @@ -990,19 +995,20 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct try { UISettings.setupAntialiasing(g); int textWidth = fontMetrics.getStringBounds(myText, g).getBounds().width; - return new JBDimension(JBUI.scale(9) + textWidth + JBUI.scale(4), - Math.max(fontMetrics.getHeight(), JBUI.scale(24)), true); + return new JBDimension(width + gap * 2 + textWidth, + Math.max(fontMetrics.getHeight(), height), true); } finally { g.dispose(); } } else { - return JBUI.size(7, 24); + return new JBDimension(width, height, true); } } else { - return JBUI.size(24, 7); + //noinspection SuspiciousNameCombination + return new JBDimension(height, width, true); } } @@ -1029,7 +1035,7 @@ public class ActionToolbarImpl extends JPanel implements ActionToolbar, QuickAct int top = (getHeight() - fontMetrics.getHeight()) / 2; UISettings.setupAntialiasing(g); g.setColor(JBColor.foreground()); - g.drawString(myText, JBUI.scale(9), top + fontMetrics.getAscent()); + g.drawString(myText, gap * 2 + center + gap, top + fontMetrics.getAscent()); } } else {