mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Darcula & HiDPI: can't see text in search fields
This commit is contained in:
+14
-12
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2000-2014 JetBrains s.r.o.
|
* Copyright 2000-2015 JetBrains s.r.o.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,6 +21,7 @@ import com.intellij.openapi.util.IconLoader;
|
|||||||
import com.intellij.openapi.util.text.StringUtil;
|
import com.intellij.openapi.util.text.StringUtil;
|
||||||
import com.intellij.ui.Gray;
|
import com.intellij.ui.Gray;
|
||||||
import com.intellij.util.ui.JBInsets;
|
import com.intellij.util.ui.JBInsets;
|
||||||
|
import com.intellij.util.ui.JBUI;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import javax.swing.border.Border;
|
import javax.swing.border.Border;
|
||||||
@@ -114,10 +115,11 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private SearchAction getActionUnder(MouseEvent e) {
|
private SearchAction getActionUnder(MouseEvent e) {
|
||||||
Point point = new Point(e.getX() - 8, e.getY() - 8);
|
int off = JBUI.scale(8);
|
||||||
return point.distance(getSearchIconCoord()) <= 8
|
Point point = new Point(e.getX() - off, e.getY() - off);
|
||||||
|
return point.distance(getSearchIconCoord()) <= off
|
||||||
? SearchAction.POPUP
|
? SearchAction.POPUP
|
||||||
: hasText() && point.distance(getClearIconCoord()) <= 8
|
: hasText() && point.distance(getClearIconCoord()) <= off
|
||||||
? SearchAction.CLEAR
|
? SearchAction.CLEAR
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
@@ -125,22 +127,22 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
|
|||||||
protected Rectangle getDrawingRect() {
|
protected Rectangle getDrawingRect() {
|
||||||
final JTextComponent c = myTextField;
|
final JTextComponent c = myTextField;
|
||||||
final JBInsets i = JBInsets.create(c.getInsets());
|
final JBInsets i = JBInsets.create(c.getInsets());
|
||||||
final int x = i.right - 4 - 16;
|
final int x = i.right - JBUI.scale(4) - JBUI.scale(16);
|
||||||
final int y = i.top - 3;
|
final int y = i.top - 3;
|
||||||
final int w = c.getWidth() - i.width() + 16*2 +7*2 - 5;
|
final int w = c.getWidth() - i.width() + JBUI.scale(16*2 +7*2 - 5);
|
||||||
int h = c.getBounds().height - i.height() + 4*2 - 3;
|
int h = c.getBounds().height - i.height() + JBUI.scale(4*2 - 3);
|
||||||
if (h%2==1) h++;
|
if (h%2==1) h++;
|
||||||
return new Rectangle(x, y, w, h);
|
return new Rectangle(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Point getSearchIconCoord() {
|
protected Point getSearchIconCoord() {
|
||||||
final Rectangle r = getDrawingRect();
|
final Rectangle r = getDrawingRect();
|
||||||
return new Point(r.x + 3, r.y + (r.height - 16) / 2 + 1);
|
return new Point(r.x + JBUI.scale(3), r.y + (r.height - JBUI.scale(16)) / 2 + JBUI.scale(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Point getClearIconCoord() {
|
protected Point getClearIconCoord() {
|
||||||
final Rectangle r = getDrawingRect();
|
final Rectangle r = getDrawingRect();
|
||||||
return new Point(r.x + r.width - 16 - 2, r.y + (r.height - 16) / 2);
|
return new Point(r.x + r.width - JBUI.scale(16) - JBUI.scale(2), r.y + (r.height - JBUI.scale(16)) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -162,7 +164,7 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
|
|||||||
g.setColor(c.getBackground());
|
g.setColor(c.getBackground());
|
||||||
final boolean noBorder = c.getClientProperty("JTextField.Search.noBorderRing") == Boolean.TRUE;
|
final boolean noBorder = c.getClientProperty("JTextField.Search.noBorderRing") == Boolean.TRUE;
|
||||||
int radius = r.height-1;
|
int radius = r.height-1;
|
||||||
g.fillRoundRect(r.x, r.y+1, r.width, r.height - (noBorder ? 2 : 1), radius, radius);
|
g.fillRoundRect(r.x, r.y+1, r.width, r.height - JBUI.scale((noBorder ? 2 : 1)), radius, radius);
|
||||||
g.setColor(c.isEnabled() ? Gray._100 : new Color(0x535353));
|
g.setColor(c.isEnabled() ? Gray._100 : new Color(0x535353));
|
||||||
if (!noBorder) {
|
if (!noBorder) {
|
||||||
if (c.hasFocus()) {
|
if (c.hasFocus()) {
|
||||||
@@ -193,9 +195,9 @@ public class DarculaTextFieldUI extends BasicTextFieldUI {
|
|||||||
final int height = c.getHeight();
|
final int height = c.getHeight();
|
||||||
final Insets i = border.getBorderInsets(c);
|
final Insets i = border.getBorderInsets(c);
|
||||||
if (c.hasFocus()) {
|
if (c.hasFocus()) {
|
||||||
g.fillRoundRect(i.left - 5, i.top - 2, width - i.right - i.left + 10, height - i.top - i.bottom + 6, 5, 5);
|
g.fillRoundRect(i.left - JBUI.scale(5), i.top - JBUI.scale(2), width - i.right - i.left + JBUI.scale(10), height - i.top - i.bottom + JBUI.scale(6), JBUI.scale(5), JBUI.scale(5));
|
||||||
} else {
|
} else {
|
||||||
g.fillRect(i.left - 5, i.top - 2, width - i.right - i.left + 12, height - i.top - i.bottom + 6);
|
g.fillRect(i.left - JBUI.scale(5), i.top - JBUI.scale(2), width - i.right - i.left + JBUI.scale(12), height - i.top - i.bottom + JBUI.scale(6));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
super.paintBackground(g);
|
super.paintBackground(g);
|
||||||
|
|||||||
Reference in New Issue
Block a user