mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IDEA-117296 Fixed buttons look bad under Darcula and IntelliJ lafs
This commit is contained in:
+7
-4
@@ -36,19 +36,19 @@ public class DarculaButtonPainter implements Border, UIResource {
|
||||
final Graphics2D g2d = (Graphics2D)g;
|
||||
final Insets ins = getBorderInsets(c);
|
||||
final int yOff = (ins.top + ins.bottom) / 4;
|
||||
int offset = getOffset();
|
||||
final boolean square = DarculaButtonUI.isSquare(c);
|
||||
int offset = square ? 1 : getOffset();
|
||||
if (c.hasFocus()) {
|
||||
DarculaUIUtil.paintFocusRing(g2d, offset, yOff, width - 2 * offset, height - 2 * yOff);
|
||||
} else {
|
||||
final GraphicsConfig config = new GraphicsConfig(g);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
|
||||
g2d.setPaint(
|
||||
UIUtil.getGradientPaint(width / 2, y + yOff + 1, Gray._80.withAlpha(90), width / 2, height - 2 * yOff, Gray._90.withAlpha(90)));
|
||||
g2d.setPaint(UIUtil.getGradientPaint(width / 2, y + yOff + 1, Gray._80.withAlpha(90), width / 2, height - 2 * yOff, Gray._90.withAlpha(90)));
|
||||
//g.drawRoundRect(x + offset + 1, y + yOff + 1, width - 2 * offset, height - 2*yOff, 5, 5);
|
||||
|
||||
((Graphics2D)g).setPaint(Gray._100.withAlpha(180));
|
||||
g.drawRoundRect(x + offset, y + yOff, width - 2 * offset, height - 2*yOff, 5, 5);
|
||||
g.drawRoundRect(x + offset, y + yOff, width - 2 * offset, height - 2*yOff, square ? 3 : 5, square ? 3 : 5);
|
||||
|
||||
config.restore();
|
||||
}
|
||||
@@ -56,6 +56,9 @@ public class DarculaButtonPainter implements Border, UIResource {
|
||||
|
||||
@Override
|
||||
public Insets getBorderInsets(Component c) {
|
||||
if (DarculaButtonUI.isSquare(c)) {
|
||||
return new InsetsUIResource(2, 0, 2, 0);
|
||||
}
|
||||
return new InsetsUIResource(8, 16, 8, 14);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,20 +37,27 @@ public class DarculaButtonUI extends BasicButtonUI {
|
||||
return new DarculaButtonUI();
|
||||
}
|
||||
|
||||
public static boolean isSquare(Component c) {
|
||||
return c instanceof JButton && "square".equals(((JButton)c).getClientProperty("JButton.buttonType"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
final Border border = c.getBorder();
|
||||
final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
|
||||
final boolean square = isSquare(c);
|
||||
if (c.isEnabled() && border != null) {
|
||||
final Insets ins = border.getBorderInsets(c);
|
||||
final int yOff = (ins.top + ins.bottom) / 4;
|
||||
if (((JButton)c).isDefaultButton()) {
|
||||
((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getSelectedButtonColor1(), 0, c.getHeight(), getSelectedButtonColor2()));
|
||||
if (!square) {
|
||||
if (((JButton)c).isDefaultButton()) {
|
||||
((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getSelectedButtonColor1(), 0, c.getHeight(), getSelectedButtonColor2()));
|
||||
}
|
||||
else {
|
||||
((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getButtonColor1(), 0, c.getHeight(), getButtonColor2()));
|
||||
}
|
||||
}
|
||||
else {
|
||||
((Graphics2D)g).setPaint(UIUtil.getGradientPaint(0, 0, getButtonColor1(), 0, c.getHeight(), getButtonColor2()));
|
||||
}
|
||||
g.fillRoundRect(4, yOff, c.getWidth() - 2 * 4, c.getHeight() - 2 * yOff, 5, 5);
|
||||
g.fillRoundRect(square ? 2 : 4, yOff, c.getWidth() - 2 * 4, c.getHeight() - 2 * yOff, square ? 3 : 5, square ? 3 : 5);
|
||||
}
|
||||
config.restore();
|
||||
super.paint(g, c);
|
||||
|
||||
Reference in New Issue
Block a user