mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fix MacOs borders for fractional scale
This commit is contained in:
@@ -131,25 +131,33 @@ public class DarculaUIUtil {
|
||||
}
|
||||
|
||||
public static void paintErrorBorder(Graphics2D g, int width, int height, int arc, boolean symmetric, boolean hasFocus) {
|
||||
paintErrorBorder(g, width, height, (float)arc, symmetric, hasFocus);
|
||||
}
|
||||
|
||||
public static void paintErrorBorder(Graphics2D g, int width, int height, float arc, boolean symmetric, boolean hasFocus) {
|
||||
g.setPaint(hasFocus ? ACTIVE_ERROR_COLOR : INACTIVE_ERROR_COLOR);
|
||||
doPaint(g, width, height, arc, symmetric);
|
||||
}
|
||||
|
||||
public static void paintFocusBorder(Graphics2D g, int width, int height, int arc, boolean symmetric) {
|
||||
paintFocusBorder(g, width, height, (float)arc, symmetric);
|
||||
}
|
||||
|
||||
public static void paintFocusBorder(Graphics2D g, int width, int height, float arc, boolean symmetric) {
|
||||
g.setPaint(IntelliJLaf.isGraphite() ? MAC_GRAPHITE_COLOR : MAC_REGULAR_COLOR);
|
||||
doPaint(g, width, height, arc, symmetric);
|
||||
}
|
||||
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
private static void doPaint(Graphics2D g, int width, int height, int arc, boolean symmetric) {
|
||||
double bw = UIUtil.isUnderDefaultMacTheme() ? (UIUtil.isRetina(g) ? 0.5 : 1.0) : 0.0;
|
||||
private static void doPaint(Graphics2D g, int width, int height, float arc, boolean symmetric) {
|
||||
double bw = UIUtil.isUnderDefaultMacTheme() ? JBUI.scale(UIUtil.isRetina(g) ? 0.5f : 1.0f) : 0.0;
|
||||
double lw = JBUI.scale(UIUtil.isUnderDefaultMacTheme() ? 3 : 2);
|
||||
|
||||
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
|
||||
g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
|
||||
double outerArc = arc > 0 ? arc + lw - JBUI.scale(2) : lw;
|
||||
double rightOuterArc = symmetric ? outerArc : JBUI.scale(6);
|
||||
double outerArc = arc > 0 ? arc + lw - JBUI.scale(2f) : lw;
|
||||
double rightOuterArc = symmetric ? outerArc : JBUI.scale(6f);
|
||||
Path2D outerRect = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
outerRect.moveTo(width - rightOuterArc, 0);
|
||||
outerRect.quadTo(width, 0, width, rightOuterArc);
|
||||
@@ -162,7 +170,7 @@ public class DarculaUIUtil {
|
||||
outerRect.closePath();
|
||||
|
||||
lw += bw;
|
||||
double rightInnerArc = symmetric ? outerArc : JBUI.scale(7);
|
||||
double rightInnerArc = symmetric ? outerArc : JBUI.scale(7f);
|
||||
Path2D innerRect = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
innerRect.moveTo(width - rightInnerArc, lw);
|
||||
innerRect.quadTo(width - lw, lw , width - lw, rightInnerArc);
|
||||
|
||||
+12
-12
@@ -51,7 +51,7 @@ public class MacComboBoxBorder extends MacIntelliJTextBorder {
|
||||
area.intersect(new Area(clip));
|
||||
g2.setClip(area);
|
||||
|
||||
int arc = isRound(c) ? JBUI.scale(6) : 0;
|
||||
float arc = isRound(c) ? JBUI.scale(6f) : 0;
|
||||
Insets i = ((JComponent)c).getInsets();
|
||||
|
||||
if (c instanceof JComboBox) {
|
||||
@@ -80,15 +80,15 @@ public class MacComboBoxBorder extends MacIntelliJTextBorder {
|
||||
}
|
||||
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
double lw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
|
||||
float lw = JBUI.scale(UIUtil.isRetina(g2) ? 0.5f : 1.0f);
|
||||
border.append(new RoundRectangle2D.Double(JBUI.scale(3), JBUI.scale(3),
|
||||
c.getWidth() - JBUI.scale(6),
|
||||
c.getHeight() - JBUI.scale(6),
|
||||
c.getWidth() - JBUI.scale(3)*2,
|
||||
c.getHeight() - JBUI.scale(3)*2,
|
||||
arc, arc), false);
|
||||
double innerArc = arc > 0 ? arc - lw : 0.0;
|
||||
float innerArc = JBUI.scale(arc > 0 ? arc - lw : 0.0f);
|
||||
border.append(new RoundRectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
|
||||
c.getWidth() - JBUI.scale(6) - lw * 2,
|
||||
c.getHeight() - JBUI.scale(6) - lw * 2,
|
||||
c.getWidth() - (JBUI.scale(3) + lw) * 2,
|
||||
c.getHeight() - (JBUI.scale(3) + lw) * 2,
|
||||
innerArc, innerArc), false);
|
||||
g2.setColor(Gray.xBC);
|
||||
g2.fill(border);
|
||||
@@ -146,15 +146,15 @@ public class MacComboBoxBorder extends MacIntelliJTextBorder {
|
||||
|
||||
@Override void clipForBorder(Component c, Graphics2D g2, int width, int height) {
|
||||
Area area = new Area(new Rectangle2D.Double(0, 0, width, height));
|
||||
double lw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
|
||||
double lw = JBUI.scale(UIUtil.isRetina(g2) ? 0.5f : 1.0f);
|
||||
Shape innerShape = isRound(c) ?
|
||||
new RoundRectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
|
||||
width - JBUI.scale(6) - lw * 2,
|
||||
height - JBUI.scale(6) - lw * 2,
|
||||
width - (JBUI.scale(3) + lw) * 2,
|
||||
height - (JBUI.scale(3) + lw) * 2,
|
||||
JBUI.scale(3) + lw, JBUI.scale(3) + lw) :
|
||||
new Rectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
|
||||
width - JBUI.scale(6) - lw * 2,
|
||||
height - JBUI.scale(6) - lw * 2);
|
||||
width - (JBUI.scale(3) + lw) * 2,
|
||||
height - (JBUI.scale(3) + lw) * 2);
|
||||
|
||||
area.subtract(new Area(innerShape));
|
||||
area.add(getButtonBounds(c));
|
||||
|
||||
+3
-3
@@ -41,7 +41,7 @@ import java.beans.PropertyChangeListener;
|
||||
public class MacIntelliJComboBoxUI extends BasicComboBoxUI {
|
||||
private static final Border ourDefaultEditorBorder = JBUI.Borders.empty(1, 0);
|
||||
|
||||
static final int VALUE_OFFSET = JBUI.scale(5);
|
||||
static final float VALUE_OFFSET = JBUI.scale(5f);
|
||||
private Icon DEFAULT_ICON;
|
||||
|
||||
private PropertyChangeListener myEditorChangeListener;
|
||||
@@ -129,7 +129,7 @@ public class MacIntelliJComboBoxUI extends BasicComboBoxUI {
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
return JBUI.size(DEFAULT_ICON.getIconWidth(), DEFAULT_ICON.getIconHeight());
|
||||
return new Dimension(DEFAULT_ICON.getIconWidth(), DEFAULT_ICON.getIconHeight());
|
||||
}
|
||||
};
|
||||
button.setBorder(BorderFactory.createEmptyBorder());
|
||||
@@ -146,7 +146,7 @@ public class MacIntelliJComboBoxUI extends BasicComboBoxUI {
|
||||
Insets i = comboBox.getInsets();
|
||||
int iconWidth = DEFAULT_ICON.getIconWidth() + i.right;
|
||||
int iconHeight = DEFAULT_ICON.getIconHeight() + i.top + i.bottom;
|
||||
return new Dimension(Math.max(d.width + 7, iconWidth), iconHeight);
|
||||
return new Dimension(Math.max(d.width + JBUI.scale(7), iconWidth), iconHeight);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-3
@@ -54,7 +54,7 @@ public class MacIntelliJSpinnerUI extends DarculaSpinnerUI {
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
g2.setColor(UIManager.getColor("FormattedTextField.background"));
|
||||
|
||||
double arc = JBUI.scale(6);
|
||||
double arc = JBUI.scale(6f);
|
||||
Path2D rect = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
rect.moveTo(x, i.top);
|
||||
rect.lineTo(x, c.getHeight() - i.bottom);
|
||||
@@ -88,7 +88,7 @@ public class MacIntelliJSpinnerUI extends DarculaSpinnerUI {
|
||||
Insets i = spinner.getInsets();
|
||||
int iconWidth = DEFAULT_ICON.getIconWidth() + i.right;
|
||||
int iconHeight = DEFAULT_ICON.getIconHeight() + i.top + i.bottom;
|
||||
return new Dimension(Math.max(d.width + 7, iconWidth), Math.max(d.height, iconHeight));
|
||||
return new Dimension(Math.max(d.width + JBUI.scale(7), iconWidth), Math.max(d.height, iconHeight));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -124,7 +124,7 @@ public class MacIntelliJSpinnerUI extends DarculaSpinnerUI {
|
||||
editor.setBounds(JBUI.scale(2) + i.left,
|
||||
JBUI.scale(2) + i.top,
|
||||
w - (i.left + i.right + DEFAULT_ICON.getIconWidth() + JBUI.scale(6)),
|
||||
h - (i.top + i.bottom + JBUI.scale(4)));
|
||||
h - (i.top + i.bottom + JBUI.scale(2)*2));
|
||||
}
|
||||
|
||||
@Nullable Rectangle getArrowButtonBounds() {
|
||||
|
||||
+9
-9
@@ -61,13 +61,13 @@ public class MacIntelliJTextBorder implements Border, UIResource, ErrorBorderCap
|
||||
g2.translate(x, y);
|
||||
|
||||
Path2D border = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
double lw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
|
||||
double lw = JBUI.scale(UIUtil.isRetina(g2) ? 0.5f : 1.0f);
|
||||
border.append(new Rectangle2D.Double(JBUI.scale(3), JBUI.scale(3),
|
||||
c.getWidth() - JBUI.scale(6),
|
||||
c.getHeight() - JBUI.scale(6)), false);
|
||||
c.getWidth() - JBUI.scale(3)*2,
|
||||
c.getHeight() - JBUI.scale(3)*2), false);
|
||||
border.append(new Rectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
|
||||
c.getWidth() - JBUI.scale(6) - lw * 2,
|
||||
c.getHeight() - JBUI.scale(6) - lw * 2), false);
|
||||
c.getWidth() - (JBUI.scale(3) + lw) * 2,
|
||||
c.getHeight() - (JBUI.scale(3) + lw) * 2), false);
|
||||
g2.setColor(Gray.xBC);
|
||||
g2.fill(border);
|
||||
|
||||
@@ -79,7 +79,7 @@ public class MacIntelliJTextBorder implements Border, UIResource, ErrorBorderCap
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Component c, Graphics2D g2, int width, int height, int arc) {
|
||||
public void paint(Component c, Graphics2D g2, int width, int height, float arc) {
|
||||
clipForBorder(c, g2, width, height);
|
||||
|
||||
if (((JComponent)c).getClientProperty("JComponent.error.outline") == Boolean.TRUE) {
|
||||
@@ -95,10 +95,10 @@ public class MacIntelliJTextBorder implements Border, UIResource, ErrorBorderCap
|
||||
|
||||
void clipForBorder(Component c, Graphics2D g2, int width, int height) {
|
||||
Area area = new Area(new Rectangle2D.Double(0, 0, width, height));
|
||||
double lw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
|
||||
double lw = JBUI.scale(UIUtil.isRetina(g2) ? 0.5f : 1.0f);
|
||||
area.subtract(new Area(new Rectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
|
||||
width - JBUI.scale(6) - lw * 2,
|
||||
height - JBUI.scale(6) - lw * 2)));
|
||||
width - (JBUI.scale(3) + lw) * 2,
|
||||
height - (JBUI.scale(3) + lw) * 2)));
|
||||
area.intersect(new Area(g2.getClip()));
|
||||
g2.setClip(area);
|
||||
}
|
||||
|
||||
+13
-13
@@ -90,7 +90,7 @@ public class MacIntelliJTextFieldUI extends TextFieldWithPopupHandlerUI {
|
||||
}
|
||||
else if (component.getBorder() instanceof MacIntelliJTextBorder) {
|
||||
g.setColor(component.getBackground());
|
||||
g.fillRect(JBUI.scale(3), JBUI.scale(3), component.getWidth() - JBUI.scale(6), component.getHeight() - JBUI.scale(6));
|
||||
g.fillRect(JBUI.scale(3), JBUI.scale(3), component.getWidth() - JBUI.scale(3)*2, component.getHeight() - JBUI.scale(3)*2);
|
||||
}
|
||||
else {
|
||||
super.paintBackground(g);
|
||||
@@ -105,11 +105,11 @@ public class MacIntelliJTextFieldUI extends TextFieldWithPopupHandlerUI {
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
g2.translate(r.x, r.y);
|
||||
|
||||
int arc = JBUI.scale(6);
|
||||
double lw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
|
||||
float arc = JBUI.scale(6f);
|
||||
double lw = JBUI.scale(UIUtil.isRetina(g2) ? 0.5f : 1.0f);
|
||||
Shape outerShape = new RoundRectangle2D.Double(JBUI.scale(3), JBUI.scale(3),
|
||||
r.width - JBUI.scale(6),
|
||||
r.height - JBUI.scale(6),
|
||||
r.width - JBUI.scale(3)*2,
|
||||
r.height - JBUI.scale(3)*2,
|
||||
arc, arc);
|
||||
g2.setColor(c.getBackground());
|
||||
g2.fill(outerShape);
|
||||
@@ -117,8 +117,8 @@ public class MacIntelliJTextFieldUI extends TextFieldWithPopupHandlerUI {
|
||||
Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
path.append(outerShape, false);
|
||||
path.append(new RoundRectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
|
||||
r.width - JBUI.scale(6) - lw*2,
|
||||
r.height - JBUI.scale(6) - lw*2,
|
||||
r.width - (JBUI.scale(3) + lw)*2,
|
||||
r.height - (JBUI.scale(3) + lw)*2,
|
||||
arc-lw, arc-lw), false);
|
||||
|
||||
g2.setColor(Gray.xBC);
|
||||
@@ -141,11 +141,11 @@ public class MacIntelliJTextFieldUI extends TextFieldWithPopupHandlerUI {
|
||||
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, MacUIUtil.USE_QUARTZ ? RenderingHints.VALUE_STROKE_PURE : RenderingHints.VALUE_STROKE_NORMALIZE);
|
||||
g2.translate(r.x, r.y);
|
||||
|
||||
int arc = JBUI.scale(6);
|
||||
double lw = UIUtil.isRetina(g2) ? 0.5 : 1.0;
|
||||
float arc = JBUI.scale(6);
|
||||
double lw = JBUI.scale(UIUtil.isRetina(g2) ? 0.5f : 1.0f);
|
||||
Shape outerShape = new RoundRectangle2D.Double(JBUI.scale(3), JBUI.scale(3),
|
||||
r.width - JBUI.scale(6),
|
||||
r.height - JBUI.scale(6),
|
||||
r.width - JBUI.scale(3)*2,
|
||||
r.height - JBUI.scale(3)*2,
|
||||
arc, arc);
|
||||
g2.setColor(c.getBackground());
|
||||
g2.fill(outerShape);
|
||||
@@ -153,8 +153,8 @@ public class MacIntelliJTextFieldUI extends TextFieldWithPopupHandlerUI {
|
||||
Path2D path = new Path2D.Double(Path2D.WIND_EVEN_ODD);
|
||||
path.append(outerShape, false);
|
||||
path.append(new RoundRectangle2D.Double(JBUI.scale(3) + lw, JBUI.scale(3) + lw,
|
||||
r.width - JBUI.scale(6) - lw*2,
|
||||
r.height - JBUI.scale(6) - lw*2,
|
||||
r.width - (JBUI.scale(3) + lw)*2,
|
||||
r.height - (JBUI.scale(3) + lw)*2,
|
||||
arc-lw, arc-lw), false);
|
||||
|
||||
g2.setColor(Gray.xBC);
|
||||
|
||||
Reference in New Issue
Block a user