From ab59d20bf25b4bc2efe36620e4fea2d59dc22ccd Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Wed, 17 Jun 2020 00:46:00 +0300 Subject: [PATCH] [vcs-log] respect scaling in vcs log filter components GitOrigin-RevId: 4a6a8e1ec8bff55570ec9073fd16b1a50a445231 --- .../log/ui/filter/VcsLogPopupComponent.java | 30 ++++++++++++++----- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogPopupComponent.java index b5cfd3aa45a1..74607a7b4d5e 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogPopupComponent.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/VcsLogPopupComponent.java @@ -18,7 +18,6 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import javax.swing.border.Border; -import javax.swing.border.LineBorder; import java.awt.*; import java.awt.event.*; import java.awt.geom.Area; @@ -170,15 +169,17 @@ public abstract class VcsLogPopupComponent extends JPanel { } private static Border createUnfocusedBorder() { - return BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE), - JBUI.Borders.empty(2)); + return BorderFactory.createCompoundBorder(JBUI.Borders.empty(BORDER_SIZE), JBUI.Borders.empty(2)); } - private static class FilledRoundedBorder extends LineBorder { + private static class FilledRoundedBorder implements Border { + private final Color myColor; + private final int myThickness; private final int myArcSize; FilledRoundedBorder(@NotNull Color color, int arcSize, int thickness) { - super(color, thickness); + myColor = color; + myThickness = thickness; myArcSize = arcSize; } @@ -186,9 +187,12 @@ public abstract class VcsLogPopupComponent extends JPanel { public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) { GraphicsConfig config = GraphicsUtil.setupAAPainting(g); - g.setColor(lineColor); - Area area = new Area(new RoundRectangle2D.Double(x, y, width, height, myArcSize, myArcSize)); - int innerArc = Math.max(myArcSize - thickness, 0); + g.setColor(myColor); + + int thickness = JBUI.scale(myThickness); + int arcSize = JBUI.scale(myArcSize); + Area area = new Area(new RoundRectangle2D.Double(x, y, width, height, arcSize, arcSize)); + int innerArc = Math.max(arcSize - thickness, 0); area.subtract(new Area(new RoundRectangle2D.Double(x + thickness, y + thickness, width - 2 * thickness, height - 2 * thickness, innerArc, innerArc))); @@ -196,6 +200,16 @@ public abstract class VcsLogPopupComponent extends JPanel { config.restore(); } + + @Override + public Insets getBorderInsets(Component c) { + return JBUI.insets(myThickness); + } + + @Override + public boolean isBorderOpaque() { + return false; + } } private static class DynamicLabel extends JLabel {